web/static-dist/libs/iframe-resizer.js
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
!function(e){function n(i,o){if(t[i])return t[i].exports;var r={i:i,l:!1,exports:{}};return 0!=o&&(t[i]=r),e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}var t={};n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="/static-dist/",n(n.s=13)}({13:function(e,n,t){e.exports=t("7faff6f083c3860ecee5")},"7faff6f083c3860ecee5":function(e,n,t){"use strict";t("a7210068117fc0991694")},a7210068117fc0991694:function(e,n,t){var i,o,r;!function(t){"use strict";function a(e,n,i){"addEventListener"in t?e.addEventListener(n,i,!1):"attachEvent"in t&&e.attachEvent("on"+n,i)}function c(e,n,i){"removeEventListener"in t?e.removeEventListener(n,i,!1):"detachEvent"in t&&e.detachEvent("on"+n,i)}function u(){var e,n=["moz","webkit","o","ms"];for(e=0;e<n.length&&!q;e+=1)q=t[n[e]+"RequestAnimationFrame"];q||s("setup","RequestAnimationFrame not supported")}function f(e){return V[e]?V[e].log:N}function s(e,n){m("log",e,n,f(e))}function l(e,n){m("info",e,n,f(e))}function d(e,n){m("warn",e,n,!0)}function m(e,n,i,o){!0===o&&t.console}function g(e){function n(){function e(){x(W),y(N)}i("Height"),i("Width"),k(e,W,"init")}function i(e){var n=Number(V[N]["max"+e]),t=Number(V[N]["min"+e]),i=e.toLowerCase(),o=Number(W[i]);s(N,"Checking "+i+" is in range "+t+"-"+n),o<t&&(o=t,s(N,"Set "+i+" to min value")),o>n&&(o=n,s(N,"Set "+i+" to max value")),W[i]=""+o}function o(e){return P.substr(P.indexOf(":")+H+e)}function r(e){s(N,"MessageCallback passed: {iframe: "+W.iframe.id+", message: "+e+"}"),R("messageCallback",{iframe:W.iframe,message:JSON.parse(e)}),s(N,"--")}function u(){var e=document.body.getBoundingClientRect(),n=W.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:n.height,iframeWidth:n.width,clientHeight:Math.max(document.documentElement.clientHeight,t.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,t.innerWidth||0),offsetTop:parseInt(n.top-e.top,10),offsetLeft:parseInt(n.left-e.left,10),scrollTop:t.pageYOffset,scrollLeft:t.pageXOffset})}function f(e,n){function t(){M("Send Page Info","pageInfo:"+u(),e,n)}O(t,32)}function m(){function e(e,o){function r(){V[i]?f(V[i].iframe,i):n()}["scroll","resize"].forEach(function(n){s(i,e+n+" listener for sendPageInfo"),o(t,n,r)})}function n(){e("Remove ",c)}var i=N;!function(){e("Add ",a)}(),V[i].stopPageInfo=n}function g(){V[N]&&V[N].stopPageInfo&&(V[N].stopPageInfo(),delete V[N].stopPageInfo)}function F(e){var n=e.getBoundingClientRect();return b(N),{x:Math.floor(Number(n.left)+Number(j.x)),y:Math.floor(Number(n.top)+Number(j.y))}}function z(e){var n=e?F(W.iframe):{x:0,y:0},i=function(){return{x:Number(W.width)+n.x,y:Number(W.height)+n.y}}();s(N,"Reposition requested from iFrame (offset x:"+n.x+" y:"+n.y+")"),t.top!==t.self?function(){t.parentIFrame?t.parentIFrame["scrollTo"+(e?"Offset":"")](i.x,i.y):d(N,"Unable to scroll to requested position, window.parentIFrame not found")}():function(){j=i,E(),s(N,"--")}()}function E(){!1!==R("scrollCallback",j)?y(N):v()}function C(e){var n=e.split("#")[1]||"",i=decodeURIComponent(n),o=document.getElementById(i)||document.getElementsByName(i)[0];o?function(){var e=F(o);s(N,"Moving to in page link (#"+n+") at x: "+e.x+" y: "+e.y),j={x:e.x,y:e.y},E(),s(N,"--")}():t.top!==t.self?function(){t.parentIFrame?t.parentIFrame.moveToAnchor(n):s(N,"In page link #"+n+" not found and window.parentIFrame not found")}():s(N,"In page link #"+n+" not found")}function R(e,n){return h(N,e,n)}function T(){V[N].firstRun=!1}var P=e.data,W={},N=null;"[iFrameResizerChild]Ready"===P?function(){for(var e in V)M("iFrame requested init",I(e),document.getElementById(e),e)}():function(){return A===(""+P).substr(0,L)&&P.substr(L).split(":")[0]in V}()?(W=function(){var e=P.substr(L).split(":");return{iframe:V[e[0]].iframe,id:e[0],height:e[1],width:e[2],type:e[3]}}(),N=D=W.id,!function(){var e=W.type in{true:1,false:1,undefined:1};return e&&s(N,"Ignoring init message from meta parent page"),e}()&&function(e){var n=!0;return V[e]||(n=!1,d(W.type+" No settings for "+e+". Message was: "+P)),n}(N)&&(s(N,"Received: "+P),function(){var e=!0;return null===W.iframe&&(d(N,"IFrame ("+W.id+") not found"),e=!1),e}()&&function(){var n=e.origin,t=V[N].checkOrigin;if(t&&""+n!="null"&&!function(){return t.constructor===Array?function(){var e=0,i=!1;for(s(N,"Checking connection is from allowed list of origins: "+t);e<t.length;e++)if(t[e]===n){i=!0;break}return i}():function(){var e=V[N].remoteHost;return s(N,"Checking connection is from: "+e),n===e}()}())throw new Error("Unexpected message received from: "+n+" for "+W.iframe.id+". Message was: "+e.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}()&&function(){switch(V[N].firstRun&&T(),W.type){case"close":p(W.iframe);break;case"message":r(o(6));break;case"scrollTo":z(!1);break;case"scrollToOffset":z(!0);break;case"pageInfo":f(V[N].iframe,N),m();break;case"pageInfoStop":g();break;case"inPageLink":C(o(9));break;case"reset":w(W);break;case"init":n(),R("initCallback",W.iframe),R("resizedCallback",W);break;default:n(),R("resizedCallback",W)}}())):l(N,"Ignored: "+P)}function h(e,n,t){var i=null,o=null;if(V[e]){if("function"!=typeof(i=V[e][n]))throw new TypeError(n+" on iFrame["+e+"] is not a function");o=i(t)}return o}function p(e){var n=e.id;s(n,"Removing iFrame: "+n),e.parentNode.removeChild(e),h(n,"closedCallback",n),s(n,"--"),delete V[n]}function b(e){null===j&&(j={x:void 0!==t.pageXOffset?t.pageXOffset:document.documentElement.scrollLeft,y:void 0!==t.pageYOffset?t.pageYOffset:document.documentElement.scrollTop},s(e,"Get page position: "+j.x+","+j.y))}function y(e){null!==j&&(t.scrollTo(j.x,j.y),s(e,"Set page position: "+j.x+","+j.y),v())}function v(){j=null}function w(e){function n(){x(e),M("reset","reset",e.iframe,e.id)}s(e.id,"Size reset requested by "+("init"===e.type?"host page":"iFrame")),b(e.id),k(n,e,"reset")}function x(e){function n(n){e.iframe.style[n]=e[n]+"px",s(e.id,"IFrame ("+o+") "+n+" set to "+e[n]+"px")}function t(n){S||"0"!==e[n]||(S=!0,s(o,"Hidden iFrame detected, creating visibility listener"),z())}function i(e){n(e),t(e)}var o=e.iframe.id;V[o]&&(V[o].sizeHeight&&i("height"),V[o].sizeWidth&&i("width"))}function k(e,n,t){t!==n.type&&q?(s(n.id,"Requesting animation frame"),q(e)):e()}function M(e,n,t,i){function o(){var o=V[i].targetOrigin;s(i,"["+e+"] Sending msg to iframe["+i+"] ("+n+") targetOrigin: "+o),t.contentWindow.postMessage(A+n,o)}function r(){l(i,"["+e+"] IFrame("+i+") not found"),V[i]&&delete V[i]}i=i||t.id,V[i]&&function(){t&&"contentWindow"in t&&null!==t.contentWindow?o():r()}()}function I(e){return e+":"+V[e].bodyMarginV1+":"+V[e].sizeWidth+":"+V[e].log+":"+V[e].interval+":"+V[e].enablePublicMethods+":"+V[e].autoResize+":"+V[e].bodyMargin+":"+V[e].heightCalculationMethod+":"+V[e].bodyBackground+":"+V[e].bodyPadding+":"+V[e].tolerance+":"+V[e].inPageLinks+":"+V[e].resizeFrom+":"+V[e].widthCalculationMethod}function F(e,n){function t(){var e=n&&n.id||J.id+W++;return null!==document.getElementById(e)&&(e+=W++),e}function i(){var n=V[u].firstRun,t=V[u].heightCalculationMethod in B;!n&&t&&w({iframe:e,height:0,width:0,type:"init"})}function o(e){if("object"!=typeof e)throw new TypeError("Options is not an object")}function r(e){for(var n in J)J.hasOwnProperty(n)&&(V[u][n]=e.hasOwnProperty(n)?e[n]:J[n])}function c(e){return""===e||"file://"===e?"*":e}var u=function(i){return D=i,""===i&&(e.id=i=t(),N=(n||{}).log,D=i,s(i,"Added missing iframe ID: "+i+" ("+e.src+")")),i}(e.id);!function(){return u in V&&"iFrameResizer"in e}()?(function(n){n=n||{},V[u]={firstRun:!0,iframe:e,remoteHost:e.src.split("/").slice(0,3).join("/")},o(n),r(n),V[u].targetOrigin=!0===V[u].checkOrigin?c(V[u].remoteHost):"*"}(n),function(){s(u,"IFrame scrolling "+(V[u].scrolling?"enabled":"disabled")+" for "+u),e.style.overflow=!1===V[u].scrolling?"hidden":"auto",e.scrolling=!1===V[u].scrolling?"no":"yes"}(),function(){function n(n){1/0!==V[u][n]&&0!==V[u][n]&&(e.style[n]=V[u][n]+"px",s(u,"Set "+n+" = "+V[u][n]+"px"))}function t(e){if(V[u]["min"+e]>V[u]["max"+e])throw new Error("Value for min"+e+" can not be greater than max"+e)}t("Height"),t("Width"),n("maxHeight"),n("minHeight"),n("maxWidth"),n("minWidth")}(),function(){"number"!=typeof V[u].bodyMargin&&"0"!==V[u].bodyMargin||(V[u].bodyMarginV1=V[u].bodyMargin,V[u].bodyMargin=V[u].bodyMargin+"px")}(),function(n){function t(){M("iFrame.onload",n,e),i()}a(e,"load",t),M("init",n,e)}(I(u)),function(){Function.prototype.bind&&(V[u].iframe.iFrameResizer={close:p.bind(null,V[u].iframe),resize:M.bind(null,"Window resize","resize",V[u].iframe),moveToAnchor:function(e){M("Move to anchor","moveToAnchor:"+e,V[u].iframe,u)},sendMessage:function(e){e=JSON.stringify(e),M("Send Message","message:"+e,V[u].iframe,u)}})}()):d(u,"Ignored iFrame, already setup.")}function O(e,n){null===U&&(U=setTimeout(function(){U=null,e()},n))}function z(){function e(){for(var e in V)!function(e){function n(n){return"0px"===V[e].iframe.style[n]}(function(e){return null!==e.offsetParent})(V[e].iframe)&&(n("height")||n("width"))&&M("Visibility change","resize",V[e].iframe,e)}(e)}function n(n){s("window","Mutation observed: "+n[0].target+" "+n[0].type),O(e,16)}var i=t.MutationObserver||t.WebKitMutationObserver;i&&function(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};new i(n).observe(e,t)}()}function E(e){function n(){R("Window "+e,"resize")}s("window","Trigger event: "+e),O(n,16)}function C(){function e(){R("Tab Visable","resize")}"hidden"!==document.visibilityState&&(s("document","Trigger event: Visiblity change"),O(e,16))}function R(e,n){for(var t in V)(function(e){return"parent"===V[e].resizeFrom&&V[e].autoResize&&!V[e].firstRun})(t)&&M(e,n,document.getElementById(t),t)}function T(){a(t,"message",g),a(t,"resize",function(){E("resize")}),a(document,"visibilitychange",C),a(document,"-webkit-visibilitychange",C),a(t,"focusin",function(){E("focus")}),a(t,"focus",function(){E("focus")})}function P(){function e(e,t){t&&(!function(){if(!t.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==t.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+t.tagName+">")}(),F(t,e),n.push(t))}var n;return u(),T(),function(t,i){switch(n=[],typeof i){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(i||"iframe"),e.bind(void 0,t));break;case"object":e(t,i);break;default:throw new TypeError("Unexpected data type ("+typeof i+")")}return n}}var W=0,N=!1,S=!1,H="message".length,A="[iFrameSizer]",L=A.length,j=null,q=t.requestAnimationFrame,B={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},V={},U=null,D="Host Page",J={autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,widthCalculationMethod:"scroll",closedCallback:function(){},initCallback:function(){},messageCallback:function(){d("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};t.jQuery&&function(e){e.fn?e.fn.iFrameResize=function(e){function n(n,t){F(t,e)}return this.filter("iframe").each(n).end()}:l("","Unable to bind to jQuery, it is not fully loaded.")}(jQuery),o=[],i=P,void 0!==(r="function"==typeof i?i.apply(n,o):i)&&(e.exports=r)}(window||{})}});
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。