Sha256: 147e07ca7b7ff8d30c15f05f6216ff043608997221a9a1f1c082f74cec9efa2f

Contents?: true

Size: 1.9 KB

Versions: 33

Compression:

Stored size: 1.9 KB

Contents

/* 	
    Plugin: iframe autoheight jQuery Plugin 
    Author: original code by NATHAN SMITH; converted to plugin by Jesse House
    File: jquery.iframe-auto-height.plugin.js
    Description: when the page loads set the height of an iframe based on the height of its contents
    Remarks: original code from http://sonspring.com/journal/jquery-iframe-sizing    
    Version: 1.0.0 - see README: http://github.com/house9/jquery-iframe-auto-height
*/
(function ($) {
    $.fn.iframeAutoHeight = function (options) {
        // set default option values
        var options = $.extend({
            heightOffset: 0
        }, options);

        // iterate over the matched elements passed to the plugin
        $(this).each(function () {
            // Check if browser is Opera or Safari(Webkit so Chrome as well)
            if ($.browser.safari || $.browser.opera) {
                // Start timer when loaded.
                $(this).load(function () {
                    var iframe = this;
                    var delayedResize = function () {
                        resizeHeight(iframe);
                    };
                    setTimeout(delayedResize, 0);
                });

                // Safari and Opera need a kick-start.
                var source = $(this).attr('src');
                $(this).attr('src', '');
                $(this).attr('src', source);
            }
            else {
                // For other browsers.
                $(this).load(function () {
                    resizeHeight(this);
                });
            }

            // resizeHeight
            function resizeHeight(iframe) {
                // Set inline style to equal the body height of the iframed content plus a little
                var newHeight = iframe.contentWindow.document.body.offsetHeight + options.heightOffset;
                iframe.style.height = newHeight + 'px';
            }

        }); // end
    }
})(jQuery);

Version data entries

33 entries across 17 versions & 1 rubygems

Version Path
mail_engine-0.1.15 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.15 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.14 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.14 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.13 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.13 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.12 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.12 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.11 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.11 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.10 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.10 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.9 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.9 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.8 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.8 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.7 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.7 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.6 test/dummy/public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js
mail_engine-0.1.6 public/javascripts/mail_engine/jquery.iframe-auto-height.plugin.js