src/pyams_skin/resources/js/ext/flot/jquery.flot.selection.min.js
changeset 546 9f02c09d2393
parent 98 89a28618a327
--- a/src/pyams_skin/resources/js/ext/flot/jquery.flot.selection.min.js	Thu Sep 26 11:55:17 2019 +0200
+++ b/src/pyams_skin/resources/js/ext/flot/jquery.flot.selection.min.js	Wed Oct 16 13:00:43 2019 +0200
@@ -1,7 +1,1 @@
-/* Javascript plotting library for jQuery, version 0.8.3.
-
-Copyright (c) 2007-2014 IOLA and Ole Laursen.
-Licensed under the MIT license.
-
-*/
-(function($){function init(plot){var selection={first:{x:-1,y:-1},second:{x:-1,y:-1},show:false,active:false};var savedhandlers={};var mouseUpHandler=null;function onMouseMove(e){if(selection.active){updateSelection(e);plot.getPlaceholder().trigger("plotselecting",[getSelection()])}}function onMouseDown(e){if(e.which!=1)return;document.body.focus();if(document.onselectstart!==undefined&&savedhandlers.onselectstart==null){savedhandlers.onselectstart=document.onselectstart;document.onselectstart=function(){return false}}if(document.ondrag!==undefined&&savedhandlers.ondrag==null){savedhandlers.ondrag=document.ondrag;document.ondrag=function(){return false}}setSelectionPos(selection.first,e);selection.active=true;mouseUpHandler=function(e){onMouseUp(e)};$(document).one("mouseup",mouseUpHandler)}function onMouseUp(e){mouseUpHandler=null;if(document.onselectstart!==undefined)document.onselectstart=savedhandlers.onselectstart;if(document.ondrag!==undefined)document.ondrag=savedhandlers.ondrag;selection.active=false;updateSelection(e);if(selectionIsSane())triggerSelectedEvent();else{plot.getPlaceholder().trigger("plotunselected",[]);plot.getPlaceholder().trigger("plotselecting",[null])}return false}function getSelection(){if(!selectionIsSane())return null;if(!selection.show)return null;var r={},c1=selection.first,c2=selection.second;$.each(plot.getAxes(),function(name,axis){if(axis.used){var p1=axis.c2p(c1[axis.direction]),p2=axis.c2p(c2[axis.direction]);r[name]={from:Math.min(p1,p2),to:Math.max(p1,p2)}}});return r}function triggerSelectedEvent(){var r=getSelection();plot.getPlaceholder().trigger("plotselected",[r]);if(r.xaxis&&r.yaxis)plot.getPlaceholder().trigger("selected",[{x1:r.xaxis.from,y1:r.yaxis.from,x2:r.xaxis.to,y2:r.yaxis.to}])}function clamp(min,value,max){return value<min?min:value>max?max:value}function setSelectionPos(pos,e){var o=plot.getOptions();var offset=plot.getPlaceholder().offset();var plotOffset=plot.getPlotOffset();pos.x=clamp(0,e.pageX-offset.left-plotOffset.left,plot.width());pos.y=clamp(0,e.pageY-offset.top-plotOffset.top,plot.height());if(o.selection.mode=="y")pos.x=pos==selection.first?0:plot.width();if(o.selection.mode=="x")pos.y=pos==selection.first?0:plot.height()}function updateSelection(pos){if(pos.pageX==null)return;setSelectionPos(selection.second,pos);if(selectionIsSane()){selection.show=true;plot.triggerRedrawOverlay()}else clearSelection(true)}function clearSelection(preventEvent){if(selection.show){selection.show=false;plot.triggerRedrawOverlay();if(!preventEvent)plot.getPlaceholder().trigger("plotunselected",[])}}function extractRange(ranges,coord){var axis,from,to,key,axes=plot.getAxes();for(var k in axes){axis=axes[k];if(axis.direction==coord){key=coord+axis.n+"axis";if(!ranges[key]&&axis.n==1)key=coord+"axis";if(ranges[key]){from=ranges[key].from;to=ranges[key].to;break}}}if(!ranges[key]){axis=coord=="x"?plot.getXAxes()[0]:plot.getYAxes()[0];from=ranges[coord+"1"];to=ranges[coord+"2"]}if(from!=null&&to!=null&&from>to){var tmp=from;from=to;to=tmp}return{from:from,to:to,axis:axis}}function setSelection(ranges,preventEvent){var axis,range,o=plot.getOptions();if(o.selection.mode=="y"){selection.first.x=0;selection.second.x=plot.width()}else{range=extractRange(ranges,"x");selection.first.x=range.axis.p2c(range.from);selection.second.x=range.axis.p2c(range.to)}if(o.selection.mode=="x"){selection.first.y=0;selection.second.y=plot.height()}else{range=extractRange(ranges,"y");selection.first.y=range.axis.p2c(range.from);selection.second.y=range.axis.p2c(range.to)}selection.show=true;plot.triggerRedrawOverlay();if(!preventEvent&&selectionIsSane())triggerSelectedEvent()}function selectionIsSane(){var minSize=plot.getOptions().selection.minSize;return Math.abs(selection.second.x-selection.first.x)>=minSize&&Math.abs(selection.second.y-selection.first.y)>=minSize}plot.clearSelection=clearSelection;plot.setSelection=setSelection;plot.getSelection=getSelection;plot.hooks.bindEvents.push(function(plot,eventHolder){var o=plot.getOptions();if(o.selection.mode!=null){eventHolder.mousemove(onMouseMove);eventHolder.mousedown(onMouseDown)}});plot.hooks.drawOverlay.push(function(plot,ctx){if(selection.show&&selectionIsSane()){var plotOffset=plot.getPlotOffset();var o=plot.getOptions();ctx.save();ctx.translate(plotOffset.left,plotOffset.top);var c=$.color.parse(o.selection.color);ctx.strokeStyle=c.scale("a",.8).toString();ctx.lineWidth=1;ctx.lineJoin=o.selection.shape;ctx.fillStyle=c.scale("a",.4).toString();var x=Math.min(selection.first.x,selection.second.x)+.5,y=Math.min(selection.first.y,selection.second.y)+.5,w=Math.abs(selection.second.x-selection.first.x)-1,h=Math.abs(selection.second.y-selection.first.y)-1;ctx.fillRect(x,y,w,h);ctx.strokeRect(x,y,w,h);ctx.restore()}});plot.hooks.shutdown.push(function(plot,eventHolder){eventHolder.unbind("mousemove",onMouseMove);eventHolder.unbind("mousedown",onMouseDown);if(mouseUpHandler)$(document).unbind("mouseup",mouseUpHandler)})}$.plot.plugins.push({init:init,options:{selection:{mode:null,color:"#e8cfac",shape:"round",minSize:5}},name:"selection",version:"1.1"})})(jQuery);
\ No newline at end of file
+!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);