eads@18: /* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
eads@18: * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
eads@18: * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
eads@18: *
eads@18: * $LastChangedDate: 2007-07-21 18:44:59 -0500 (Sat, 21 Jul 2007) $
eads@18: * $Rev: 2446 $
eads@18: *
eads@18: * Version 2.1.1
eads@18: */
eads@18:
eads@18: (function($){
eads@18:
eads@18: /**
eads@18: * The bgiframe is chainable and applies the iframe hack to get
eads@18: * around zIndex issues in IE6. It will only apply itself in IE6
eads@18: * and adds a class to the iframe called 'bgiframe'. The iframe
eads@18: * is appeneded as the first child of the matched element(s)
eads@18: * with a tabIndex and zIndex of -1.
eads@18: *
eads@18: * By default the plugin will take borders, sized with pixel units,
eads@18: * into account. If a different unit is used for the border's width,
eads@18: * then you will need to use the top and left settings as explained below.
eads@18: *
eads@18: * NOTICE: This plugin has been reported to cause perfromance problems
eads@18: * when used on elements that change properties (like width, height and
eads@18: * opacity) a lot in IE6. Most of these problems have been caused by
eads@18: * the expressions used to calculate the elements width, height and
eads@18: * borders. Some have reported it is due to the opacity filter. All
eads@18: * these settings can be changed if needed as explained below.
eads@18: *
eads@18: * @example $('div').bgiframe();
eads@18: * @before
eads@18: * @result
eads@18: *
eads@18: * @param Map settings Optional settings to configure the iframe.
eads@18: * @option String|Number top The iframe must be offset to the top
eads@18: * by the width of the top border. This should be a negative
eads@18: * number representing the border-top-width. If a number is
eads@18: * is used here, pixels will be assumed. Otherwise, be sure
eads@18: * to specify a unit. An expression could also be used.
eads@18: * By default the value is "auto" which will use an expression
eads@18: * to get the border-top-width if it is in pixels.
eads@18: * @option String|Number left The iframe must be offset to the left
eads@18: * by the width of the left border. This should be a negative
eads@18: * number representing the border-left-width. If a number is
eads@18: * is used here, pixels will be assumed. Otherwise, be sure
eads@18: * to specify a unit. An expression could also be used.
eads@18: * By default the value is "auto" which will use an expression
eads@18: * to get the border-left-width if it is in pixels.
eads@18: * @option String|Number width This is the width of the iframe. If
eads@18: * a number is used here, pixels will be assume. Otherwise, be sure
eads@18: * to specify a unit. An experssion could also be used.
eads@18: * By default the value is "auto" which will use an experssion
eads@18: * to get the offsetWidth.
eads@18: * @option String|Number height This is the height of the iframe. If
eads@18: * a number is used here, pixels will be assume. Otherwise, be sure
eads@18: * to specify a unit. An experssion could also be used.
eads@18: * By default the value is "auto" which will use an experssion
eads@18: * to get the offsetHeight.
eads@18: * @option Boolean opacity This is a boolean representing whether or not
eads@18: * to use opacity. If set to true, the opacity of 0 is applied. If
eads@18: * set to false, the opacity filter is not applied. Default: true.
eads@18: * @option String src This setting is provided so that one could change
eads@18: * the src of the iframe to whatever they need.
eads@18: * Default: "javascript:false;"
eads@18: *
eads@18: * @name bgiframe
eads@18: * @type jQuery
eads@18: * @cat Plugins/bgiframe
eads@18: * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
eads@18: */
eads@18: $.fn.bgIframe = $.fn.bgiframe = function(s) {
eads@18: // This is only for IE6
eads@18: if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
eads@18: s = $.extend({
eads@18: top : 'auto', // auto == .currentStyle.borderTopWidth
eads@18: left : 'auto', // auto == .currentStyle.borderLeftWidth
eads@18: width : 'auto', // auto == offsetWidth
eads@18: height : 'auto', // auto == offsetHeight
eads@18: opacity : true,
eads@18: src : 'javascript:false;'
eads@18: }, s || {});
eads@18: var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
eads@18: html = '';
eads@18: return this.each(function() {
eads@18: if ( $('> iframe.bgiframe', this).length == 0 )
eads@18: this.insertBefore( document.createElement(html), this.firstChild );
eads@18: });
eads@18: }
eads@18: return this;
eads@18: };
eads@18:
eads@18: })(jQuery);