moodle_local_treestudyplan/amd/build/simpleline/simpleline.min.js

3 lines
9.6 KiB
JavaScript
Raw Normal View History

2023-08-19 17:54:40 +02:00
define("local_treestudyplan/simpleline/simpleline",["exports","./css-calc"],(function(_exports,_cssCalc){function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _typeof(obj){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.SimpleLine=void 0;var obj,key,value,specsCopy=function specsCopy(to,from){for(var ix in to)from.hasOwnProperty(ix)&&("object"==_typeof(to[ix])&&"object"==_typeof(from[ix])?Array.isArray(to[ix])?Array.isArray(from[ix])&&(to[ix]=Array.from(from[ix])):specsCopy(to[ix],from[ix]):to[ix]=from[ix])},getElementPosition=function(el,reference){if(!(el&&el instanceof HTMLElement))return{x:0,y:0};if(reference&&reference instanceof HTMLElement||(reference=document.querySelector("body")),el.offsetParent===reference)return{x:el.offsetLeft,y:el.offsetTop};var elR=el.getBoundingClientRect(),refR=reference.getBoundingClientRect();return{x:elR.left-refR.left,y:elR.top-refR.top}},SimpleLine=function(){function SimpleLine(start,end,config){var func,delay,timer,_this=this;if(function(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}(this,SimpleLine),this.svg=null,this.id=SimpleLine.idCounter++,this.setConfig(config),start instanceof HTMLElement)this.start=start;else{if(!("string"==typeof start||this.start instanceof String))return void console.error("Start element not string or dom element",start);if(this.startSelector=start,this.start=document.querySelector(start),!(this.start instanceof HTMLElement))return void console.error("Cannot find start element:",start)}if(end instanceof HTMLElement)this.end=end;else{if(!("string"==typeof end||this.end instanceof String))return void console.error("End element not string or dom element",start);if(this.endSelector=end,this.end=document.querySelector(end),!(this.end instanceof HTMLElement))return void console.error("Cannot find end element:",end)}this.resizeObserver=new ResizeObserver((func=function(){_this.update()},delay=20,function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];var context=this;clearTimeout(timer),timer=setTimeout((function(){func.apply(context,args)}),delay)})),this.resizeObserver.observe(this.start),this.resizeObserver.observe(this.end),this.mutationObserver=new MutationObserver((function(mutations_list){mutations_list.forEach((function(mutation){mutation.removedNodes.forEach((function(removed_node){removed_node!=this.start&&removed_node!=this.end||(console.warning("Element removed",removed_node),this.remove())}))}))})),this.mutationObserver.observe(this.start.parentElement,{subtree:!1,childList:!0}),this.mutationObserver.observe(this.end.parentElement,{subtree:!1,childList:!0}),this.positionCheck(),this.specs.autorefresh>0&&(this.refreshTimer=setInterval((function(){_this.positionCheck()}),this.specs.autorefresh)),this.active=!0,this.update()}var Constructor,protoProps,staticProps;return Constructor=SimpleLine,(protoProps=[{key:"setConfig",value:function(config){var _this2=this;this.specs||(this.specs={autorefresh:10,class:"",color:"",anchors:{start:["middle","right"],end:["middle","left"]},gravity:{start:1,end:1},stroke:"4px"}),config&&"object"==_typeof(config)&&specsCopy(this.specs,config),this.svg&&(clearInterval(this.refreshTimer),this.specs.autorefresh>0&&(this.refreshTimer=setInterval((function(){_this2.positionCheck()}),this.specs.autorefresh)),this.update())}},{key:"cssClass",get:function(){return this.specs.class},set:function(cssClass){this.specs.class=cssClass,this.update()}},{key:"positionCheck",value:function(){var startPos={x:this.start.offsetLe
//# sourceMappingURL=simpleline.min.js.map