X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/resources/src/jquery/jquery.footHovzer.js diff --git a/resources/src/jquery/jquery.footHovzer.js b/resources/src/jquery/jquery.footHovzer.js new file mode 100644 index 00000000..e601ddb1 --- /dev/null +++ b/resources/src/jquery/jquery.footHovzer.js @@ -0,0 +1,66 @@ +/** + * @class jQuery.plugin.footHovzer + */ +( function ( $ ) { + var $hovzer, footHovzer, $spacer; + + function getHovzer() { + if ( $hovzer === undefined ) { + $hovzer = $( '
' ).appendTo( 'body' ); + } + return $hovzer; + } + + /** + * Utility to stack stuff in an overlay fixed on the bottom of the page. + * + * Usage: + * + * var hovzer = $.getFootHovzer(); + * hovzer.$.append( $myCollection ); + * hovzer.update(); + * + * @static + * @inheritable + * @return {jQuery.footHovzer} + */ + $.getFootHovzer = function () { + footHovzer.$ = getHovzer(); + return footHovzer; + }; + + /** + * @private + * @class jQuery.footHovzer + */ + footHovzer = { + + /** + * @property {jQuery} $ The stack container + */ + + /** + * Update dimensions of stack to account for changes in the subtree. + */ + update: function () { + var $body; + + $body = $( 'body' ); + + if ( $spacer === undefined ) { + $spacer = $( '
' ).attr( 'id', 'jquery-foot-hovzer-spacer' ); + $spacer.appendTo( $body ); + } + // Ensure CSS is applied by browser before using .outerHeight() + setTimeout( function () { + $spacer.css( 'height', getHovzer().outerHeight( /* includeMargin = */ true ) ); + }, 0 ); + } + }; + + /** + * @class jQuery + * @mixins jQuery.plugin.footHovzer + */ + +}( jQuery ) );