lookbook 0.8.0 → 1.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -830
- data/app/assets/lookbook/css/lookbook.css +55 -0
- data/app/assets/lookbook/css/themes/blue.css +42 -0
- data/app/assets/lookbook/css/themes/indigo.css +42 -0
- data/app/assets/lookbook/css/themes/zinc.css +42 -0
- data/app/assets/lookbook/css/{tooltip_theme.css → tooltip.css} +14 -8
- data/app/assets/lookbook/js/app.js +64 -61
- data/app/assets/lookbook/js/components/clipboard.js +47 -0
- data/app/assets/lookbook/js/components/tooltip.js +30 -0
- data/app/assets/lookbook/js/config.js +7 -4
- data/app/assets/lookbook/js/helpers/build.js +22 -0
- data/app/assets/lookbook/js/helpers/dom.js +45 -0
- data/app/assets/lookbook/js/helpers/layout.js +21 -0
- data/app/assets/lookbook/js/helpers/request.js +16 -0
- data/app/assets/lookbook/js/helpers/string.js +11 -0
- data/app/assets/lookbook/js/lib/socket.js +4 -3
- data/app/assets/lookbook/js/lib/tippy.js +8 -0
- data/app/assets/lookbook/js/lookbook.js +61 -0
- data/app/assets/lookbook/js/plugins/logger.js +39 -0
- data/app/assets/lookbook/js/stores/filter.js +2 -2
- data/app/assets/lookbook/js/stores/inspector.js +22 -16
- data/app/assets/lookbook/js/stores/layout.js +101 -5
- data/app/assets/lookbook/js/stores/nav.js +17 -16
- data/app/assets/lookbook/js/stores/pages.js +4 -2
- data/app/assets/lookbook/js/stores/settings.js +7 -0
- data/app/assets/lookbook/js/stores/workbench.js +29 -0
- data/app/components/lookbook/button/component.html.erb +28 -0
- data/app/components/lookbook/button/component.js +55 -0
- data/app/components/lookbook/button/component.rb +39 -0
- data/app/components/lookbook/button_group/component.html.erb +3 -0
- data/app/components/lookbook/button_group/component.rb +18 -0
- data/app/components/lookbook/code/component.css +57 -0
- data/app/components/lookbook/code/component.html.erb +10 -0
- data/app/components/lookbook/code/component.js +3 -0
- data/app/components/lookbook/code/component.rb +56 -0
- data/app/components/lookbook/code/highlight_github_light.css +217 -0
- data/app/components/lookbook/component.rb +41 -0
- data/app/components/lookbook/copy_button/component.html.erb +11 -0
- data/app/components/lookbook/copy_button/component.js +16 -0
- data/app/components/lookbook/copy_button/component.rb +23 -0
- data/app/components/lookbook/dimensions_display/component.html.erb +10 -0
- data/app/components/lookbook/dimensions_display/component.js +30 -0
- data/app/components/lookbook/dimensions_display/component.rb +18 -0
- data/app/components/lookbook/embed/component.html.erb +50 -0
- data/app/components/lookbook/embed/component.js +39 -0
- data/app/components/lookbook/embed/component.rb +22 -0
- data/app/components/lookbook/filter/component.html.erb +17 -0
- data/app/components/lookbook/filter/component.js +21 -0
- data/app/components/lookbook/filter/component.rb +15 -0
- data/app/components/lookbook/header/component.html.erb +79 -0
- data/app/components/lookbook/header/component.rb +9 -0
- data/app/components/lookbook/icon/component.css +11 -0
- data/app/components/lookbook/icon/component.html.erb +5 -0
- data/app/components/lookbook/icon/component.js +5 -0
- data/app/components/lookbook/icon/component.rb +23 -0
- data/app/components/lookbook/nav/component.html.erb +33 -0
- data/app/components/lookbook/nav/component.js +52 -0
- data/app/components/lookbook/nav/component.rb +37 -0
- data/app/components/lookbook/nav/item/component.html.erb +23 -0
- data/app/components/lookbook/nav/item/component.js +66 -0
- data/app/components/lookbook/nav/item/component.rb +84 -0
- data/app/components/lookbook/params_editor/component.html.erb +3 -0
- data/app/components/lookbook/params_editor/component.js +12 -0
- data/app/components/lookbook/params_editor/component.rb +11 -0
- data/app/components/lookbook/params_editor/field/component.html.erb +50 -0
- data/app/components/lookbook/params_editor/field/component.js +36 -0
- data/app/components/lookbook/params_editor/field/component.rb +41 -0
- data/app/components/lookbook/prose/component.css +12 -0
- data/app/components/lookbook/prose/component.html.erb +3 -0
- data/app/components/lookbook/prose/component.rb +26 -0
- data/app/components/lookbook/split_layout/component.html.erb +13 -0
- data/app/components/lookbook/split_layout/component.js +151 -0
- data/app/components/lookbook/split_layout/component.rb +11 -0
- data/app/components/lookbook/tabbed_content/component.html.erb +5 -0
- data/app/components/lookbook/tabbed_content/component.js +21 -0
- data/app/components/lookbook/tabbed_content/component.rb +20 -0
- data/app/components/lookbook/tabbed_content/section/component.html.erb +8 -0
- data/app/components/lookbook/tabbed_content/section/component.rb +9 -0
- data/app/components/lookbook/tabs/component.css +8 -0
- data/app/components/lookbook/tabs/component.html.erb +14 -0
- data/app/components/lookbook/tabs/component.js +107 -0
- data/app/components/lookbook/tabs/component.rb +30 -0
- data/app/components/lookbook/tabs/dropdown_tab/component.html.erb +14 -0
- data/app/components/lookbook/tabs/dropdown_tab/component.rb +16 -0
- data/app/components/lookbook/tabs/tab/component.html.erb +18 -0
- data/app/components/lookbook/tabs/tab/component.rb +16 -0
- data/app/components/lookbook/tag_component.rb +29 -0
- data/app/components/lookbook/toolbar/component.css +16 -0
- data/app/components/lookbook/toolbar/component.html.erb +5 -0
- data/app/components/lookbook/toolbar/component.rb +26 -0
- data/app/components/lookbook/viewport/component.css +11 -0
- data/app/components/lookbook/viewport/component.html.erb +57 -0
- data/app/{assets/lookbook/js/components/preview-window.js → components/lookbook/viewport/component.js} +57 -14
- data/app/components/lookbook/viewport/component.rb +21 -0
- data/app/controllers/lookbook/application_controller.rb +16 -5
- data/app/controllers/lookbook/pages_controller.rb +18 -8
- data/app/controllers/lookbook/previews_controller.rb +60 -23
- data/app/helpers/lookbook/application_helper.rb +5 -1
- data/app/helpers/lookbook/component_helper.rb +22 -10
- data/app/helpers/lookbook/output_helper.rb +8 -4
- data/app/helpers/lookbook/page_helper.rb +13 -21
- data/app/views/layouts/lookbook/application.html.erb +76 -28
- data/app/views/layouts/lookbook/inspector.html.erb +7 -0
- data/app/views/layouts/lookbook/page.html.erb +53 -0
- data/app/views/layouts/lookbook/shell.html.erb +64 -0
- data/app/views/layouts/lookbook/skeleton.html.erb +27 -10
- data/app/views/layouts/lookbook/standalone.html.erb +5 -0
- data/app/views/lookbook/404.html.erb +15 -0
- data/app/views/lookbook/error.html.erb +34 -34
- data/app/views/lookbook/index.html.erb +11 -6
- data/app/views/lookbook/pages/show.html.erb +29 -67
- data/app/views/{layouts/lookbook → lookbook}/preview.html.erb +3 -5
- data/app/views/lookbook/previews/panels/_notes.html.erb +19 -25
- data/app/views/lookbook/previews/panels/_output.html.erb +7 -18
- data/app/views/lookbook/previews/panels/_params.html.erb +13 -15
- data/app/views/lookbook/previews/panels/_preview.html.erb +6 -52
- data/app/views/lookbook/previews/panels/_source.html.erb +7 -16
- data/app/views/lookbook/previews/show.html.erb +130 -24
- data/config/routes.rb +5 -5
- data/lib/lookbook/code_formatter.rb +37 -13
- data/lib/lookbook/collection.rb +19 -16
- data/lib/lookbook/config.rb +125 -0
- data/lib/lookbook/engine.rb +79 -74
- data/lib/lookbook/entity.rb +47 -0
- data/lib/lookbook/error.rb +1 -2
- data/lib/lookbook/features.rb +1 -1
- data/lib/lookbook/markdown.rb +3 -4
- data/lib/lookbook/page.rb +21 -12
- data/lib/lookbook/page_collection.rb +8 -0
- data/lib/lookbook/params.rb +15 -4
- data/lib/lookbook/preview.rb +15 -6
- data/lib/lookbook/preview_collection.rb +8 -0
- data/lib/lookbook/preview_controller.rb +6 -2
- data/lib/lookbook/preview_example.rb +5 -6
- data/lib/lookbook/preview_group.rb +4 -9
- data/lib/lookbook/{code_inspector.rb → source_inspector.rb} +2 -2
- data/lib/lookbook/theme.rb +22 -0
- data/lib/lookbook/utils.rb +10 -2
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +4 -1
- data/lib/tasks/lookbook_tasks.rake +12 -0
- data/public/lookbook-assets/css/app.css +2340 -1
- data/public/lookbook-assets/css/app.css.map +11 -1
- data/public/lookbook-assets/css/lookbook.css +3040 -0
- data/public/lookbook-assets/css/lookbook.css.map +1 -0
- data/public/lookbook-assets/css/themes/blue.css +44 -0
- data/public/lookbook-assets/css/themes/blue.css.map +1 -0
- data/public/lookbook-assets/css/themes/indigo.css +44 -0
- data/public/lookbook-assets/css/themes/indigo.css.map +1 -0
- data/public/lookbook-assets/css/themes/zinc.css +44 -0
- data/public/lookbook-assets/css/themes/zinc.css.map +1 -0
- data/public/lookbook-assets/js/app.js +10861 -1
- data/public/lookbook-assets/js/app.js.map +2571 -1
- data/public/lookbook-assets/js/embed.js +895 -1
- data/public/lookbook-assets/js/embed.js.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +13529 -0
- data/public/lookbook-assets/js/lookbook.js.map +1 -0
- metadata +127 -114
- data/app/assets/lookbook/css/app.css +0 -161
- data/app/assets/lookbook/css/code_theme.css +0 -214
- data/app/assets/lookbook/js/components/app.js +0 -55
- data/app/assets/lookbook/js/components/code.js +0 -5
- data/app/assets/lookbook/js/components/copy.js +0 -20
- data/app/assets/lookbook/js/components/embed.js +0 -89
- data/app/assets/lookbook/js/components/filter.js +0 -35
- data/app/assets/lookbook/js/components/inspector.js +0 -66
- data/app/assets/lookbook/js/components/nav-group.js +0 -47
- data/app/assets/lookbook/js/components/nav-item.js +0 -29
- data/app/assets/lookbook/js/components/nav.js +0 -28
- data/app/assets/lookbook/js/components/page.js +0 -25
- data/app/assets/lookbook/js/components/param.js +0 -34
- data/app/assets/lookbook/js/components/sidebar.js +0 -18
- data/app/assets/lookbook/js/components/sizes.js +0 -16
- data/app/assets/lookbook/js/components/splitter.js +0 -25
- data/app/assets/lookbook/js/components/tabs.js +0 -52
- data/app/assets/lookbook/js/lib/split.js +0 -15
- data/app/assets/lookbook/js/stores/sidebar.js +0 -26
- data/app/views/layouts/lookbook/basic.html.erb +0 -7
- data/app/views/lookbook/components/_branding.html.erb +0 -8
- data/app/views/lookbook/components/_code.html.erb +0 -17
- data/app/views/lookbook/components/_copy_button.html.erb +0 -11
- data/app/views/lookbook/components/_drawer.html.erb +0 -112
- data/app/views/lookbook/components/_embed.html.erb +0 -39
- data/app/views/lookbook/components/_errors.html.erb +0 -13
- data/app/views/lookbook/components/_filter.html.erb +0 -18
- data/app/views/lookbook/components/_header.html.erb +0 -6
- data/app/views/lookbook/components/_icon.html.erb +0 -5
- data/app/views/lookbook/components/_nav.html.erb +0 -16
- data/app/views/lookbook/components/_nav_collection.html.erb +0 -5
- data/app/views/lookbook/components/_nav_group.html.erb +0 -14
- data/app/views/lookbook/components/_nav_item.html.erb +0 -24
- data/app/views/lookbook/components/_nav_page.html.erb +0 -22
- data/app/views/lookbook/components/_nav_preview.html.erb +0 -13
- data/app/views/lookbook/components/_not_found.html.erb +0 -11
- data/app/views/lookbook/components/_param.html.erb +0 -21
- data/app/views/lookbook/components/_preview.html.erb +0 -77
- data/app/views/lookbook/components/_sidebar.html.erb +0 -69
- data/app/views/lookbook/pages/not_found.html.erb +0 -15
- data/app/views/lookbook/previews/error.html.erb +0 -1
- data/app/views/lookbook/previews/inputs/_select.html.erb +0 -7
- data/app/views/lookbook/previews/inputs/_text.html.erb +0 -8
- data/app/views/lookbook/previews/inputs/_textarea.html.erb +0 -8
- data/app/views/lookbook/previews/inputs/_toggle.html.erb +0 -13
- data/app/views/lookbook/previews/not_found.html.erb +0 -23
@@ -1,2 +1,896 @@
|
|
1
|
-
(()=>{var e={};!function(t){if("undefined"!=typeof window){var n=!0,o="",i=0,r="",a=null,u="",c=!1,s={resize:1,click:1},d=128,l=!0,f=1,m="bodyOffset",h=m,g=!0,p="",v={},y=32,w=null,b=!1,T=!1,E="[iFrameSizer]",O=E.length,S="",M={max:1,min:1,bodyScroll:1,documentElementScroll:1},I="child",N=window.parent,A="*",C=0,z=!1,k=null,R=16,x=1,L="scroll",F=L,P=window,D=function(){re("onMessage function not defined")},j=function(){},q=function(){},H={height:function(){return re("Custom height calculation function not defined"),document.documentElement.offsetHeight},width:function(){return re("Custom width calculation function not defined"),document.body.scrollWidth}},W={},B=!1;try{var J=Object.create({},{passive:{get:function(){B=!0}}});window.addEventListener("test",ee,J),window.removeEventListener("test",ee,J)}catch(e){}var U,V,X,Y,K,Q,G,Z={bodyOffset:function(){return document.body.offsetHeight+pe("marginTop")+pe("marginBottom")},offset:function(){return Z.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},custom:function(){return H.height()},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,ye(Z))},min:function(){return Math.min.apply(null,ye(Z))},grow:function(){return Z.max()},lowestElement:function(){return Math.max(Z.bodyOffset()||Z.documentElementOffset(),ve("bottom",be()))},taggedElement:function(){return we("bottom","data-iframe-height")}},$={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},custom:function(){return H.width()},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max($.bodyScroll(),$.documentElementScroll())},max:function(){return Math.max.apply(null,ye($))},min:function(){return Math.min.apply(null,ye($))},rightMostElement:function(){return ve("right",be())},taggedElement:function(){return we("right","data-iframe-width")}},_=(U=Te,K=null,Q=0,G=function(){Q=Date.now(),K=null,Y=U.apply(V,X),K||(V=X=null)},function(){var e=Date.now();Q||(Q=e);var t=R-(e-Q);return V=this,X=arguments,t<=0||t>R?(K&&(clearTimeout(K),K=null),Q=e,Y=U.apply(V,X),K||(V=X=null)):K||(K=setTimeout(G,t)),Y});te(window,"message",(function(t){var n={init:function(){p=t.data,N=t.source,ae(),l=!1,setTimeout((function(){g=!1}),d)},reset:function(){g?ie("Page reset ignored by init"):(ie("Page size reset by host page"),Se("resetPage"))},resize:function(){Ee("resizeParent","Parent window requested size check")},moveToAnchor:function(){v.findTarget(i())},inPageLink:function(){this.moveToAnchor()},pageInfo:function(){var e=i();ie("PageInfoFromParent called from parent: "+e),q(JSON.parse(e)),ie(" --")},message:function(){var e=i();ie("onMessage called from parent: "+e),D(JSON.parse(e)),ie(" --")}};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&&"iFrameResize"in window||"jQuery"in window&&"iFrameResize"in window.jQuery.prototype||r()||re("Unexpected message ("+t.data+")")}E===(""+t.data).substr(0,O)&&(!1===l?a():r()?n.init():ie('Ignored message of type "'+o()+'". Received before initialization.'))})),te(window,"readystatechange",Ne),Ne()}function ee(){}function te(e,t,n,o){e.addEventListener(t,n,!!B&&(o||{}))}function ne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function oe(e){return E+"["+S+"] "+e}function ie(e){b&&"object"==typeof window.console&&console.log(oe(e))}function re(e){"object"==typeof window.console&&console.warn(oe(e))}function ae(){var e;!function(){function e(e){return"true"===e}var a=p.substr(O).split(":");S=a[0],i=t!==a[1]?Number(a[1]):i,c=t!==a[2]?e(a[2]):c,b=t!==a[3]?e(a[3]):b,y=t!==a[4]?Number(a[4]):y,n=t!==a[6]?e(a[6]):n,r=a[7],h=t!==a[8]?a[8]:h,o=a[9],u=a[10],C=t!==a[11]?Number(a[11]):C,v.enable=t!==a[12]&&e(a[12]),I=t!==a[13]?a[13]:I,F=t!==a[14]?a[14]:F,T=t!==a[15]?Boolean(a[15]):T}(),ie("Initialising iFrame ("+window.location.href+")"),function(){function e(){var e=window.iFrameResizer;ie("Reading data from page: "+JSON.stringify(e)),Object.keys(e).forEach(ue,e),D="onMessage"in e?e.onMessage:D,j="onReady"in e?e.onReady:j,A="targetOrigin"in e?e.targetOrigin:A,h="heightCalculationMethod"in e?e.heightCalculationMethod:h,F="widthCalculationMethod"in e?e.widthCalculationMethod:F}function t(e,t){return"function"==typeof e&&(ie("Setup custom "+t+"CalcMethod"),H[t]=e,e="custom"),e}"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),h=t(h,"height"),F=t(F,"width"));ie("TargetOrigin for parent set to: "+A)}(),function(){t===r&&(r=i+"px");ce("margin",function(e,t){-1!==t.indexOf("-")&&(re("Negative CSS value ignored for "+e),t="");return t}("margin",r))}(),ce("background",o),ce("padding",u),(e=document.createElement("div")).style.clear="both",e.style.display="block",e.style.height="0",document.body.appendChild(e),fe(),me(),document.documentElement.style.height="",document.body.style.height="",ie('HTML & body height set to "auto"'),ie("Enable public methods"),P.parentIFrame={autoResize:function(e){return!0===e&&!1===n?(n=!0,he()):!1===e&&!0===n&&(n=!1,de("remove"),null!==a&&a.disconnect(),clearInterval(w)),Ie(0,0,"autoResize",JSON.stringify(n)),n},close:function(){Ie(0,0,"close")},getId:function(){return S},getPageInfo:function(e){"function"==typeof e?(q=e,Ie(0,0,"pageInfo")):(q=function(){},Ie(0,0,"pageInfoStop"))},moveToAnchor:function(e){v.findTarget(e)},reset:function(){Me("parentIFrame.reset")},scrollTo:function(e,t){Ie(t,e,"scrollTo")},scrollToOffset:function(e,t){Ie(t,e,"scrollToOffset")},sendMessage:function(e,t){Ie(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod:function(e){h=e,fe()},setWidthCalculationMethod:function(e){F=e,me()},setTargetOrigin:function(e){ie("Set targetOrigin: "+e),A=e},size:function(e,t){Ee("size","parentIFrame.size("+(e||"")+(t?","+t:"")+")",e,t)}},function(){if(!0!==T)return;function e(e){Ie(0,0,e.type,e.screenY+":"+e.screenX)}function t(t,n){ie("Add event listener: "+n),te(window.document,t,e)}t("mouseenter","Mouse Enter"),t("mouseleave","Mouse Leave")}(),he(),v=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);ie("Moving to in page link (#"+i+") at x: "+t.x+" y: "+t.y),Ie(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):(ie("In page link (#"+i+") not found in iFrame, so sending to parent"),Ie(0,0,"inPageLink","#"+i))}function i(){var e=window.location.hash,t=window.location.href;""!==e&&"#"!==e&&o(t)}function r(){function e(e){function t(e){e.preventDefault(),o(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&te(e,"click",t)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),e)}function a(){te(window,"hashchange",i)}function u(){setTimeout(i,d)}function c(){Array.prototype.forEach&&document.querySelectorAll?(ie("Setting up location.hash handlers"),r(),a(),u()):re("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}v.enable?c():ie("In page linking not enabled");return{findTarget:o}}(),Ee("init","Init message from host page"),j()}function ue(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],re("Deprecated: '"+e+"' has been renamed '"+n+"'. The old method will be removed in the next major version.")}}function ce(e,n){t!==n&&""!==n&&"null"!==n&&(document.body.style[e]=n,ie("Body "+e+' set to "'+n+'"'))}function se(e){var t={add:function(t){function n(){Ee(e.eventName,e.eventType)}W[t]=n,te(window,t,n,{passive:!0})},remove:function(e){var t,n,o,i=W[e];delete W[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),ie(ne(e.method)+" event listener: "+e.eventType)}function de(e){se({method:e,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),se({method:e,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),se({method:e,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),se({method:e,eventType:"Input",eventName:"input"}),se({method:e,eventType:"Mouse Up",eventName:"mouseup"}),se({method:e,eventType:"Mouse Down",eventName:"mousedown"}),se({method:e,eventType:"Orientation Change",eventName:"orientationchange"}),se({method:e,eventType:"Print",eventName:["afterprint","beforeprint"]}),se({method:e,eventType:"Ready State Change",eventName:"readystatechange"}),se({method:e,eventType:"Touch Start",eventName:"touchstart"}),se({method:e,eventType:"Touch End",eventName:"touchend"}),se({method:e,eventType:"Touch Cancel",eventName:"touchcancel"}),se({method:e,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),se({method:e,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),se({method:e,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===I&&se({method:e,eventType:"IFrame Resized",eventName:"resize"})}function le(e,t,n,o){return t!==e&&(e in n||(re(e+" is not a valid option for "+o+"CalculationMethod."),e=t),ie(o+' calculation method set to "'+e+'"')),e}function fe(){h=le(h,m,Z,"height")}function me(){F=le(F,L,$,"width")}function he(){var e;!0===n?(de("add"),e=0>y,window.MutationObserver||window.WebKitMutationObserver?e?ge():a=function(){function e(e){function t(e){!1===e.complete&&(ie("Attach listeners to "+e.src),e.addEventListener("load",i,!1),e.addEventListener("error",r,!1),c.push(e))}"attributes"===e.type&&"src"===e.attributeName?t(e.target):"childList"===e.type&&Array.prototype.forEach.call(e.target.querySelectorAll("img"),t)}function t(e){c.splice(c.indexOf(e),1)}function n(e){ie("Remove listeners from "+e.src),e.removeEventListener("load",i,!1),e.removeEventListener("error",r,!1),t(e)}function o(e,t,o){n(e.target),Ee(t,o+": "+e.target.src)}function i(e){o(e,"imageLoad","Image loaded")}function r(e){o(e,"imageLoadFailed","Image load failed")}function a(t){Ee("mutationObserver","mutationObserver: "+t[0].target+" "+t[0].type),t.forEach(e)}function u(){var e=document.querySelector("body"),t={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return d=new s(a),ie("Create body MutationObserver"),d.observe(e,t),d}var c=[],s=window.MutationObserver||window.WebKitMutationObserver,d=u();return{disconnect:function(){"disconnect"in d&&(ie("Disconnect body MutationObserver"),d.disconnect(),c.forEach(n))}}}():(ie("MutationObserver not supported in this browser!"),ge())):ie("Auto Resize disabled")}function ge(){0!==y&&(ie("setInterval: "+y+"ms"),w=setInterval((function(){Ee("interval","setInterval: "+y)}),Math.abs(y)))}function pe(e,t){var n=0;return t=t||document.body,n=null!==(n=document.defaultView.getComputedStyle(t,null))?n[e]:0,parseInt(n,10)}function ve(e,t){for(var n=t.length,o=0,i=0,r=ne(e),a=Date.now(),u=0;u<n;u++)(o=t[u].getBoundingClientRect()[e]+pe("margin"+r,t[u]))>i&&(i=o);return a=Date.now()-a,ie("Parsed "+n+" HTML elements"),ie("Element position calculated in "+a+"ms"),function(e){e>R/2&&ie("Event throttle increased to "+(R=2*e)+"ms")}(a),i}function ye(e){return[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll()]}function we(e,t){var n=document.querySelectorAll("["+t+"]");return 0===n.length&&(re("No tagged elements ("+t+") found on page"),document.querySelectorAll("body *")),ve(e,n)}function be(){return document.querySelectorAll("body *")}function Te(e,n,o,i){var r,a;!function(){function e(e,t){return!(Math.abs(e-t)<=C)}return r=t!==o?o:Z[h](),a=t!==i?i:$[F](),e(f,r)||c&&e(x,a)}()&&"init"!==e?!(e in{init:1,interval:1,size:1})&&(h in M||c&&F in M)?Me(n):e in{interval:1}||ie("No change in size detected"):(Oe(),Ie(f=r,x=a,e))}function Ee(e,t,n,o){z&&e in s?ie("Trigger event cancelled: "+e):(e in{reset:1,resetPage:1,init:1}||ie("Trigger event: "+t),"init"===e?Te(e,t,n,o):_(e,t,n,o))}function Oe(){z||(z=!0,ie("Trigger event lock on")),clearTimeout(k),k=setTimeout((function(){z=!1,ie("Trigger event lock off"),ie("--")}),d)}function Se(e){f=Z[h](),x=$[F](),Ie(f,x,e)}function Me(e){var t=h;h=m,ie("Reset trigger event: "+e),Oe(),Se("reset"),h=t}function Ie(e,n,o,i,r){var a;t===r?r=A:ie("Message targetOrigin: "+r),ie("Sending message to host page ("+(a=S+":"+e+":"+n+":"+o+(t!==i?":"+i:""))+")"),N.postMessage(E+a,r)}function Ne(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}}()})();
|
1
|
+
(() => {
|
2
|
+
var $b2e1fd3e30ab1f5c$exports = {};
|
3
|
+
(function(undefined) {
|
4
|
+
if (typeof window === 'undefined') return; // don't run for server side render
|
5
|
+
var autoResize = true, base = 10, bodyBackground = '', bodyMargin = 0, bodyMarginStr = '', bodyObserver = null, bodyPadding = '', calculateWidth = false, doubleEventList = {
|
6
|
+
resize: 1,
|
7
|
+
click: 1
|
8
|
+
}, eventCancelTimer = 128, firstRun = true, height1 = 1, heightCalcModeDefault = 'bodyOffset', heightCalcMode = heightCalcModeDefault, initLock = true, initMsg = '', inPageLinks = {}, interval = 32, intervalTimer = null, logging = false, mouseEvents = false, msgID = '[iFrameSizer]', msgIdLen = msgID.length, myID = '', resetRequiredMethods = {
|
9
|
+
max: 1,
|
10
|
+
min: 1,
|
11
|
+
bodyScroll: 1,
|
12
|
+
documentElementScroll: 1
|
13
|
+
}, resizeFrom = 'child', sendPermit = true, target1 = window.parent, targetOriginDefault = '*', tolerance = 0, triggerLocked = false, triggerLockedTimer = null, throttledTimer = 16, width1 = 1, widthCalcModeDefault = 'scroll', widthCalcMode = widthCalcModeDefault, win = window, onMessage = function() {
|
14
|
+
warn('onMessage function not defined');
|
15
|
+
}, onReady = function() {}, onPageInfo = function() {}, customCalcMethods = {
|
16
|
+
height: function() {
|
17
|
+
warn('Custom height calculation function not defined');
|
18
|
+
return document.documentElement.offsetHeight;
|
19
|
+
},
|
20
|
+
width: function() {
|
21
|
+
warn('Custom width calculation function not defined');
|
22
|
+
return document.body.scrollWidth;
|
23
|
+
}
|
24
|
+
}, eventHandlersByName = {}, passiveSupported = false;
|
25
|
+
function noop() {}
|
26
|
+
try {
|
27
|
+
var options = Object.create({}, {
|
28
|
+
passive: {
|
29
|
+
get: function() {
|
30
|
+
passiveSupported = true;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
34
|
+
window.addEventListener('test', noop, options);
|
35
|
+
window.removeEventListener('test', noop, options);
|
36
|
+
} catch (error) {
|
37
|
+
/* */ }
|
38
|
+
function addEventListener(el, evt, func, options) {
|
39
|
+
el.addEventListener(evt, func, passiveSupported ? options || {} : false);
|
40
|
+
}
|
41
|
+
function removeEventListener(el, evt, func) {
|
42
|
+
el.removeEventListener(evt, func, false);
|
43
|
+
}
|
44
|
+
function capitalizeFirstLetter(string) {
|
45
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
46
|
+
}
|
47
|
+
// Based on underscore.js
|
48
|
+
function throttle(func) {
|
49
|
+
var context, args, result, timeout = null, previous = 0, later = function() {
|
50
|
+
previous = Date.now();
|
51
|
+
timeout = null;
|
52
|
+
result = func.apply(context, args);
|
53
|
+
if (!timeout) // eslint-disable-next-line no-multi-assign
|
54
|
+
context = args = null;
|
55
|
+
};
|
56
|
+
return function() {
|
57
|
+
var now = Date.now();
|
58
|
+
if (!previous) previous = now;
|
59
|
+
var remaining = throttledTimer - (now - previous);
|
60
|
+
context = this;
|
61
|
+
args = arguments;
|
62
|
+
if (remaining <= 0 || remaining > throttledTimer) {
|
63
|
+
if (timeout) {
|
64
|
+
clearTimeout(timeout);
|
65
|
+
timeout = null;
|
66
|
+
}
|
67
|
+
previous = now;
|
68
|
+
result = func.apply(context, args);
|
69
|
+
if (!timeout) // eslint-disable-next-line no-multi-assign
|
70
|
+
context = args = null;
|
71
|
+
} else if (!timeout) timeout = setTimeout(later, remaining);
|
72
|
+
return result;
|
73
|
+
};
|
74
|
+
}
|
75
|
+
function formatLogMsg(msg) {
|
76
|
+
return msgID + '[' + myID + '] ' + msg;
|
77
|
+
}
|
78
|
+
function log(msg) {
|
79
|
+
if (logging && 'object' === typeof window.console) // eslint-disable-next-line no-console
|
80
|
+
console.log(formatLogMsg(msg));
|
81
|
+
}
|
82
|
+
function warn(msg) {
|
83
|
+
if ('object' === typeof window.console) // eslint-disable-next-line no-console
|
84
|
+
console.warn(formatLogMsg(msg));
|
85
|
+
}
|
86
|
+
function init() {
|
87
|
+
readDataFromParent();
|
88
|
+
log('Initialising iFrame (' + window.location.href + ')');
|
89
|
+
readDataFromPage();
|
90
|
+
setMargin();
|
91
|
+
setBodyStyle('background', bodyBackground);
|
92
|
+
setBodyStyle('padding', bodyPadding);
|
93
|
+
injectClearFixIntoBodyElement();
|
94
|
+
checkHeightMode();
|
95
|
+
checkWidthMode();
|
96
|
+
stopInfiniteResizingOfIFrame();
|
97
|
+
setupPublicMethods();
|
98
|
+
setupMouseEvents();
|
99
|
+
startEventListeners();
|
100
|
+
inPageLinks = setupInPageLinks();
|
101
|
+
sendSize('init', 'Init message from host page');
|
102
|
+
onReady();
|
103
|
+
}
|
104
|
+
function readDataFromParent() {
|
105
|
+
function strBool(str) {
|
106
|
+
return 'true' === str;
|
107
|
+
}
|
108
|
+
var data = initMsg.substr(msgIdLen).split(':');
|
109
|
+
myID = data[0];
|
110
|
+
bodyMargin = undefined !== data[1] ? Number(data[1]) : bodyMargin // For V1 compatibility
|
111
|
+
;
|
112
|
+
calculateWidth = undefined !== data[2] ? strBool(data[2]) : calculateWidth;
|
113
|
+
logging = undefined !== data[3] ? strBool(data[3]) : logging;
|
114
|
+
interval = undefined !== data[4] ? Number(data[4]) : interval;
|
115
|
+
autoResize = undefined !== data[6] ? strBool(data[6]) : autoResize;
|
116
|
+
bodyMarginStr = data[7];
|
117
|
+
heightCalcMode = undefined !== data[8] ? data[8] : heightCalcMode;
|
118
|
+
bodyBackground = data[9];
|
119
|
+
bodyPadding = data[10];
|
120
|
+
tolerance = undefined !== data[11] ? Number(data[11]) : tolerance;
|
121
|
+
inPageLinks.enable = undefined !== data[12] ? strBool(data[12]) : false;
|
122
|
+
resizeFrom = undefined !== data[13] ? data[13] : resizeFrom;
|
123
|
+
widthCalcMode = undefined !== data[14] ? data[14] : widthCalcMode;
|
124
|
+
mouseEvents = undefined !== data[15] ? Boolean(data[15]) : mouseEvents;
|
125
|
+
}
|
126
|
+
function depricate(key) {
|
127
|
+
var splitName = key.split('Callback');
|
128
|
+
if (splitName.length === 2) {
|
129
|
+
var name = 'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1);
|
130
|
+
this[name] = this[key];
|
131
|
+
delete this[key];
|
132
|
+
warn("Deprecated: '" + key + "' has been renamed '" + name + "'. The old method will be removed in the next major version.");
|
133
|
+
}
|
134
|
+
}
|
135
|
+
function readDataFromPage() {
|
136
|
+
function readData() {
|
137
|
+
var data = window.iFrameResizer;
|
138
|
+
log('Reading data from page: ' + JSON.stringify(data));
|
139
|
+
Object.keys(data).forEach(depricate, data);
|
140
|
+
onMessage = 'onMessage' in data ? data.onMessage : onMessage;
|
141
|
+
onReady = 'onReady' in data ? data.onReady : onReady;
|
142
|
+
targetOriginDefault = 'targetOrigin' in data ? data.targetOrigin : targetOriginDefault;
|
143
|
+
heightCalcMode = 'heightCalculationMethod' in data ? data.heightCalculationMethod : heightCalcMode;
|
144
|
+
widthCalcMode = 'widthCalculationMethod' in data ? data.widthCalculationMethod : widthCalcMode;
|
145
|
+
}
|
146
|
+
function setupCustomCalcMethods(calcMode, calcFunc) {
|
147
|
+
if ('function' === typeof calcMode) {
|
148
|
+
log('Setup custom ' + calcFunc + 'CalcMethod');
|
149
|
+
customCalcMethods[calcFunc] = calcMode;
|
150
|
+
calcMode = 'custom';
|
151
|
+
}
|
152
|
+
return calcMode;
|
153
|
+
}
|
154
|
+
if ('iFrameResizer' in window && Object === window.iFrameResizer.constructor) {
|
155
|
+
readData();
|
156
|
+
heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');
|
157
|
+
widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width');
|
158
|
+
}
|
159
|
+
log('TargetOrigin for parent set to: ' + targetOriginDefault);
|
160
|
+
}
|
161
|
+
function chkCSS(attr, value) {
|
162
|
+
if (-1 !== value.indexOf('-')) {
|
163
|
+
warn('Negative CSS value ignored for ' + attr);
|
164
|
+
value = '';
|
165
|
+
}
|
166
|
+
return value;
|
167
|
+
}
|
168
|
+
function setBodyStyle(attr, value) {
|
169
|
+
if (undefined !== value && '' !== value && 'null' !== value) {
|
170
|
+
document.body.style[attr] = value;
|
171
|
+
log('Body ' + attr + ' set to "' + value + '"');
|
172
|
+
}
|
173
|
+
}
|
174
|
+
function setMargin() {
|
175
|
+
// If called via V1 script, convert bodyMargin from int to str
|
176
|
+
if (undefined === bodyMarginStr) bodyMarginStr = bodyMargin + 'px';
|
177
|
+
setBodyStyle('margin', chkCSS('margin', bodyMarginStr));
|
178
|
+
}
|
179
|
+
function stopInfiniteResizingOfIFrame() {
|
180
|
+
document.documentElement.style.height = '';
|
181
|
+
document.body.style.height = '';
|
182
|
+
log('HTML & body height set to "auto"');
|
183
|
+
}
|
184
|
+
function manageTriggerEvent(options) {
|
185
|
+
var listener = {
|
186
|
+
add: function(eventName) {
|
187
|
+
function handleEvent() {
|
188
|
+
sendSize(options.eventName, options.eventType);
|
189
|
+
}
|
190
|
+
eventHandlersByName[eventName] = handleEvent;
|
191
|
+
addEventListener(window, eventName, handleEvent, {
|
192
|
+
passive: true
|
193
|
+
});
|
194
|
+
},
|
195
|
+
remove: function(eventName) {
|
196
|
+
var handleEvent = eventHandlersByName[eventName];
|
197
|
+
delete eventHandlersByName[eventName];
|
198
|
+
removeEventListener(window, eventName, handleEvent);
|
199
|
+
}
|
200
|
+
};
|
201
|
+
if (options.eventNames && Array.prototype.map) {
|
202
|
+
options.eventName = options.eventNames[0];
|
203
|
+
options.eventNames.map(listener[options.method]);
|
204
|
+
} else listener[options.method](options.eventName);
|
205
|
+
log(capitalizeFirstLetter(options.method) + ' event listener: ' + options.eventType);
|
206
|
+
}
|
207
|
+
function manageEventListeners(method) {
|
208
|
+
manageTriggerEvent({
|
209
|
+
method: method,
|
210
|
+
eventType: 'Animation Start',
|
211
|
+
eventNames: [
|
212
|
+
'animationstart',
|
213
|
+
'webkitAnimationStart'
|
214
|
+
]
|
215
|
+
});
|
216
|
+
manageTriggerEvent({
|
217
|
+
method: method,
|
218
|
+
eventType: 'Animation Iteration',
|
219
|
+
eventNames: [
|
220
|
+
'animationiteration',
|
221
|
+
'webkitAnimationIteration'
|
222
|
+
]
|
223
|
+
});
|
224
|
+
manageTriggerEvent({
|
225
|
+
method: method,
|
226
|
+
eventType: 'Animation End',
|
227
|
+
eventNames: [
|
228
|
+
'animationend',
|
229
|
+
'webkitAnimationEnd'
|
230
|
+
]
|
231
|
+
});
|
232
|
+
manageTriggerEvent({
|
233
|
+
method: method,
|
234
|
+
eventType: 'Input',
|
235
|
+
eventName: 'input'
|
236
|
+
});
|
237
|
+
manageTriggerEvent({
|
238
|
+
method: method,
|
239
|
+
eventType: 'Mouse Up',
|
240
|
+
eventName: 'mouseup'
|
241
|
+
});
|
242
|
+
manageTriggerEvent({
|
243
|
+
method: method,
|
244
|
+
eventType: 'Mouse Down',
|
245
|
+
eventName: 'mousedown'
|
246
|
+
});
|
247
|
+
manageTriggerEvent({
|
248
|
+
method: method,
|
249
|
+
eventType: 'Orientation Change',
|
250
|
+
eventName: 'orientationchange'
|
251
|
+
});
|
252
|
+
manageTriggerEvent({
|
253
|
+
method: method,
|
254
|
+
eventType: 'Print',
|
255
|
+
eventName: [
|
256
|
+
'afterprint',
|
257
|
+
'beforeprint'
|
258
|
+
]
|
259
|
+
});
|
260
|
+
manageTriggerEvent({
|
261
|
+
method: method,
|
262
|
+
eventType: 'Ready State Change',
|
263
|
+
eventName: 'readystatechange'
|
264
|
+
});
|
265
|
+
manageTriggerEvent({
|
266
|
+
method: method,
|
267
|
+
eventType: 'Touch Start',
|
268
|
+
eventName: 'touchstart'
|
269
|
+
});
|
270
|
+
manageTriggerEvent({
|
271
|
+
method: method,
|
272
|
+
eventType: 'Touch End',
|
273
|
+
eventName: 'touchend'
|
274
|
+
});
|
275
|
+
manageTriggerEvent({
|
276
|
+
method: method,
|
277
|
+
eventType: 'Touch Cancel',
|
278
|
+
eventName: 'touchcancel'
|
279
|
+
});
|
280
|
+
manageTriggerEvent({
|
281
|
+
method: method,
|
282
|
+
eventType: 'Transition Start',
|
283
|
+
eventNames: [
|
284
|
+
'transitionstart',
|
285
|
+
'webkitTransitionStart',
|
286
|
+
'MSTransitionStart',
|
287
|
+
'oTransitionStart',
|
288
|
+
'otransitionstart'
|
289
|
+
]
|
290
|
+
});
|
291
|
+
manageTriggerEvent({
|
292
|
+
method: method,
|
293
|
+
eventType: 'Transition Iteration',
|
294
|
+
eventNames: [
|
295
|
+
'transitioniteration',
|
296
|
+
'webkitTransitionIteration',
|
297
|
+
'MSTransitionIteration',
|
298
|
+
'oTransitionIteration',
|
299
|
+
'otransitioniteration'
|
300
|
+
]
|
301
|
+
});
|
302
|
+
manageTriggerEvent({
|
303
|
+
method: method,
|
304
|
+
eventType: 'Transition End',
|
305
|
+
eventNames: [
|
306
|
+
'transitionend',
|
307
|
+
'webkitTransitionEnd',
|
308
|
+
'MSTransitionEnd',
|
309
|
+
'oTransitionEnd',
|
310
|
+
'otransitionend'
|
311
|
+
]
|
312
|
+
});
|
313
|
+
if ('child' === resizeFrom) manageTriggerEvent({
|
314
|
+
method: method,
|
315
|
+
eventType: 'IFrame Resized',
|
316
|
+
eventName: 'resize'
|
317
|
+
});
|
318
|
+
}
|
319
|
+
function checkCalcMode(calcMode, calcModeDefault, modes, type) {
|
320
|
+
if (calcModeDefault !== calcMode) {
|
321
|
+
if (!(calcMode in modes)) {
|
322
|
+
warn(calcMode + ' is not a valid option for ' + type + 'CalculationMethod.');
|
323
|
+
calcMode = calcModeDefault;
|
324
|
+
}
|
325
|
+
log(type + ' calculation method set to "' + calcMode + '"');
|
326
|
+
}
|
327
|
+
return calcMode;
|
328
|
+
}
|
329
|
+
function checkHeightMode() {
|
330
|
+
heightCalcMode = checkCalcMode(heightCalcMode, heightCalcModeDefault, getHeight, 'height');
|
331
|
+
}
|
332
|
+
function checkWidthMode() {
|
333
|
+
widthCalcMode = checkCalcMode(widthCalcMode, widthCalcModeDefault, getWidth, 'width');
|
334
|
+
}
|
335
|
+
function startEventListeners() {
|
336
|
+
if (true === autoResize) {
|
337
|
+
manageEventListeners('add');
|
338
|
+
setupMutationObserver();
|
339
|
+
} else log('Auto Resize disabled');
|
340
|
+
}
|
341
|
+
// function stopMsgsToParent() {
|
342
|
+
// log('Disable outgoing messages')
|
343
|
+
// sendPermit = false
|
344
|
+
// }
|
345
|
+
// function removeMsgListener() {
|
346
|
+
// log('Remove event listener: Message')
|
347
|
+
// removeEventListener(window, 'message', receiver)
|
348
|
+
// }
|
349
|
+
function disconnectMutationObserver() {
|
350
|
+
if (null !== bodyObserver) /* istanbul ignore next */ // Not testable in PhantonJS
|
351
|
+
bodyObserver.disconnect();
|
352
|
+
}
|
353
|
+
function stopEventListeners() {
|
354
|
+
manageEventListeners('remove');
|
355
|
+
disconnectMutationObserver();
|
356
|
+
clearInterval(intervalTimer);
|
357
|
+
}
|
358
|
+
// function teardown() {
|
359
|
+
// stopMsgsToParent()
|
360
|
+
// removeMsgListener()
|
361
|
+
// if (true === autoResize) stopEventListeners()
|
362
|
+
// }
|
363
|
+
function injectClearFixIntoBodyElement() {
|
364
|
+
var clearFix = document.createElement('div');
|
365
|
+
clearFix.style.clear = 'both';
|
366
|
+
// Guard against the following having been globally redefined in CSS.
|
367
|
+
clearFix.style.display = 'block';
|
368
|
+
clearFix.style.height = '0';
|
369
|
+
document.body.appendChild(clearFix);
|
370
|
+
}
|
371
|
+
function setupInPageLinks() {
|
372
|
+
function getPagePosition() {
|
373
|
+
return {
|
374
|
+
x: window.pageXOffset !== undefined ? window.pageXOffset : document.documentElement.scrollLeft,
|
375
|
+
y: window.pageYOffset !== undefined ? window.pageYOffset : document.documentElement.scrollTop
|
376
|
+
};
|
377
|
+
}
|
378
|
+
function getElementPosition(el) {
|
379
|
+
var elPosition = el.getBoundingClientRect(), pagePosition = getPagePosition();
|
380
|
+
return {
|
381
|
+
x: parseInt(elPosition.left, 10) + parseInt(pagePosition.x, 10),
|
382
|
+
y: parseInt(elPosition.top, 10) + parseInt(pagePosition.y, 10)
|
383
|
+
};
|
384
|
+
}
|
385
|
+
function findTarget(location) {
|
386
|
+
function jumpToTarget(target) {
|
387
|
+
var jumpPosition = getElementPosition(target);
|
388
|
+
log('Moving to in page link (#' + hash + ') at x: ' + jumpPosition.x + ' y: ' + jumpPosition.y);
|
389
|
+
sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset') // X&Y reversed at sendMsg uses height/width
|
390
|
+
;
|
391
|
+
}
|
392
|
+
var hash = location.split('#')[1] || location, hashData = decodeURIComponent(hash), target2 = document.getElementById(hashData) || document.getElementsByName(hashData)[0];
|
393
|
+
if (undefined !== target2) jumpToTarget(target2);
|
394
|
+
else {
|
395
|
+
log('In page link (#' + hash + ') not found in iFrame, so sending to parent');
|
396
|
+
sendMsg(0, 0, 'inPageLink', '#' + hash);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
function checkLocationHash() {
|
400
|
+
var hash = window.location.hash;
|
401
|
+
var href = window.location.href;
|
402
|
+
if ('' !== hash && '#' !== hash) findTarget(href);
|
403
|
+
}
|
404
|
+
function bindAnchors() {
|
405
|
+
function setupLink(el) {
|
406
|
+
function linkClicked(e) {
|
407
|
+
e.preventDefault();
|
408
|
+
/* jshint validthis:true */ findTarget(this.getAttribute('href'));
|
409
|
+
}
|
410
|
+
if ('#' !== el.getAttribute('href')) addEventListener(el, 'click', linkClicked);
|
411
|
+
}
|
412
|
+
Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'), setupLink);
|
413
|
+
}
|
414
|
+
function bindLocationHash() {
|
415
|
+
addEventListener(window, 'hashchange', checkLocationHash);
|
416
|
+
}
|
417
|
+
function initCheck() {
|
418
|
+
// Check if page loaded with location hash after init resize
|
419
|
+
setTimeout(checkLocationHash, eventCancelTimer);
|
420
|
+
}
|
421
|
+
function enableInPageLinks() {
|
422
|
+
/* istanbul ignore else */ // Not testable in phantonJS
|
423
|
+
if (Array.prototype.forEach && document.querySelectorAll) {
|
424
|
+
log('Setting up location.hash handlers');
|
425
|
+
bindAnchors();
|
426
|
+
bindLocationHash();
|
427
|
+
initCheck();
|
428
|
+
} else warn('In page linking not fully supported in this browser! (See README.md for IE8 workaround)');
|
429
|
+
}
|
430
|
+
if (inPageLinks.enable) enableInPageLinks();
|
431
|
+
else log('In page linking not enabled');
|
432
|
+
return {
|
433
|
+
findTarget: findTarget
|
434
|
+
};
|
435
|
+
}
|
436
|
+
function setupMouseEvents() {
|
437
|
+
if (mouseEvents !== true) return;
|
438
|
+
function sendMouse(e) {
|
439
|
+
sendMsg(0, 0, e.type, e.screenY + ':' + e.screenX);
|
440
|
+
}
|
441
|
+
function addMouseListener(evt, name) {
|
442
|
+
log('Add event listener: ' + name);
|
443
|
+
addEventListener(window.document, evt, sendMouse);
|
444
|
+
}
|
445
|
+
addMouseListener('mouseenter', 'Mouse Enter');
|
446
|
+
addMouseListener('mouseleave', 'Mouse Leave');
|
447
|
+
}
|
448
|
+
function setupPublicMethods() {
|
449
|
+
log('Enable public methods');
|
450
|
+
win.parentIFrame = {
|
451
|
+
autoResize: function autoResizeF(resize) {
|
452
|
+
if (true === resize && false === autoResize) {
|
453
|
+
autoResize = true;
|
454
|
+
startEventListeners();
|
455
|
+
} else if (false === resize && true === autoResize) {
|
456
|
+
autoResize = false;
|
457
|
+
stopEventListeners();
|
458
|
+
}
|
459
|
+
sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize));
|
460
|
+
return autoResize;
|
461
|
+
},
|
462
|
+
close: function closeF() {
|
463
|
+
sendMsg(0, 0, 'close');
|
464
|
+
// teardown()
|
465
|
+
},
|
466
|
+
getId: function getIdF() {
|
467
|
+
return myID;
|
468
|
+
},
|
469
|
+
getPageInfo: function getPageInfoF(callback) {
|
470
|
+
if ('function' === typeof callback) {
|
471
|
+
onPageInfo = callback;
|
472
|
+
sendMsg(0, 0, 'pageInfo');
|
473
|
+
} else {
|
474
|
+
onPageInfo = function() {};
|
475
|
+
sendMsg(0, 0, 'pageInfoStop');
|
476
|
+
}
|
477
|
+
},
|
478
|
+
moveToAnchor: function moveToAnchorF(hash) {
|
479
|
+
inPageLinks.findTarget(hash);
|
480
|
+
},
|
481
|
+
reset: function resetF() {
|
482
|
+
resetIFrame('parentIFrame.reset');
|
483
|
+
},
|
484
|
+
scrollTo: function scrollToF(x, y) {
|
485
|
+
sendMsg(y, x, 'scrollTo') // X&Y reversed at sendMsg uses height/width
|
486
|
+
;
|
487
|
+
},
|
488
|
+
scrollToOffset: function scrollToF(x, y) {
|
489
|
+
sendMsg(y, x, 'scrollToOffset') // X&Y reversed at sendMsg uses height/width
|
490
|
+
;
|
491
|
+
},
|
492
|
+
sendMessage: function sendMessageF(msg, targetOrigin) {
|
493
|
+
sendMsg(0, 0, 'message', JSON.stringify(msg), targetOrigin);
|
494
|
+
},
|
495
|
+
setHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod) {
|
496
|
+
heightCalcMode = heightCalculationMethod;
|
497
|
+
checkHeightMode();
|
498
|
+
},
|
499
|
+
setWidthCalculationMethod: function setWidthCalculationMethodF(widthCalculationMethod) {
|
500
|
+
widthCalcMode = widthCalculationMethod;
|
501
|
+
checkWidthMode();
|
502
|
+
},
|
503
|
+
setTargetOrigin: function setTargetOriginF(targetOrigin) {
|
504
|
+
log('Set targetOrigin: ' + targetOrigin);
|
505
|
+
targetOriginDefault = targetOrigin;
|
506
|
+
},
|
507
|
+
size: function sizeF(customHeight, customWidth) {
|
508
|
+
var valString = '' + (customHeight || '') + (customWidth ? ',' + customWidth : '');
|
509
|
+
sendSize('size', 'parentIFrame.size(' + valString + ')', customHeight, customWidth);
|
510
|
+
}
|
511
|
+
};
|
512
|
+
}
|
513
|
+
function initInterval() {
|
514
|
+
if (0 !== interval) {
|
515
|
+
log('setInterval: ' + interval + 'ms');
|
516
|
+
intervalTimer = setInterval(function() {
|
517
|
+
sendSize('interval', 'setInterval: ' + interval);
|
518
|
+
}, Math.abs(interval));
|
519
|
+
}
|
520
|
+
}
|
521
|
+
// Not testable in PhantomJS
|
522
|
+
/* istanbul ignore next */ function setupBodyMutationObserver() {
|
523
|
+
function addImageLoadListners(mutation) {
|
524
|
+
function addImageLoadListener(element) {
|
525
|
+
if (false === element.complete) {
|
526
|
+
log('Attach listeners to ' + element.src);
|
527
|
+
element.addEventListener('load', imageLoaded, false);
|
528
|
+
element.addEventListener('error', imageError, false);
|
529
|
+
elements.push(element);
|
530
|
+
}
|
531
|
+
}
|
532
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') addImageLoadListener(mutation.target);
|
533
|
+
else if (mutation.type === 'childList') Array.prototype.forEach.call(mutation.target.querySelectorAll('img'), addImageLoadListener);
|
534
|
+
}
|
535
|
+
function removeFromArray(element) {
|
536
|
+
elements.splice(elements.indexOf(element), 1);
|
537
|
+
}
|
538
|
+
function removeImageLoadListener(element) {
|
539
|
+
log('Remove listeners from ' + element.src);
|
540
|
+
element.removeEventListener('load', imageLoaded, false);
|
541
|
+
element.removeEventListener('error', imageError, false);
|
542
|
+
removeFromArray(element);
|
543
|
+
}
|
544
|
+
function imageEventTriggered(event, type, typeDesc) {
|
545
|
+
removeImageLoadListener(event.target);
|
546
|
+
sendSize(type, typeDesc + ': ' + event.target.src);
|
547
|
+
}
|
548
|
+
function imageLoaded(event) {
|
549
|
+
imageEventTriggered(event, 'imageLoad', 'Image loaded');
|
550
|
+
}
|
551
|
+
function imageError(event) {
|
552
|
+
imageEventTriggered(event, 'imageLoadFailed', 'Image load failed');
|
553
|
+
}
|
554
|
+
function mutationObserved(mutations) {
|
555
|
+
sendSize('mutationObserver', 'mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type);
|
556
|
+
// Deal with WebKit / Blink asyncing image loading when tags are injected into the page
|
557
|
+
mutations.forEach(addImageLoadListners);
|
558
|
+
}
|
559
|
+
function createMutationObserver() {
|
560
|
+
var target = document.querySelector('body'), config = {
|
561
|
+
attributes: true,
|
562
|
+
attributeOldValue: false,
|
563
|
+
characterData: true,
|
564
|
+
characterDataOldValue: false,
|
565
|
+
childList: true,
|
566
|
+
subtree: true
|
567
|
+
};
|
568
|
+
observer = new MutationObserver(mutationObserved);
|
569
|
+
log('Create body MutationObserver');
|
570
|
+
observer.observe(target, config);
|
571
|
+
return observer;
|
572
|
+
}
|
573
|
+
var elements = [], MutationObserver = window.MutationObserver || window.WebKitMutationObserver, observer = createMutationObserver();
|
574
|
+
return {
|
575
|
+
disconnect: function() {
|
576
|
+
if ('disconnect' in observer) {
|
577
|
+
log('Disconnect body MutationObserver');
|
578
|
+
observer.disconnect();
|
579
|
+
elements.forEach(removeImageLoadListener);
|
580
|
+
}
|
581
|
+
}
|
582
|
+
};
|
583
|
+
}
|
584
|
+
function setupMutationObserver() {
|
585
|
+
var forceIntervalTimer = 0 > interval;
|
586
|
+
// Not testable in PhantomJS
|
587
|
+
/* istanbul ignore if */ if (window.MutationObserver || window.WebKitMutationObserver) {
|
588
|
+
if (forceIntervalTimer) initInterval();
|
589
|
+
else bodyObserver = setupBodyMutationObserver();
|
590
|
+
} else {
|
591
|
+
log('MutationObserver not supported in this browser!');
|
592
|
+
initInterval();
|
593
|
+
}
|
594
|
+
}
|
595
|
+
// document.documentElement.offsetHeight is not reliable, so
|
596
|
+
// we have to jump through hoops to get a better value.
|
597
|
+
function getComputedStyle(prop, el) {
|
598
|
+
var retVal = 0;
|
599
|
+
el = el || document.body // Not testable in phantonJS
|
600
|
+
;
|
601
|
+
retVal = document.defaultView.getComputedStyle(el, null);
|
602
|
+
retVal = null !== retVal ? retVal[prop] : 0;
|
603
|
+
return parseInt(retVal, base);
|
604
|
+
}
|
605
|
+
function chkEventThottle(timer) {
|
606
|
+
if (timer > throttledTimer / 2) {
|
607
|
+
throttledTimer = 2 * timer;
|
608
|
+
log('Event throttle increased to ' + throttledTimer + 'ms');
|
609
|
+
}
|
610
|
+
}
|
611
|
+
// Idea from https://github.com/guardian/iframe-messenger
|
612
|
+
function getMaxElement(side, elements) {
|
613
|
+
var elementsLength = elements.length, elVal = 0, maxVal = 0, Side = capitalizeFirstLetter(side), timer = Date.now();
|
614
|
+
for(var i = 0; i < elementsLength; i++){
|
615
|
+
elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin' + Side, elements[i]);
|
616
|
+
if (elVal > maxVal) maxVal = elVal;
|
617
|
+
}
|
618
|
+
timer = Date.now() - timer;
|
619
|
+
log('Parsed ' + elementsLength + ' HTML elements');
|
620
|
+
log('Element position calculated in ' + timer + 'ms');
|
621
|
+
chkEventThottle(timer);
|
622
|
+
return maxVal;
|
623
|
+
}
|
624
|
+
function getAllMeasurements(dimensions) {
|
625
|
+
return [
|
626
|
+
dimensions.bodyOffset(),
|
627
|
+
dimensions.bodyScroll(),
|
628
|
+
dimensions.documentElementOffset(),
|
629
|
+
dimensions.documentElementScroll()
|
630
|
+
];
|
631
|
+
}
|
632
|
+
function getTaggedElements(side, tag) {
|
633
|
+
function noTaggedElementsFound() {
|
634
|
+
warn('No tagged elements (' + tag + ') found on page');
|
635
|
+
return document.querySelectorAll('body *');
|
636
|
+
}
|
637
|
+
var elements = document.querySelectorAll('[' + tag + ']');
|
638
|
+
if (elements.length === 0) noTaggedElementsFound();
|
639
|
+
return getMaxElement(side, elements);
|
640
|
+
}
|
641
|
+
function getAllElements() {
|
642
|
+
return document.querySelectorAll('body *');
|
643
|
+
}
|
644
|
+
var getHeight = {
|
645
|
+
bodyOffset: function getBodyOffsetHeight() {
|
646
|
+
return document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom');
|
647
|
+
},
|
648
|
+
offset: function() {
|
649
|
+
return getHeight.bodyOffset() // Backwards compatability
|
650
|
+
;
|
651
|
+
},
|
652
|
+
bodyScroll: function getBodyScrollHeight() {
|
653
|
+
return document.body.scrollHeight;
|
654
|
+
},
|
655
|
+
custom: function getCustomWidth() {
|
656
|
+
return customCalcMethods.height();
|
657
|
+
},
|
658
|
+
documentElementOffset: function getDEOffsetHeight() {
|
659
|
+
return document.documentElement.offsetHeight;
|
660
|
+
},
|
661
|
+
documentElementScroll: function getDEScrollHeight() {
|
662
|
+
return document.documentElement.scrollHeight;
|
663
|
+
},
|
664
|
+
max: function getMaxHeight() {
|
665
|
+
return Math.max.apply(null, getAllMeasurements(getHeight));
|
666
|
+
},
|
667
|
+
min: function getMinHeight() {
|
668
|
+
return Math.min.apply(null, getAllMeasurements(getHeight));
|
669
|
+
},
|
670
|
+
grow: function growHeight() {
|
671
|
+
return getHeight.max() // Run max without the forced downsizing
|
672
|
+
;
|
673
|
+
},
|
674
|
+
lowestElement: function getBestHeight() {
|
675
|
+
return Math.max(getHeight.bodyOffset() || getHeight.documentElementOffset(), getMaxElement('bottom', getAllElements()));
|
676
|
+
},
|
677
|
+
taggedElement: function getTaggedElementsHeight() {
|
678
|
+
return getTaggedElements('bottom', 'data-iframe-height');
|
679
|
+
}
|
680
|
+
}, getWidth = {
|
681
|
+
bodyScroll: function getBodyScrollWidth() {
|
682
|
+
return document.body.scrollWidth;
|
683
|
+
},
|
684
|
+
bodyOffset: function getBodyOffsetWidth() {
|
685
|
+
return document.body.offsetWidth;
|
686
|
+
},
|
687
|
+
custom: function getCustomWidth() {
|
688
|
+
return customCalcMethods.width();
|
689
|
+
},
|
690
|
+
documentElementScroll: function getDEScrollWidth() {
|
691
|
+
return document.documentElement.scrollWidth;
|
692
|
+
},
|
693
|
+
documentElementOffset: function getDEOffsetWidth() {
|
694
|
+
return document.documentElement.offsetWidth;
|
695
|
+
},
|
696
|
+
scroll: function getMaxWidth() {
|
697
|
+
return Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll());
|
698
|
+
},
|
699
|
+
max: function getMaxWidth() {
|
700
|
+
return Math.max.apply(null, getAllMeasurements(getWidth));
|
701
|
+
},
|
702
|
+
min: function getMinWidth() {
|
703
|
+
return Math.min.apply(null, getAllMeasurements(getWidth));
|
704
|
+
},
|
705
|
+
rightMostElement: function rightMostElement() {
|
706
|
+
return getMaxElement('right', getAllElements());
|
707
|
+
},
|
708
|
+
taggedElement: function getTaggedElementsWidth() {
|
709
|
+
return getTaggedElements('right', 'data-iframe-width');
|
710
|
+
}
|
711
|
+
};
|
712
|
+
function sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth) {
|
713
|
+
function resizeIFrame() {
|
714
|
+
height1 = currentHeight;
|
715
|
+
width1 = currentWidth;
|
716
|
+
sendMsg(height1, width1, triggerEvent);
|
717
|
+
}
|
718
|
+
function isSizeChangeDetected() {
|
719
|
+
function checkTolarance(a, b) {
|
720
|
+
var retVal = Math.abs(a - b) <= tolerance;
|
721
|
+
return !retVal;
|
722
|
+
}
|
723
|
+
currentHeight = undefined !== customHeight ? customHeight : getHeight[heightCalcMode]();
|
724
|
+
currentWidth = undefined !== customWidth ? customWidth : getWidth[widthCalcMode]();
|
725
|
+
return checkTolarance(height1, currentHeight) || calculateWidth && checkTolarance(width1, currentWidth);
|
726
|
+
}
|
727
|
+
function isForceResizableEvent() {
|
728
|
+
return !(triggerEvent in {
|
729
|
+
init: 1,
|
730
|
+
interval: 1,
|
731
|
+
size: 1
|
732
|
+
});
|
733
|
+
}
|
734
|
+
function isForceResizableCalcMode() {
|
735
|
+
return heightCalcMode in resetRequiredMethods || calculateWidth && widthCalcMode in resetRequiredMethods;
|
736
|
+
}
|
737
|
+
function logIgnored() {
|
738
|
+
log('No change in size detected');
|
739
|
+
}
|
740
|
+
function checkDownSizing() {
|
741
|
+
if (isForceResizableEvent() && isForceResizableCalcMode()) resetIFrame(triggerEventDesc);
|
742
|
+
else if (!(triggerEvent in {
|
743
|
+
interval: 1
|
744
|
+
})) logIgnored();
|
745
|
+
}
|
746
|
+
var currentHeight, currentWidth;
|
747
|
+
if (isSizeChangeDetected() || 'init' === triggerEvent) {
|
748
|
+
lockTrigger();
|
749
|
+
resizeIFrame();
|
750
|
+
} else checkDownSizing();
|
751
|
+
}
|
752
|
+
var sizeIFrameThrottled = throttle(sizeIFrame);
|
753
|
+
function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth) {
|
754
|
+
function recordTrigger() {
|
755
|
+
if (!(triggerEvent in {
|
756
|
+
reset: 1,
|
757
|
+
resetPage: 1,
|
758
|
+
init: 1
|
759
|
+
})) log('Trigger event: ' + triggerEventDesc);
|
760
|
+
}
|
761
|
+
function isDoubleFiredEvent() {
|
762
|
+
return triggerLocked && triggerEvent in doubleEventList;
|
763
|
+
}
|
764
|
+
if (!isDoubleFiredEvent()) {
|
765
|
+
recordTrigger();
|
766
|
+
if (triggerEvent === 'init') sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth);
|
767
|
+
else sizeIFrameThrottled(triggerEvent, triggerEventDesc, customHeight, customWidth);
|
768
|
+
} else log('Trigger event cancelled: ' + triggerEvent);
|
769
|
+
}
|
770
|
+
function lockTrigger() {
|
771
|
+
if (!triggerLocked) {
|
772
|
+
triggerLocked = true;
|
773
|
+
log('Trigger event lock on');
|
774
|
+
}
|
775
|
+
clearTimeout(triggerLockedTimer);
|
776
|
+
triggerLockedTimer = setTimeout(function() {
|
777
|
+
triggerLocked = false;
|
778
|
+
log('Trigger event lock off');
|
779
|
+
log('--');
|
780
|
+
}, eventCancelTimer);
|
781
|
+
}
|
782
|
+
function triggerReset(triggerEvent) {
|
783
|
+
height1 = getHeight[heightCalcMode]();
|
784
|
+
width1 = getWidth[widthCalcMode]();
|
785
|
+
sendMsg(height1, width1, triggerEvent);
|
786
|
+
}
|
787
|
+
function resetIFrame(triggerEventDesc) {
|
788
|
+
var hcm = heightCalcMode;
|
789
|
+
heightCalcMode = heightCalcModeDefault;
|
790
|
+
log('Reset trigger event: ' + triggerEventDesc);
|
791
|
+
lockTrigger();
|
792
|
+
triggerReset('reset');
|
793
|
+
heightCalcMode = hcm;
|
794
|
+
}
|
795
|
+
function sendMsg(height, width, triggerEvent, msg, targetOrigin) {
|
796
|
+
function setTargetOrigin() {
|
797
|
+
if (undefined === targetOrigin) targetOrigin = targetOriginDefault;
|
798
|
+
else log('Message targetOrigin: ' + targetOrigin);
|
799
|
+
}
|
800
|
+
function sendToParent() {
|
801
|
+
var size = height + ':' + width, message = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : '');
|
802
|
+
log('Sending message to host page (' + message + ')');
|
803
|
+
target1.postMessage(msgID + message, targetOrigin);
|
804
|
+
}
|
805
|
+
if (true === sendPermit) {
|
806
|
+
setTargetOrigin();
|
807
|
+
sendToParent();
|
808
|
+
}
|
809
|
+
}
|
810
|
+
function receiver(event) {
|
811
|
+
var processRequestFromParent = {
|
812
|
+
init: function initFromParent() {
|
813
|
+
initMsg = event.data;
|
814
|
+
target1 = event.source;
|
815
|
+
init();
|
816
|
+
firstRun = false;
|
817
|
+
setTimeout(function() {
|
818
|
+
initLock = false;
|
819
|
+
}, eventCancelTimer);
|
820
|
+
},
|
821
|
+
reset: function resetFromParent() {
|
822
|
+
if (!initLock) {
|
823
|
+
log('Page size reset by host page');
|
824
|
+
triggerReset('resetPage');
|
825
|
+
} else log('Page reset ignored by init');
|
826
|
+
},
|
827
|
+
resize: function resizeFromParent() {
|
828
|
+
sendSize('resizeParent', 'Parent window requested size check');
|
829
|
+
},
|
830
|
+
moveToAnchor: function moveToAnchorF() {
|
831
|
+
inPageLinks.findTarget(getData());
|
832
|
+
},
|
833
|
+
inPageLink: function inPageLinkF() {
|
834
|
+
this.moveToAnchor();
|
835
|
+
},
|
836
|
+
pageInfo: function pageInfoFromParent() {
|
837
|
+
var msgBody = getData();
|
838
|
+
log('PageInfoFromParent called from parent: ' + msgBody);
|
839
|
+
onPageInfo(JSON.parse(msgBody));
|
840
|
+
log(' --');
|
841
|
+
},
|
842
|
+
message: function messageFromParent() {
|
843
|
+
var msgBody = getData();
|
844
|
+
log('onMessage called from parent: ' + msgBody);
|
845
|
+
// eslint-disable-next-line sonarjs/no-extra-arguments
|
846
|
+
onMessage(JSON.parse(msgBody));
|
847
|
+
log(' --');
|
848
|
+
}
|
849
|
+
};
|
850
|
+
function isMessageForUs() {
|
851
|
+
return msgID === ('' + event.data).substr(0, msgIdLen) // ''+ Protects against non-string messages
|
852
|
+
;
|
853
|
+
}
|
854
|
+
function getMessageType() {
|
855
|
+
return event.data.split(']')[1].split(':')[0];
|
856
|
+
}
|
857
|
+
function getData() {
|
858
|
+
return event.data.substr(event.data.indexOf(':') + 1);
|
859
|
+
}
|
860
|
+
function isMiddleTier() {
|
861
|
+
return !$b2e1fd3e30ab1f5c$exports && 'iFrameResize' in window || 'jQuery' in window && 'iFrameResize' in window.jQuery.prototype;
|
862
|
+
}
|
863
|
+
function isInitMsg() {
|
864
|
+
// Test if this message is from a child below us. This is an ugly test, however, updating
|
865
|
+
// the message format would break backwards compatibity.
|
866
|
+
return event.data.split(':')[2] in {
|
867
|
+
true: 1,
|
868
|
+
false: 1
|
869
|
+
};
|
870
|
+
}
|
871
|
+
function callFromParent() {
|
872
|
+
var messageType = getMessageType();
|
873
|
+
if (messageType in processRequestFromParent) processRequestFromParent[messageType]();
|
874
|
+
else if (!isMiddleTier() && !isInitMsg()) warn('Unexpected message (' + event.data + ')');
|
875
|
+
}
|
876
|
+
function processMessage() {
|
877
|
+
if (false === firstRun) callFromParent();
|
878
|
+
else if (isInitMsg()) processRequestFromParent.init();
|
879
|
+
else log('Ignored message of type "' + getMessageType() + '". Received before initialization.');
|
880
|
+
}
|
881
|
+
if (isMessageForUs()) processMessage();
|
882
|
+
}
|
883
|
+
// Normally the parent kicks things off when it detects the iFrame has loaded.
|
884
|
+
// If this script is async-loaded, then tell parent page to retry init.
|
885
|
+
function chkLateLoaded() {
|
886
|
+
if ('loading' !== document.readyState) window.parent.postMessage('[iFrameResizerChild]Ready', '*');
|
887
|
+
}
|
888
|
+
addEventListener(window, 'message', receiver);
|
889
|
+
addEventListener(window, 'readystatechange', chkLateLoaded);
|
890
|
+
chkLateLoaded();
|
891
|
+
})();
|
892
|
+
|
893
|
+
|
894
|
+
|
895
|
+
})();
|
2
896
|
//# sourceMappingURL=embed.js.map
|