annotate js/bt/other_libs/bgiframe_2.1.1/jquery.bgiframe.js @ 18:0d557e6e73f7

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