File: jquery.iframe-auto-height-plugin.1.9.0.min.js

package info (click to toggle)
mono-tools 4.2-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 13,868 kB
  • sloc: cs: 100,909; sh: 3,845; makefile: 2,040; javascript: 1,557; xml: 126
file content (7 lines) | stat: -rw-r--r-- 2,395 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
/*
  Plugin: iframe autoheight jQuery Plugin
  Version: 1.9.0
  Description: when the page loads set the height of an iframe based on the height of its contents
  see README: http://github.com/house9/jquery-iframe-auto-height 
*/
(function(a){a.fn.iframeAutoHeight=function(b){function d(a){c.debug&&c.debug===!0&&window.console&&console.log(a)}function e(b,c){d("Diagnostics from '"+c+"'");try{d("  "+a(b,window.top.document).contents().find("body")[0].scrollHeight+" for ...find('body')[0].scrollHeight"),d("  "+a(b.contentWindow.document).height()+" for ...contentWindow.document).height()"),d("  "+a(b.contentWindow.document.body).height()+" for ...contentWindow.document.body).height()")}catch(e){d("  unable to check in this state")}d("End diagnostics -> results vary by browser and when diagnostics are requested")}var c=a.extend({heightOffset:0,minHeight:0,callback:function(a){},animate:!1,debug:!1,diagnostics:!1,resetToMinHeight:!1,triggerFunctions:[],heightCalculationOverrides:[]},b);return d(c),this.each(function(){function g(a){var c=null;return jQuery.each(b,function(b,d){if(a[d])return c=f[d],!1}),c===null&&(c=f["default"]),c}function i(b){c.diagnostics&&e(b,"resizeHeight"),c.resetToMinHeight&&c.resetToMinHeight===!0&&(b.style.height=c.minHeight+"px");var f=a(b,window.top.document).contents().find("body"),h=g(a.browser),i=h(b,f,c,a.browser);d(i),i<c.minHeight&&(d("new height is less than minHeight"),i=c.minHeight+c.heightOffset),d("New Height: "+i),c.animate?a(b).animate({height:i+"px"},{duration:500}):b.style.height=i+"px",c.callback.apply(a(b),[{newFrameHeight:i}])}var b=["webkit","mozilla","msie","opera"],f=[];f["default"]=function(a,b,c,d){return b[0].scrollHeight+c.heightOffset},jQuery.each(b,function(a,b){f[b]=f["default"]}),jQuery.each(c.heightCalculationOverrides,function(a,b){f[b.browser]=b.calculation});var h=0;d(this),c.diagnostics&&e(this,"each iframe");if(c.triggerFunctions.length>0){d(c.triggerFunctions.length+" trigger Functions");for(var j=0;j<c.triggerFunctions.length;j++)c.triggerFunctions[j](i,this)}if(a.browser.webkit||a.browser.opera){d("browser is webkit or opera"),a(this).load(function(){var a=0,b=this,e=function(){i(b)};h===0?a=500:b.style.height=c.minHeight+"px",d("load delay: "+a),setTimeout(e,a),h++});var k=a(this).attr("src");a(this).attr("src",""),a(this).attr("src",k)}else a(this).load(function(){i(this)})})}})(jQuery);