app/jquery/jquery-bgiframe.js
author Sverre Rabbelier <srabbelier@gmail.com>
Thu, 19 Mar 2009 23:25:34 +0000
changeset 1942 832a1e80eee0
parent 1235 41cb87ed9b81
permissions -rw-r--r--
Verbiage fix in Mentor list heading Patch by: Sverre Rabbelier
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1212
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
 * $LastChangedDate: 2007-07-21 18:44:59 -0500 (Sat, 21 Jul 2007) $
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
 * $Rev: 2446 $
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
 * Version 2.1.1
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
 */
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
(function($){
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
/**
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
 * The bgiframe is chainable and applies the iframe hack to get
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
 * around zIndex issues in IE6. It will only apply itself in IE6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
 * and adds a class to the iframe called 'bgiframe'. The iframe
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
 * is appeneded as the first child of the matched element(s)
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
 * with a tabIndex and zIndex of -1.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
 * By default the plugin will take borders, sized with pixel units,
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
 * into account. If a different unit is used for the border's width,
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
 * then you will need to use the top and left settings as explained below.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
 * NOTICE: This plugin has been reported to cause perfromance problems
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
 * when used on elements that change properties (like width, height and
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
 * opacity) a lot in IE6. Most of these problems have been caused by
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
 * the expressions used to calculate the elements width, height and
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
 * borders. Some have reported it is due to the opacity filter. All
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
 * these settings can be changed if needed as explained below.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
 * @example $('div').bgiframe();
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
 * @before <div><p>Paragraph</p></div>
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
 * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
 * @param Map settings Optional settings to configure the iframe.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
 * @option String|Number top The iframe must be offset to the top
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
 * 		by the width of the top border. This should be a negative
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
 *      number representing the border-top-width. If a number is
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
 * 		is used here, pixels will be assumed. Otherwise, be sure
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
 *		to specify a unit. An expression could also be used.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
 * 		By default the value is "auto" which will use an expression
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
 * 		to get the border-top-width if it is in pixels.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
 * @option String|Number left The iframe must be offset to the left
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
 * 		by the width of the left border. This should be a negative
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
 *      number representing the border-left-width. If a number is
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
 * 		is used here, pixels will be assumed. Otherwise, be sure
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
 *		to specify a unit. An expression could also be used.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
 * 		By default the value is "auto" which will use an expression
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
 * 		to get the border-left-width if it is in pixels.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
 * @option String|Number width This is the width of the iframe. If
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
 *		a number is used here, pixels will be assume. Otherwise, be sure
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
 * 		to specify a unit. An experssion could also be used.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
 *		By default the value is "auto" which will use an experssion
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
 * 		to get the offsetWidth.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
 * @option String|Number height This is the height of the iframe. If
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
 *		a number is used here, pixels will be assume. Otherwise, be sure
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
 * 		to specify a unit. An experssion could also be used.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
 *		By default the value is "auto" which will use an experssion
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
 * 		to get the offsetHeight.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
 * @option Boolean opacity This is a boolean representing whether or not
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
 * 		to use opacity. If set to true, the opacity of 0 is applied. If
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
 *		set to false, the opacity filter is not applied. Default: true.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
 * @option String src This setting is provided so that one could change
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
 *		the src of the iframe to whatever they need.
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
 *		Default: "javascript:false;"
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
 *
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
 * @name bgiframe
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
 * @type jQuery
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
 * @cat Plugins/bgiframe
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
 */
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
$.fn.bgIframe = $.fn.bgiframe = function(s) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
	// This is only for IE6
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
	if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
		s = $.extend({
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
			top     : 'auto', // auto == .currentStyle.borderTopWidth
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
			width   : 'auto', // auto == offsetWidth
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
			height  : 'auto', // auto == offsetHeight
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
			opacity : true,
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    81
			src     : 'javascript:false;'
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
		}, s || {});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
		var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    85
		               'style="display:block;position:absolute;z-index:-1;'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
			               (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
					       'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
					       'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
					       'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
					       'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
					'"/>';
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    92
		return this.each(function() {
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
			if ( $('> iframe.bgiframe', this).length == 0 )
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
				this.insertBefore( document.createElement(html), this.firstChild );
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    95
		});
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    96
	}
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
	return this;
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
};
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
1b64b5922227 Added jquery thickbox, ajaxQueue, autocomplete and bgiframe
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
})(jQuery);