2 lines
9.8 KiB
JavaScript
2 lines
9.8 KiB
JavaScript
System.register([],(function(t){"use strict";return{execute:function(){function _AwaitValue(t){this.wrapped=t}function _AsyncGenerator(t){var e,r;function resume(e,r){try{var n=t[e](r),a=n.value,i=a instanceof _AwaitValue;Promise.resolve(i?a.wrapped:a).then((function(t){i?resume("return"===e?"return":"next",t):settle(n.done?"return":"normal",t)}),(function(t){resume("throw",t)}))}catch(t){settle("throw",t)}}function settle(t,n){switch(t){case"return":e.resolve({value:n,done:!0});break;case"throw":e.reject(n);break;default:e.resolve({value:n,done:!1})}(e=e.next)?resume(e.key,e.arg):r=null}this._invoke=function send(t,n){return new Promise((function(a,i){var o={key:t,arg:n,resolve:a,reject:i,next:null};r?r=r.next=o:(e=r=o,resume(t,n))}))},"function"!=typeof t.return&&(this.return=void 0)}function asyncGeneratorStep(t,e,r,n,a,i,o){try{var l=t[i](o),s=l.value}catch(t){return void r(t)}l.done?e(s):Promise.resolve(s).then(n,a)}function _slicedToArray(t,e){return _arrayWithHoles(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 o,l=t[Symbol.iterator]();!(n=(o=l.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){a=!0,i=t}finally{try{n||null==l.return||l.return()}finally{if(a)throw i}}return r}(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}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}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"==typeof Symbol&&Symbol.asyncIterator&&(_AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}),_AsyncGenerator.prototype.next=function(t){return this._invoke("next",t)},_AsyncGenerator.prototype.throw=function(t){return this._invoke("throw",t)},_AsyncGenerator.prototype.return=function(t){return this._invoke("return",t)};t("default",{name:"placemark",init:function init(t){var e=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 r,n,a,i,o,l,s,c,u,p,m,f,d,h,y,k,_,v,b,g,x,A;return regeneratorRuntime.wrap((function _callee$(w){for(;;)switch(w.prev=w.next){case 0:return g=function _addMarkerButtons(t){return Object.keys(u).forEach((function(e){var r=b(String(e));t.push({id:"placemark_marker_"+e,svgicon:e,icon:"markers-"+e+".png",title:r,type:"context",events:{click:v},panel:"placemark_panel",list:"placemark_marker",isDefault:"leftarrow"===e})})),t},b=function _getTitle(t){var e=c.langList.find((function(e){return e.id===t}));return e?e.title:t},v=function _setArrowFromButton(t){var e=this.id.split("_"),r=e[2];e[3]&&(r+="_"+e[3]),a("#placemark_marker").attr("value",r)},_=function _updateReferences(t){var e="placemark_marker_"+t.id,n="marker-start",i=m(t,n);if(i&&i.attributes.class){var l=t.getAttribute(n);if(l){var s=t.id.length,c=l.substr(-s-1,s);if(t.id!==c){var u=a("#placemark_marker").attr("value")||"leftarrow";h(e,u),r.changeSelectedAttribute(n,"url(#"+e+")"),r.call("changed",o)}}}},k=function _colorChanged(t){var e=t.getAttribute("stroke"),r=m(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 n="marker-start",i=m(t,n);if(i&&a(i).remove(),t.removeAttribute(n),"nomarker"!==e){var o="placemark_marker_"+t.id;h(o,e),t.setAttribute(n,"url(#"+o+")"),r.call("changed",[t])}else r.call("changed",[t])},h=function _addMarker(t,e){var a=r.getElem(t);if(!a&&""!==e&&"nomarker"!==e){var i=r.getColor("stroke"),o=50,l=e;if(u[l]){l.includes("left")&&(o=0),l.includes("right")&&(o=100),a=n({element:"marker",attr:{id:t,markerUnits:"strokeWidth",orient:"auto",style:"pointer-events:none",class:l}});var s=n(u[l]),c="_o"===l.substr(-2)?"none":i;return s.setAttribute("fill",c),s.setAttribute("stroke",i),s.setAttribute("stroke-width",10),a.append(s),a.setAttribute("viewBox","0 0 100 100"),a.setAttribute("markerWidth",10),a.setAttribute("markerHeight",10),a.setAttribute("refX",o),a.setAttribute("refY",50),r.findDefs().append(a),a}}},d=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")&&a(r).children().each((function(r,n){"txt"===_slicedToArray(n.id.split("_"),3)[2]&&a(n).attr({"font-family":t,"font-size":e})}))}))},f=function _updateText(t){var e=t.split(";");o.forEach((function(t){t&&t.getAttribute("class").includes("placemark")&&a(t).children().each((function(t,r){var n=_slicedToArray(r.id.split("_"),4),i=n[2],o=n[3];"txt"===i&&a(r).text(e[o])}))}))},m=function _getLinked(t,e){if(!t)return null;var n=t.getAttribute(e);if(!n)return null;var a=n.match(/\(#(.*)\)/);return a&&2===a.length?r.getElem(a[1]):null},p=function _showPanel(t){a("#placemark_panel").toggle(t)},r=e.canvas,n=r.addSVGElementFromJson,a=t.$,i=t.importLocale,w.next=17,i();case 17:return c=w.sent,u={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){u[t+"_o"]=u[t]})),x=[{id:"tool_placemark",icon:"placemark.png",type:"mode",position:12,events:{click:function click(){p(!0),r.setMode("placemark")}}}],A=[{type:"button-select",panel:"placemark_panel",id:"placemark_marker",colnum:3,events:{change:v}},{type:"input",panel:"placemark_panel",id:"placemarkText",size:20,defval:"",events:{change:function change(){f(this.value)}}},{type:"input",panel:"placemark_panel",id:"placemarkFont",size:7,defval:"Arial 10",events:{change:function change(){d(this.value)}}}],w.abrupt("return",{name:c.name,svgicons:"placemark-icons.xml",buttons:g(c.buttons.map((function(t,e){return Object.assign(x[e],t)}))),context_tools:c.contextTools.map((function(t,e){return Object.assign(A[e],t)})),callback:function callback(){a("#placemark_panel").hide()},mouseDown:function mouseDown(t){var e=r.getColor("stroke"),n=r.getStrokeWidth();if("placemark"===r.getMode()){l=!0;var i=r.getNextId(),o=a("#placemarkText").val().split(";"),c=a("#placemarkFont").val().split(" "),u=Number.parseInt(c.pop());c=c.join(" ");var p=t.start_x+10,m=t.start_y+10,f=0,d=[{element:"line",attr:{id:i+"_pline_0",fill:"none",stroke:e,"stroke-width":n,"stroke-linecap":"round",x1:t.start_x,y1:t.start_y,x2:p,y2:m}}];return o.forEach((function(t,r){f=Math.max(f,t.length),d.push({element:"line",attr:{id:i+"_tline_"+r,fill:"none",stroke:e,"stroke-width":n,"stroke-linecap":"round",x1:p,y1:m+(u+6)*r,x2:p+t.length*u*.5+u,y2:m+(u+6)*r}}),d.push({element:"text",attr:{id:i+"_txt_"+r,fill:e,stroke:"none","stroke-width":0,x:p+3,y:m-3+(u+6)*r,"font-family":c,"font-size":u,"text-anchor":"start"},children:[t]})})),o.length>0&&d.push({element:"line",attr:{id:i+"_vline_0",fill:"none",stroke:e,"stroke-width":n,"stroke-linecap":"round",x1:p,y1:m,x2:p,y2:m+(u+6)*(o.length-1)}}),s=r.addSVGElementFromJson({element:"g",attr:{id:i,class:"placemark",fontSize:u,maxlen:f,lines:o.length,x:t.start_x,y:t.start_y,px:t.start_x,py:t.start_y},children:d}),y(s.firstElementChild,a("#placemark_marker").attr("value")||"leftarrow"),{started:!0}}},mouseMove:function mouseMove(t){if(l&&"placemark"===r.getMode()){var e=t.mouse_x/r.getZoom(),n=t.mouse_y/r.getZoom(),i=a(s).attr(["fontSize","maxlen","lines","px","py"]),o=i.fontSize,c=i.maxlen,u=i.lines,p=i.px,m=i.py;return a(s).attr({x:e,y:n}),a(s).children().each((function(t,r){var a=_slicedToArray(r.id.split("_"),4),i=a[2],l=a[3],s=n+(o+6)*l,f=e+c*o*.5+o,d=e+(f-e)/2<p?f:e,h=n+(o+6)*(u-1)/2<m?n+(o+6)*(u-1):n;"pline"===i&&(r.setAttribute("x2",d),r.setAttribute("y2",h)),"tline"===i&&(r.setAttribute("x1",e),r.setAttribute("y1",s),r.setAttribute("x2",f),r.setAttribute("y2",s)),"vline"===i&&(r.setAttribute("x1",d),r.setAttribute("y1",n),r.setAttribute("x2",d),r.setAttribute("y2",n+(o+6)*(u-1))),"txt"===i&&(r.setAttribute("x",e+o/2),r.setAttribute("y",s-3))})),{started:!0}}},mouseUp:function mouseUp(){if("placemark"===r.getMode()){var t=a(s).attr(["x","y","px","py"]),e=t.x,n=t.y,i=t.px,o=t.py;return{keep:e!=i&&n!=o,element:s}}},selectedChanged:function selectedChanged(t){(o=t.elems).forEach((function(t){if(t&&t.getAttribute("class").includes("placemark")){var e=[];a(t).children().each((function(t,r){"txt"===_slicedToArray(r.id.split("_"),3)[2]&&(a("#placemarkFont").val(r.getAttribute("font-family")+" "+r.getAttribute("font-size")),e.push(a(r).text()))})),a("#placemarkText").val(e.join(";")),p(!0)}else p(!1)}))},elementChanged:function elementChanged(t){t.elems.forEach((function(t){t.id.includes("pline_0")&&(k(t),_(t))}))}});case 23:case"end":return w.stop()}}),_callee)})))()}})}}}));
|