X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.footHovzer.js;h=e601ddb1b63e908137a7254133a741c56eae0466;hb=1df6b21c90965ec7bb204d6fbab6082cc5805c3a;hp=56fc32d49226d38b224464fb6621ca93db72797f;hpb=79ebb4b0288b709fb53cff8f7ebc5f50221931c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/jquery/jquery.footHovzer.js b/resources/src/jquery/jquery.footHovzer.js index 56fc32d492..e601ddb1b6 100644 --- a/resources/src/jquery/jquery.footHovzer.js +++ b/resources/src/jquery/jquery.footHovzer.js @@ -1,17 +1,8 @@ /** - * Utility to stack stuff in an overlay fixed on the bottom of the page. - * - * Usage: - * - * var hovzer = $.getFootHovzer(); - * hovzer.$.append( $myCollection ); - * hovzer.update(); - * - * - * @author Timo Tijhof, 2012 + * @class jQuery.plugin.footHovzer */ ( function ( $ ) { - var $hovzer, footHovzer, prevHeight, newHeight; + var $hovzer, footHovzer, $spacer; function getHovzer() { if ( $hovzer === undefined ) { @@ -20,26 +11,56 @@ 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 ( prevHeight === undefined ) { - prevHeight = getHovzer().outerHeight( /*includeMargin=*/true ); - $body.css( 'paddingBottom', '+=' + prevHeight + 'px' ); - } else { - newHeight = getHovzer().outerHeight( true ); - $body.css( 'paddingBottom', ( parseFloat( $body.css( 'paddingBottom' ) ) - prevHeight ) + newHeight ); - - prevHeight = newHeight; + + 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 ); } }; - $.getFootHovzer = function () { - footHovzer.$ = getHovzer(); - return footHovzer; - }; + /** + * @class jQuery + * @mixins jQuery.plugin.footHovzer + */ }( jQuery ) );