e601ddb1b63e908137a7254133a741c56eae0466
[lhc/web/wiklou.git] / resources / src / jquery / jquery.footHovzer.js
1 /**
2 * @class jQuery.plugin.footHovzer
3 */
4 ( function ( $ ) {
5 var $hovzer, footHovzer, $spacer;
6
7 function getHovzer() {
8 if ( $hovzer === undefined ) {
9 $hovzer = $( '<div id="jquery-foot-hovzer"></div>' ).appendTo( 'body' );
10 }
11 return $hovzer;
12 }
13
14 /**
15 * Utility to stack stuff in an overlay fixed on the bottom of the page.
16 *
17 * Usage:
18 *
19 * var hovzer = $.getFootHovzer();
20 * hovzer.$.append( $myCollection );
21 * hovzer.update();
22 *
23 * @static
24 * @inheritable
25 * @return {jQuery.footHovzer}
26 */
27 $.getFootHovzer = function () {
28 footHovzer.$ = getHovzer();
29 return footHovzer;
30 };
31
32 /**
33 * @private
34 * @class jQuery.footHovzer
35 */
36 footHovzer = {
37
38 /**
39 * @property {jQuery} $ The stack container
40 */
41
42 /**
43 * Update dimensions of stack to account for changes in the subtree.
44 */
45 update: function () {
46 var $body;
47
48 $body = $( 'body' );
49
50 if ( $spacer === undefined ) {
51 $spacer = $( '<div>' ).attr( 'id', 'jquery-foot-hovzer-spacer' );
52 $spacer.appendTo( $body );
53 }
54 // Ensure CSS is applied by browser before using .outerHeight()
55 setTimeout( function () {
56 $spacer.css( 'height', getHovzer().outerHeight( /* includeMargin = */ true ) );
57 }, 0 );
58 }
59 };
60
61 /**
62 * @class jQuery
63 * @mixins jQuery.plugin.footHovzer
64 */
65
66 }( jQuery ) );