svgedit/dist/editor/extensions/ext-placemark/ext-placemark.js

3 lines
8.7 KiB
JavaScript
Raw Normal View History

2020-09-06 06:32:10 +00:00
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}var t={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,l,o,s,c,u,m,p,f,d,h,k,_,y,v,g,b,x,A,w;return regeneratorRuntime.wrap((function _callee$(L){for(;;)switch(L.prev=L.next){case 0:return x=function _addMarkerButtons(t){return Object.keys(m).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:g},panel:"placemark_panel",list:"placemark_marker",isDefault:"leftarrow"===e})})),t},b=function _getTitle(t){var e=u.langList.find((function(e){return e.id===t}));return e?e.title:t},g=function _setArrowFromButton(t){var e=this.id.split("_"),r=e[2];e[3]&&(r+="_"+e[3]),i("#placemark_marker").attr("value",r)},v=function _updateReferences(t){var e="placemark_marker_"+t.id,r="marker-start",a=f(t,r);if(a&&a.attributes.class){var o=t.getAttribute(r);if(o){var s=t.id.length,c=o.substr(-s-1,s);if(t.id!==c){var u=i("#placemark_marker").attr("value")||"leftarrow";k(e,u),n.changeSelectedAttribute(r,"url(#"+e+")"),n.call("changed",l)}}}},y=function _colorChanged(t){var e=t.getAttribute("stroke"),r=f(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)}}},_=function _setMarker(t,e){var r="marker-start",a=f(t,r);if(a&&i(a).remove(),t.removeAttribute(r),"nomarker"!==e){var l="placemark_marker_"+t.id;k(l,e),t.setAttribute(r,"url(#"+l+")"),n.call("changed",[t])}else n.call("changed",[t])},k=function _addMarker(t,e){var r=n.getElem(t);if(!r&&""!==e&&"nomarker"!==e){var i=n.getColor("stroke"),l=50,o=e;if(m[o]){o.includes("left")&&(l=0),o.includes("right")&&(l=100),r=a({element:"marker",attr:{id:t,markerUnits:"strokeWidth",orient:"auto",style:"pointer-events:none",class:o}});var s=a(m[o]),c="_o"===o.substr(-2)?"none":i;return s.setAttribute("fill",c),s.setAttribute("stroke",i),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),n.findDefs().append(r),r}}},h=function _updateFont(t){t=t.split(" ");var e=Number.parseInt(t.pop());t=t.join(" "),l.forEach((function(r){r&&r.getAttribute("class").includes("placemark")&&i(r).children().each((function(r,n){"txt"===_slicedToArray(n.id.split("_"),3)[2]&&i(n).attr({"font-family":t,"font-size":e})}))}))},d=function _updateText(t){var e=t.split(";");l.forEac
//# sourceMappingURL=ext-placemark.js.map