Files
svgedit/dist/editor/system/extensions/ext-overview_window/ext-overview_window.js
2021-03-08 23:05:05 +01:00

2 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){var t={exports:{}};return e(t,t.exports),t.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$1=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$1(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},h=Object.defineProperty,g={f:n?h:function defineProperty(e,t,r){if(anObject(e),t=toPrimitive(t,!0),anObject(r),v)try{return h(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 g.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},m="__core-js_shared__",b=r[m]||setGlobal(m,{}),_=Function.toString;"function"!=typeof b.inspectSource&&(b.inspectSource=function(e){return _.call(e)});var x,O,N,I=b.inspectSource,E=r.WeakMap,S="function"==typeof E&&/native code/.test(I(E)),j=createCommonjsModule((function(e){(e.exports=function(e,t){return b[e]||(b[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.9.1",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),M=0,F=Math.random(),k=j("keys"),sharedKey=function(e){return k[e]||(k[e]=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++M+F).toString(36)}(e))},P={},T=r.WeakMap;if(S){var A=b.state||(b.state=new T),V=A.get,L=A.has,C=A.set;x=function(e,t){return t.facade=e,C.call(A,e,t),t},O=function(e){return V.call(A,e)||{}},N=function(e){return L.call(A,e)}}else{var D=sharedKey("state");P[D]=!0,x=function(e,t){return t.facade=e,y(e,D,t),t},O=function(e){return has$1(e,D)?e[D]:{}},N=function(e){return has$1(e,D)}}var B,W,X={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}}},R=createCommonjsModule((function(e){var t=X.get,n=X.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$1(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||I(this)}))})),Y=r,aFunction=function(e){return"function"==typeof e?e:void 0},getBuiltIn=function(e,t){return arguments.length<2?aFunction(Y[e])||aFunction(r[e]):Y[e]&&Y[e][t]||r[e]&&r[e][t]},z=Math.ceil,G=Math.floor,toInteger=function(e){return isNaN(e=+e)?0:(e>0?G:z)(e)},H=Math.min,q=Math.max,U=Math.min,createMethod$1=function(e){return function(t,r,n){var o,i,a=toIndexedObject(t),u=(o=a.length)>0?H(toInteger(o),9007199254740991):0,c=function(e,t){var r=toInteger(e);return r<0?q(r+t,0):U(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}},K={includes:createMethod$1(!0),indexOf:createMethod$1(!1)},$=K.indexOf,objectKeysInternal=function(e,t){var r,n=toIndexedObject(e),o=0,i=[];for(r in n)!has$1(P,r)&&has$1(n,r)&&i.push(r);for(;t.length>o;)has$1(n,r=t[o++])&&(~$(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=g.f,o=d.f,i=0;i<r.length;i++){var a=r[i];has$1(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),R(n,o,a,e)}},fe=K.indexOf,se=[].indexOf,le=!!se&&1/[1].indexOf(1,-0)<0,pe=!!(W=[]["indexOf"])&&fails((function(){W.call(null,B||function(){throw 1},1)}));_export({target:"Array",proto:!0,forced:le||!pe},{indexOf:function indexOf(e){return le?se.apply(this,arguments)||0:fe(this,e,arguments.length>1?arguments[1]:void 0)}});var ve="\t\n\v\f\r    \u2028\u2029\ufeff",we="["+ve+"]",de=RegExp("^"+we+we+"*"),he=RegExp(we+we+"*$"),createMethod=function(e){return function(t){var r=String(requireObjectCoercible(t));return 1&e&&(r=r.replace(de,"")),2&e&&(r=r.replace(he,"")),r}},ge={start:createMethod(1),end:createMethod(2),trim:createMethod(3)},ye=ge.trim,me=r.parseInt,be=/^[+-]?0[Xx]/,_e=8!==me(ve+"08")||22!==me(ve+"0x16")?function parseInt(e,t){var r=ye(String(e));return me(r,t>>>0||(be.test(r)?16:10))}:me;_export({target:"Number",stat:!0,forced:Number.parseInt!=_e},{parseInt:_e});var xe,Oe=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 Oe&&"function"==typeof(n=t.constructor)&&n!==r&&isObject(o=n.prototype)&&o!==r.prototype&&Oe(e,o),e},Ne=Object.keys||function keys(e){return objectKeysInternal(e,J)},Ie=n?Object.defineProperties:function defineProperties(e,t){anObject(e);for(var r,n=Ne(t),o=n.length,i=0;o>i;)g.f(e,r=n[i++],t[r]);return e},Ee=getBuiltIn("document","documentElement"),Se=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<script>"+e+"</"+"script>"},NullProtoObject=function(){try{xe=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;NullProtoObject=xe?function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t}(xe):((t=documentCreateElement("iframe")).style.display="none",Ee.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[Se]=!0;var je=Object.create||function create(e,t){var r;return null!==e?(EmptyConstructor.prototype=anObject(e),r=new EmptyConstructor,EmptyConstructor.prototype=null,r[Se]=e):r=NullProtoObject(),void 0===t?r:Ie(r,t)},Me=Z.f,Fe=d.f,ke=g.f,Pe=ge.trim,Te="Number",Ae=r.Number,Ve=Ae.prototype,Le=classofRaw(je(Ve))==Te,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=Pe(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(Te,!Ae(" 0o1")||!Ae("0b1")||Ae("+0x1"))){for(var Ce,De=function Number(e){var t=arguments.length<1?0:e,r=this;return r instanceof De&&(Le?fails((function(){Ve.valueOf.call(r)})):classofRaw(r)!=Te)?inheritIfRequired(new Ae(toNumber(t)),r,De):toNumber(t)},Be=n?Me(Ae):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),We=0;Be.length>We;We++)has$1(Ae,Ce=Be[We])&&!has$1(De,Ce)&&ke(De,Ce,Fe(Ae,Ce));De.prototype=Ve,Ve.constructor=De,R(r,Te,De)}var Xe=ge.trim,Re=r.parseFloat,Ye=1/Re(ve+"-0")!=-1/0?function parseFloat(e){var t=Xe(String(e)),r=Re(t);return 0===r&&"-"==t.charAt(0)?-0:r}:Re;_export({target:"Number",stat:!0,forced:Number.parseFloat!=Ye},{parseFloat:Ye}),_export({global:!0,forced:parseInt!=_e},{parseInt:_e});var ze=!1,Ge=[],He=void 0!==window.ontouchstart;e("default",{name:"overview_window",init:function init(e){var t=e.$,r=e.isChrome,n={};if(r()){var o=navigator.userAgent.indexOf("Chrome/")+7;if(Number.parseInt(navigator.userAgent.substring(o))<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 i=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(){n.viewBoxDragging||i()})),t("#workarea").resize(i),i();var a=function updateViewDimensions(){var e=t("#svgroot").attr("width"),r=t("#svgroot").attr("height"),n=r/e*t("#overviewMiniView").attr("width");t("#overviewMiniView").attr("viewBox","640 480 "+e+" "+r),t("#overviewMiniView").attr("height",n),i()};a(),n.viewBoxDragging=!1;var u=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)},c=document.querySelector("#overview_window_view_box");return function dragmove(e,t,r,n,o,i){ze||document.addEventListener(He?"touchmove":"mousemove",(function(e){var t=e;e.touches&&(t=e.touches[0]);for(var r=0;r<Ge.length;r++)Ge[r](t.clientX,t.clientY)})),ze=!0;var a=!1,u=!1,c=0,f=0,s=0,l=0;t.addEventListener(He?"touchstart":"mousedown",(function(t){if(t.stopPropagation(),t.preventDefault(),"false"!==e.dataset.dragEnabled){var r=t;t.touches&&(r=t.touches[0]),a=!0,c=e.offsetLeft-r.clientX,f=e.offsetTop-r.clientY}})),document.addEventListener(He?"touchend":"mouseup",(function(t){o&&u&&o(e,r,parseInt(e.style.left),parseInt(e.style.top)),a=!1,u=!1})),document.addEventListener(He?"touchmove":"mousemove",(function(t){i&&u&&i(e,parseInt(e.style.left),parseInt(e.style.top))})),Ge.push((function move(t,r){if(a){if(u||(u=!0,n&&n(e,s,l)),s=t+c,l=r+f,"true"===e.dataset.dragBoundary){if(s<1||s>=window.innerWidth-e.offsetWidth)return;if(l<1||l>=window.innerHeight-e.offsetHeight)return}e.style.left=s+"px",e.style.top=l+"px"}}))}(c,c,document.querySelector("#overviewMiniView"),(function onStart(){n.viewBoxDragging=!0,u()}),(function onEnd(e,r,o,i){e.offsetLeft+e.offsetWidth>t(r).attr("width")?e.style.left=t(r).attr("width")-e.offsetWidth+"px":e.offsetLeft<0&&(e.style.left="0px"),e.offsetTop+e.offsetHeight>t(r).attr("height")?e.style.top=t(r).attr("height")-e.offsetHeight+"px":e.offsetTop<0&&(e.style.top="0px"),n.viewBoxDragging=!1,u()}),(function onDrag(){u()})),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")),c=Number.parseFloat(t("#overview_window_view_box").css("min-height")),f=r-.5*a,s=n-.5*c;f<0&&(f=0),s<0&&(s=0),f+a>o&&(f=o-a),s+c>i&&(s=i-c),t("#overview_window_view_box").css("top",s+"px"),t("#overview_window_view_box").css("left",f+"px"),u()})),{name:"overview window",canvasUpdated:a,workareaResized:i}}})}}}));