svgedit/dist/editor/extensions/ext-overview_window/ext-overview_window.js

12 lines
14 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var e="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},t=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof e&&e)||function(){return this}()||Function("return this")(),fails=function(e){try{return!!e()}catch(e){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!n.call({1:2},1)?function propertyIsEnumerable(e){var t=o(this,e);return!!t&&t.enumerable}:n},createPropertyDescriptor=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},a={}.toString,classofRaw=function(e){return a.call(e).slice(8,-1)},c="".split,u=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 u(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")},f={}.hasOwnProperty,has=function(e,t){return f.call(e,t)},s=t.document,l=isObject(s)&&isObject(s.createElement),documentCreateElement=function(e){return l?s.createElement(e):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),v=Object.getOwnPropertyDescriptor,w={f:r?v:function getOwnPropertyDescriptor(e,t){if(e=toIndexedObject(e),t=toPrimitive(t,!0),p)try{return v(e,t)}catch(e){}if(has(e,t))return createPropertyDescriptor(!i.f.call(e,t),e[t])}},anObject=function(e){if(!isObject(e))throw TypeError(String(e)+" is not an object");return e},d=Object.defineProperty,g={f:r?d:function defineProperty(e,t,r){if(anObject(e),t=toPrimitive(t,!0),anObject(r),p)try{return d(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}},h=r?function(e,t,r){return g.f(e,t,createPropertyDescriptor(1,r))}:function(e,t,r){return e[t]=r,e},setGlobal=function(e,r){try{h(t,e,r)}catch(n){t[e]=r}return r},y=t["__core-js_shared__"]||setGlobal("__core-js_shared__",{}),b=Function.toString;"function"!=typeof y.inspectSource&&(y.inspectSource=function(e){return b.call(e)});var m,_,x,O=y.inspectSource,N=t.WeakMap,S="function"==typeof N&&/native code/.test(O(N)),j=createCommonjsModule((function(e){(e.exports=function(e,t){return y[e]||(y[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.7.0",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),E=0,I=Math.random(),F=j("keys"),sharedKey=function(e){return F[e]||(F[e]=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++E+I).toString(36)}(e))},M={},k=t.WeakMap;if(S){var P=y.state||(y.state=new k),A=P.get,T=P.has,C=P.set;m=function(e,t){return t.facade=e,C.call(P,e,t),t},_=function(e){return A.call(P,e)||{}},x=function(e){return T.call(P,e)}}else{var V=sharedKey("state");M[V]=!0,m=function(e,t){return t.facade=e,h(e,V,t),t},_=function(e){return has(e,V)?e[V]:{}},x=function(e){return has(e,V)}}var D,L,R={set:m,get:_,has:x,enforce:function(e){return x(e)?_(e):m(e,{})},getterFor:function(e){return function(t){var r;if(!isObject(t)||(r=_(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return r}}},B=createCommonjsModule((function(e){var r=R.get,n=R.enforce,o=String(String).split("String");(e.exports=function(e,r,i,a){var c,u=!!a&&!!a.unsafe,f=!!a&&!!a.enumerable,s=!!a&&!!a.noTargetGet;"function"==typeof i&&("string"!=typeof r||has(i,"name")||h(i,"name",r),(c=n(i)).source||(c.source=o.join("string"==typeof r?r:""))),e!==t?(u?!s&&e[r]&&(f=!0):delete e[r],f?e[r]=i:h(e,r,i)):f?e[r]=i:setGlobal(r,i)})(Function.prototype,"toString",(function toString(){return"function"==typeof this&&r(this).source||O(this)}))})),z=t,aFunction=function(e){return"function"==typeof e?e:void 0},getBuiltIn=function(e,r){return arguments.length<2?aFunction(z[e])||aFunction(t[e]):z[e]&&z[e][r]||t[e]&&t[e][r]},X=Math.ceil,G=Math.floor,toInteger=function(e){return isNaN(e=+e)?0:(e>0?G:X)(e)},Y=Math.min,W=Math.max,U=Math.min,createMethod=function(e){return function(t,r,n){var o,i,a=toIndexedObject(t),c=(o=a.length)>0?Y(toInteger(o),9007199254740991):0,u=function(e,t){var r=toInteger(e);return r<0?W(r+t,0):U(r,t)}(n,c);if(e&&r!=r){for(;c>u;)if((i=a[u++])!=i)return!0}else for(;c>u;u++)if((e||u in a)&&a[u]===r)return e||u||0;return!e&&-1}},K={includes:createMethod(!0),indexOf:createMethod(!1)},$=K.indexOf,objectKeysInternal=function(e,t){var r,n=toIndexedObject(e),o=0,i=[];for(r in n)!has(M,r)&&has(n,r)&&i.push(r);for(;t.length>o;)has(n,r=t[o++])&&(~$(i,r)||i.push(r));return i},q=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],H=q.concat("length","prototype"),J={f:Object.getOwnPropertyNames||function getOwnPropertyNames(e){return objectKeysInternal(e,H)}},Q={f:Object.getOwnPropertySymbols},Z=getBuiltIn("Reflect","ownKeys")||function ownKeys(e){var t=J.f(anObject(e)),r=Q.f;return r?t.concat(r(e)):t},copyConstructorProperties=function(e,t){for(var r=Z(t),n=g.f,o=w.f,i=0;i<r.length;i++){var a=r[i];has(e,a)||n(e,a,o(t,a))}},ee=/#|\.prototype\./,isForced=function(e,t){var r=re[te(e)];return r==oe||r!=ne&&("function"==typeof t?fails(t):!!t)},te=isForced.normalize=function(e){return String(e).replace(ee,".").toLowerCase()},re=isForced.data={},ne=isForced.NATIVE="N",oe=isForced.POLYFILL="P",ie=isForced,ae=w.f,_export=function(e,r){var n,o,i,a,c,u=e.target,f=e.global,s=e.stat;if(n=f?t:s?t[u]||setGlobal(u,{}):(t[u]||{}).prototype)for(o in r){if(a=r[o],i=e.noTargetGet?(c=ae(n,o))&&c.value:n[o],!ie(f?o:u+(s?".":"#")+o,e.forced)&&void 0!==i){if(typeof a==typeof i)continue;copyConstructorProperties(a,i)}(e.sham||i&&i.sham)&&h(a,"sham",!0),B(n,o,a,e)}},ce=Object.defineProperty,ue={},thrower=function(e){throw e},fe=K.indexOf,se=[].indexOf,le=!!se&&1/[1].indexOf(1,-0)<0,pe=!!(L=[]["indexOf"])&&fails((function(){L.call(null,D||function(){throw 1},1)})),ve=function(e,t){if(has(ue,e))return ue[e];t||(t={});var n=[][e],o=!!has(t,"ACCESSORS")&&t.ACCESSORS,i=has(t,0)?t[0]:thrower,a=has(t,1)?t[1]:void 0;return ue[e]=!!n&&!fails((function(){if(o&&!r)return!0;var e={length:-1};o?ce(e,1,{enumerable:!0,get:thrower}):e[1]=1,n.call(e,i,a)}))}("indexOf",{ACCESSORS:!0,1:0});_export({target:"Array",proto:!0,forced:le||!pe||!ve},{indexOf:function indexOf(e){return le?se.apply(this,arguments)||0:fe(this,e,arguments.length>1?arguments[1]:void 0)}});var we,de=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 de&&"function"==typeof(n=t.constructor)&&n!==r&&isObject(o=n.prototype)&&o!==r.prototype&&de(e,o),e},ge=Object.keys||function keys(e){return objectKeysInternal(e,q)},he=r?Object.defineProperties:function defineProperties(e,t){anObject(e);for(var r,n=ge(t),o=n.length,i=0;o>i;)g.f(e,r=n[i++],t[r]);return e},ye=getBuiltIn("document","documentElement"),be=sharedKey("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<script>"+e+"<\/script>"},NullProtoObject=function(){try{we=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t;NullProtoObject=we?function(e){e.write(scriptTag("")),e.close();var t=e.parentWindow.Object;return e=null,t}(we):((t=documentCreateElement("iframe")).style.display="none",ye.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(scriptTag("document.F=Object")),e.close(),e.F);for(var r=q.length;r--;)delete NullProtoObject.prototype[q[r]];return NullProtoObject()};M[be]=!0;var me=Object.create||function create(e,t){var r;return null!==e?(EmptyConstructor.prototype=anObject(e),r=new EmptyConstructor,EmptyConstructor.prototype=null,r[be]=e):r=NullProtoObject(),void 0===t?r:he(r,t)},_e="\t\n\v\f\r    \u2028\u2029\ufeff",xe="["+_e+"]",Oe=RegExp("^"+xe+xe+"*"),Ne=RegExp(xe+xe+"*$"),createMethod$1=function(e){return function(t){var r=String(requireObjectCoercible(t));return 1&e&&(r=r.replace(Oe,"")),2&e&&(r=r.replace(Ne,"")),r}},Se={start:createMethod$1(1),end:createMethod$1(2),trim:createMethod$1(3)},je=J.f,Ee=w.f,Ie=g.f,Fe=Se.trim,Me=t.Number,ke=Me.prototype,Pe="Number"==classofRaw(me(ke)),toNumber=function(e){var t,r,n,o,i,a,c,u,f=toPrimitive(e,!1);if("string"==typeof f&&f.length>2)if(43===(t=(f=Fe(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,c=0;c<a;c++)if((u=i.charCodeAt(c))<48||u>o)return NaN;return parseInt(i,n)}return+f};if(ie("Number",!Me(" 0o1")||!Me("0b1")||Me("+0x1"))){for(var Ae,Te=function Number(e){var t=arguments.length<1?0:e,r=this;return r instanceof Te&&(Pe?fails((function(){ke.valueOf.call(r)})):"Number"!=classofRaw(r))?inheritIfRequired(new Me(toNumber(t)),r,Te):toNumber(t)},Ce=r?je(Me):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),Ve=0;Ce.length>Ve;Ve++)has(Me,Ae=Ce[Ve])&&!has(Te,Ae)&&Ie(Te,Ae,Ee(Me,Ae));Te.prototype=ke,ke.constructor=Te,B(t,"Number",Te)}var De=Se.trim,Le=t.parseFloat,Re=1/Le(_e+"-0")!=-1/0?function parseFloat(e){var t=De(String(e)),r=Le(t);return 0===r&&"-"==t.charAt(0)?-0:r}:Le;_export({target:"Number",stat:!0,forced:Number.parseFloat!=Re},{parseFloat:Re});var Be=Se.trim,ze=t.parseInt,Xe=/^[+-]?0[Xx]/,Ge=8!==ze(_e+"08")||22!==ze(_e+"0x16")?function parseInt(e,t){var r=Be(String(e));return ze(r,t>>>0||(Xe.test(r)?16:10))}:ze;_export({target:"Number",stat:!0,forced:Number.parseInt!=Ge},{parseInt:Ge});
/**
* @file ext-overview_window.js
*
* @license MIT
*
* @copyright 2013 James Sacksteder
*
*/
var Ye={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")),c=t("#overviewMiniView").attr("width"),u=t("#overviewMiniView").attr("height"),f=n/i*c,s=o/a*u,l=r/i*c,p=e/a*u;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 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(){n.viewBoxDragging=!0},stop:function stop(){n.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:a,workareaResized:i}}};export default Ye;
//# sourceMappingURL=ext-overview_window.js.map