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

10 lines
43 KiB
JavaScript
Raw Normal View History

System.register([],(function(t){"use strict";return{execute:function(){var e="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},r=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof e&&e)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},n=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),o={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,a={f:i&&!o.call({1:2},1)?function propertyIsEnumerable(t){var e=i(this,t);return!!e&&e.enumerable}:o},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},c={}.toString,classofRaw=function(t){return c.call(t).slice(8,-1)},u="".split,f=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?u.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 f(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")},s={}.hasOwnProperty,has=function(t,e){return s.call(t,e)},l=r.document,p=isObject(l)&&isObject(l.createElement),documentCreateElement=function(t){return p?l.createElement(t):{}},h=!n&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),y=Object.getOwnPropertyDescriptor,v={f:n?y:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),h)try{return y(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!a.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},d=Object.defineProperty,g={f:n?d:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),h)try{return d(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}},m=n?function(t,e,r){return g.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,e){try{m(r,t,e)}catch(n){r[t]=e}return e},b="__core-js_shared__",w=r[b]||setGlobal(b,{}),S=Function.toString;"function"!=typeof w.inspectSource&&(w.inspectSource=function(t){return S.call(t)});var O,j,x,E=w.inspectSource,P=r.WeakMap,_="function"==typeof P&&/native code/.test(E(P)),A=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)"})})),T=0,k=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++T+k).toString(36)},L=A("keys"),sharedKey=function(t){return L[t]||(L[t]=uid(t))},G={},I=r.WeakMap;if(_){var C=new I,M=C.get,N=C.has,R=C.set;O=function(t,e){return R.call(C,t,e),e},j=function(t){return M.call(C,t)||{}},x=function(t){return N.call(C,t)}}else{var D=sharedKey("state");G[D]=!0,O=function(t,e){return m(t,D,e),e},j=function(t){return has(t,D)?t[D]:{}},x=function(t){return has(t,D)}}var V,z,U={set:O,get:j,has:x,enforce:function(t){return x(t)?j(t):O(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=j(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},W=
2020-09-06 06:32:10 +00:00
/**
2020-09-08 23:35:47 +00:00
* @file ext-grid.js
*
* @license Apache-2.0
*
* @copyright 2010 Redou Mine, 2010 Alexis Deveria
*
*/t("default",{name:"grid",init:function init(t){var e=this;return function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function _next(t){asyncGeneratorStep(i,n,o,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(i,n,o,_next,_throw,"throw",t)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var r,n,o,i,a,c,u,f,s,l,p,h,y,v,d,g,m,b,w,S,O,j;return regeneratorRuntime.wrap((function _callee$(x){for(;;)switch(x.prev=x.next){case 0:return O=function _gridUpdate(){v&&S(u.getZoom()),r("#canvasGrid").toggle(v),r("#view_grid").toggleClass("push_button_pressed tool_button")},S=function _updateGrid(t){var e=h[i.curConfig.baseUnit]*t,r=100/e,n=1;y.some((function(t){return n=t,r<=t}));var o=n*e;l.width=o,l.height=o;var a=l.getContext("2d"),c=.5,f=o/10;a.globalAlpha=.2,a.strokeStyle=i.curConfig.gridColor;for(var s=1;s<10;s++){var p=Math.round(f*s)+.5;a.moveTo(p,o),a.lineTo(p,0),a.moveTo(o,p),a.lineTo(0,p)}a.stroke(),a.beginPath(),a.globalAlpha=.5,a.moveTo(c,o),a.lineTo(c,0),a.moveTo(o,c),a.lineTo(0,c),a.stroke();var v=l.toDataURL("image/png");b.setAttribute("width",o),b.setAttribute("height",o),b.parentNode.setAttribute("width",o),b.parentNode.setAttribute("height",o),u.setHref(b,v)},r=t.$,n=t.NS,o=t.getTypeMap,i=e,x.next=6,__variableDynamicImportRuntime0__("./locale/".concat(i.curPrefs.lang,".js"));case 6:return a=x.sent,c=a.default,u=i.canvas,f=document.getElementById("svgcanvas").ownerDocument,s=u.assignAttributes,l=document.createElement("canvas"),p=r("#canvasBackground"),h=o(),y=[.01,.1,1,10,100,1e3],v=i.curConfig.showGrid||!1,r(l).hide().appendTo("body"),d=f.createElementNS(n.SVG,"svg"),s(d,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"}),p.append(d),g=f.createElementNS(n.SVG,"defs"),m=f.createElementNS(n.SVG,"pattern"),s(m,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100}),b=f.createElementNS(n.SVG,"image"),s(b,{x:0,y:0,width:100,height:100}),m.append(b),g.append(m),r("#canvasGrid").append(g),w=f.createElementNS(n.SVG,"rect"),s(w,{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(w),j=[{id:"view_grid",icon:"grid.png",type:"context",panel:"editor_panel",events:{click:function click(){i.curConfig.showGrid=v=!v,O()}}}],x.abrupt("return",{name:c.name,svgicons:"grid-icon.xml",zoomChanged:function zoomChanged(t){v&&S(t)},callback:function callback(){v&&O()},buttons:c.buttons.map((function(t,e){return Object.assign(j[e],t)}))});case 28:case"end":return x.stop()}}),_callee)})))()}});var fo=Object.freeze({__proto__:null,default:{name:"View Grid",buttons:[{title:"Show/Hide Grid"}]}}),so=Object.freeze({__proto__:null,default:{name:"",buttons:[{title:"/"}]}})}}}));