Files
svgedit/dist/editor/system/extensions/ext-overview_window/ext-overview_window.js
JFH 28019eef07 Refactor canvas in multiple pieces to increase maintainability (#446)
* #refactor-canvas getJsonFromSvgElement and svgroot code moved to separate file
* #refactor-canvas build files changes
* #refactor-canvas addSVGElementsFromJson move to json file
* #refactor-canvas selected element option function move separate file
* #refactor-canvas moveUpDownSelected move to select-elem
* ##refactor-canvas build file updated
* #refactor-canvas moveSelectedElements  move to selected-elem
* #refactor-canvas cloneSelectedElements move to slected-elem
* #refactor-canvas alignSelectedElements move to selected-elem
* #refactor-canvas deleteSelectedElements move to selected-elem
* #refactor-canvas copySelectedElements and groupSelectedElements move to selected-elem
* #refactor-canvas pushGroupProperty, ungroupSelectedElement move to selected-elem
* #refactor-canvas comment changes
* #refactor-canvas UndoManager move to separate file
* #refactor-canvas event file move to mouseMove, mouseUpEvent and dblClickEvent
* #refactor-canvas mouseDown move to event
* #refactor-canvas move to undo file
* #refactor alignment changes  and set function revert return
* #refactor-canvas textaction move to separate file
* #refactor-canvas paste-element function move to separate file
* #refactor-canvas set and get  method move to separate file
* #refactor-canvas set and get function moved changes
* #refactor clear file import and regaring function moved changes changes
* #refactor-canvas svg related function move to separate file
* #refactor-canvas setBackground methos move to elem-get-set file
* #refactor-canvas getBsplinePoint method move to event file
* #refactor-canvas export functions move to svg-exec
* #refactor-canvas svg related function moved separate file
* #refactor-canvas updateCanvas,  cycleElement move to selected-elem file
* #refactor-canvas removeUnusedDefElems move to svg-exec file
* #refactor-canvas blur method move to separate file blur-event.js
* #refactor-canvas selection related function move to separate file slection.js
* #refactor-canvas convertGradients, mousewheelmove event bind function move to other files
* #refactor-canvas extension function move to selection file
* #refactor-canvas svg tag long string changes to es6 format
* eslint fixes
* eslint and test fixes
* add netlify logo per their requirements
* #refactor-canvas path file separate to path-method.js and path-actions.js
* #refactor-canvas lint issue fixed
* #refactor-canvas path.js file class and const move to path-method.js
* #refactor-canvas eslint issue fixed. 'jsdoc/check-examples': 'off' already so removed eslint-disable jsdoc/check-examples
* #refactor-canvas path class moved changes and copy-elem.js file cypress test issue fixed
* #refactor-canvas UI - Clipboard paste element  cypress issue fixed
* #refactor-canvas cypress test cases issue fixed changes
* #refactor-canvas cypress test cases issue fixed changes
* #refactor-canvas cypress test case issue fixed
* npm update and fix a few eslint new errors
* fix snapshot and run tests
* add star tool to cypress
* #refactor-canvas shapelibrary, star, polygon and panning tool issue fixed
* build
* Update layer.js
* revert proper declarations

Authored-by OptimistikSAS
2020-11-11 11:38:45 +01:00

11 lines
14 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
System.register([],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}var check=function(e){return e&&e.Math==Math&&e},r=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof t&&t)||function(){return this}()||Function("return this")(),fails=function(e){try{return!!e()}catch(e){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(e){var t=i(this,e);return!!t&&t.enumerable}:o},createPropertyDescriptor=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},u={}.toString,classofRaw=function(e){return u.call(e).slice(8,-1)},c="".split,f=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==classofRaw(e)?c.call(e,""):Object(e)}:Object,requireObjectCoercible=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},toIndexedObject=function(e){return f(requireObjectCoercible(e))},isObject=function(e){return"object"==typeof e?null!==e:"function"==typeof e},toPrimitive=function(e,t){if(!isObject(e))return e;var r,n;if(t&&"function"==typeof(r=e.toString)&&!isObject(n=r.call(e)))return n;if("function"==typeof(r=e.valueOf)&&!isObject(n=r.call(e)))return n;if(!t&&"function"==typeof(r=e.toString)&&!isObject(n=r.call(e)))return n;throw TypeError("Can't convert object to primitive value")},s={}.hasOwnProperty,has=function(e,t){return s.call(e,t)},l=r.document,p=isObject(l)&&isObject(l.createElement),documentCreateElement=function(e){return p?l.createElement(e):{}},v=!n&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),w=Object.getOwnPropertyDescriptor,d={f:n?w:function getOwnPropertyDescriptor(e,t){if(e=toIndexedObject(e),t=toPrimitive(t,!0),v)try{return w(e,t)}catch(e){}if(has(e,t))return createPropertyDescriptor(!a.f.call(e,t),e[t])}},anObject=function(e){if(!isObject(e))throw TypeError(String(e)+" is not an object");return e},g=Object.defineProperty,h={f:n?g:function defineProperty(e,t,r){if(anObject(e),t=toPrimitive(t,!0),anObject(r),v)try{return g(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(e[t]=r.value),e}},y=n?function(e,t,r){return h.f(e,t,createPropertyDescriptor(1,r))}:function(e,t,r){return e[t]=r,e},setGlobal=function(e,t){try{y(r,e,t)}catch(n){r[e]=t}return t},b="__core-js_shared__",m=r[b]||setGlobal(b,{}),_=Function.toString;"function"!=typeof m.inspectSource&&(m.inspectSource=function(e){return _.call(e)});var x,O,N,S=m.inspectSource,E=r.WeakMap,j="function"==typeof E&&/native code/.test(S(E)),I=createCommonjsModule((function(e){(e.exports=function(e,t){return m[e]||(m[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.7.0",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),F=0,M=Math.random(),k=I("keys"),sharedKey=function(e){return k[e]||(k[e]=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++F+M).toString(36)}(e))},P={},A=r.WeakMap;if(j){var T=m.state||(m.state=new A),C=T.get,V=T.has,D=T.set;x=function(e,t){return t.facade=e,D.call(T,e,t),t},O=function(e){return C.call(T,e)||{}},N=function(e){return V.call(T,e)}}else{var R=sharedKey("state");P[R]=!0,x=function(e,t){return t.facade=e,y(e,R,t),t},O=function(e){return has(e,R)?e[R]:{}},N=function(e){return has(e,R)}}var L,B,z={set:x,get:O,has:N,enforce:function(e){return N(e)?O(e):x(e,{})},getterFor:function(e){return function(t){var r;if(!isObject(t)||(r=O(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}},X=createCommonjsModule((function(e){var t=z.get,n=z.enforce,o=String(String).split("String");(e.exports=function(e,t,i,a){var u,c=!!a&&!!a.unsafe,f=!!a&&!!a.enumerable,s=!!a&&!!a.noTargetGet;"function"==typeof i&&("string"!=typeof t||has(i,"name")||y(i,"name",t),(u=n(i)).source||(u.source=o.join("string"==typeof t?t:""))),e!==r?(c?!s&&e[t]&&(f=!0):delete e[t],f?e[t]=i:y(e,t,i)):f?e[t]=i:setGlobal(t,i)})(Function.prototype,"toString",(function toString(){return"function"==typeof this&&t(this).source||S(this)}))})),G=r,aFunction=function(e){return"function"==typeof e?e:void 0},getBuiltIn=function(e,t){return arguments.length<2?aFunction(G[e])||aFunction(r[e]):G[e]&&G[e][t]||r[e]&&r[e][t]},Y=Math.ceil,q=Math.floor,toInteger=function(e){return isNaN(e=+e)?0:(e>0?q:Y)(e)},W=Math.min,U=Math.max,K=Math.min,createMethod=function(e){return function(t,r,n){var o,i,a=toIndexedObject(t),u=(o=a.length)>0?W(toInteger(o),9007199254740991):0,c=function(e,t){var r=toInteger(e);return r<0?U(r+t,0):K(r,t)}(n,u);if(e&&r!=r){for(;u>c;)if((i=a[c++])!=i)return!0}else for(;u>c;c++)if((e||c in a)&&a[c]===r)return e||c||0;return!e&&-1}},$={includes:createMethod(!0),indexOf:createMethod(!1)},H=$.indexOf,objectKeysInternal=function(e,t){var r,n=toIndexedObject(e),o=0,i=[];for(r in n)!has(P,r)&&has(n,r)&&i.push(r);for(;t.length>o;)has(n,r=t[o++])&&(~H(i,r)||i.push(r));return i},J=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Q=J.concat("length","prototype"),Z={f:Object.getOwnPropertyNames||function getOwnPropertyNames(e){return objectKeysInternal(e,Q)}},ee={f:Object.getOwnPropertySymbols},te=getBuiltIn("Reflect","ownKeys")||function ownKeys(e){var t=Z.f(anObject(e)),r=ee.f;return r?t.concat(r(e)):t},copyConstructorProperties=function(e,t){for(var r=te(t),n=h.f,o=d.f,i=0;i<r.length;i++){var a=r[i];has(e,a)||n(e,a,o(t,a))}},re=/#|\.prototype\./,isForced=function(e,t){var r=oe[ne(e)];return r==ae||r!=ie&&("function"==typeof t?fails(t):!!t)},ne=isForced.normalize=function(e){return String(e).replace(re,".").toLowerCase()},oe=isForced.data={},ie=isForced.NATIVE="N",ae=isForced.POLYFILL="P",ue=isForced,ce=d.f,_export=function(e,t){var n,o,i,a,u,c=e.target,f=e.global,s=e.stat;if(n=f?r:s?r[c]||setGlobal(c,{}):(r[c]||{}).prototype)for(o in t){if(a=t[o],i=e.noTargetGet?(u=ce(n,o))&&u.value:n[o],!ue(f?o:c+(s?".":"#")+o,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;copyConstructorProperties(a,i)}(e.sham||i&&i.sham)&&y(a,"sham",!0),X(n,o,a,e)}},fe=Object.defineProperty,se={},thrower=function(e){throw e},le=$.indexOf,pe=[].indexOf,ve=!!pe&&1/[1].indexOf(1,-0)<0,we=!!(B=[]["indexOf"])&&fails((function(){B.call(null,L||function(){throw 1},1)})),de=function(e,t){if(has(se,e))return se[e];t||(t={});var r=[][e],o=!!has(t,"ACCESSORS")&&t.ACCESSORS,i=has(t,0)?t[0]:thrower,a=has(t,1)?t[1]:void 0;return se[e]=!!r&&!fails((function(){if(o&&!n)return!0;var e={length:-1};o?fe(e,1,{enumerable:!0,get:thrower}):e[1]=1,r.call(e,i,a)}))}("indexOf",{ACCESSORS:!0,1:0});_export({target:"Array",proto:!0,forced:ve||!we||!de},{indexOf:function indexOf(e){return ve?pe.apply(this,arguments)||0:le(this,e,arguments.length>1?arguments[1]:void 0)}});var ge,he=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(r,[]),t=r instanceof Array}catch(e){}return function setPrototypeOf(r,n){return anObject(r),function(e){if(!isObject(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(n),t?e.call(r,n):r.__proto__=n,r}}():void 0),inheritIfRequired=function(e,t,r){var n,o;return he&&"function"==typeof(n=t.constructor)&&n!==r&&isObject(o=n.prototype)&&o!==r.prototype&&he(e,o),e},ye=Object.keys||function keys(e){return objectKeysInternal(e,J)},be=n?Object.defineProperties:function defineProperties(e,t){anObject(e);for(var r,n=ye(t),o=n.length,i=0;o>i;)h.f(e,r=n[i++],t[r]);return e},me=getBuiltIn("document","documentElement"),_e=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<script>"+e+"</"+"script>"},NullProtoObject=function(){try{ge=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;NullProtoObject=ge?function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t}(ge):((t=documentCreateElement("iframe")).style.display="none",me.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F);for(var r=J.length;r--;)delete NullProtoObject.prototype[J[r]];return NullProtoObject()};P[_e]=!0;var xe=Object.create||function create(e,t){var r;return null!==e?(EmptyConstructor.prototype=anObject(e),r=new EmptyConstructor,EmptyConstructor.prototype=null,r[_e]=e):r=NullProtoObject(),void 0===t?r:be(r,t)},Oe="\t\n\v\f\r    \u2028\u2029\ufeff",Ne="["+Oe+"]",Se=RegExp("^"+Ne+Ne+"*"),Ee=RegExp(Ne+Ne+"*$"),createMethod$1=function(e){return function(t){var r=String(requireObjectCoercible(t));return 1&e&&(r=r.replace(Se,"")),2&e&&(r=r.replace(Ee,"")),r}},je={start:createMethod$1(1),end:createMethod$1(2),trim:createMethod$1(3)},Ie=Z.f,Fe=d.f,Me=h.f,ke=je.trim,Pe="Number",Ae=r.Number,Te=Ae.prototype,Ce=classofRaw(xe(Te))==Pe,toNumber=function(e){var t,r,n,o,i,a,u,c,f=toPrimitive(e,!1);if("string"==typeof f&&f.length>2)if(43===(t=(f=ke(f)).charCodeAt(0))||45===t){if(88===(r=f.charCodeAt(2))||120===r)return NaN}else if(48===t){switch(f.charCodeAt(1)){case 66:case 98:n=2,o=49;break;case 79:case 111:n=8,o=55;break;default:return+f}for(a=(i=f.slice(2)).length,u=0;u<a;u++)if((c=i.charCodeAt(u))<48||c>o)return NaN;return parseInt(i,n)}return+f};if(ue(Pe,!Ae(" 0o1")||!Ae("0b1")||Ae("+0x1"))){for(var Ve,De=function Number(e){var t=arguments.length<1?0:e,r=this;return r instanceof De&&(Ce?fails((function(){Te.valueOf.call(r)})):classofRaw(r)!=Pe)?inheritIfRequired(new Ae(toNumber(t)),r,De):toNumber(t)},Re=n?Ie(Ae):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),Le=0;Re.length>Le;Le++)has(Ae,Ve=Re[Le])&&!has(De,Ve)&&Me(De,Ve,Fe(Ae,Ve));De.prototype=Te,Te.constructor=De,X(r,Pe,De)}var Be=je.trim,ze=r.parseFloat,Xe=1/ze(Oe+"-0")!=-1/0?function parseFloat(e){var t=Be(String(e)),r=ze(t);return 0===r&&"-"==t.charAt(0)?-0:r}:ze;_export({target:"Number",stat:!0,forced:Number.parseFloat!=Xe},{parseFloat:Xe});var Ge=je.trim,Ye=r.parseInt,qe=/^[+-]?0[Xx]/,We=8!==Ye(Oe+"08")||22!==Ye(Oe+"0x16")?function parseInt(e,t){var r=Ge(String(e));return Ye(r,t>>>0||(qe.test(r)?16:10))}:Ye;_export({target:"Number",stat:!0,forced:Number.parseInt!=We},{parseInt:We});
/**
* @file ext-overview_window.js
*
* @license MIT
*
* @copyright 2013 James Sacksteder
*
*/
e("default",{name:"overview_window",init:function init(e){var t=e.$,r=e.isChrome,n=e.isIE,o={};if(r()){var i=navigator.userAgent.indexOf("Chrome/")+7;if(Number.parseInt(navigator.userAgent.substring(i))<49)return}t("#sidepanels").append('<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;"><div id="overview_window_content" style="position:relative; left:12px; top:0px;"><div style="background-color:#A0A0A0; display:inline-block; overflow:visible;"><svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><use x="0" y="0" xlink:href="#svgroot"> </use></svg><div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);"></div></div></div></div>');var a=function updateViewBox(){var e=Number.parseFloat(t("#workarea").css("height")),r=Number.parseFloat(t("#workarea").css("width")),n=t("#workarea").scrollLeft(),o=t("#workarea").scrollTop(),i=Number.parseFloat(t("#svgcanvas").css("width")),a=Number.parseFloat(t("#svgcanvas").css("height")),u=t("#overviewMiniView").attr("width"),c=t("#overviewMiniView").attr("height"),f=n/i*u,s=o/a*c,l=r/i*u,p=e/a*c;t("#overview_window_view_box").css("min-width",l+"px"),t("#overview_window_view_box").css("min-height",p+"px"),t("#overview_window_view_box").css("top",s+"px"),t("#overview_window_view_box").css("left",f+"px")};t("#workarea").scroll((function(){o.viewBoxDragging||a()})),t("#workarea").resize(a),a();var u=function updateViewDimensions(){var e=t("#svgroot").attr("width"),r=t("#svgroot").attr("height"),o=640,i=480;n()&&(o=0,i=0);var u=r/e*t("#overviewMiniView").attr("width");t("#overviewMiniView").attr("viewBox",o+" "+i+" "+e+" "+r),t("#overviewMiniView").attr("height",u),a()};u(),o.viewBoxDragging=!1;var c=function updateViewPortFromViewBox(){var e=Number.parseFloat(t("#svgcanvas").css("width")),r=Number.parseFloat(t("#svgcanvas").css("height")),n=t("#overviewMiniView").attr("width"),o=t("#overviewMiniView").attr("height"),i=Number.parseFloat(t("#overview_window_view_box").css("left"))/n*e,a=Number.parseFloat(t("#overview_window_view_box").css("top"))/o*r;t("#workarea").scrollLeft(i),t("#workarea").scrollTop(a)};return t("#overview_window_view_box").draggable({containment:"parent",drag:c,start:function start(){o.viewBoxDragging=!0},stop:function stop(){o.viewBoxDragging=!1}}),t("#overviewMiniView").click((function(e){var r=e.offsetX||e.originalEvent.layerX,n=e.offsetY||e.originalEvent.layerY,o=t("#overviewMiniView").attr("width"),i=t("#overviewMiniView").attr("height"),a=Number.parseFloat(t("#overview_window_view_box").css("min-width")),u=Number.parseFloat(t("#overview_window_view_box").css("min-height")),f=r-.5*a,s=n-.5*u;f<0&&(f=0),s<0&&(s=0),f+a>o&&(f=o-a),s+u>i&&(s=i-u),t("#overview_window_view_box").css("top",s+"px"),t("#overview_window_view_box").css("left",f+"px"),c()})),{name:"overview window",canvasUpdated:u,workareaResized:a}}})}}}));