mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
9 lines
14 KiB
JavaScript
9 lines
14 KiB
JavaScript
|
/*! iFrame Resizer (iframeSizer.min.js ) - v4.3.2 - 2021-10-18
|
||
|
* Desc: Force cross domain iframes to size to content.
|
||
|
* Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame.
|
||
|
* Copyright: (c) 2021 David J. Bradshaw - dave@bradshaw.net
|
||
|
* License: MIT
|
||
|
*/
|
||
|
|
||
|
!function(u){var f,l,a,x,M,I,k,r,m,F,i,g,z;function h(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function O(e,n,i){e.addEventListener(n,i,!1)}function R(e,n,i){e.removeEventListener(n,i,!1)}function o(e){return M+"["+(e="Host page: "+(n=e),e=window.top!==window.self?window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+n:"Nested host page: "+n:e)+"]";var n}function t(e){return F[e]?F[e].log:l}function T(e,n){s("log",e,n,t(e))}function E(e,n){s("info",e,n,t(e))}function N(e,n){s("warn",e,n,!0)}function s(e,n,i,t){!0===t&&"object"==typeof window.console&&console[e](o(n),i)}function e(n){function i(){t("Height"),t("Width"),L(function(){A(y),H(v),l("onResized",y)},y,"init")}function e(){var e=b.substr(I).split(":"),n=e[1]?parseInt(e[1],10):0,i=F[e[0]]&&F[e[0]].iframe,t=getComputedStyle(i);return{iframe:i,id:e[0],height:n+function(e){if("border-box"!==e.boxSizing)return 0;var n=e.paddingTop?parseInt(e.paddingTop,10):0,e=e.paddingBottom?parseInt(e.paddingBottom,10):0;return n+e}(t)+function(e){if("border-box"!==e.boxSizing)return 0;var n=e.borderTopWidth?parseInt(e.borderTopWidth,10):0,e=e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0;return n+e}(t),width:e[2],type:e[3]}}function t(e){var n=Number(F[v]["max"+e]),i=Number(F[v]["min"+e]),t=e.toLowerCase(),e=Number(y[t]);T(v,"Checking "+t+" is in range "+i+"-"+n),e<i&&(e=i,T(v,"Set "+t+" to min value")),n<e&&(e=n,T(v,"Set "+t+" to max value")),y[t]=""+e}function o(){function e(){return t.constructor===Array?function(){var e=0,n=!1;for(T(v,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===i){n=!0;break}return n}():(e=F[v]&&F[v].remoteHost,T(v,"Checking connection is from: "+e),i===e);var e}var i=n.origin,t=F[v]&&F[v].checkOrigin;if(t&&""+i!="null"&&!e())throw new Error("Unexpected message received from: "+i+" for "+y.iframe.id+". Message was: "+n.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return 1}function a(e){return b.substr(b.indexOf(":")+x+e)}function s(i,t){var e,n,o;e=function(){var e,n;B("Send Page Info","pageInfo:"+(e=document.body.getBoundingClientRect(),n=y.iframe.getBoundingClientRect(),JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})),i,t)},n=32,z[o=t]||(z[o]=setTimeout(function(){z[o]=null,e()},n))}function r(e){e=e.getBoundingClientRect();return S(v),{x:Math.floor(Number(e.left)+Number(k.x)),y:Math.floor(Number(e.top)+Number(k.y))}}function d(e){var n=e?r(y.iframe):{x:0,y:0},i={x:Number(y.width)+n.x,y:Number(y.height)+n.y};T(v,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),window.top!==window.self?window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):N(v,"Unable to scroll to requested position, window.parentIFrame not found"):(k=i,c(),T(v,"--"))}function c(){!1!==l("onScroll",k)?H(v):j()}function u(e){var n,i=e.split("#")[1]||"",e=decodeURIComponent(i),t=document.getElementById(e)||document.getElementsByName(e)[0];t?(n=r(t),T(v,"Moving to in page link (#"+i+") at x: "+n.x+" y: "+n.y),k={x:n.x,y:n.y},c(),T(v,"--")):window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):T(v,"In page link #"+i+" not found and window.parentIFrame not found"):T(v,"In page link #"+i+" not found")}function f(e){var n,i={};i=0===Number(y.width)&&0===Number(y.height)?{x:(n=a(9).split(":"))[1],y:n[0]}:{x:y.width,y:y.height},l(e,{iframe:y.iframe,screenX:Number(i.x),screenY:Number(i.y),type:y.type})}function l(e,n){return W(v,e,n)}function m(){switch(F[v]&&F[v].firstRun&&F[
|
||
|
//# sourceMappingURL=iframeResizer.map
|