iframe-resizer
Advanced tools
Comparing version 3.4.2 to 3.5.0
{ | ||
"name": "iframe-resizer", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"homepage": "https://github.com/davidjbradshaw/iframe-resizer", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"author": { | ||
@@ -23,0 +23,0 @@ "name": "David J. Bradshaw", |
// IE8 polyfils for iframeResizer.js | ||
Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this||"function"!=typeof a)throw new TypeError;for(var b=Object(this),c=b.length>>>0,d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)e in b&&a.call(d,b[e],e,b)}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),function(a,b){function c(a){var c=b[a];b[a]=function(a){return e(c(a))}}function d(b,c,d){return(d=this).attachEvent("on"+b,function(b){b=b||a.event,b.preventDefault=b.preventDefault||function(){b.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){b.cancelBubble=!0},c.call(d,b)})}function e(a,b){if(b=a.length)for(;b--;)a[b].addEventListener=d;else a.addEventListener=d;return a}a.addEventListener||(e([b,a]),"Element"in a?a.Element.prototype.addEventListener=d:(b.attachEvent("onreadystatechange",function(){e(b.all)}),c("getElementsByTagName"),c("getElementById"),c("createElement"),e(b.all)))}(window,document); | ||
Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(void 0===this||null===this||"function"!=typeof a)throw new TypeError;for(var b=Object(this),c=b.length>>>0,d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)e in b&&a.call(d,b[e],e,b)}),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){if(null===this)throw new TypeError(" this is null or not defined");if("function"!=typeof a)throw new TypeError(a+" is not a function");for(var c=Object(this),d=c.length>>>0,e=0;d>e;e++)e in c&&a.call(b,c[e],e,c)}),function(a,b){function c(a){var c=b[a];b[a]=function(a){return e(c(a))}}function d(b,c,d){return(d=this).attachEvent("on"+b,function(b){b=b||a.event,b.preventDefault=b.preventDefault||function(){b.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){b.cancelBubble=!0},c.call(d,b)})}function e(a,b){if(b=a.length)for(;b--;)a[b].addEventListener=d;else a.addEventListener=d;return a}a.addEventListener||(e([b,a]),"Element"in a?a.Element.prototype.addEventListener=d:(b.attachEvent("onreadystatechange",function(){e(b.all)}),c("getElementsByTagName"),c("getElementById"),c("createElement"),e(b.all)))}(window,document); | ||
//# sourceMappingURL=ie8.polyfils.map |
@@ -478,4 +478,9 @@ /* | ||
getPageInfo: function getPageInfoF(callback){ | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfo'); | ||
if ('function' === typeof callback){ | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfo'); | ||
} else { | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfoStop'); | ||
} | ||
}, | ||
@@ -482,0 +487,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.4.2 - 2015-10-09 | ||
/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v3.5.0 - 2015-10-26 | ||
* Desc: Include this file in any page being loaded into an iframe | ||
@@ -9,3 +9,3 @@ * to force the iframe to resize to the content size. | ||
!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a){var b,c,d,e=null,f=0,g=function(){f=Fa(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Fa();f||(f=h);var i=xa-(h-f);return b=this,c=arguments,0>=i||i>xa?(e&&(clearTimeout(e),e=null),f=h,d=a.apply(b,c),e||(b=c=null)):e||(e=setTimeout(g,i)),d}}function f(a){return ma+"["+oa+"] "+a}function g(b){la&&"object"==typeof a.console&&console.log(f(b))}function h(b){"object"==typeof a.console&&console.warn(f(b))}function i(){j(),g("Initialising iFrame ("+location.href+")"),k(),n(),m("background",W),m("padding",$),A(),s(),t(),o(),C(),u(),ia=B(),N("init","Init message from host page"),Da()}function j(){function a(a){return"true"===a?!0:!1}var b=ha.substr(na).split(":");oa=b[0],X=void 0!==b[1]?Number(b[1]):X,_=void 0!==b[2]?a(b[2]):_,la=void 0!==b[3]?a(b[3]):la,ja=void 0!==b[4]?Number(b[4]):ja,U=void 0!==b[6]?a(b[6]):U,Y=b[7],fa=void 0!==b[8]?b[8]:fa,W=b[9],$=b[10],ua=void 0!==b[11]?Number(b[11]):ua,ia.enable=void 0!==b[12]?a(b[12]):!1,qa=void 0!==b[13]?b[13]:qa,Aa=void 0!==b[14]?b[14]:Aa}function k(){function b(){var b=a.iFrameResizer;g("Reading data from page: "+JSON.stringify(b)),Ca="messageCallback"in b?b.messageCallback:Ca,Da="readyCallback"in b?b.readyCallback:Da,ta="targetOrigin"in b?b.targetOrigin:ta,fa="heightCalculationMethod"in b?b.heightCalculationMethod:fa,Aa="widthCalculationMethod"in b?b.widthCalculationMethod:Aa}"iFrameResizer"in a&&Object===a.iFrameResizer.constructor&&b(),g("TargetOrigin for parent set to: "+ta)}function l(a,b){return-1!==b.indexOf("-")&&(h("Negative CSS value ignored for "+a),b=""),b}function m(a,b){void 0!==b&&""!==b&&"null"!==b&&(document.body.style[a]=b,g("Body "+a+' set to "'+b+'"'))}function n(){void 0===Y&&(Y=X+"px"),m("margin",l("margin",Y))}function o(){document.documentElement.style.height="",document.body.style.height="",g('HTML & body height set to "auto"')}function p(e){function f(){N(e.eventName,e.eventType)}var h={add:function(c){b(a,c,f)},remove:function(b){c(a,b,f)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(h[e.method])):h[e.method](e.eventName),g(d(e.method)+" event listener: "+e.eventType)}function q(a){p({method:a,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),p({method:a,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),p({method:a,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),p({method:a,eventType:"Input",eventName:"input"}),p({method:a,eventType:"Mouse Up",eventName:"mouseup"}),p({method:a,eventType:"Mouse Down",eventName:"mousedown"}),p({method:a,eventType:"Orientation Change",eventName:"orientationchange"}),p({method:a,eventType:"Touch Start",eventName:"touchstart"}),p({method:a,eventType:"Touch End",eventName:"touchend"}),p({method:a,eventType:"Touch Cancel",eventName:"touchcancel"}),p({method:a,eventType:"Print",eventName:["afterprint","beforeprint"]}),p({method:a,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),p({method:a,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),p({method:a,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===qa&&p({method:a,eventType:"IFrame Resized",eventName:"resize"})}function r(a,b,c,d){return b!==a&&(a in c||(h(a+" is not a valid option for "+d+"CalculationMethod."),a=b),g(d+' calculation method set to "'+a+'"')),a}function s(){fa=r(fa,ea,Ga,"height")}function t(){Aa=r(Aa,za,Ha,"width")}function u(){!0===U?(q("add"),F()):g("Auto Resize disabled")}function v(){g("Disable outgoing messages"),ra=!1}function w(){g("Remove event listener: Message"),c(a,"message",S)}function x(){null!==Z&&Z.disconnect()}function y(){q("remove"),x(),clearInterval(ka)}function z(){v(),w(),!0===U&&y()}function A(){var a=document.createElement("div");a.style.clear="both",a.style.display="block",document.body.appendChild(a)}function B(){function c(){return{x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop}}function d(a){var b=a.getBoundingClientRect(),d=c();return{x:parseInt(b.left,10)+parseInt(d.x,10),y:parseInt(b.top,10)+parseInt(d.y,10)}}function e(a){function b(a){var b=d(a);g("Moving to in page link (#"+c+") at x: "+b.x+" y: "+b.y),R(b.y,b.x,"scrollToOffset")}var c=a.split("#")[1]||a,e=decodeURIComponent(c),f=document.getElementById(e)||document.getElementsByName(e)[0];void 0!==f?b(f):(g("In page link (#"+c+") not found in iFrame, so sending to parent"),R(0,0,"inPageLink","#"+c))}function f(){""!==location.hash&&"#"!==location.hash&&e(location.href)}function i(){function a(a){function c(a){a.preventDefault(),e(this.getAttribute("href"))}"#"!==a.getAttribute("href")&&b(a,"click",c)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),a)}function j(){b(a,"hashchange",f)}function k(){setTimeout(f,ba)}function l(){Array.prototype.forEach&&document.querySelectorAll?(g("Setting up location.hash handlers"),i(),j(),k()):h("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ia.enable?l():g("In page linking not enabled"),{findTarget:e}}function C(){g("Enable public methods"),Ba.parentIFrame={autoResize:function(a){return!0===a&&!1===U?(U=!0,u()):!1===a&&!0===U&&(U=!1,y()),U},close:function(){R(0,0,"close"),z()},getId:function(){return oa},getPageInfo:function(a){Ea=a,R(0,0,"pageInfo")},moveToAnchor:function(a){ia.findTarget(a)},reset:function(){Q("parentIFrame.reset")},scrollTo:function(a,b){R(b,a,"scrollTo")},scrollToOffset:function(a,b){R(b,a,"scrollToOffset")},sendMessage:function(a,b){R(0,0,"message",JSON.stringify(a),b)},setHeightCalculationMethod:function(a){fa=a,s()},setWidthCalculationMethod:function(a){Aa=a,t()},setTargetOrigin:function(a){g("Set targetOrigin: "+a),ta=a},size:function(a,b){var c=""+(a?a:"")+(b?","+b:"");N("size","parentIFrame.size("+c+")",a,b)}}}function D(){0!==ja&&(g("setInterval: "+ja+"ms"),ka=setInterval(function(){N("interval","setInterval: "+ja)},Math.abs(ja)))}function E(){function b(a){function b(a){!1===a.complete&&(g("Attach listeners to "+a.src),a.addEventListener("load",f,!1),a.addEventListener("error",h,!1),k.push(a))}"attributes"===a.type&&"src"===a.attributeName?b(a.target):"childList"===a.type&&Array.prototype.forEach.call(a.target.querySelectorAll("img"),b)}function c(a){k.splice(k.indexOf(a),1)}function d(a){g("Remove listeners from "+a.src),a.removeEventListener("load",f,!1),a.removeEventListener("error",h,!1),c(a)}function e(a,b,c){d(a.target),N(b,c+": "+a.target.src,void 0,void 0)}function f(a){e(a,"imageLoad","Image loaded")}function h(a){e(a,"imageLoadFailed","Image load failed")}function i(a){N("mutationObserver","mutationObserver: "+a[0].target+" "+a[0].type),a.forEach(b)}function j(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return m=new l(i),g("Create body MutationObserver"),m.observe(a,b),m}var k=[],l=a.MutationObserver||a.WebKitMutationObserver,m=j();return{disconnect:function(){"disconnect"in m&&(g("Disconnect body MutationObserver"),m.disconnect(),k.forEach(d))}}}function F(){var b=0>ja;a.MutationObserver||a.WebKitMutationObserver?b?D():Z=E():(g("MutationObserver not supported in this browser!"),D())}function G(a){function b(a){var b=/^\d+(px)?$/i;if(b.test(a))return parseInt(a,V);var d=c.style.left,e=c.runtimeStyle.left;return c.runtimeStyle.left=c.currentStyle.left,c.style.left=a||0,a=c.style.pixelLeft,c.style.left=d,c.runtimeStyle.left=e,a}var c=document.body,d=0;return"defaultView"in document&&"getComputedStyle"in document.defaultView?(d=document.defaultView.getComputedStyle(c,null),d=null!==d?d[a]:0):d=b(c.currentStyle[a]),parseInt(d,V)}function H(a){a>xa/2&&(xa=2*a,g("Event throttle increased to "+xa+"ms"))}function I(a,b){for(var c=b.length,e=0,f=0,h=d(a),i=Fa(),j=0;c>j;j++)e=b[j].getBoundingClientRect()[a]+G("margin"+h),e>f&&(f=e);return i=Fa()-i,g("Parsed "+c+" HTML elements"),g("Element position calculated in "+i+"ms"),H(i),f}function J(a){return[a.bodyOffset(),a.bodyScroll(),a.documentElementOffset(),a.documentElementScroll()]}function K(a,b){function c(){return h("No tagged elements ("+b+") found on page"),da}var d=document.querySelectorAll("["+b+"]");return 0===d.length?c():I(a,d)}function L(){return document.querySelectorAll("body *")}function M(a,b,c,d){function e(){da=l,ya=m,R(da,ya,a)}function f(){function a(a,b){var c=Math.abs(a-b)<=ua;return!c}return l=void 0!==c?c:Ga[fa](),m=void 0!==d?d:Ha[Aa](),a(da,l)||_&&a(ya,m)}function h(){return!(a in{init:1,interval:1,size:1})}function i(){return fa in pa||_&&Aa in pa}function j(){g("No change in size detected")}function k(){h()&&i()?Q(b):a in{interval:1}||j()}var l,m;f()||"init"===a?(O(),e()):k()}function N(a,b,c,d){function e(){a in{reset:1,resetPage:1,init:1}||g("Trigger event: "+b)}function f(){return va&&a in aa}f()?g("Trigger event cancelled: "+a):(e(),Ia(a,b,c,d))}function O(){va||(va=!0,g("Trigger event lock on")),clearTimeout(wa),wa=setTimeout(function(){va=!1,g("Trigger event lock off"),g("--")},ba)}function P(a){da=Ga[fa](),ya=Ha[Aa](),R(da,ya,a)}function Q(a){var b=fa;fa=ea,g("Reset trigger event: "+a),O(),P("reset"),fa=b}function R(a,b,c,d,e){function f(){void 0===e?e=ta:g("Message targetOrigin: "+e)}function h(){var f=a+":"+b,h=oa+":"+f+":"+c+(void 0!==d?":"+d:"");g("Sending message to host page ("+h+")"),sa.postMessage(ma+h,e)}!0===ra&&(f(),h())}function S(b){function c(){return ma===(""+b.data).substr(0,na)}function d(){ha=b.data,sa=b.source,i(),ca=!1,setTimeout(function(){ga=!1},ba)}function e(){ga?g("Page reset ignored by init"):(g("Page size reset by host page"),P("resetPage"))}function f(){N("resizeParent","Parent window requested size check")}function j(){var a=l();ia.findTarget(a)}function k(){return b.data.split("]")[1].split(":")[0]}function l(){return b.data.substr(b.data.indexOf(":")+1)}function m(){return"iFrameResize"in a}function n(){var a=l();g("MessageCallback called from parent: "+a),Ca(JSON.parse(a)),g(" --")}function o(){var a=l();g("PageInfoFromParent called from parent: "+a),Ea(JSON.parse(a)),g(" --")}function p(){return b.data.split(":")[2]in{"true":1,"false":1}}function q(){switch(k()){case"reset":e();break;case"resize":f();break;case"moveToAnchor":j();break;case"message":n();break;case"pageInfo":o();break;default:m()||p()||h("Unexpected message ("+b.data+")")}}function r(){!1===ca?q():p()?d():g('Ignored message of type "'+k()+'". Received before initialization.')}c()&&r()}function T(){"loading"!==document.readyState&&a.parent.postMessage("[iFrameResizerChild]Ready","*")}var U=!0,V=10,W="",X=0,Y="",Z=null,$="",_=!1,aa={resize:1,click:1},ba=128,ca=!0,da=1,ea="bodyOffset",fa=ea,ga=!0,ha="",ia={},ja=32,ka=null,la=!1,ma="[iFrameSizer]",na=ma.length,oa="",pa={max:1,min:1,bodyScroll:1,documentElementScroll:1},qa="child",ra=!0,sa=a.parent,ta="*",ua=0,va=!1,wa=null,xa=16,ya=1,za="scroll",Aa=za,Ba=a,Ca=function(){h("MessageCallback function not defined")},Da=function(){},Ea=function(){},Fa=Date.now||function(){return(new Date).getTime()},Ga={bodyOffset:function(){return document.body.offsetHeight+G("marginTop")+G("marginBottom")},offset:function(){return Ga.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,J(Ga))},min:function(){return Math.min.apply(null,J(Ga))},grow:function(){return Ga.max()},lowestElement:function(){return Math.max(Ga.bodyOffset(),I("bottom",L()))},taggedElement:function(){return K("bottom","data-iframe-height")}},Ha={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Ha.bodyScroll(),Ha.documentElementScroll())},max:function(){return Math.max.apply(null,J(Ha))},min:function(){return Math.min.apply(null,J(Ha))},rightMostElement:function(){return I("right",L())},taggedElement:function(){return K("right","data-iframe-width")}},Ia=e(M);b(a,"message",S),T()}(window||{}); | ||
!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a){var b,c,d,e=null,f=0,g=function(){f=Fa(),e=null,d=a.apply(b,c),e||(b=c=null)};return function(){var h=Fa();f||(f=h);var i=xa-(h-f);return b=this,c=arguments,0>=i||i>xa?(e&&(clearTimeout(e),e=null),f=h,d=a.apply(b,c),e||(b=c=null)):e||(e=setTimeout(g,i)),d}}function f(a){return ma+"["+oa+"] "+a}function g(b){la&&"object"==typeof a.console&&console.log(f(b))}function h(b){"object"==typeof a.console&&console.warn(f(b))}function i(){j(),g("Initialising iFrame ("+location.href+")"),k(),n(),m("background",W),m("padding",$),A(),s(),t(),o(),C(),u(),ia=B(),N("init","Init message from host page"),Da()}function j(){function a(a){return"true"===a?!0:!1}var b=ha.substr(na).split(":");oa=b[0],X=void 0!==b[1]?Number(b[1]):X,_=void 0!==b[2]?a(b[2]):_,la=void 0!==b[3]?a(b[3]):la,ja=void 0!==b[4]?Number(b[4]):ja,U=void 0!==b[6]?a(b[6]):U,Y=b[7],fa=void 0!==b[8]?b[8]:fa,W=b[9],$=b[10],ua=void 0!==b[11]?Number(b[11]):ua,ia.enable=void 0!==b[12]?a(b[12]):!1,qa=void 0!==b[13]?b[13]:qa,Aa=void 0!==b[14]?b[14]:Aa}function k(){function b(){var b=a.iFrameResizer;g("Reading data from page: "+JSON.stringify(b)),Ca="messageCallback"in b?b.messageCallback:Ca,Da="readyCallback"in b?b.readyCallback:Da,ta="targetOrigin"in b?b.targetOrigin:ta,fa="heightCalculationMethod"in b?b.heightCalculationMethod:fa,Aa="widthCalculationMethod"in b?b.widthCalculationMethod:Aa}"iFrameResizer"in a&&Object===a.iFrameResizer.constructor&&b(),g("TargetOrigin for parent set to: "+ta)}function l(a,b){return-1!==b.indexOf("-")&&(h("Negative CSS value ignored for "+a),b=""),b}function m(a,b){void 0!==b&&""!==b&&"null"!==b&&(document.body.style[a]=b,g("Body "+a+' set to "'+b+'"'))}function n(){void 0===Y&&(Y=X+"px"),m("margin",l("margin",Y))}function o(){document.documentElement.style.height="",document.body.style.height="",g('HTML & body height set to "auto"')}function p(e){function f(){N(e.eventName,e.eventType)}var h={add:function(c){b(a,c,f)},remove:function(b){c(a,b,f)}};e.eventNames&&Array.prototype.map?(e.eventName=e.eventNames[0],e.eventNames.map(h[e.method])):h[e.method](e.eventName),g(d(e.method)+" event listener: "+e.eventType)}function q(a){p({method:a,eventType:"Animation Start",eventNames:["animationstart","webkitAnimationStart"]}),p({method:a,eventType:"Animation Iteration",eventNames:["animationiteration","webkitAnimationIteration"]}),p({method:a,eventType:"Animation End",eventNames:["animationend","webkitAnimationEnd"]}),p({method:a,eventType:"Input",eventName:"input"}),p({method:a,eventType:"Mouse Up",eventName:"mouseup"}),p({method:a,eventType:"Mouse Down",eventName:"mousedown"}),p({method:a,eventType:"Orientation Change",eventName:"orientationchange"}),p({method:a,eventType:"Touch Start",eventName:"touchstart"}),p({method:a,eventType:"Touch End",eventName:"touchend"}),p({method:a,eventType:"Touch Cancel",eventName:"touchcancel"}),p({method:a,eventType:"Print",eventName:["afterprint","beforeprint"]}),p({method:a,eventType:"Transition Start",eventNames:["transitionstart","webkitTransitionStart","MSTransitionStart","oTransitionStart","otransitionstart"]}),p({method:a,eventType:"Transition Iteration",eventNames:["transitioniteration","webkitTransitionIteration","MSTransitionIteration","oTransitionIteration","otransitioniteration"]}),p({method:a,eventType:"Transition End",eventNames:["transitionend","webkitTransitionEnd","MSTransitionEnd","oTransitionEnd","otransitionend"]}),"child"===qa&&p({method:a,eventType:"IFrame Resized",eventName:"resize"})}function r(a,b,c,d){return b!==a&&(a in c||(h(a+" is not a valid option for "+d+"CalculationMethod."),a=b),g(d+' calculation method set to "'+a+'"')),a}function s(){fa=r(fa,ea,Ga,"height")}function t(){Aa=r(Aa,za,Ha,"width")}function u(){!0===U?(q("add"),F()):g("Auto Resize disabled")}function v(){g("Disable outgoing messages"),ra=!1}function w(){g("Remove event listener: Message"),c(a,"message",S)}function x(){null!==Z&&Z.disconnect()}function y(){q("remove"),x(),clearInterval(ka)}function z(){v(),w(),!0===U&&y()}function A(){var a=document.createElement("div");a.style.clear="both",a.style.display="block",document.body.appendChild(a)}function B(){function c(){return{x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop}}function d(a){var b=a.getBoundingClientRect(),d=c();return{x:parseInt(b.left,10)+parseInt(d.x,10),y:parseInt(b.top,10)+parseInt(d.y,10)}}function e(a){function b(a){var b=d(a);g("Moving to in page link (#"+c+") at x: "+b.x+" y: "+b.y),R(b.y,b.x,"scrollToOffset")}var c=a.split("#")[1]||a,e=decodeURIComponent(c),f=document.getElementById(e)||document.getElementsByName(e)[0];void 0!==f?b(f):(g("In page link (#"+c+") not found in iFrame, so sending to parent"),R(0,0,"inPageLink","#"+c))}function f(){""!==location.hash&&"#"!==location.hash&&e(location.href)}function i(){function a(a){function c(a){a.preventDefault(),e(this.getAttribute("href"))}"#"!==a.getAttribute("href")&&b(a,"click",c)}Array.prototype.forEach.call(document.querySelectorAll('a[href^="#"]'),a)}function j(){b(a,"hashchange",f)}function k(){setTimeout(f,ba)}function l(){Array.prototype.forEach&&document.querySelectorAll?(g("Setting up location.hash handlers"),i(),j(),k()):h("In page linking not fully supported in this browser! (See README.md for IE8 workaround)")}return ia.enable?l():g("In page linking not enabled"),{findTarget:e}}function C(){g("Enable public methods"),Ba.parentIFrame={autoResize:function(a){return!0===a&&!1===U?(U=!0,u()):!1===a&&!0===U&&(U=!1,y()),U},close:function(){R(0,0,"close"),z()},getId:function(){return oa},getPageInfo:function(a){"function"==typeof a?(Ea=a,R(0,0,"pageInfo")):(Ea=a,R(0,0,"pageInfoStop"))},moveToAnchor:function(a){ia.findTarget(a)},reset:function(){Q("parentIFrame.reset")},scrollTo:function(a,b){R(b,a,"scrollTo")},scrollToOffset:function(a,b){R(b,a,"scrollToOffset")},sendMessage:function(a,b){R(0,0,"message",JSON.stringify(a),b)},setHeightCalculationMethod:function(a){fa=a,s()},setWidthCalculationMethod:function(a){Aa=a,t()},setTargetOrigin:function(a){g("Set targetOrigin: "+a),ta=a},size:function(a,b){var c=""+(a?a:"")+(b?","+b:"");N("size","parentIFrame.size("+c+")",a,b)}}}function D(){0!==ja&&(g("setInterval: "+ja+"ms"),ka=setInterval(function(){N("interval","setInterval: "+ja)},Math.abs(ja)))}function E(){function b(a){function b(a){!1===a.complete&&(g("Attach listeners to "+a.src),a.addEventListener("load",f,!1),a.addEventListener("error",h,!1),k.push(a))}"attributes"===a.type&&"src"===a.attributeName?b(a.target):"childList"===a.type&&Array.prototype.forEach.call(a.target.querySelectorAll("img"),b)}function c(a){k.splice(k.indexOf(a),1)}function d(a){g("Remove listeners from "+a.src),a.removeEventListener("load",f,!1),a.removeEventListener("error",h,!1),c(a)}function e(a,b,c){d(a.target),N(b,c+": "+a.target.src,void 0,void 0)}function f(a){e(a,"imageLoad","Image loaded")}function h(a){e(a,"imageLoadFailed","Image load failed")}function i(a){N("mutationObserver","mutationObserver: "+a[0].target+" "+a[0].type),a.forEach(b)}function j(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0};return m=new l(i),g("Create body MutationObserver"),m.observe(a,b),m}var k=[],l=a.MutationObserver||a.WebKitMutationObserver,m=j();return{disconnect:function(){"disconnect"in m&&(g("Disconnect body MutationObserver"),m.disconnect(),k.forEach(d))}}}function F(){var b=0>ja;a.MutationObserver||a.WebKitMutationObserver?b?D():Z=E():(g("MutationObserver not supported in this browser!"),D())}function G(a){function b(a){var b=/^\d+(px)?$/i;if(b.test(a))return parseInt(a,V);var d=c.style.left,e=c.runtimeStyle.left;return c.runtimeStyle.left=c.currentStyle.left,c.style.left=a||0,a=c.style.pixelLeft,c.style.left=d,c.runtimeStyle.left=e,a}var c=document.body,d=0;return"defaultView"in document&&"getComputedStyle"in document.defaultView?(d=document.defaultView.getComputedStyle(c,null),d=null!==d?d[a]:0):d=b(c.currentStyle[a]),parseInt(d,V)}function H(a){a>xa/2&&(xa=2*a,g("Event throttle increased to "+xa+"ms"))}function I(a,b){for(var c=b.length,e=0,f=0,h=d(a),i=Fa(),j=0;c>j;j++)e=b[j].getBoundingClientRect()[a]+G("margin"+h),e>f&&(f=e);return i=Fa()-i,g("Parsed "+c+" HTML elements"),g("Element position calculated in "+i+"ms"),H(i),f}function J(a){return[a.bodyOffset(),a.bodyScroll(),a.documentElementOffset(),a.documentElementScroll()]}function K(a,b){function c(){return h("No tagged elements ("+b+") found on page"),da}var d=document.querySelectorAll("["+b+"]");return 0===d.length?c():I(a,d)}function L(){return document.querySelectorAll("body *")}function M(a,b,c,d){function e(){da=l,ya=m,R(da,ya,a)}function f(){function a(a,b){var c=Math.abs(a-b)<=ua;return!c}return l=void 0!==c?c:Ga[fa](),m=void 0!==d?d:Ha[Aa](),a(da,l)||_&&a(ya,m)}function h(){return!(a in{init:1,interval:1,size:1})}function i(){return fa in pa||_&&Aa in pa}function j(){g("No change in size detected")}function k(){h()&&i()?Q(b):a in{interval:1}||j()}var l,m;f()||"init"===a?(O(),e()):k()}function N(a,b,c,d){function e(){a in{reset:1,resetPage:1,init:1}||g("Trigger event: "+b)}function f(){return va&&a in aa}f()?g("Trigger event cancelled: "+a):(e(),Ia(a,b,c,d))}function O(){va||(va=!0,g("Trigger event lock on")),clearTimeout(wa),wa=setTimeout(function(){va=!1,g("Trigger event lock off"),g("--")},ba)}function P(a){da=Ga[fa](),ya=Ha[Aa](),R(da,ya,a)}function Q(a){var b=fa;fa=ea,g("Reset trigger event: "+a),O(),P("reset"),fa=b}function R(a,b,c,d,e){function f(){void 0===e?e=ta:g("Message targetOrigin: "+e)}function h(){var f=a+":"+b,h=oa+":"+f+":"+c+(void 0!==d?":"+d:"");g("Sending message to host page ("+h+")"),sa.postMessage(ma+h,e)}!0===ra&&(f(),h())}function S(b){function c(){return ma===(""+b.data).substr(0,na)}function d(){ha=b.data,sa=b.source,i(),ca=!1,setTimeout(function(){ga=!1},ba)}function e(){ga?g("Page reset ignored by init"):(g("Page size reset by host page"),P("resetPage"))}function f(){N("resizeParent","Parent window requested size check")}function j(){var a=l();ia.findTarget(a)}function k(){return b.data.split("]")[1].split(":")[0]}function l(){return b.data.substr(b.data.indexOf(":")+1)}function m(){return"iFrameResize"in a}function n(){var a=l();g("MessageCallback called from parent: "+a),Ca(JSON.parse(a)),g(" --")}function o(){var a=l();g("PageInfoFromParent called from parent: "+a),Ea(JSON.parse(a)),g(" --")}function p(){return b.data.split(":")[2]in{"true":1,"false":1}}function q(){switch(k()){case"reset":e();break;case"resize":f();break;case"moveToAnchor":j();break;case"message":n();break;case"pageInfo":o();break;default:m()||p()||h("Unexpected message ("+b.data+")")}}function r(){!1===ca?q():p()?d():g('Ignored message of type "'+k()+'". Received before initialization.')}c()&&r()}function T(){"loading"!==document.readyState&&a.parent.postMessage("[iFrameResizerChild]Ready","*")}var U=!0,V=10,W="",X=0,Y="",Z=null,$="",_=!1,aa={resize:1,click:1},ba=128,ca=!0,da=1,ea="bodyOffset",fa=ea,ga=!0,ha="",ia={},ja=32,ka=null,la=!1,ma="[iFrameSizer]",na=ma.length,oa="",pa={max:1,min:1,bodyScroll:1,documentElementScroll:1},qa="child",ra=!0,sa=a.parent,ta="*",ua=0,va=!1,wa=null,xa=16,ya=1,za="scroll",Aa=za,Ba=a,Ca=function(){h("MessageCallback function not defined")},Da=function(){},Ea=function(){},Fa=Date.now||function(){return(new Date).getTime()},Ga={bodyOffset:function(){return document.body.offsetHeight+G("marginTop")+G("marginBottom")},offset:function(){return Ga.bodyOffset()},bodyScroll:function(){return document.body.scrollHeight},documentElementOffset:function(){return document.documentElement.offsetHeight},documentElementScroll:function(){return document.documentElement.scrollHeight},max:function(){return Math.max.apply(null,J(Ga))},min:function(){return Math.min.apply(null,J(Ga))},grow:function(){return Ga.max()},lowestElement:function(){return Math.max(Ga.bodyOffset(),I("bottom",L()))},taggedElement:function(){return K("bottom","data-iframe-height")}},Ha={bodyScroll:function(){return document.body.scrollWidth},bodyOffset:function(){return document.body.offsetWidth},documentElementScroll:function(){return document.documentElement.scrollWidth},documentElementOffset:function(){return document.documentElement.offsetWidth},scroll:function(){return Math.max(Ha.bodyScroll(),Ha.documentElementScroll())},max:function(){return Math.max.apply(null,J(Ha))},min:function(){return Math.min.apply(null,J(Ha))},rightMostElement:function(){return I("right",L())},taggedElement:function(){return K("right","data-iframe-width")}},Ia=e(M);b(a,"message",S),T()}(window||{}); | ||
//# sourceMappingURL=iframeResizer.contentWindow.map |
@@ -69,2 +69,11 @@ /* | ||
function removeEventListener(el,evt,func){ | ||
/* istanbul ignore else */ // Not testable in phantonJS | ||
if ('removeEventListener' in window){ | ||
el.removeEventListener(evt,func, false); | ||
} else if ('detachEvent' in window){ //IE | ||
el.detachEvent('on'+evt,func); | ||
} | ||
} | ||
function setupRequestAnimationFrame(){ | ||
@@ -152,12 +161,12 @@ var | ||
var | ||
max = Number(settings[iframeId]['max'+Dimension]), | ||
min = Number(settings[iframeId]['min'+Dimension]), | ||
max = Number(settings[iframeId]['max' + Dimension]), | ||
min = Number(settings[iframeId]['min' + Dimension]), | ||
dimension = Dimension.toLowerCase(), | ||
size = Number(messageData[dimension]); | ||
log(iframeId,'Checking '+dimension+' is in range '+min+'-'+max); | ||
log(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max); | ||
if (size<min) { | ||
size=min; | ||
log(iframeId,'Set '+dimension+' to min value'); | ||
log(iframeId,'Set ' + dimension + ' to min value'); | ||
} | ||
@@ -167,6 +176,6 @@ | ||
size=max; | ||
log(iframeId,'Set '+dimension+' to max value'); | ||
log(iframeId,'Set ' + dimension + ' to max value'); | ||
} | ||
messageData[dimension]=''+size; | ||
messageData[dimension] = '' + size; | ||
} | ||
@@ -247,18 +256,69 @@ | ||
function sendPageInfoToIframe(){ | ||
function getPageInfo(){ | ||
var | ||
bodyPosition = document.body.getBoundingClientRect(), | ||
iFramePosition = messageData.iframe.getBoundingClientRect(), | ||
position = JSON.stringify({ | ||
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), | ||
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), | ||
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), | ||
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), | ||
scrollTop: window.pageYOffset, | ||
scrollLeft: window.pageXOffset | ||
iFramePosition = messageData.iframe.getBoundingClientRect(); | ||
return JSON.stringify({ | ||
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), | ||
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), | ||
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), | ||
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), | ||
scrollTop: window.pageYOffset, | ||
scrollLeft: window.pageXOffset | ||
}); | ||
} | ||
function sendPageInfoToIframe(iframe,iframeId){ | ||
function debouncedTrigger(){ | ||
trigger( | ||
'Send Page Info', | ||
'pageInfo:' + getPageInfo(), | ||
iframe, | ||
iframeId | ||
); | ||
} | ||
debouce(debouncedTrigger,32); | ||
} | ||
function startPageInfoMonitor(){ | ||
function setListener(type,func){ | ||
function sendPageInfo(){ | ||
if (settings[id]){ | ||
sendPageInfoToIframe(settings[id].iframe,id); | ||
} else { | ||
stop(); | ||
} | ||
} | ||
['scroll','resize'].forEach(function(evt){ | ||
log(id, type + evt + ' listener for sendPageInfo'); | ||
func(window,evt,sendPageInfo); | ||
}); | ||
} | ||
trigger('Send Page Info','pageInfo:' + position, settings[iframeId].iframe, iframeId); | ||
function stop(){ | ||
setListener('Remove ', removeEventListener); | ||
} | ||
function start(){ | ||
setListener('Add ', addEventListener); | ||
} | ||
var id = iframeId; //Create locally scoped copy of iFrame ID | ||
start(); | ||
settings[id].stopPageInfo = stop; | ||
} | ||
function stopPageInfoMonitor(){ | ||
if (settings[iframeId] && settings[iframeId].stopPageInfo){ | ||
settings[iframeId].stopPageInfo(); | ||
delete settings[iframeId].stopPageInfo; | ||
} | ||
} | ||
function checkIFrameExists(){ | ||
@@ -387,4 +447,8 @@ var retBool = true; | ||
case 'pageInfo': | ||
sendPageInfoToIframe(); | ||
sendPageInfoToIframe(settings[iframeId].iframe,iframeId); | ||
startPageInfoMonitor(); | ||
break; | ||
case 'pageInfoStop': | ||
stopPageInfoMonitor(); | ||
break; | ||
case 'inPageLink': | ||
@@ -563,2 +627,3 @@ findTarget(getMsgBody(9)); | ||
function postMessageToIFrame(){ | ||
var target = settings[id].targetOrigin; | ||
log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target); | ||
@@ -575,10 +640,16 @@ iframe.contentWindow.postMessage( msgId + msg, target ); | ||
function chkAndSend(){ | ||
if(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS | ||
postMessageToIFrame(); | ||
} else { | ||
iFrameNotFound(); | ||
} | ||
} | ||
id = id || iframe.id; | ||
var target = settings[id].targetOrigin; | ||
if(iframe && 'contentWindow' in iframe){ | ||
postMessageToIFrame(); | ||
} else { | ||
iFrameNotFound(); | ||
if(settings[id]) { | ||
chkAndSend(); | ||
} | ||
} | ||
@@ -870,9 +941,12 @@ | ||
function init(options,element){ | ||
if(!element) { | ||
return; //Stop mootools creating problems | ||
} else if(!element.tagName) { | ||
throw new TypeError('Object is not a valid DOM element'); | ||
} else if ('IFRAME' !== element.tagName.toUpperCase()) { | ||
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>'); | ||
} else { | ||
function chkType(){ | ||
if(!element.tagName) { | ||
throw new TypeError('Object is not a valid DOM element'); | ||
} else if ('IFRAME' !== element.tagName.toUpperCase()) { | ||
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>'); | ||
} | ||
} | ||
if(element) { | ||
chkType(); | ||
setupIFrame(element, options); | ||
@@ -879,0 +953,0 @@ iFrames.push(element); |
@@ -1,2 +0,2 @@ | ||
/*! iFrame Resizer (iframeSizer.min.js ) - v3.4.2 - 2015-10-09 | ||
/*! iFrame Resizer (iframeSizer.min.js ) - v3.5.0 - 2015-10-26 | ||
* Desc: Force cross domain iframes to size to content. | ||
@@ -8,3 +8,3 @@ * Requires: iframeResizer.contentWindow.min.js to be loaded into the target frame. | ||
!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(){var b,c=["moz","webkit","o","ms"];for(b=0;b<c.length&&!M;b+=1)M=a[c[b]+"RequestAnimationFrame"];M||g("setup","RequestAnimationFrame not supported")}function d(b){var c="Host page: "+b;return a.top!==a.self&&(c=a.parentIFrame&&a.parentIFrame.getId?a.parentIFrame.getId()+": "+b:"Nested host page: "+b),c}function e(a){return J+"["+d(a)+"]"}function f(a){return O[a]?O[a].log:F}function g(a,b){j("log",a,b,f(a))}function h(a,b){j("info",a,b,f(a))}function i(a,b){j("warn",a,b,!0)}function j(b,c,d,f){!0===f&&"object"==typeof a.console&&console[b](e(c),d)}function k(b){function c(){function a(){r(N),o(P)}e("Height"),e("Width"),s(a,N,"init")}function d(){var a=M.substr(K).split(":");return{iframe:O[a[0]].iframe,id:a[0],height:a[1],width:a[2],type:a[3]}}function e(a){var b=Number(O[P]["max"+a]),c=Number(O[P]["min"+a]),d=a.toLowerCase(),e=Number(N[d]);g(P,"Checking "+d+" is in range "+c+"-"+b),c>e&&(e=c,g(P,"Set "+d+" to min value")),e>b&&(e=b,g(P,"Set "+d+" to max value")),N[d]=""+e}function f(){function a(){function a(){var a=0,b=!1;for(g(P,"Checking connection is from allowed list of origins: "+d);a<d.length;a++)if(d[a]===c){b=!0;break}return b}function b(){var a=O[P].remoteHost;return g(P,"Checking connection is from: "+a),c===a}return d.constructor===Array?a():b()}var c=b.origin,d=O[P].checkOrigin;if(d&&""+c!="null"&&!a())throw new Error("Unexpected message received from: "+c+" for "+N.iframe.id+". Message was: "+b.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function j(){return J===(""+M).substr(0,K)&&M.substr(K).split(":")[0]in O}function k(){var a=N.type in{"true":1,"false":1,undefined:1};return a&&g(P,"Ignoring init message from meta parent page"),a}function v(a){return M.substr(M.indexOf(":")+I+a)}function w(a){g(P,"MessageCallback passed: {iframe: "+N.iframe.id+", message: "+a+"}"),D("messageCallback",{iframe:N.iframe,message:JSON.parse(a)}),g(P,"--")}function x(){var b=document.body.getBoundingClientRect(),c=N.iframe.getBoundingClientRect(),d=JSON.stringify({clientHeight:Math.max(document.documentElement.clientHeight,a.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,a.innerWidth||0),offsetTop:parseInt(c.top-b.top,10),offsetLeft:parseInt(c.left-b.left,10),scrollTop:a.pageYOffset,scrollLeft:a.pageXOffset});t("Send Page Info","pageInfo:"+d,O[P].iframe,P)}function y(){var a=!0;return null===N.iframe&&(i(P,"IFrame ("+N.id+") not found"),a=!1),a}function z(a){var b=a.getBoundingClientRect();return n(P),{x:Math.floor(Number(b.left)+Number(L.x)),y:Math.floor(Number(b.top)+Number(L.y))}}function A(b){function c(){L=h,B(),g(P,"--")}function d(){return{x:Number(N.width)+f.x,y:Number(N.height)+f.y}}function e(){a.parentIFrame?a.parentIFrame["scrollTo"+(b?"Offset":"")](h.x,h.y):i(P,"Unable to scroll to requested position, window.parentIFrame not found")}var f=b?z(N.iframe):{x:0,y:0},h=d();g(P,"Reposition requested from iFrame (offset x:"+f.x+" y:"+f.y+")"),a.top!==a.self?e():c()}function B(){!1!==D("scrollCallback",L)?o(P):p()}function C(b){function c(){var a=z(h);g(P,"Moving to in page link (#"+e+") at x: "+a.x+" y: "+a.y),L={x:a.x,y:a.y},B(),g(P,"--")}function d(){a.parentIFrame?a.parentIFrame.moveToAnchor(e):g(P,"In page link #"+e+" not found and window.parentIFrame not found")}var e=b.split("#")[1]||"",f=decodeURIComponent(e),h=document.getElementById(f)||document.getElementsByName(f)[0];h?c():a.top!==a.self?d():g(P,"In page link #"+e+" not found")}function D(a,b){return l(P,a,b)}function E(){switch(O[P].firstRun&&H(),N.type){case"close":m(N.iframe);break;case"message":w(v(6));break;case"scrollTo":A(!1);break;case"scrollToOffset":A(!0);break;case"pageInfo":x();break;case"inPageLink":C(v(9));break;case"reset":q(N);break;case"init":c(),D("initCallback",N.iframe),D("resizedCallback",N);break;default:c(),D("resizedCallback",N)}}function F(a){var b=!0;return O[a]||(b=!1,i(N.type+" No settings for "+a+". Message was: "+M)),b}function G(){for(var a in O)t("iFrame requested init",u(a),document.getElementById(a),a)}function H(){O[P].firstRun=!1}var M=b.data,N={},P=null;"[iFrameResizerChild]Ready"===M?G():j()?(N=d(),P=Q=N.id,!k()&&F(P)&&(g(P,"Received: "+M),y()&&f()&&E())):h(P,"Ignored: "+M)}function l(a,b,c){var d=null,e=null;if(O[a]){if(d=O[a][b],"function"!=typeof d)throw new TypeError(b+" on iFrame["+a+"] is not a function");e=d(c)}return e}function m(a){var b=a.id;g(b,"Removing iFrame: "+b),a.parentNode.removeChild(a),l(b,"closedCallback",b),g(b,"--"),delete O[b]}function n(b){null===L&&(L={x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop},g(b,"Get page position: "+L.x+","+L.y))}function o(b){null!==L&&(a.scrollTo(L.x,L.y),g(b,"Set page position: "+L.x+","+L.y),p())}function p(){L=null}function q(a){function b(){r(a),t("reset","reset",a.iframe,a.id)}g(a.id,"Size reset requested by "+("init"===a.type?"host page":"iFrame")),n(a.id),s(b,a,"reset")}function r(a){function b(b){a.iframe.style[b]=a[b]+"px",g(a.id,"IFrame ("+e+") "+b+" set to "+a[b]+"px")}function c(b){G||"0"!==a[b]||(G=!0,g(e,"Hidden iFrame detected, creating visibility listener"),x())}function d(a){b(a),c(a)}var e=a.iframe.id;O[e]&&(O[e].sizeHeight&&d("height"),O[e].sizeWidth&&d("width"))}function s(a,b,c){c!==b.type&&M?(g(b.id,"Requesting animation frame"),M(a)):a()}function t(a,b,c,d){function e(){g(d,"["+a+"] Sending msg to iframe["+d+"] ("+b+") targetOrigin: "+i),c.contentWindow.postMessage(J+b,i)}function f(){h(d,"["+a+"] IFrame("+d+") not found"),O[d]&&delete O[d]}d=d||c.id;var i=O[d].targetOrigin;c&&"contentWindow"in c?e():f()}function u(a){return a+":"+O[a].bodyMarginV1+":"+O[a].sizeWidth+":"+O[a].log+":"+O[a].interval+":"+O[a].enablePublicMethods+":"+O[a].autoResize+":"+O[a].bodyMargin+":"+O[a].heightCalculationMethod+":"+O[a].bodyBackground+":"+O[a].bodyPadding+":"+O[a].tolerance+":"+O[a].inPageLinks+":"+O[a].resizeFrom+":"+O[a].widthCalculationMethod}function v(a,c){function d(){function b(b){1/0!==O[w][b]&&0!==O[w][b]&&(a.style[b]=O[w][b]+"px",g(w,"Set "+b+" = "+O[w][b]+"px"))}function c(a){if(O[w]["min"+a]>O[w]["max"+a])throw new Error("Value for min"+a+" can not be greater than max"+a)}c("Height"),c("Width"),b("maxHeight"),b("minHeight"),b("maxWidth"),b("minWidth")}function e(){var a=c&&c.id||R.id+E++;return null!==document.getElementById(a)&&(a+=E++),a}function f(b){return Q=b,""===b&&(a.id=b=e(),F=(c||{}).log,Q=b,g(b,"Added missing iframe ID: "+b+" ("+a.src+")")),b}function h(){g(w,"IFrame scrolling "+(O[w].scrolling?"enabled":"disabled")+" for "+w),a.style.overflow=!1===O[w].scrolling?"hidden":"auto",a.scrolling=!1===O[w].scrolling?"no":"yes"}function j(){("number"==typeof O[w].bodyMargin||"0"===O[w].bodyMargin)&&(O[w].bodyMarginV1=O[w].bodyMargin,O[w].bodyMargin=""+O[w].bodyMargin+"px")}function k(){var b=O[w].firstRun,c=O[w].heightCalculationMethod in N;!b&&c&&q({iframe:a,height:0,width:0,type:"init"})}function l(){Function.prototype.bind&&(O[w].iframe.iFrameResizer={close:m.bind(null,O[w].iframe),resize:t.bind(null,"Window resize","resize",O[w].iframe),moveToAnchor:function(a){t("Move to anchor","inPageLink:"+a,O[w].iframe,w)},sendMessage:function(a){a=JSON.stringify(a),t("Send Message","message:"+a,O[w].iframe,w)}})}function n(c){function d(){t("iFrame.onload",c,a),k()}b(a,"load",d),t("init",c,a)}function o(a){if("object"!=typeof a)throw new TypeError("Options is not an object")}function p(a){for(var b in R)R.hasOwnProperty(b)&&(O[w][b]=a.hasOwnProperty(b)?a[b]:R[b])}function r(a){return""===a||"file://"===a?"*":a}function s(b){b=b||{},O[w]={firstRun:!0,iframe:a,remoteHost:a.src.split("/").slice(0,3).join("/")},o(b),p(b),O[w].targetOrigin=!0===O[w].checkOrigin?r(O[w].remoteHost):"*"}function v(){return w in O&&"iFrameResizer"in a}var w=f(a.id);v()?i(w,"Ignored iFrame, already setup."):(s(c),h(),d(),j(),n(u(w)),l())}function w(a,b){null===P&&(P=setTimeout(function(){P=null,a()},b))}function x(){function b(){function a(a){function b(b){return"0px"===O[a].iframe.style[b]}function c(a){return null!==a.offsetParent}c(O[a].iframe)&&(b("height")||b("width"))&&t("Visibility change","resize",O[a].iframe,a)}for(var b in O)a(b)}function c(a){g("window","Mutation observed: "+a[0].target+" "+a[0].type),w(b,16)}function d(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},d=new e(c);d.observe(a,b)}var e=a.MutationObserver||a.WebKitMutationObserver;e&&d()}function y(a){function b(){A("Window "+a,"resize")}g("window","Trigger event: "+a),w(b,16)}function z(){function a(){A("Tab Visable","resize")}"hidden"!==document.visibilityState&&(g("document","Trigger event: Visiblity change"),w(a,16))}function A(a,b){function c(a){return"parent"===O[a].resizeFrom&&O[a].autoResize&&!O[a].firstRun}for(var d in O)c(d)&&t(a,b,document.getElementById(d),d)}function B(){b(a,"message",k),b(a,"resize",function(){y("resize")}),b(document,"visibilitychange",z),b(document,"-webkit-visibilitychange",z),b(a,"focusin",function(){y("focus")}),b(a,"focus",function(){y("focus")})}function C(){function a(a,c){if(c){if(!c.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==c.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+c.tagName+">");v(c,a),b.push(c)}}var b;return c(),B(),function(c,d){switch(b=[],typeof d){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a.bind(void 0,c));break;case"object":a(c,d);break;default:throw new TypeError("Unexpected data type ("+typeof d+")")}return b}}function D(a){a.fn.iFrameResize=function(a){return this.filter("iframe").each(function(b,c){v(c,a)}).end()}}var E=0,F=!1,G=!1,H="message",I=H.length,J="[iFrameSizer]",K=J.length,L=null,M=a.requestAnimationFrame,N={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},O={},P=null,Q="Host Page",R={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(){i("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};a.jQuery&&D(jQuery),"function"==typeof define&&define.amd?define([],C):"object"==typeof module&&"object"==typeof module.exports?module.exports=C():a.iFrameResize=a.iFrameResize||C()}(window||{}); | ||
!function(a){"use strict";function b(b,c,d){"addEventListener"in a?b.addEventListener(c,d,!1):"attachEvent"in a&&b.attachEvent("on"+c,d)}function c(b,c,d){"removeEventListener"in a?b.removeEventListener(c,d,!1):"detachEvent"in a&&b.detachEvent("on"+c,d)}function d(){var b,c=["moz","webkit","o","ms"];for(b=0;b<c.length&&!N;b+=1)N=a[c[b]+"RequestAnimationFrame"];N||h("setup","RequestAnimationFrame not supported")}function e(b){var c="Host page: "+b;return a.top!==a.self&&(c=a.parentIFrame&&a.parentIFrame.getId?a.parentIFrame.getId()+": "+b:"Nested host page: "+b),c}function f(a){return K+"["+e(a)+"]"}function g(a){return P[a]?P[a].log:G}function h(a,b){k("log",a,b,g(a))}function i(a,b){k("info",a,b,g(a))}function j(a,b){k("warn",a,b,!0)}function k(b,c,d,e){!0===e&&"object"==typeof a.console&&console[b](f(c),d)}function l(d){function e(){function a(){s(V),p(W)}g("Height"),g("Width"),t(a,V,"init")}function f(){var a=U.substr(L).split(":");return{iframe:P[a[0]].iframe,id:a[0],height:a[1],width:a[2],type:a[3]}}function g(a){var b=Number(P[W]["max"+a]),c=Number(P[W]["min"+a]),d=a.toLowerCase(),e=Number(V[d]);h(W,"Checking "+d+" is in range "+c+"-"+b),c>e&&(e=c,h(W,"Set "+d+" to min value")),e>b&&(e=b,h(W,"Set "+d+" to max value")),V[d]=""+e}function k(){function a(){function a(){var a=0,d=!1;for(h(W,"Checking connection is from allowed list of origins: "+c);a<c.length;a++)if(c[a]===b){d=!0;break}return d}function d(){var a=P[W].remoteHost;return h(W,"Checking connection is from: "+a),b===a}return c.constructor===Array?a():d()}var b=d.origin,c=P[W].checkOrigin;if(c&&""+b!="null"&&!a())throw new Error("Unexpected message received from: "+b+" for "+V.iframe.id+". Message was: "+d.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function l(){return K===(""+U).substr(0,L)&&U.substr(L).split(":")[0]in P}function w(){var a=V.type in{"true":1,"false":1,undefined:1};return a&&h(W,"Ignoring init message from meta parent page"),a}function y(a){return U.substr(U.indexOf(":")+J+a)}function z(a){h(W,"MessageCallback passed: {iframe: "+V.iframe.id+", message: "+a+"}"),N("messageCallback",{iframe:V.iframe,message:JSON.parse(a)}),h(W,"--")}function A(){var b=document.body.getBoundingClientRect(),c=V.iframe.getBoundingClientRect();return JSON.stringify({clientHeight:Math.max(document.documentElement.clientHeight,a.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,a.innerWidth||0),offsetTop:parseInt(c.top-b.top,10),offsetLeft:parseInt(c.left-b.left,10),scrollTop:a.pageYOffset,scrollLeft:a.pageXOffset})}function B(a,b){function c(){u("Send Page Info","pageInfo:"+A(),a,b)}x(c,32)}function C(){function d(b,c){function d(){P[g]?B(P[g].iframe,g):e()}["scroll","resize"].forEach(function(e){h(g,b+e+" listener for sendPageInfo"),c(a,e,d)})}function e(){d("Remove ",c)}function f(){d("Add ",b)}var g=W;f(),P[g].stopPageInfo=e}function D(){P[W]&&P[W].stopPageInfo&&(P[W].stopPageInfo(),delete P[W].stopPageInfo)}function E(){var a=!0;return null===V.iframe&&(j(W,"IFrame ("+V.id+") not found"),a=!1),a}function F(a){var b=a.getBoundingClientRect();return o(W),{x:Math.floor(Number(b.left)+Number(M.x)),y:Math.floor(Number(b.top)+Number(M.y))}}function G(b){function c(){M=g,H(),h(W,"--")}function d(){return{x:Number(V.width)+f.x,y:Number(V.height)+f.y}}function e(){a.parentIFrame?a.parentIFrame["scrollTo"+(b?"Offset":"")](g.x,g.y):j(W,"Unable to scroll to requested position, window.parentIFrame not found")}var f=b?F(V.iframe):{x:0,y:0},g=d();h(W,"Reposition requested from iFrame (offset x:"+f.x+" y:"+f.y+")"),a.top!==a.self?e():c()}function H(){!1!==N("scrollCallback",M)?p(W):q()}function I(b){function c(){var a=F(g);h(W,"Moving to in page link (#"+e+") at x: "+a.x+" y: "+a.y),M={x:a.x,y:a.y},H(),h(W,"--")}function d(){a.parentIFrame?a.parentIFrame.moveToAnchor(e):h(W,"In page link #"+e+" not found and window.parentIFrame not found")}var e=b.split("#")[1]||"",f=decodeURIComponent(e),g=document.getElementById(f)||document.getElementsByName(f)[0];g?c():a.top!==a.self?d():h(W,"In page link #"+e+" not found")}function N(a,b){return m(W,a,b)}function O(){switch(P[W].firstRun&&T(),V.type){case"close":n(V.iframe);break;case"message":z(y(6));break;case"scrollTo":G(!1);break;case"scrollToOffset":G(!0);break;case"pageInfo":B(P[W].iframe,W),C();break;case"pageInfoStop":D();break;case"inPageLink":I(y(9));break;case"reset":r(V);break;case"init":e(),N("initCallback",V.iframe),N("resizedCallback",V);break;default:e(),N("resizedCallback",V)}}function Q(a){var b=!0;return P[a]||(b=!1,j(V.type+" No settings for "+a+". Message was: "+U)),b}function S(){for(var a in P)u("iFrame requested init",v(a),document.getElementById(a),a)}function T(){P[W].firstRun=!1}var U=d.data,V={},W=null;"[iFrameResizerChild]Ready"===U?S():l()?(V=f(),W=R=V.id,!w()&&Q(W)&&(h(W,"Received: "+U),E()&&k()&&O())):i(W,"Ignored: "+U)}function m(a,b,c){var d=null,e=null;if(P[a]){if(d=P[a][b],"function"!=typeof d)throw new TypeError(b+" on iFrame["+a+"] is not a function");e=d(c)}return e}function n(a){var b=a.id;h(b,"Removing iFrame: "+b),a.parentNode.removeChild(a),m(b,"closedCallback",b),h(b,"--"),delete P[b]}function o(b){null===M&&(M={x:void 0!==a.pageXOffset?a.pageXOffset:document.documentElement.scrollLeft,y:void 0!==a.pageYOffset?a.pageYOffset:document.documentElement.scrollTop},h(b,"Get page position: "+M.x+","+M.y))}function p(b){null!==M&&(a.scrollTo(M.x,M.y),h(b,"Set page position: "+M.x+","+M.y),q())}function q(){M=null}function r(a){function b(){s(a),u("reset","reset",a.iframe,a.id)}h(a.id,"Size reset requested by "+("init"===a.type?"host page":"iFrame")),o(a.id),t(b,a,"reset")}function s(a){function b(b){a.iframe.style[b]=a[b]+"px",h(a.id,"IFrame ("+e+") "+b+" set to "+a[b]+"px")}function c(b){H||"0"!==a[b]||(H=!0,h(e,"Hidden iFrame detected, creating visibility listener"),y())}function d(a){b(a),c(a)}var e=a.iframe.id;P[e]&&(P[e].sizeHeight&&d("height"),P[e].sizeWidth&&d("width"))}function t(a,b,c){c!==b.type&&N?(h(b.id,"Requesting animation frame"),N(a)):a()}function u(a,b,c,d){function e(){var e=P[d].targetOrigin;h(d,"["+a+"] Sending msg to iframe["+d+"] ("+b+") targetOrigin: "+e),c.contentWindow.postMessage(K+b,e)}function f(){i(d,"["+a+"] IFrame("+d+") not found"),P[d]&&delete P[d]}function g(){c&&"contentWindow"in c&&null!==c.contentWindow?e():f()}d=d||c.id,P[d]&&g()}function v(a){return a+":"+P[a].bodyMarginV1+":"+P[a].sizeWidth+":"+P[a].log+":"+P[a].interval+":"+P[a].enablePublicMethods+":"+P[a].autoResize+":"+P[a].bodyMargin+":"+P[a].heightCalculationMethod+":"+P[a].bodyBackground+":"+P[a].bodyPadding+":"+P[a].tolerance+":"+P[a].inPageLinks+":"+P[a].resizeFrom+":"+P[a].widthCalculationMethod}function w(a,c){function d(){function b(b){1/0!==P[w][b]&&0!==P[w][b]&&(a.style[b]=P[w][b]+"px",h(w,"Set "+b+" = "+P[w][b]+"px"))}function c(a){if(P[w]["min"+a]>P[w]["max"+a])throw new Error("Value for min"+a+" can not be greater than max"+a)}c("Height"),c("Width"),b("maxHeight"),b("minHeight"),b("maxWidth"),b("minWidth")}function e(){var a=c&&c.id||S.id+F++;return null!==document.getElementById(a)&&(a+=F++),a}function f(b){return R=b,""===b&&(a.id=b=e(),G=(c||{}).log,R=b,h(b,"Added missing iframe ID: "+b+" ("+a.src+")")),b}function g(){h(w,"IFrame scrolling "+(P[w].scrolling?"enabled":"disabled")+" for "+w),a.style.overflow=!1===P[w].scrolling?"hidden":"auto",a.scrolling=!1===P[w].scrolling?"no":"yes"}function i(){("number"==typeof P[w].bodyMargin||"0"===P[w].bodyMargin)&&(P[w].bodyMarginV1=P[w].bodyMargin,P[w].bodyMargin=""+P[w].bodyMargin+"px")}function k(){var b=P[w].firstRun,c=P[w].heightCalculationMethod in O;!b&&c&&r({iframe:a,height:0,width:0,type:"init"})}function l(){Function.prototype.bind&&(P[w].iframe.iFrameResizer={close:n.bind(null,P[w].iframe),resize:u.bind(null,"Window resize","resize",P[w].iframe),moveToAnchor:function(a){u("Move to anchor","inPageLink:"+a,P[w].iframe,w)},sendMessage:function(a){a=JSON.stringify(a),u("Send Message","message:"+a,P[w].iframe,w)}})}function m(c){function d(){u("iFrame.onload",c,a),k()}b(a,"load",d),u("init",c,a)}function o(a){if("object"!=typeof a)throw new TypeError("Options is not an object")}function p(a){for(var b in S)S.hasOwnProperty(b)&&(P[w][b]=a.hasOwnProperty(b)?a[b]:S[b])}function q(a){return""===a||"file://"===a?"*":a}function s(b){b=b||{},P[w]={firstRun:!0,iframe:a,remoteHost:a.src.split("/").slice(0,3).join("/")},o(b),p(b),P[w].targetOrigin=!0===P[w].checkOrigin?q(P[w].remoteHost):"*"}function t(){return w in P&&"iFrameResizer"in a}var w=f(a.id);t()?j(w,"Ignored iFrame, already setup."):(s(c),g(),d(),i(),m(v(w)),l())}function x(a,b){null===Q&&(Q=setTimeout(function(){Q=null,a()},b))}function y(){function b(){function a(a){function b(b){return"0px"===P[a].iframe.style[b]}function c(a){return null!==a.offsetParent}c(P[a].iframe)&&(b("height")||b("width"))&&u("Visibility change","resize",P[a].iframe,a)}for(var b in P)a(b)}function c(a){h("window","Mutation observed: "+a[0].target+" "+a[0].type),x(b,16)}function d(){var a=document.querySelector("body"),b={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},d=new e(c);d.observe(a,b)}var e=a.MutationObserver||a.WebKitMutationObserver;e&&d()}function z(a){function b(){B("Window "+a,"resize")}h("window","Trigger event: "+a),x(b,16)}function A(){function a(){B("Tab Visable","resize")}"hidden"!==document.visibilityState&&(h("document","Trigger event: Visiblity change"),x(a,16))}function B(a,b){function c(a){return"parent"===P[a].resizeFrom&&P[a].autoResize&&!P[a].firstRun}for(var d in P)c(d)&&u(a,b,document.getElementById(d),d)}function C(){b(a,"message",l),b(a,"resize",function(){z("resize")}),b(document,"visibilitychange",A),b(document,"-webkit-visibilitychange",A),b(a,"focusin",function(){z("focus")}),b(a,"focus",function(){z("focus")})}function D(){function a(a,c){function d(){if(!c.tagName)throw new TypeError("Object is not a valid DOM element");if("IFRAME"!==c.tagName.toUpperCase())throw new TypeError("Expected <IFRAME> tag, found <"+c.tagName+">")}c&&(d(),w(c,a),b.push(c))}var b;return d(),C(),function(c,d){switch(b=[],typeof d){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(d||"iframe"),a.bind(void 0,c));break;case"object":a(c,d);break;default:throw new TypeError("Unexpected data type ("+typeof d+")")}return b}}function E(a){a.fn.iFrameResize=function(a){return this.filter("iframe").each(function(b,c){w(c,a)}).end()}}var F=0,G=!1,H=!1,I="message",J=I.length,K="[iFrameSizer]",L=K.length,M=null,N=a.requestAnimationFrame,O={max:1,scroll:1,bodyScroll:1,documentElementScroll:1},P={},Q=null,R="Host Page",S={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(){j("MessageCallback function not defined")},resizedCallback:function(){},scrollCallback:function(){return!0}};a.jQuery&&E(jQuery),"function"==typeof define&&define.amd?define([],D):"object"==typeof module&&"object"==typeof module.exports?module.exports=D():a.iFrameResize=a.iFrameResize||D()}(window||{}); | ||
//# sourceMappingURL=iframeResizer.map |
{ | ||
"name": "iframe-resizer", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"homepage": "https://github.com/davidjbradshaw/iframe-resizer", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -6,3 +6,2 @@ # iFrame Resizer | ||
[](https://coveralls.io/github/davidjbradshaw/iframe-resizer) | ||
[](LICENSE) | ||
@@ -13,3 +12,3 @@ This library enables the automatic resizing of the height and width of both same and cross domain iFrames to fit their contained content. It provides a range of features to address the most common issues with using iFrames, these include: | ||
* Works with multiple and nested iFrames. | ||
* Automatic domain authentication for cross domain iFrames. | ||
* Domain authentication for cross domain iFrames. | ||
* Provides a range of page size calculation methods to support complex CSS layouts. | ||
@@ -21,2 +20,3 @@ * Detects changes to the DOM that can cause the page to resize using [MutationObserver](https://developer.mozilla.org/en/docs/Web/API/MutationObserver). | ||
* Provides custom sizing and scrolling methods. | ||
* Exposes parent position and viewport size to the iFrame. | ||
* Works with [ViewerJS](http://viewerjs.org/) to support PDF and ODF documents. | ||
@@ -321,3 +321,3 @@ * Fallback support down to IE8. | ||
### getPageInfo(callback) | ||
### getPageInfo(callback || false) | ||
@@ -333,2 +333,6 @@ Ask the containing page for its positioning coordinates. You need to provide a callback which receives an object with the following properties: | ||
Your callback function will be recalled when the parent page is scrolled or resized. | ||
Pass `false` to disable the callback. | ||
### scrollTo(x,y) | ||
@@ -514,3 +518,5 @@ | ||
* v3.4.1 [#271](https://github.com/davidjbradshaw/iframe-resizer/issues/271) Fix bower.json to point to *js* folder, rather then *src* [[Yachi](https://github.com/yachi)]. Only teardown events on close if currently enabled. | ||
* v3.5.0 Recall getPageInfo callback when parent page position changes. Added Array.prototype.forEach to IE8 polyfils. | ||
* v3.4.2 Only teardown events on close if currently enabled. | ||
* v3.4.1 [#271](https://github.com/davidjbradshaw/iframe-resizer/issues/271) Fix bower.json to point to *js* folder, rather then *src* [[Yachi](https://github.com/yachi)]. | ||
* v3.4.0 [#262](https://github.com/davidjbradshaw/iframe-resizer/issues/262) Add getPageInfo method to parentIFrame [[Pierre Olivier](https://github.com/pomartel)]. [#263](https://github.com/davidjbradshaw/iframe-resizer/issues/263) Change leftMostElement to rightMostElement [[Luiz Panariello](https://github.com/LuizPanariello)]. [#265](https://github.com/davidjbradshaw/iframe-resizer/issues/265) Fix issue when no options being passed and added test for this. | ||
@@ -580,3 +586,3 @@ * v3.3.1 Point index.js to the JS folder, instead of the src folder. Added touch event listeners. AutoResize method now returns current state. | ||
* v1.0.2 [#2](https://github.com/davidjbradshaw/iframe-resizer/issues/2) mime-type changed for IE8-10. | ||
* v1.0.0 Initial published release. | ||
* v1.0.0 Initial pubic release. | ||
@@ -587,1 +593,4 @@ | ||
Licensed under the [MIT License](LICENSE). | ||
[](https://nodei.co/npm/iframe-resizer/) | ||
[](https://nodei.co/npm/iframe-resizer/) |
@@ -18,3 +18,3 @@ define(['iframeResizerContent','jquery'], function(mockMsgListener,$) { | ||
messageCallback: function(msg){msgCalled = msg;}, | ||
readyCallback: function(){window.parent.readyCalled = true;alert('ready')}, | ||
readyCallback: function(){this.readyCalled = true;}, | ||
targetOrigin: '*' | ||
@@ -39,3 +39,3 @@ }; | ||
window.msgCalled = null; | ||
window.readyCalled = false; | ||
//window.readyCalled = null; | ||
@@ -112,2 +112,7 @@ beforeEach(function(){ | ||
it('getPageInfoStop', function() { | ||
win.parentIFrame.getPageInfo(); | ||
expect(msgObject.source.postMessage).toHaveBeenCalledWith('[iFrameSizer]parentIFrameTests:0:0:pageInfoStop', '*'); | ||
}); | ||
it('scrollTo', function() { | ||
@@ -145,4 +150,4 @@ win.parentIFrame.scrollTo(10,10); | ||
xit('readyCallack', function() { | ||
expect(window.iFrameResizer.readyCallback).toHaveBeenCalled(); | ||
it('readyCallack', function() { | ||
expect(window.readyCalled).toEqual(true); | ||
}); | ||
@@ -149,0 +154,0 @@ |
@@ -20,2 +20,4 @@ define(['iframeResizer'], function(iFrameResize) { | ||
expect(msg.indexOf('"offsetTop":0,"offsetLeft":0,"scrollTop":0,"scrollLeft":0')).not.toEqual(0); | ||
} | ||
if(0!==msg.indexOf('pageInfoStop')){ | ||
tearDown(iframe1); | ||
@@ -27,2 +29,3 @@ done(); | ||
mockMsgFromIFrame(iframe1,'pageInfo'); | ||
mockMsgFromIFrame(iframe1,'pageInfoStop'); | ||
}); | ||
@@ -29,0 +32,0 @@ |
@@ -5,7 +5,9 @@ define(['iframeResizer'], function(iFrameResize) { | ||
describe('reset Page', function() { | ||
describe('default resize', function() { | ||
var iframe; | ||
var log=LOG; | ||
var testId = 'parentPage1'; | ||
var testId = 'defaultResize3'; | ||
var ready; | ||
beforeEach(function(done){ | ||
@@ -15,7 +17,10 @@ loadIFrame('iframe600.html'); | ||
log:log, | ||
id:testId | ||
id:testId, | ||
resizedCallback:function(){ | ||
ready=true; | ||
done(); | ||
} | ||
})[0]; | ||
spyOn(iframe.contentWindow,'postMessage').and.callFake(done); | ||
mockMsgFromIFrame(iframe,'reset'); | ||
mockMsgFromIFrame(iframe,'foo'); | ||
}); | ||
@@ -28,3 +33,3 @@ | ||
it('receive message', function() { | ||
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith('[iFrameSizer]reset', 'http://localhost:9876'); | ||
expect(ready).toBe(true); | ||
}); | ||
@@ -34,6 +39,6 @@ }); | ||
describe('late load msg received', function() { | ||
describe('reset Page', function() { | ||
var iframe; | ||
var log=LOG; | ||
var testId = 'parentPage2'; | ||
var testId = 'parentPage1'; | ||
@@ -48,3 +53,3 @@ beforeEach(function(done){ | ||
spyOn(iframe.contentWindow,'postMessage').and.callFake(done); | ||
window.postMessage('[iFrameResizerChild]Ready','*'); | ||
mockMsgFromIFrame(iframe,'reset'); | ||
}); | ||
@@ -57,3 +62,3 @@ | ||
it('receive message', function() { | ||
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith('[iFrameSizer]parentPage2:8:false:true:32:true:true:null:bodyOffset:null:null:0:false:parent:scroll', 'http://localhost:9876'); | ||
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith('[iFrameSizer]reset', 'http://localhost:9876'); | ||
}); | ||
@@ -63,22 +68,28 @@ }); | ||
xdescribe('default resize', function() { | ||
describe('late load msg received', function() { | ||
var iframe; | ||
var log=LOG; | ||
var testId = 'defaultResize3'; | ||
var testId = 'parentPage2'; | ||
it('receive message', function(done) { | ||
beforeEach(function(done){ | ||
loadIFrame('iframe600.html'); | ||
iframe = iFrameResize({ | ||
log:log, | ||
id:testId, | ||
resizeCallback:function(){ | ||
setTimeout(tearDown.bind(null,iframe),1); | ||
done(); | ||
} | ||
id:testId | ||
})[0]; | ||
mockMsgFromIFrame(iframe,'foo'); | ||
spyOn(iframe.contentWindow,'postMessage').and.callFake(done); | ||
window.postMessage('[iFrameResizerChild]Ready','*'); | ||
}); | ||
afterEach(function(){ | ||
tearDown(iframe); | ||
}) | ||
it('receive message', function() { | ||
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith('[iFrameSizer]parentPage2:8:false:true:32:true:true:null:bodyOffset:null:null:0:false:parent:scroll', 'http://localhost:9876'); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -48,3 +48,20 @@ /* | ||
if (!Array.prototype.forEach) { | ||
Array.prototype.forEach = function(callback, thisArg) { | ||
if (this === null) throw new TypeError(' this is null or not defined'); | ||
if (typeof callback !== 'function') throw new TypeError(callback + ' is not a function'); | ||
var | ||
O = Object(this), | ||
len = O.length >>> 0; | ||
for (var k=0 ; k < len ; k++) { | ||
if (k in O) | ||
callback.call(thisArg, O[k], k, O); | ||
} | ||
}; | ||
} | ||
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence | ||
@@ -79,3 +96,3 @@ (function(win, doc){ | ||
if('Element' in win)win.Element.prototype.addEventListener = addEvent; //IE8 | ||
else{ //IE < 8 | ||
else{ //IE < 8 | ||
doc.attachEvent('onreadystatechange', function(){addListen(doc.all);}); //Make sure we also init at domReady | ||
@@ -82,0 +99,0 @@ docHijack('getElementsByTagName'); |
@@ -478,4 +478,9 @@ /* | ||
getPageInfo: function getPageInfoF(callback){ | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfo'); | ||
if ('function' === typeof callback){ | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfo'); | ||
} else { | ||
pageInfoCallback = callback; | ||
sendMsg(0,0,'pageInfoStop'); | ||
} | ||
}, | ||
@@ -482,0 +487,0 @@ |
@@ -69,2 +69,11 @@ /* | ||
function removeEventListener(el,evt,func){ | ||
/* istanbul ignore else */ // Not testable in phantonJS | ||
if ('removeEventListener' in window){ | ||
el.removeEventListener(evt,func, false); | ||
} else if ('detachEvent' in window){ //IE | ||
el.detachEvent('on'+evt,func); | ||
} | ||
} | ||
function setupRequestAnimationFrame(){ | ||
@@ -152,12 +161,12 @@ var | ||
var | ||
max = Number(settings[iframeId]['max'+Dimension]), | ||
min = Number(settings[iframeId]['min'+Dimension]), | ||
max = Number(settings[iframeId]['max' + Dimension]), | ||
min = Number(settings[iframeId]['min' + Dimension]), | ||
dimension = Dimension.toLowerCase(), | ||
size = Number(messageData[dimension]); | ||
log(iframeId,'Checking '+dimension+' is in range '+min+'-'+max); | ||
log(iframeId,'Checking ' + dimension + ' is in range ' + min + '-' + max); | ||
if (size<min) { | ||
size=min; | ||
log(iframeId,'Set '+dimension+' to min value'); | ||
log(iframeId,'Set ' + dimension + ' to min value'); | ||
} | ||
@@ -167,6 +176,6 @@ | ||
size=max; | ||
log(iframeId,'Set '+dimension+' to max value'); | ||
log(iframeId,'Set ' + dimension + ' to max value'); | ||
} | ||
messageData[dimension]=''+size; | ||
messageData[dimension] = '' + size; | ||
} | ||
@@ -247,18 +256,69 @@ | ||
function sendPageInfoToIframe(){ | ||
function getPageInfo(){ | ||
var | ||
bodyPosition = document.body.getBoundingClientRect(), | ||
iFramePosition = messageData.iframe.getBoundingClientRect(), | ||
position = JSON.stringify({ | ||
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), | ||
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), | ||
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), | ||
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), | ||
scrollTop: window.pageYOffset, | ||
scrollLeft: window.pageXOffset | ||
iFramePosition = messageData.iframe.getBoundingClientRect(); | ||
return JSON.stringify({ | ||
clientHeight: Math.max(document.documentElement.clientHeight, window.innerHeight || 0), | ||
clientWidth: Math.max(document.documentElement.clientWidth, window.innerWidth || 0), | ||
offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10), | ||
offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10), | ||
scrollTop: window.pageYOffset, | ||
scrollLeft: window.pageXOffset | ||
}); | ||
} | ||
function sendPageInfoToIframe(iframe,iframeId){ | ||
function debouncedTrigger(){ | ||
trigger( | ||
'Send Page Info', | ||
'pageInfo:' + getPageInfo(), | ||
iframe, | ||
iframeId | ||
); | ||
} | ||
debouce(debouncedTrigger,32); | ||
} | ||
function startPageInfoMonitor(){ | ||
function setListener(type,func){ | ||
function sendPageInfo(){ | ||
if (settings[id]){ | ||
sendPageInfoToIframe(settings[id].iframe,id); | ||
} else { | ||
stop(); | ||
} | ||
} | ||
['scroll','resize'].forEach(function(evt){ | ||
log(id, type + evt + ' listener for sendPageInfo'); | ||
func(window,evt,sendPageInfo); | ||
}); | ||
} | ||
trigger('Send Page Info','pageInfo:' + position, settings[iframeId].iframe, iframeId); | ||
function stop(){ | ||
setListener('Remove ', removeEventListener); | ||
} | ||
function start(){ | ||
setListener('Add ', addEventListener); | ||
} | ||
var id = iframeId; //Create locally scoped copy of iFrame ID | ||
start(); | ||
settings[id].stopPageInfo = stop; | ||
} | ||
function stopPageInfoMonitor(){ | ||
if (settings[iframeId] && settings[iframeId].stopPageInfo){ | ||
settings[iframeId].stopPageInfo(); | ||
delete settings[iframeId].stopPageInfo; | ||
} | ||
} | ||
function checkIFrameExists(){ | ||
@@ -387,4 +447,8 @@ var retBool = true; | ||
case 'pageInfo': | ||
sendPageInfoToIframe(); | ||
sendPageInfoToIframe(settings[iframeId].iframe,iframeId); | ||
startPageInfoMonitor(); | ||
break; | ||
case 'pageInfoStop': | ||
stopPageInfoMonitor(); | ||
break; | ||
case 'inPageLink': | ||
@@ -563,2 +627,3 @@ findTarget(getMsgBody(9)); | ||
function postMessageToIFrame(){ | ||
var target = settings[id].targetOrigin; | ||
log(id,'[' + calleeMsg + '] Sending msg to iframe['+id+'] ('+msg+') targetOrigin: '+target); | ||
@@ -575,10 +640,16 @@ iframe.contentWindow.postMessage( msgId + msg, target ); | ||
function chkAndSend(){ | ||
if(iframe && 'contentWindow' in iframe && (null !== iframe.contentWindow)){ //Null test for PhantomJS | ||
postMessageToIFrame(); | ||
} else { | ||
iFrameNotFound(); | ||
} | ||
} | ||
id = id || iframe.id; | ||
var target = settings[id].targetOrigin; | ||
if(iframe && 'contentWindow' in iframe){ | ||
postMessageToIFrame(); | ||
} else { | ||
iFrameNotFound(); | ||
if(settings[id]) { | ||
chkAndSend(); | ||
} | ||
} | ||
@@ -870,9 +941,12 @@ | ||
function init(options,element){ | ||
if(!element) { | ||
return; //Stop mootools creating problems | ||
} else if(!element.tagName) { | ||
throw new TypeError('Object is not a valid DOM element'); | ||
} else if ('IFRAME' !== element.tagName.toUpperCase()) { | ||
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>'); | ||
} else { | ||
function chkType(){ | ||
if(!element.tagName) { | ||
throw new TypeError('Object is not a valid DOM element'); | ||
} else if ('IFRAME' !== element.tagName.toUpperCase()) { | ||
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>'); | ||
} | ||
} | ||
if(element) { | ||
chkType(); | ||
setupIFrame(element, options); | ||
@@ -879,0 +953,0 @@ iFrames.push(element); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
764384
84
9097
589