10 lines
4.4 KiB
JavaScript
10 lines
4.4 KiB
JavaScript
System.register([],(function(e,t){"use strict";return{execute:function(){function asyncGeneratorStep(e,t,r,n,a,i,o){try{var l=e[i](o),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,a)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function _next(e){asyncGeneratorStep(i,n,a,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(i,n,a,_next,_throw,"throw",e)}_next(void 0)}))}}
|
|
/**
|
|
* @file ext-arrows.js
|
|
*
|
|
* @license MIT
|
|
*
|
|
* @copyright 2010 Alexis Deveria
|
|
*
|
|
*/e("default",{name:"arrows",init:function init(e){var r=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var n,a,i,o,l,c,u,d,s,f,m,h,v,k,g,_,b,p,w,x,A;return regeneratorRuntime.wrap((function _callee2$(y){for(;;)switch(y.prev=y.next){case 0:return x=function _colorChanged(t){var r=t.getAttribute("stroke"),n=["start","mid","end"],a=o.findDefs();u.each(n,(function(i,o){var l=g(t,"marker-"+o);if(l){var c=u(l).children().attr("fill"),d=u(l).children().attr("d");if(c!==r){var s=u(a).find("marker"),m=null;if(s.each((function(){var e=u(this).children().attr(["fill","d"]);e.fill===r&&e.d===d&&(m=this)})),!m){var h=l.id.includes("_fw")?"fw":"bk";m=p(h,o,f+h+s.length),u(m).children().attr("fill",r)}u(t).attr("marker-"+o,"url(#"+m.id+")");var v=!0;u(e.svgcontent).find("line, polyline, path, polygon").each((function(){var e=this;if(u.each(n,(function(t,r){if(u(e).attr("marker-"+r)==="url(#"+l.id+")")return v=!1})),!v)return!1})),v&&u(l).remove()}}}))},w=function _setArrow(){b();var e=this.value;if("none"!==e){var t="fw";"mid_bk"===e?(e="mid",t="bk"):"both"===e?(p("bk",e),o.changeSelectedAttribute("marker-start","url(#"+k.bk.id+")"),e="end",t="fw"):"start"===e&&(t="bk"),p(t,e),o.changeSelectedAttribute("marker-"+e,"url(#"+k[t].id+")"),o.call("changed",s)}},p=function _addMarker(e,t,r){r=r||f+e;var n=k[e];"mid"===t&&(n.refx=5);var a=o.getElem(r);if(!a){a=l({element:"marker",attr:{viewBox:"0 0 10 10",id:r,refY:5,markerUnits:"strokeWidth",markerWidth:5,markerHeight:5,orient:"auto",style:"pointer-events:none"}});var i=l({element:"path",attr:{d:n.d,fill:"#000000"}});a.append(i),o.findDefs().append(a)}return a.setAttribute("refX",n.refx),a},b=function _resetMarker(){var e=s[0];e.removeAttribute("marker-start"),e.removeAttribute("marker-mid"),e.removeAttribute("marker-end")},_=function _showPanel(e){if(u("#arrow_panel").toggle(e),e){var t,r=s[0],n=r.getAttribute("marker-end"),a=r.getAttribute("marker-start"),i=r.getAttribute("marker-mid");n&&a?t="both":n?t="end":a?t="start":i&&(t="mid",i.includes("bk")&&(t="mid_bk")),a||i||n||(t="none"),u("#arrow_list").val(t)}},g=function _getLinked(e,t){var r=e.getAttribute(t);if(!r)return null;var n=r.match(/\(#(.*)\)/);return n&&2===n.length?o.getElem(n[1]):null},v=function _unsetArrowNonce(e){m=!1,f=d,k.fw.id=f+"fw",k.bk.id=f+"bk"},h=function _setArrowNonce(e,t){m=!0,f=d+t+"_",k.fw.id=f+"fw",k.bk.id=f+"bk"},n=r,y.next=11,t.import("./locale/".concat(n.curPrefs.lang,".js"));case 11:return a=y.sent,i=a.default,o=n.canvas,l=o.addSVGElementFromJson,c=e.nonce,u=e.$,d="se_arrow_",m=e.randomize_ids,o.bind("setnonce",h),o.bind("unsetnonce",v),k={fw:{d:"m0,0l10,5l-10,5l5,-5l-5,-5z",refx:8,id:(f=m?d+c+"_":d)+"fw"},bk:{d:"m10,0l-10,5l10,5l-5,-5l5,-5z",refx:2,id:f+"bk"}},A=[{type:"select",panel:"arrow_panel",id:"arrow_list",defval:"none",events:{change:w}}],y.abrupt("return",{name:i.name,context_tools:i.contextTools.map((function(e,t){return Object.assign(A[t],e)})),callback:function callback(){u("#arrow_panel").hide(),u("#arrow_list option")[0].id="connector_no_arrow"},addLangData:function addLangData(e){return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var t,r,n;return regeneratorRuntime.wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:return e.lang,t=e.importLocale,a.next=3,t();case 3:return r=a.sent,n=r.langList,a.abrupt("return",{data:n});case 6:case"end":return a.stop()}}),_callee)})))()},selectedChanged:function selectedChanged(e){for(var t=["line","path","polyline","polygon"],r=(s=e.elems).length;r--;){var n=s[r];n&&t.includes(n.tagName)&&e.selectedElement&&!e.multiselected?_(!0):_(!1)}},elementChanged:function elementChanged(e){var t=e.elems[0];t&&(t.getAttribute("marker-start")||t.getAttribute("marker-mid")||t.getAttribute("marker-end"))&&x(t)}});case 22:case"end":return y.stop()}}),_callee2)})))()}})}}}));
|