src/pyams_skin/resources/js/ext/flot/jquery.flot.selection.min.js
changeset 566 a1707c607eec
parent 565 318533413200
child 567 bca1726b1d85
equal deleted inserted replaced
565:318533413200 566:a1707c607eec
     1 !function(e){e.plot.plugins.push({init:function(o){function t(e){m.active&&(d(e),o.getPlaceholder().trigger("plotselecting",[l()]))}function n(t){var n=o.getOptions();1===t.which&&null!==n.selection.mode&&(m.currentMode="xy",document.body.focus(),void 0!==document.onselectstart&&null==v.onselectstart&&(v.onselectstart=document.onselectstart,document.onselectstart=function(){return!1}),void 0!==document.ondrag&&null==v.ondrag&&(v.ondrag=document.ondrag,document.ondrag=function(){return!1}),u(m.first,t),m.active=!0,T=function(e){i(e)},e(document).one("mouseup",T))}function i(e){return T=null,void 0!==document.onselectstart&&(document.onselectstart=v.onselectstart),void 0!==document.ondrag&&(document.ondrag=v.ondrag),m.active=!1,d(e),g()?r():(o.getPlaceholder().trigger("plotunselected",[]),o.getPlaceholder().trigger("plotselecting",[null])),!1}function l(){if(!g())return null;if(!m.show)return null;var t={},n={x:m.first.x,y:m.first.y},i={x:m.second.x,y:m.second.y};return"x"===c(o)&&(n.y=0,i.y=o.height()),"y"===c(o)&&(n.x=0,i.x=o.width()),e.each(o.getAxes(),function(e,o){if(o.used){var l=o.c2p(n[o.direction]),r=o.c2p(i[o.direction]);t[e]={from:Math.min(l,r),to:Math.max(l,r)}}}),t}function r(){var e=l();o.getPlaceholder().trigger("plotselected",[e]),e.xaxis&&e.yaxis&&o.getPlaceholder().trigger("selected",[{x1:e.xaxis.from,y1:e.yaxis.from,x2:e.xaxis.to,y2:e.yaxis.to}])}function s(e,o,t){return o<e?e:o>t?t:o}function c(e){var o=e.getOptions();return"smart"===o.selection.mode?m.currentMode:o.selection.mode}function a(e){if(m.first){var o={x:e.x-m.first.x,y:e.y-m.first.y};Math.abs(o.x)<y?m.currentMode="y":Math.abs(o.y)<y?m.currentMode="x":m.currentMode="xy"}}function u(e,t){var n=o.getPlaceholder().offset(),i=o.getPlotOffset();e.x=s(0,t.pageX-n.left-i.left,o.width()),e.y=s(0,t.pageY-n.top-i.top,o.height()),e!==m.first&&a(e),"y"===c(o)&&(e.x=e===m.first?0:o.width()),"x"===c(o)&&(e.y=e===m.first?0:o.height())}function d(e){null!=e.pageX&&(u(m.second,e),g()?(m.show=!0,o.triggerRedrawOverlay()):f(!0))}function f(e){m.show&&(m.show=!1,m.currentMode="",o.triggerRedrawOverlay(),e||o.getPlaceholder().trigger("plotunselected",[]))}function h(e,t){var n,i,l,r,s=o.getAxes();for(var c in s)if((n=s[c]).direction===t&&(r=t+n.n+"axis",e[r]||1!==n.n||(r=t+"axis"),e[r])){i=e[r].from,l=e[r].to;break}if(e[r]||(n="x"===t?o.getXAxes()[0]:o.getYAxes()[0],i=e[t+"1"],l=e[t+"2"]),null!=i&&null!=l&&i>l){var a=i;i=l,l=a}return{from:i,to:l,axis:n}}function g(){var e=o.getOptions().selection.minSize;return Math.abs(m.second.x-m.first.x)>=e&&Math.abs(m.second.y-m.first.y)>=e}function x(e,o,t,n,i,l,r,s){var c=Math.max(0,Math.min(15,n/2-2,i/2-2));e.fillStyle="#ffffff","xy"===s&&(e.beginPath(),e.moveTo(o,t+c),e.lineTo(o-3,t+c),e.lineTo(o-3,t-3),e.lineTo(o+c,t-3),e.lineTo(o+c,t),e.lineTo(o,t),e.closePath(),e.moveTo(o,t+i-c),e.lineTo(o-3,t+i-c),e.lineTo(o-3,t+i+3),e.lineTo(o+c,t+i+3),e.lineTo(o+c,t+i),e.lineTo(o,t+i),e.closePath(),e.moveTo(o+n,t+c),e.lineTo(o+n+3,t+c),e.lineTo(o+n+3,t-3),e.lineTo(o+n-c,t-3),e.lineTo(o+n-c,t),e.lineTo(o+n,t),e.closePath(),e.moveTo(o+n,t+i-c),e.lineTo(o+n+3,t+i-c),e.lineTo(o+n+3,t+i+3),e.lineTo(o+n-c,t+i+3),e.lineTo(o+n-c,t+i),e.lineTo(o+n,t+i),e.closePath(),e.stroke(),e.fill()),o=l,t=r,"x"===s&&(e.beginPath(),e.moveTo(o,t+15),e.lineTo(o,t-15),e.lineTo(o-3,t-15),e.lineTo(o-3,t+15),e.closePath(),e.moveTo(o+n,t+15),e.lineTo(o+n,t-15),e.lineTo(o+n+3,t-15),e.lineTo(o+n+3,t+15),e.closePath(),e.stroke(),e.fill()),"y"===s&&(e.beginPath(),e.moveTo(o-15,t),e.lineTo(o+15,t),e.lineTo(o+15,t-3),e.lineTo(o-15,t-3),e.closePath(),e.moveTo(o-15,t+i),e.lineTo(o+15,t+i),e.lineTo(o+15,t+i+3),e.lineTo(o-15,t+i+3),e.closePath(),e.stroke(),e.fill())}var m={first:{x:-1,y:-1},second:{x:-1,y:-1},show:!1,currentMode:"xy",active:!1},y=e.plot.uiConstants.SNAPPING_CONSTANT,v={},T=null;o.clearSelection=f,o.setSelection=function(e,t){var n;"y"===c(o)?(m.first.x=0,m.second.x=o.width()):(n=h(e,"x"),m.first.x=n.axis.p2c(n.from),m.second.x=n.axis.p2c(n.to)),"x"===c(o)?(m.first.y=0,m.second.y=o.height()):(n=h(e,"y"),m.first.y=n.axis.p2c(n.from),m.second.y=n.axis.p2c(n.to)),m.show=!0,o.triggerRedrawOverlay(),!t&&g()&&r()},o.getSelection=l,o.hooks.bindEvents.push(function(e,o){null!=e.getOptions().selection.mode&&(o.mousemove(t),o.mousedown(n))}),o.hooks.drawOverlay.push(function(o,t){if(m.show&&g()){var n=o.getPlotOffset(),i=o.getOptions();t.save(),t.translate(n.left,n.top);var l=e.color.parse(i.selection.color),r=i.selection.visualization,s=1;"fill"===r&&(s=.8),t.strokeStyle=l.scale("a",s).toString(),t.lineWidth=1,t.lineJoin=i.selection.shape,t.fillStyle=l.scale("a",.4).toString();var a=Math.min(m.first.x,m.second.x)+.5,u=a,d=Math.min(m.first.y,m.second.y)+.5,f=d,h=Math.abs(m.second.x-m.first.x)-1,y=Math.abs(m.second.y-m.first.y)-1;"x"===c(o)&&(y+=d,d=0),"y"===c(o)&&(h+=a,a=0),"fill"===r?(t.fillRect(a,d,h,y),t.strokeRect(a,d,h,y)):(t.fillRect(0,0,o.width(),o.height()),t.clearRect(a,d,h,y),x(t,a,d,h,y,u,f,c(o))),t.restore()}}),o.hooks.shutdown.push(function(o,i){i.unbind("mousemove",t),i.unbind("mousedown",n),T&&e(document).unbind("mouseup",T)})},options:{selection:{mode:null,visualization:"focus",color:"#888888",shape:"round",minSize:5}},name:"selection",version:"1.1"})}(jQuery);