@uiengine/ui
Version:
UIengine user interface.
1 lines • 13.3 kB
JavaScript
(self.webpackChunk_uiengine_ui=self.webpackChunk_uiengine_ui||[]).push([[685],{3794:function(e){!function(t){if("undefined"!=typeof window){var n=!0,o=10,i="",r=0,a="",u=null,c="",s=!1,d={resize:1,click:1},l=128,f=!0,m=1,h="bodyOffset",g=h,p=!0,v="",y={},b=32,w=null,T=!1,E="[iFrameSizer]",O=E.length,S="",M={max:1,min:1,bodyScroll:1,documentElementScroll:1},I="child",N=!0,k=window.parent,A="*",C=0,z=!1,R=null,x=16,L=1,F="scroll",P=F,D=window,j=function(){ue("onMessage function not defined")},q=function(){},H=function(){},W={height:function(){return ue("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return ue("Custom width calculation function not defined"),document.body.scrollWidth}},B={},J=!1;try{var U=Object.create({},{passive:{get:function(){J=!0}}});window.addEventListener("test",ne,U),window.removeEventListener("test",ne,U)}catch(e){}var _,V,K,Q,X,Y,G,Z=Date.now||function(){return(new Date).getTime()},$={bodyOffset:function(){return document.body.offsetHeight+ye("marginTop")+ye("marginBottom")},offset:function(){return $.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return W.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,we($))},min:function(){return Math.min.apply(null,we($))},grow:function(){return $.max()},lowestElement:function(){return Math.max($.bodyOffset()||$.documentElementOffset(),be("bottom",Ee()))},taggedElement:function(){return Te("bottom","data-iframe-height")}},ee={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return W.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(ee.bodyScroll(),ee.documentElementScroll())},max:function(){return Math.max.apply(null,we(ee))},min:function(){return Math.min.apply(null,we(ee))},rightMostElement:function(){return be("right",Ee())},taggedElement:function(){return Te("right","data-iframe-width")}},te=(_=Oe,X=null,Y=0,G=function(){Y=Z(),X=null,Q=_.apply(V,K),X||(V=K=null)},function(){var e=Z();Y||(Y=e);var t=x-(e-Y);return V=this,K=arguments,t<=0||t>x?(X&&(clearTimeout(X),X=null),Y=e,Q=_.apply(V,K),X||(V=K=null)):X||(X=setTimeout(G,t)),Q});oe(window,"message",(function(t){var n={init:function(){v=t.data,k=t.source,ce(),f=!1,setTimeout((function(){p=!1}),l)},reset:function(){p?ae("Page reset ignored by init"):(ae("Page size reset by host page"),Ie("resetPage"))},resize:function(){Se("resizeParent","Parent window requested size check")},moveToAnchor:function(){y.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();ae("PageInfoFromParent called from parent: "+e),H(JSON.parse(e)),ae(" --")},message:function(){var e=i();ae("onMessage called from parent: "+e),j(JSON.parse(e)),ae(" --")}};function o(){return t.data.split("]")[1].split(":")[0]}function i(){return t.data.substr(t.data.indexOf(":")+1)}function r(){return t.data.split(":")[2]in{true:1,false:1}}function a(){var i=o();i in n?n[i]():!e.exports&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||ue("Unexpected message ("+t.data+")")}E===(""+t.data).substr(0,O)&&(!1===f?a():r()?n.init():ae('Ignored message of type "'+o()+'". Received before initialization.'))})),oe(window,"readystatechange",Ae),Ae()}function ne(){}function oe(e,t,n,o){e.addEventListener(t,n,!!J&&(o||{}))}function ie(e){return e.charAt(0).toUpperCase()+e.slice(1)}function re(e){return E+"["+S+"] "+e}function ae(e){T&&"object"==typeof window.console&&console.log(re(e))}function ue(e){"object"==typeof window.console&&console.warn(re(e))}function ce(){var e;!function(){function e(e){return"true"===e}var o=v.substr(O).split(":");S=o[0],r=t!==o[1]?Number(o[1]):r,s=t!==o[2]?e(o[2]):s,T=t!==o[3]?e(o[3]):T,b=t!==o[4]?Number(o[4]):b,n=t!==o[6]?e(o[6]):n,a=o[7],g=t!==o[8]?o[8]:g,i=o[9],c=o[10],C=t!==o[11]?Number(o[11]):C,y.enable=t!==o[12]&&e(o[12]),I=t!==o[13]?o[13]:I,P=t!==o[14]?o[14]:P}(),ae("Initialising iFrame ("+location.href+")"),function(){function e(){var e=window.iFrameResizer;ae("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(se,e),j="onMessage"in e?e.onMessage:j,q="onReady"in e?e.onReady:q,A="targetOrigin"in e?e.targetOrigin:A,g="heightCalculationMethod"in e?e.heightCalculationMethod:g,P="widthCalculationMethod"in e?e.widthCalculationMethod:P}function t(e,t){return"function"==typeof e&&(ae("Setup custom "+t+"CalcMethod"),W[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),g=t(g,"height"),P=t(P,"width"));ae("TargetOrigin for parent set to: "+A)}(),function(){t===a&&(a=r+"px");de("margin",function(e,t){-1!==t.indexOf("-")&&(ue("Negative CSS value ignored for "+e),t="");return t}("margin",a))}(),de("background",i),de("padding",c),(e=document.createElement("div")).style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e),he(),ge(),document.documentElement.style.height="",document.body.style.height="",ae('HTML & body height set to "auto"'),ae("Enable public methods"),D.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,pe()):!1===e&&!0===n&&(n=!1,fe("remove"),null!==u&&u.disconnect(),clearInterval(w)),ke(0,0,"autoResize",JSON.stringify(n)),n},close:function(){ke(0,0,"close")},getId:function(){return S},getPageInfo:function(e){"function"==typeof e?(H=e,ke(0,0,"pageInfo")):(H=function(){},ke(0,0,"pageInfoStop"))},moveToAnchor:function(e){y.findTarget(e)},reset:function(){Ne("parentIFrame.reset")},scrollTo:function(e,t){ke(t,e,"scrollTo")},scrollToOffset:function(e,t){ke(t,e,"scrollToOffset")},sendMessage:function(e,t){ke(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){g=e,he()},setWidthCalculationMethod:function(e){P=e,ge()},setTargetOrigin:function(e){ae("Set targetOrigin: "+e),A=e},size:function(e,t){Se("size","parentIFrame.size("+(e||"")+(t?","+t:"")+")",e,t)}},pe(),y=function(){function e(){return{x:window.pageXOffset!==t?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==t?window.pageYOffset:document.documentElement.scrollTop}}function n(t){var n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,10)+parseInt(o.x,10),y:parseInt(n.top,10)+parseInt(o.y,10)}}function o(e){function o(e){var t=n(e);ae("Moving to in page link (#"+i+") at x: "+t.x+" y: "+t.y),ke(t.y,t.x,"scrollToOffset")}var i=e.split("#")[1]||e,r=decodeURIComponent(i),a=document.getElementById(r)||document.getElementsByName(r)[0];t!==a?o(a):(ae("In page link (#"+i+") not found in iFrame, so sending to parent"),ke(0,0,"inPageLink","#"+i))}function i(){""!==location.hash&&"#"!==location.hash&&o(location.href)}function r(){function e(e){function t(e){e.preventDefault(),o(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&oe(e,"click",t)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),e)}function a(){oe(window,"hashchange",i)}function u(){setTimeout(i,l)}function c(){Array.prototype.forEach&&document.querySelectorAll?(ae("Setting up location.hash handlers"),r(),a(),u()):ue("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}y.enable?c():ae("In page linking not enabled");return{findTarget:o}}(),Se("init","Init message from host page"),q()}function se(e){var t=e.split("Callback");if(2===t.length){var n="on"+t[0].charAt(0).toUpperCase()+t[0].slice(1);this[n]=this[e],delete this[e],ue("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function de(e,n){t!==n&&""!==n&&"null"!==n&&(document.body.style[e]=n,ae("Body "+e+' set to "'+n+'"'))}function le(e){var t={add:function(t){function n(){Se(e.eventName,e.eventType)}B[t]=n,oe(window,t,n,{passive:!0})},remove:function(e){var t,n,o,i=B[e];delete B[e],t=window,n=e,o=i,t.removeEventListener(n,o,!1)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(t[e.method])):t[e.method](e.eventName),ae(ie(e.method)+" event listener: "+e.eventType)}function fe(e){le({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),le({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),le({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),le({method:e,eventType:"Input",eventName:"input"}),le({method:e,eventType:"Mouse Up",eventName:"mouseup"}),le({method:e,eventType:"Mouse Down",eventName:"mousedown"}),le({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),le({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),le({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),le({method:e,eventType:"Touch Start",eventName:"touchstart"}),le({method:e,eventType:"Touch End",eventName:"touchend"}),le({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),le({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),le({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),le({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===I&&le({method:e,eventType:"IFrame Resized",eventName:"resize"})}function me(e,t,n,o){return t!==e&&(e in n||(ue(e+" is not a valid option for "+o+"CalculationMethod."),e=t),ae(o+' calculation method set to "'+e+'"')),e}function he(){g=me(g,h,$,"height")}function ge(){P=me(P,F,ee,"width")}function pe(){var e;!0===n?(fe("add"),e=0>b,window.MutationObserver||window.WebKitMutationObserver?e?ve():u=function(){function e(e){function t(e){!1===e.complete&&(ae("Attach listeners to "+e.src),e.addEventListener("load",r,!1),e.addEventListener("error",a,!1),s.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function n(e){s.splice(s.indexOf(e),1)}function o(e){ae("Remove listeners from "+e.src),e.removeEventListener("load",r,!1),e.removeEventListener("error",a,!1),n(e)}function i(e,n,i){o(e.target),Se(n,i+": "+e.target.src,t,t)}function r(e){i(e,"imageLoad","Image loaded")}function a(e){i(e,"imageLoadFailed","Image load failed")}function u(t){Se("mutationObserver","mutationObserver: "+t[0].target+" "+t[0].type),t.forEach(e)}function c(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return l=new d(u),ae("Create body MutationObserver"),l.observe(e,t),l}var s=[],d=window.MutationObserver||window.WebKitMutationObserver,l=c();return{disconnect:function(){"disconnect"in l&&(ae("Disconnect body MutationObserver"),l.disconnect(),s.forEach(o))}}}():(ae("MutationObserver not supported in this browser!"),ve())):ae("Auto Resize disabled")}function ve(){0!==b&&(ae("setInterval: "+b+"ms"),w=setInterval((function(){Se("interval","setInterval: "+b)}),Math.abs(b)))}function ye(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,o)}function be(e,t){for(var n=t.length,o=0,i=0,r=ie(e),a=Z(),u=0;u<n;u++)(o=t[u].getBoundingClientRect()[e]+ye("margin"+r,t[u]))>i&&(i=o);return a=Z()-a,ae("Parsed "+n+" HTML elements"),ae("Element position calculated in "+a+"ms"),function(e){e>x/2&&ae("Event throttle increased to "+(x=2*e)+"ms")}(a),i}function we(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function Te(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(ue("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),be(e,n)}function Ee(){return document.querySelectorAll("body *")}function Oe(e,n,o,i){var r,a;!function(){function e(e,t){return!(Math.abs(e-t)<=C)}return r=t!==o?o:$[g](),a=t!==i?i:ee[P](),e(m,r)||s&&e(L,a)}()&&"init"!==e?!(e in{init:1,interval:1,size:1})&&(g in M||s&&P in M)?Ne(n):e in{interval:1}||ae("No change in size detected"):(Me(),ke(m=r,L=a,e))}function Se(e,t,n,o){z&&e in d?ae("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||ae("Trigger event: "+t),"init"===e?Oe(e,t,n,o):te(e,t,n,o))}function Me(){z||(z=!0,ae("Trigger event lock on")),clearTimeout(R),R=setTimeout((function(){z=!1,ae("Trigger event lock off"),ae("--")}),l)}function Ie(e){m=$[g](),L=ee[P](),ke(m,L,e)}function Ne(e){var t=g;g=h,ae("Reset trigger event: "+e),Me(),Ie("reset"),g=t}function ke(e,n,o,i,r){var a;!0===N&&(t===r?r=A:ae("Message targetOrigin: "+r),ae("Sending message to host page ("+(a=S+":"+e+":"+n+":"+o+(t!==i?":"+i:""))+")"),k.postMessage(E+a,r))}function Ae(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}()}},function(e){var t;t=3794,e(e.s=t)}]);