2 lines
8.8 KiB
JavaScript
2 lines
8.8 KiB
JavaScript
System.register([],(function(t,e){"use strict";return{execute:function(){function asyncGeneratorStep(t,e,r,n,a,i,l){try{var o=t[i](l),s=o.value}catch(t){return void r(t)}o.done?e(s):Promise.resolve(s).then(n,a)}function _slicedToArray(t,e){return function _arrayWithHoles(t){if(Array.isArray(t))return t}(t)||function _iterableToArrayLimit(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,a=!1,i=void 0;try{for(var l,o=t[Symbol.iterator]();!(n=(l=o.next()).done)&&(r.push(l.value),!e||r.length!==e);n=!0);}catch(t){a=!0,i=t}finally{try{n||null==o.return||o.return()}finally{if(a)throw i}}return r}(t,e)||function _unsupportedIterableToArray(t,e){if(!t)return;if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray(t,e)}(t,e)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}t("default",{name:"placemark",init:function init(t){var r=this;return function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,a){var i=t.apply(e,r);function _next(t){asyncGeneratorStep(i,n,a,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(i,n,a,_next,_throw,"throw",t)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var n,a,i,l,o,s,c,u,m,p,f,d,h,k,_,y,v,g,b,x,A,w,L;return regeneratorRuntime.wrap((function _callee$(M){for(;;)switch(M.prev=M.next){case 0:return A=function _addMarkerButtons(t){return Object.keys(p).forEach((function(e){var r=x(String(e));t.push({id:"placemark_marker_"+e,svgicon:e,icon:"markers-"+e+".png",title:r,type:"context",events:{click:b},panel:"placemark_panel",list:"placemark_marker",isDefault:"leftarrow"===e})})),t},x=function _getTitle(t){var e=m.langList.find((function(e){return e.id===t}));return e?e.title:t},b=function _setArrowFromButton(t){var e=this.id.split("_"),r=e[2];e[3]&&(r+="_"+e[3]),l("#placemark_marker").attr("value",r)},g=function _updateReferences(t){var e="placemark_marker_"+t.id,r="marker-start",n=d(t,r);if(n&&n.attributes.class){var i=t.getAttribute(r);if(i){var s=t.id.length,c=i.substr(-s-1,s);if(t.id!==c){var u=l("#placemark_marker").attr("value")||"leftarrow";_(e,u),a.changeSelectedAttribute(r,"url(#"+e+")"),a.call("changed",o)}}}},v=function _colorChanged(t){var e=t.getAttribute("stroke"),r=d(t,"marker-start");if(r&&r.attributes.class){var n=r.lastElementChild;if(n){var a=n.getAttribute("fill"),i=n.getAttribute("stroke");a&&"none"!==a&&n.setAttribute("fill",e),i&&"none"!==i&&n.setAttribute("stroke",e)}}},y=function _setMarker(t,e){var r="marker-start",n=d(t,r);if(n&&l(n).remove(),t.removeAttribute(r),"nomarker"!==e){var i="placemark_marker_"+t.id;_(i,e),t.setAttribute(r,"url(#"+i+")"),a.call("changed",[t])}else a.call("changed",[t])},_=function _addMarker(t,e){var r=a.getElem(t);if(!r&&""!==e&&"nomarker"!==e){var n=a.getColor("stroke"),l=50,o=e;if(p[o]){o.includes("left")&&(l=0),o.includes("right")&&(l=100),r=i({element:"marker",attr:{id:t,markerUnits:"strokeWidth",orient:"auto",style:"pointer-events:none",class:o}});var s=i(p[o]),c="_o"===o.substr(-2)?"none":n;return s.setAttribute("fill",c),s.setAttribute("stroke",n),s.setAttribute("stroke-width",10),r.append(s),r.setAttribute("viewBox","0 0 100 100"),r.setAttribute("markerWidth",10),r.setAttribute("markerHeight",10),r.setAttribute("refX",l),r.setAttribute("refY",50),a.findDefs().append(r),r}}},k=function _updateFont(t){t=t.split(" ");var e=Number.parseInt(t.pop());t=t.join(" "),o.forEach((function(r){r&&r.getAttribute("class").includes("placemark")&&l(r).children().each((function(r,n){"txt"===_slicedToArray(n.id.split("_"),3)[2]&&l(n).attr({"font-family":t,"font-size":e})}))}))},h=function _updateText(t){var e=t.split(";");o.forEach((function(t){t&&t.getAttribute("class").includes("placemark")&&l(t).children().each((function(t,r){var n=_slicedToArray(r.id.split("_"),4),a=n[2],i=n[3];"txt"===a&&l(r).text(e[i])}))}))},d=function _getLinked(t,e){if(!t)return null;var r=t.getAttribute(e);if(!r)return null;var n=r.match(/\(#(.*)\)/);return n&&2===n.length?a.getElem(n[1]):null},f=function _showPanel(t){l("#placemark_panel").toggle(t)},a=(n=r).canvas,i=a.addSVGElementFromJson,l=t.$,M.next=17,e.import("./locale/".concat(n.curPrefs.lang,".js"));case 17:return u=M.sent,m=u.default,p={nomarker:{},forwardslash:{element:"path",attr:{d:"M30,100 L70,0"}},reverseslash:{element:"path",attr:{d:"M30,0 L70,100"}},verticalslash:{element:"path",attr:{d:"M50,0 L50,100"}},xmark:{element:"path",attr:{d:"M20,80 L80,20 M80,80 L20,20"}},leftarrow:{element:"path",attr:{d:"M0,50 L100,90 L70,50 L100,10 Z"}},rightarrow:{element:"path",attr:{d:"M100,50 L0,90 L30,50 L0,10 Z"}},box:{element:"path",attr:{d:"M20,20 L20,80 L80,80 L80,20 Z"}},star:{element:"path",attr:{d:"M10,30 L90,30 L20,90 L50,10 L80,90 Z"}},mcircle:{element:"circle",attr:{r:30,cx:50,cy:50}},triangle:{element:"path",attr:{d:"M10,80 L50,20 L80,80 Z"}}},["leftarrow","rightarrow","box","star","mcircle","triangle"].forEach((function(t){p[t+"_o"]=p[t]})),w=[{id:"tool_placemark",icon:"placemark.png",type:"mode",position:12,events:{click:function click(){f(!0),a.setMode("placemark")}}}],L=[{type:"button-select",panel:"placemark_panel",id:"placemark_marker",colnum:3,events:{change:b}},{type:"input",panel:"placemark_panel",id:"placemarkText",size:20,defval:"",events:{change:function change(){h(this.value)}}},{type:"input",panel:"placemark_panel",id:"placemarkFont",size:7,defval:"Arial 10",events:{change:function change(){k(this.value)}}}],M.abrupt("return",{name:m.name,svgicons:"placemark-icons.xml",buttons:A(m.buttons.map((function(t,e){return Object.assign(w[e],t)}))),context_tools:m.contextTools.map((function(t,e){return Object.assign(L[e],t)})),callback:function callback(){l("#placemark_panel").hide()},mouseDown:function mouseDown(t){var e=a.getColor("stroke"),r=a.getStrokeWidth();if("placemark"===a.getMode()){s=!0;var n=a.getNextId(),i=l("#placemarkText").val().split(";"),o=l("#placemarkFont").val().split(" "),u=Number.parseInt(o.pop());o=o.join(" ");var m=t.start_x+10,p=t.start_y+10,f=0,d=[{element:"line",attr:{id:n+"_pline_0",fill:"none",stroke:e,"stroke-width":r,"stroke-linecap":"round",x1:t.start_x,y1:t.start_y,x2:m,y2:p}}];return i.forEach((function(t,a){f=Math.max(f,t.length),d.push({element:"line",attr:{id:n+"_tline_"+a,fill:"none",stroke:e,"stroke-width":r,"stroke-linecap":"round",x1:m,y1:p+(u+6)*a,x2:m+t.length*u*.5+u,y2:p+(u+6)*a}}),d.push({element:"text",attr:{id:n+"_txt_"+a,fill:e,stroke:"none","stroke-width":0,x:m+3,y:p-3+(u+6)*a,"font-family":o,"font-size":u,"text-anchor":"start"},children:[t]})})),i.length>0&&d.push({element:"line",attr:{id:n+"_vline_0",fill:"none",stroke:e,"stroke-width":r,"stroke-linecap":"round",x1:m,y1:p,x2:m,y2:p+(u+6)*(i.length-1)}}),c=a.addSVGElementFromJson({element:"g",attr:{id:n,class:"placemark",fontSize:u,maxlen:f,lines:i.length,x:t.start_x,y:t.start_y,px:t.start_x,py:t.start_y},children:d}),y(c.firstElementChild,l("#placemark_marker").attr("value")||"leftarrow"),{started:!0}}},mouseMove:function mouseMove(t){if(s&&"placemark"===a.getMode()){var e=t.mouse_x/a.getZoom(),r=t.mouse_y/a.getZoom(),n=l(c).attr(["fontSize","maxlen","lines","px","py"]),i=n.fontSize,o=n.maxlen,u=n.lines,m=n.px,p=n.py;return l(c).attr({x:e,y:r}),l(c).children().each((function(t,n){var a=_slicedToArray(n.id.split("_"),4),l=a[2],s=a[3],c=r+(i+6)*s,f=e+o*i*.5+i,d=e+(f-e)/2<m?f:e,h=r+(i+6)*(u-1)/2<p?r+(i+6)*(u-1):r;"pline"===l&&(n.setAttribute("x2",d),n.setAttribute("y2",h)),"tline"===l&&(n.setAttribute("x1",e),n.setAttribute("y1",c),n.setAttribute("x2",f),n.setAttribute("y2",c)),"vline"===l&&(n.setAttribute("x1",d),n.setAttribute("y1",r),n.setAttribute("x2",d),n.setAttribute("y2",r+(i+6)*(u-1))),"txt"===l&&(n.setAttribute("x",e+i/2),n.setAttribute("y",c-3))})),{started:!0}}},mouseUp:function mouseUp(){if("placemark"===a.getMode()){var t=l(c).attr(["x","y","px","py"]),e=t.x,r=t.y,n=t.px,i=t.py;return{keep:e!=n&&r!=i,element:c}}},selectedChanged:function selectedChanged(t){(o=t.elems).forEach((function(t){if(t&&t.getAttribute("class").includes("placemark")){var e=[];l(t).children().each((function(t,r){"txt"===_slicedToArray(r.id.split("_"),3)[2]&&(l("#placemarkFont").val(r.getAttribute("font-family")+" "+r.getAttribute("font-size")),e.push(l(r).text()))})),l("#placemarkText").val(e.join(";")),f(!0)}else f(!1)}))},elementChanged:function elementChanged(t){t.elems.forEach((function(t){t.id.includes("pline_0")&&(v(t),g(t))}))}});case 24:case"end":return M.stop()}}),_callee)})))()}})}}}));
|