svgedit/dist/editor/system/extensions/ext-markers/ext-markers.js

12 lines
58 KiB
JavaScript
Raw Normal View History

System.register([],(function(t,e){"use strict";return{execute:function(){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},n=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof r&&r)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},o=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),i={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,c={f:a&&!i.call({1:2},1)?function propertyIsEnumerable(t){var e=a(this,t);return!!e&&e.enumerable}:i},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},u={}.toString,classofRaw=function(t){return u.call(t).slice(8,-1)},s="".split,l=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?s.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return l(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!isObject(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},p=n.document,h=isObject(p)&&isObject(p.createElement),documentCreateElement=function(t){return h?p.createElement(t):{}},d=!o&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),v=Object.getOwnPropertyDescriptor,y={f:o?v:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),d)try{return v(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!c.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},g=Object.defineProperty,m={f:o?g:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),d)try{return g(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},b=o?function(t,e,r){return m.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,e){try{b(n,t,e)}catch(r){n[t]=e}return e},x="__core-js_shared__",w=n[x]||setGlobal(x,{}),S=Function.toString;"function"!=typeof w.inspectSource&&(w.inspectSource=function(t){return S.call(t)});var E,_,k,O=w.inspectSource,A=n.WeakMap,j="function"==typeof A&&/native code/.test(O(A)),P=createCommonjsModule((function(t){(t.exports=function(t,e){return w[t]||(w[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),L=0,I=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++L+I).toString(36)},T=P("keys"),sharedKey=function(t){return T[t]||(T[t]=uid(t))},C={},R=n.WeakMap;if(j){var N=new R,M=N.get,G=N.has,D=N.set;E=function(t,e){return D.call(N,t,e),e},_=function(t){return M.call(N,t)||{}},k=function(t){return G.call(N,t)}}else{var B=sharedKey("state");C[B]=!0,E=function(t,e){return b(t,B,e),e},_=function(t){return has(t,B)?t[B]:{}},k=function(t){return has(t,B)}}var U,$={set:E,get:_,has:k,enforce:function(t){return k(t)?_(t):E(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=_(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},V=
2020-09-06 06:32:10 +00:00
/**
* Localizing script for SVG-edit UI.
* @module locale
* @license MIT
2020-09-08 23:35:47 +00:00
*
* @copyright 2010 Narendra Sisodya
* @copyright 2010 Alexis Deveria
2020-09-08 23:35:47 +00:00
*
*/
jQuery;var mi=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t,r){var n;return regeneratorRuntime.wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,e.import("./extensions/ext-".concat(t,"/locale/").concat(r,".js"));case 3:n=o.sent,o.next=12;break;case 6:return o.prev=6,o.t0=o.catch(0),console.error("Missing translation (".concat(r,") for extension ").concat(t," - using 'en'")),o.next=11,e.import("./extensions/ext-".concat(t,"/locale/en.js"));case 11:n=o.sent;case 12:return o.abrupt("return",n.default);case 13:case"end":return o.stop()}}),_callee2,null,[[0,6]])})));return function loadExtensionTranslation(e,r){return t.apply(this,arguments)}}();t("default",{name:"markers",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee3(){var r,n,o,i,a,c,u,s,l,f,p,h,d,v,y,g,m,b,x,w,S,E,_,k,O,A;return regeneratorRuntime.wrap((function _callee3$(j){for(;;)switch(j.prev=j.next){case 0:return O=function _buildButtonList(){var t=[];return o.each(c,(function(e,r){var n=r+"_marker_list",o=!0;Object.keys(l).forEach((function(e){var i=k(String(e));t.push({id:s+r+"_"+e,svgicon:e,icon:"markers-"+e+".png",title:i,type:"context",events:{click:E},panel:"marker_panel",list:n,isDefault:o}),o=!1}))})),t},k=function _getTitle(t){var e=n.langList.find((function(e){return e.id===t}));return e?e.title:t},_=function _setArrowFromButton3(){return(_=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t){var e,r,n;return regeneratorRuntime.wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.id.split("_"),r=e[1],n=e[2],e[3]&&(n+="_"+e[3]),"textmarker"===n){t.next=8;break}x(r,"\\"+n),t.next=10;break;case 8:return t.next=10,w(r);case 10:case"end":return t.stop()}}),_callee2,this)})))).apply(this,arguments)},E=function _setArrowFromButton2(t){return _.apply(this,arguments)},S=function _showTextPrompt3(){return(S=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t){var e,r;return regeneratorRuntime.wrap((function _callee$(n){for(;;)switch(n.prev=n.next){case 0:return"\\"===(e=o("#"+t+"_marker").val()).substr(0,1)&&(e=""),n.next=4,o.prompt("Enter text for "+t+" marker",e);case 4:(r=n.sent)&&x(t,r);case 6:case"end":return n.stop()}}),_callee)})))).apply(this,arguments)},w=function _showTextPrompt2(t){return S.apply(this,arguments)},x=function _triggerTextEntry(t,e){o("#"+t+"_marker").val(e),o("#"+t+"_marker").change()},b=function _updateReferences(t){o.each(c,(function(e,r){var n=u+r+"_"+t.id,a="marker-"+r,c=f(t,a);if(c&&c.attributes.se_type){var s=t.getAttribute(a);if(s){var l=t.id.length,p=s.substr(-l-1,l);if(t.id!==p){var d=o("#"+r+"_marker").attr("value");v(n,d),i.changeSelectedAttribute(a,"url(#"+n+")"),"line"===t.tagName&&"mid"===r&&(t=y(t)),i.call("changed",h)}}}}))},m=function _colorChanged(t){var e=t.getAttribute("stroke");o.each(c,(function(r,n){var o=f(t,"marker-"+n);if(o&&o.attributes.se_type){var i=o.lastElementChild;if(i){var a=i.getAttribute("fill"),c=i.getAttribute("stroke");a&&"none"!==a&&i.setAttribute("fill",e),c&&"none"!==c&&i.setAttribute("stroke",e)}}}))},g=function _setMarker(){var t={start_marker:"start",mid_marker:"mid",end_marker:"end"}[this.id],e="marker-"+t,r=h[0],n=f(r,e);n&&o(n).remove(),r.removeAttribute(e);var a=this.value;if(""===a&&(a="\\nomarker"),"\\nomarker"===a)return p(t,a),void i.call("changed",h);var c=u+t+"_"+r.id;v(c,a),i.changeSelectedAttribute(e,"url(#"+c+")"),"line"===r.tagName&&"mid"===t&&y(r),i.call("changed",h),p(t,a)},y=function _convertline(e){if("line"!==e.tagName)return e;var r=Number(e.getAttribute("x1")),n=Number(e.getAttribute("x2")),u=Number(e.getAttribute("y1")),s=Number(e.getAttribute("y2")),l=e.id,f=a({element:"polyline",attr:{points:r+","+u+(" "+(r+n)/2+","+(u+s)/2+" ")+n+","+s,stroke:e.getAttribute("stroke"),"stroke-width":e.getAttribute("stroke-width"),fill:"none",opacity:e.getAttribute("opacity")||1}});o.each(c,(function(t,r){var n="marker-"+r;e.getAttribute(n)&&f.setAttribute(n,e.getAttribute(n))}));var p=new t.BatchCommand;return p.addSubComman