mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 10:34:21 +00:00
f624b7c66d
* Remove graphviz and use cytoscape.js instead * Frontend generated graphs * Make installation easier and faster * Better user experience * Family api and improved interface * Fix url history when using 0, improve button selection and reset reverse with reset button * Use klay layout * Add js translations and apply review comments
7 lines
10 KiB
JavaScript
7 lines
10 KiB
JavaScript
/**
|
|
* Minified by jsDelivr using Terser v5.15.1.
|
|
* Original file: /npm/cytoscape-cxtmenu@3.5.0/cytoscape-cxtmenu.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.cytoscapeCxtmenu=e():t.cytoscapeCxtmenu=e()}(this,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.i=function(t){return t},i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){"use strict";var n=i(2),o=i(1),a=i(3),d=a.removeEles,r=a.setStyles,l=a.createElement,s=a.getPixelRatio,c=a.getOffset;t.exports=function(t){var e=o({},n,t),i=this,a=i.container(),u=void 0,p={options:e,handlers:[],container:l({class:"cxtmenu"})},h=p.container,g=l(),f=l({tag:"canvas"}),m=[],v=f.getContext("2d"),x=100,P=2*(x+e.activePadding),b=void 0,y=void 0;function S(t,e){E.drawBg=[t,e]}function M(t,i){v.globalCompositeOperation="source-over",v.clearRect(0,0,P,P),v.fillStyle=e.fillColor;for(var n=2*Math.PI/m.length,o=Math.PI/2,a=o+n,d=0;d<m.length;d++){var r=m[d];r.fillColor&&(v.fillStyle=r.fillColor),v.beginPath(),v.moveTo(t+e.activePadding,t+e.activePadding),v.arc(t+e.activePadding,t+e.activePadding,t,2*Math.PI-o,2*Math.PI-a,!0),v.closePath(),v.fill(),o+=n,a+=n,v.fillStyle=e.fillColor}v.globalCompositeOperation="destination-out",v.strokeStyle="white",v.lineWidth=e.separatorWidth,a=(o=Math.PI/2)+n;for(var l=0;l<m.length;l++){var s=t*Math.cos(o),c=t*Math.sin(o);v.beginPath(),v.moveTo(t+e.activePadding,t+e.activePadding),v.lineTo(t+e.activePadding+s,t+e.activePadding-c),v.closePath(),v.stroke(),o+=n,a+=n}v.fillStyle="white",v.globalCompositeOperation="destination-out",v.beginPath(),v.arc(t+e.activePadding,t+e.activePadding,i+e.spotlightPadding,0,2*Math.PI,!0),v.closePath(),v.fill(),v.globalCompositeOperation="source-over"}function w(t,i,n,o,a){var d=2*Math.PI/m.length,r=Math.PI/2,l=r+d;r+=d*b,l+=d*b,v.fillStyle=e.activeFillColor,v.strokeStyle="black",v.lineWidth=1,v.beginPath(),v.moveTo(n+e.activePadding,n+e.activePadding),v.arc(n+e.activePadding,n+e.activePadding,n+e.activePadding,2*Math.PI-r,2*Math.PI-l,!0),v.closePath(),v.fill(),v.fillStyle="white",v.globalCompositeOperation="destination-out";var s=n+e.activePadding+t/n*(a+e.spotlightPadding-e.indicatorSize/4),c=n+e.activePadding+i/n*(a+e.spotlightPadding-e.indicatorSize/4),u=Math.PI/4-o;v.translate(s,c),v.rotate(u);var p=e.indicatorSize>a+e.spotlightPadding?a+e.spotlightPadding:e.indicatorSize;v.beginPath(),v.fillRect(-p/2,-p/2,p,p),v.closePath(),v.fill(),v.rotate(-u),v.translate(-s,-c),v.beginPath(),v.arc(n+e.activePadding,n+e.activePadding,a+e.spotlightPadding,0,2*Math.PI,!0),v.closePath(),v.fill(),v.globalCompositeOperation="source-over"}function C(){var t=s(),e=P,i=P;f.width=e*t,f.height=i*t,f.style.width=e+"px",f.style.height=i+"px",v.setTransform(1,0,0,1,0,0),v.scale(t,t)}a.insertBefore(h,a.firstChild),h.appendChild(g),g.appendChild(f),r(h,{position:"absolute",zIndex:e.zIndex,userSelect:"none",pointerEvents:"none"}),["mousedown","mousemove","mouseup","contextmenu"].forEach((function(t){h.addEventListener(t,(function(t){return t.preventDefault(),!1}))})),r(g,{display:"none",width:P+"px",height:P+"px",position:"absolute",zIndex:1,marginLeft:-e.activePadding+"px",marginTop:-e.activePadding+"px",userSelect:"none"}),f.width=P,f.height=P;var R=!0,E={},I=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,16)};C(),function t(){E.drawBg&&M.apply(null,E.drawBg),E.drawCommands&&w.apply(null,E.drawCommands),E={},R&&I(t)}();var O,T,F,z,N,j,k,L,A,q=void 0,W=void 0,B=void 0,H={on:function(t,e,n){var o=n;return"core"===e&&(o=function(t){if(t.cyTarget===i||t.target===i)return n.apply(this,[t])}),p.handlers.push({events:t,selector:e,fn:o}),"core"===e?i.on(t,o):i.on(t,e,o),this}};function X(){R=!1,function(){for(var t=p.handlers,e=0;e<t.length;e++){var n=t[e];"core"===n.selector?i.off(n.events,n.fn):i.off(n.events,n.selector,n.fn)}window.removeEventListener("resize",C)}(),h.remove()}return T=void 0,F=!1,z=void 0,N=void 0,j=void 0,k=void 0,L=void 0,A=function(){T&&u.grabify(),z&&i.userZoomingEnabled(!0),N&&i.userPanningEnabled(!0),j&&i.boxSelectionEnabled(!0)},window.addEventListener("resize",C),H.on("resize",(function(){C()})).on(e.openMenuEvents,e.selector,(function(t){u=this;var n=this,o=this===i;if(F&&(g.style.display="none",F=!1,A()),"function"==typeof e.commands){var s=e.commands(u);s.then?s.then((function(t){m=t,p()})):(m=s,p())}else m=e.commands,p();function p(){if(m&&0!==m.length){z=i.userZoomingEnabled(),i.userZoomingEnabled(!1),N=i.userPanningEnabled(),i.userPanningEnabled(!1),j=i.boxSelectionEnabled(),i.boxSelectionEnabled(!1),(T=u.grabbable&&u.grabbable())&&u.ungrabify();var s=void 0,p=void 0,h=void 0;!o&&n&&n.isNode instanceof Function&&n.isNode()&&!n.isParent()&&!e.atMouse?(s=n.renderedPosition(),p=n.renderedOuterWidth(),n.renderedOuterHeight(),h=p/2,h=!e.adaptativeNodeSpotlightRadius&&e.minSpotlightRadius?Math.max(h,e.minSpotlightRadius):h,h=!e.adaptativeNodeSpotlightRadius&&e.maxSpotlightRadius?Math.min(h,e.maxSpotlightRadius):h):(s=t.renderedPosition||t.cyRenderedPosition,h=(p=1)/2,h=e.minSpotlightRadius?Math.max(h,e.minSpotlightRadius):h,h=e.maxSpotlightRadius?Math.min(h,e.maxSpotlightRadius):h),y=c(a),q=s.x,W=s.y,x=p/2+(e.menuRadius instanceof Function?e.menuRadius(u):Number(e.menuRadius)),P=2*(x+e.activePadding),C(),r(g,{width:P+"px",height:P+"px",display:"block",left:s.x-x+"px",top:s.y-x+"px"}),function(t,i){d(".cxtmenu-item",g);for(var n=2*Math.PI/m.length,o=Math.PI/2,a=o+n,s=0;s<m.length;s++){var c=m[s],u=(o+a)/2,p=(t+i)/2*Math.cos(u),h=(t+i)/2*Math.sin(u),f=1*Math.abs((t-i)*Math.cos(u)),v=1*Math.abs((t-i)*Math.sin(u));f=Math.max(f,v);var x=l({class:"cxtmenu-item"});r(x,{color:e.itemColor,cursor:"default",display:"table","text-align":"center",position:"absolute","text-shadow":"-1px -1px 2px "+e.itemTextShadowColor+", 1px -1px 2px "+e.itemTextShadowColor+", -1px 1px 2px "+e.itemTextShadowColor+", 1px 1px 1px "+e.itemTextShadowColor,left:"50%",top:"50%","min-height":f+"px",width:f+"px",height:f+"px",marginLeft:p-f/2+"px",marginTop:-h-f/2+"px"});var P=l({class:"cxtmenu-content"});c.content instanceof HTMLElement?P.appendChild(c.content):P.innerHTML=c.content,r(P,{width:f+"px",height:f+"px","vertical-align":"middle",display:"table-cell"}),r(P,c.contentStyle||{}),!0!==c.disabled&&!1!==c.enabled||P.setAttribute("class","cxtmenu-content cxtmenu-disabled"),g.appendChild(x),x.appendChild(P),o+=n,a+=n}}(x,h),S(x,h),b=void 0,F=!0,k=t}}})).on("cxtdrag tapdrag",e.selector,O=function(t){if(F){t.preventDefault();var i=t.originalEvent,n=i.touches&&i.touches.length>0,o=(n?i.touches[0].pageX:i.pageX)-window.pageXOffset,a=(n?i.touches[0].pageY:i.pageY)-window.pageYOffset;b=void 0;var d=o-y.left-q,r=a-y.top-W;0===d&&(d=.01);var l=Math.sqrt(d*d+r*r),s=(r*r-l*l-d*d)/(-2*l*d),c=Math.acos(s),p=void 0;if(u&&u.isNode instanceof Function&&u.isNode()&&!u.isParent()&&!e.atMouse?(p=u.renderedOuterWidth(),B=p/2,B=!e.adaptativeNodeSpotlightRadius&&e.minSpotlightRadius?Math.max(B,e.minSpotlightRadius):B,B=!e.adaptativeNodeSpotlightRadius&&e.maxSpotlightRadius?Math.min(B,e.maxSpotlightRadius):B):(B=(p=1)/2,B=e.minSpotlightRadius?Math.max(B,e.minSpotlightRadius):B,B=e.maxSpotlightRadius?Math.min(B,e.maxSpotlightRadius):B),x=p/2+(e.menuRadius instanceof Function?e.menuRadius(u):Number(e.menuRadius)),l<B+e.spotlightPadding||"number"==typeof e.outsideMenuCancel&&l>x+e.activePadding+e.outsideMenuCancel)S(x,B);else{S(x,B);var h=d*x/l,g=r*x/l;r>0&&(c=Math.PI+Math.abs(c-Math.PI));for(var f=2*Math.PI/m.length,v=Math.PI/2,P=v+f,M=0;M<m.length;M++){var w=m[M],C=v<=c&&c<=P||v<=c+2*Math.PI&&c+2*Math.PI<=P;if(!0!==w.disabled&&!1!==w.enabled||(C=!1),C){b=M;break}v+=f,P+=f}!function(t,e,i,n,o){E.drawCommands=[t,e,i,n,o]}(h,g,x,c,B)}}}).on("tapdrag",O).on("mousemove",(function(){if(void 0!==b){var t=m[b].hover;t&&(L!==b&&t.apply(u,[u,k]),L=b)}})).on("cxttapend tapend",(function(){if(g.style.display="none",void 0!==b){var t=m[b].select;t&&(t.apply(u,[u,k]),b=void 0)}L=void 0,F=!1,A()})),{destroy:function(){X()}}}},function(t,e,i){"use strict";t.exports=null!=Object.assign?Object.assign.bind(Object):function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return i.filter((function(t){return null!=t})).forEach((function(e){Object.keys(e).forEach((function(i){return t[i]=e[i]}))})),t}},function(t,e,i){"use strict";t.exports={menuRadius:function(t){return 100},selector:"node",commands:[],fillColor:"rgba(0, 0, 0, 0.75)",activeFillColor:"rgba(1, 105, 217, 0.75)",activePadding:20,indicatorSize:24,separatorWidth:3,spotlightPadding:4,adaptativeNodeSpotlightRadius:!1,minSpotlightRadius:24,maxSpotlightRadius:38,openMenuEvents:"cxttapstart taphold",itemColor:"white",itemTextShadowColor:"transparent",zIndex:9999,atMouse:!1,outsideMenuCancel:!1}},function(t,e,i){"use strict";var n=function(t,e){for(var i=Object.keys(e),n=0,o=i.length;n<o;n++)t.style[i[n]]=e[i[n]]};t.exports={removeEles:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document,i=e.querySelectorAll(t),n=0;n<i.length;n++){var o=i[n];o.parentNode.removeChild(o)}},setStyles:n,createElement:function(t){t=t||{};var e=document.createElement(t.tag||"div");return e.className=t.class||"",t.style&&n(e,t.style),e},getPixelRatio:function(){return window.devicePixelRatio||1},getOffset:function(t){var e=t.getBoundingClientRect();return{left:e.left+document.body.scrollLeft+parseFloat(getComputedStyle(document.body)["padding-left"])+parseFloat(getComputedStyle(document.body)["border-left-width"]),top:e.top+document.body.scrollTop+parseFloat(getComputedStyle(document.body)["padding-top"])+parseFloat(getComputedStyle(document.body)["border-top-width"])}}}},function(t,e,i){"use strict";var n=i(0),o=function(t){t&&t("core","cxtmenu",n)};"undefined"!=typeof cytoscape&&o(cytoscape),t.exports=o}])})); |