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

12 lines
51 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)},f="".split,s=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?f.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 s(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")},l={}.hasOwnProperty,has=function(t,e){return l.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},w="__core-js_shared__",S=n[w]||setGlobal(w,{}),x=Function.toString;"function"!=typeof S.inspectSource&&(S.inspectSource=function(t){return x.call(t)});var E,O,j,P=S.inspectSource,T=n.WeakMap,A="function"==typeof T&&/native code/.test(P(T)),_=createCommonjsModule((function(t){(t.exports=function(t,e){return S[t]||(S[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),I=0,k=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++I+k).toString(36)},L=_("keys"),sharedKey=function(t){return L[t]||(L[t]=uid(t))},R={},C=n.WeakMap;if(A){var G=new C,M=G.get,N=G.has,D=G.set;E=function(t,e){return D.call(G,t,e),e},O=function(t){return M.call(G,t)||{}},j=function(t){return N.call(G,t)}}else{var U=sharedKey("state");R[U]=!0,E=function(t,e){return b(t,U,e),e},O=function(t){return has(t,U)?t[U]:{}},j=function(t){return has(t,U)}}var V,$,B={set:E,get:O,has:j,enforce:function(t){return j(t)?O(t):E(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=O(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},
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 ii=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:"grid",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee(){var r,n,o,i,a,c,u,f,s,l,p,h,d,v,y,g,m,b,w,S,x;return regeneratorRuntime.wrap((function _callee$(E){for(;;)switch(E.prev=E.next){case 0:return S=function _gridUpdate(){d&&w(c.getZoom()),r("#canvasGrid").toggle(d),r("#view_grid").toggleClass("push_button_pressed tool_button")},w=function _updateGrid(t){var e=p[i.curConfig.baseUnit]*t,r=100/e,n=1;h.some((function(t){return n=t,r<=t}));var o=n*e;s.width=o,s.height=o;var a=s.getContext("2d"),u=.5,f=o/10;a.globalAlpha=.2,a.strokeStyle=i.curConfig.gridColor;for(var l=1;l<10;l++){var d=Math.round(f*l)+.5;a.moveTo(d,o),a.lineTo(d,0),a.moveTo(o,d),a.lineTo(0,d)}a.stroke(),a.beginPath(),a.globalAlpha=.5,a.moveTo(u,o),a.lineTo(u,0),a.moveTo(o,u),a.lineTo(0,u),a.stroke();var v=s.toDataURL("image/png");m.setAttribute("width",o),m.setAttribute("height",o),m.parentNode.setAttribute("width",o),m.parentNode.setAttribute("height",o),c.setHref(m,v)},r=t.$,n=t.NS,o=t.getTypeMap,i=e,E.next=6,ii("grid",i.curPrefs.lang);case 6:return a=E.sent,c=i.canvas,u=document.getElementById("svgcanvas").ownerDocument,f=c.assignAttributes,s=document.createElement("canvas"),l=r("#canvasBackground"),p=o(),h=[.01,.1,1,10,100,1e3],d=i.curConfig.showGrid||!1,r(s).hide().appendTo("body"),v=u.createElementNS(n.SVG,"svg"),f(v,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"}),l.append(v),y=u.createElementNS(n.SVG,"defs"),g=u.createElementNS(n.SVG,"pattern"),f(g,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100}),m=u.createElementNS(n.SVG,"image"),f(m,{x:0,y:0,width:100,height:100}),g.append(m),y.append(g),r("#canvasGrid").append(y),b=u.createElementNS(n.SVG,"rect"),f(b,{width:"100%",height:"100%",x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"}),r("#canvasGrid").append(b),x=[{id:"view_grid",icon:"grid.png",type:"context",panel:"editor_panel",events:{click:function click(){i.curConfig.showGrid=d=!d,S()}}}],E.abrupt("return",{name:a.name,svgicons:"grid-icon.xml",zoomChanged:function zoomChanged(t){d&&w(t)},callback:function callback(){d&&S()},buttons:a.buttons.map((function(t,e){return Object.assign(x[e],t)}))});case 27:case"end":return E.stop()}}),_callee)})))()}})}}}));