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

11 lines
14 KiB
JavaScript
Raw Normal View History

2020-09-08 23:35:47 +00:00
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")(),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.6.5",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=new A,C=T.get,V=T.has,D=T.set;x=function(e,t){return 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 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=createCo
2020-09-04 20:34:30 +00:00
/**
2020-09-08 23:35:47 +00:00
* @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}}})}}}));