Merge "Vector: Rewrite p-personal with nesting."
[lhc/web/wiklou.git] / resources / jquery / jquery.footHovzer.js
1 /**
2 * Utility to stack stuff in an overlay fixed on the bottom of the page.
3 *
4 * Usage:
5 * <code>
6 * var hovzer = $.getFootHovzer();
7 * hovzer.$.append( $myCollection );
8 * hovzer.update();
9 * </code>
10 *
11 * @author Timo Tijhof, 2012
12 */
13 ( function ( $ ) {
14 var $hovzer, footHovzer, prevHeight, newHeight;
15
16 function getHovzer() {
17 if ( $hovzer === undefined ) {
18 $hovzer = $( '<div id="jquery-foot-hovzer"></div>' ).appendTo( 'body' );
19 }
20 return $hovzer;
21 }
22
23 footHovzer = {
24 update: function () {
25 var $body;
26
27 $body = $( 'body' );
28 if ( prevHeight === undefined ) {
29 prevHeight = getHovzer().outerHeight( /*includeMargin=*/true );
30 $body.css( 'paddingBottom', '+=' + prevHeight + 'px' );
31 } else {
32 newHeight = getHovzer().outerHeight( true );
33 $body.css( 'paddingBottom', ( parseFloat( $body.css( 'paddingBottom' ) ) - prevHeight ) + newHeight );
34
35 prevHeight = newHeight;
36 }
37 }
38 };
39
40 $.getFootHovzer = function () {
41 footHovzer.$ = getHovzer();
42 return footHovzer;
43 };
44
45 }( jQuery ) );