annotate DataTables-1.9.4/extras/FixedHeader/js/FixedHeader.js @ 1:440f4aa3db97 draft

Added option to dowload iReports
author saskia-hiltemann
date Wed, 30 Jul 2014 07:03:43 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 * File: FixedHeader.js
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 * Version: 2.0.6
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 * Description: "Fix" a header at the top of the table, so it scrolls with the table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 * Author: Allan Jardine (www.sprymedia.co.uk)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 * Created: Wed 16 Sep 2009 19:46:30 BST
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 * Language: Javascript
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 * License: GPL v2 or BSD 3 point style
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 * Project: Just a little bit of fun - enjoy :-)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 * Contact: www.sprymedia.co.uk/contact
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 * Copyright 2009-2012 Allan Jardine, all rights reserved.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 * This source file is free software, under either the GPL v2 license or a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 * BSD style license, available at:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 * http://datatables.net/license_gpl2
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 * http://datatables.net/license_bsd
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 * Function: FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 * Purpose: Provide 'fixed' header, footer and columns on an HTML table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 * Returns: object:FixedHeader - must be called with 'new'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 * Inputs: mixed:mTable - target table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 * 1. DataTable object - when using FixedHeader with DataTables, or
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 * 2. HTML table node - when using FixedHeader without DataTables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 * object:oInit - initialisation settings, with the following properties (each optional)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 * bool:top - fix the header (default true)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 * bool:bottom - fix the footer (default false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 * bool:left - fix the left most column (default false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 * bool:right - fix the right most column (default false)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 * int:zTop - fixed header zIndex
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 * int:zBottom - fixed footer zIndex
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 * int:zLeft - fixed left zIndex
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 * int:zRight - fixed right zIndex
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 var FixedHeader = function ( mTable, oInit ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 /* Sanity check - you just know it will happen */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 if ( typeof this.fnInit != 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 alert( "FixedHeader warning: FixedHeader must be initialised with the 'new' keyword." );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 var that = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 var oSettings = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 "aoCache": [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 "oSides": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 "top": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 "bottom": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 "left": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 "right": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 "oZIndexes": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 "top": 104,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 "bottom": 103,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 "left": 102,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 "right": 101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 "oMes": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 "iTableWidth": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 "iTableHeight": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 "iTableLeft": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 "iTableRight": 0, /* note this is left+width, not actually "right" */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 "iTableTop": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 "iTableBottom": 0 /* note this is top+height, not actually "bottom" */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 "oOffset": {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 "top": 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 "nTable": null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 "bUseAbsPos": false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 "bFooter": false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 * Function: fnGetSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 * Purpose: Get the settings for this object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 * Returns: object: - settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 this.fnGetSettings = function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 return oSettings;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 * Function: fnUpdate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 * Purpose: Update the positioning and copies of the fixed elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 this.fnUpdate = function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 this._fnUpdateClones();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 this._fnUpdatePositions();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 * Function: fnPosition
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 * Purpose: Update the positioning of the fixed elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 this.fnPosition = function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 this._fnUpdatePositions();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 /* Let's do it */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 this.fnInit( mTable, oInit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110 /* Store the instance on the DataTables object for easy access */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 if ( typeof mTable.fnSettings == 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 mTable._oPluginFixedHeader = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 * Variable: FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 * Purpose: Prototype for FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 * Scope: global
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 FixedHeader.prototype = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125 * Initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 * Function: fnInit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 * Purpose: The "constructor"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 * Inputs: {as FixedHeader function}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134 fnInit: function ( oTable, oInit )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137 var that = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 /* Record the user definable settings */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140 this.fnInitSettings( s, oInit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
141
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
142 /* DataTables specific stuff */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
143 if ( typeof oTable.fnSettings == 'function' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
144 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
145 if ( typeof oTable.fnVersionCheck == 'functon' &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
146 oTable.fnVersionCheck( '1.6.0' ) !== true )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
147 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
148 alert( "FixedHeader 2 required DataTables 1.6.0 or later. "+
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
149 "Please upgrade your DataTables installation" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
150 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
151 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
152
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
153 var oDtSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
154
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
155 if ( oDtSettings.oScroll.sX != "" || oDtSettings.oScroll.sY != "" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
156 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
157 alert( "FixedHeader 2 is not supported with DataTables' scrolling mode at this time" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
158 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
159 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
160
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
161 s.nTable = oDtSettings.nTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
162 oDtSettings.aoDrawCallback.push( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
163 "fn": function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
164 FixedHeader.fnMeasure();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
165 that._fnUpdateClones.call(that);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
166 that._fnUpdatePositions.call(that);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
167 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
168 "sName": "FixedHeader"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
169 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
171 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
172 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
173 s.nTable = oTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
174 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
175
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
176 s.bFooter = ($('>tfoot', s.nTable).length > 0) ? true : false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
177
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
178 /* "Detect" browsers that don't support absolute positioing - or have bugs */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
179 s.bUseAbsPos = (jQuery.browser.msie && (jQuery.browser.version=="6.0"||jQuery.browser.version=="7.0"));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
180
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
181 /* Add the 'sides' that are fixed */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
182 if ( s.oSides.top )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
183 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
184 s.aoCache.push( that._fnCloneTable( "fixedHeader", "FixedHeader_Header", that._fnCloneThead ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
185 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
186 if ( s.oSides.bottom )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
187 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
188 s.aoCache.push( that._fnCloneTable( "fixedFooter", "FixedHeader_Footer", that._fnCloneTfoot ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
189 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
190 if ( s.oSides.left )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
191 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
192 s.aoCache.push( that._fnCloneTable( "fixedLeft", "FixedHeader_Left", that._fnCloneTLeft ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
193 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
194 if ( s.oSides.right )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
195 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
196 s.aoCache.push( that._fnCloneTable( "fixedRight", "FixedHeader_Right", that._fnCloneTRight ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
198
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
199 /* Event listeners for window movement */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
200 FixedHeader.afnScroll.push( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
201 that._fnUpdatePositions.call(that);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
202 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
203
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
204 jQuery(window).resize( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
205 FixedHeader.fnMeasure();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
206 that._fnUpdateClones.call(that);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
207 that._fnUpdatePositions.call(that);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
208 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
210 /* Get things right to start with */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
211 FixedHeader.fnMeasure();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
212 that._fnUpdateClones();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
213 that._fnUpdatePositions();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
214 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
217 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
218 * Support functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
219 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
221 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
222 * Function: fnInitSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
223 * Purpose: Take the user's settings and copy them to our local store
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
224 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
225 * Inputs: object:s - the local settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
226 * object:oInit - the user's settings object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
227 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
228 fnInitSettings: function ( s, oInit )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
229 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
230 if ( typeof oInit != 'undefined' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
231 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
232 if ( typeof oInit.top != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
233 s.oSides.top = oInit.top;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
234 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
235 if ( typeof oInit.bottom != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
236 s.oSides.bottom = oInit.bottom;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
237 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
238 if ( typeof oInit.left != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
239 s.oSides.left = oInit.left;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
240 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
241 if ( typeof oInit.right != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
242 s.oSides.right = oInit.right;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
243 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
244
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
245 if ( typeof oInit.zTop != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
246 s.oZIndexes.top = oInit.zTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
247 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
248 if ( typeof oInit.zBottom != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
249 s.oZIndexes.bottom = oInit.zBottom;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
250 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
251 if ( typeof oInit.zLeft != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
252 s.oZIndexes.left = oInit.zLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
253 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
254 if ( typeof oInit.zRight != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
255 s.oZIndexes.right = oInit.zRight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
256 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
258 if ( typeof oInit.offsetTop != 'undefined' ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
259 s.oOffset.top = oInit.offsetTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
260 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
261 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
262
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
263 /* Detect browsers which have poor position:fixed support so we can use absolute positions.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
264 * This is much slower since the position must be updated for each scroll, but widens
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
265 * compatibility
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
266 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
267 s.bUseAbsPos = (jQuery.browser.msie &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
268 (jQuery.browser.version=="6.0"||jQuery.browser.version=="7.0"));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
269 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
271 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
272 * Function: _fnCloneTable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
273 * Purpose: Clone the table node and do basic initialisation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
274 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
275 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
276 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
277 _fnCloneTable: function ( sType, sClass, fnClone )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
278 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
279 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
280 var nCTable;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
281
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
282 /* We know that the table _MUST_ has a DIV wrapped around it, because this is simply how
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
283 * DataTables works. Therefore, we can set this to be relatively position (if it is not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
284 * alreadu absolute, and use this as the base point for the cloned header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
285 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
286 if ( jQuery(s.nTable.parentNode).css('position') != "absolute" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
287 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
288 s.nTable.parentNode.style.position = "relative";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
289 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
290
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
291 /* Just a shallow clone will do - we only want the table node */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
292 nCTable = s.nTable.cloneNode( false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
293 nCTable.removeAttribute( 'id' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
294
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
295 var nDiv = document.createElement( 'div' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
296 nDiv.style.position = "absolute";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
297 nDiv.style.top = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
298 nDiv.style.left = "0px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
299 nDiv.className += " FixedHeader_Cloned "+sType+" "+sClass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
300
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
301 /* Set the zIndexes */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
302 if ( sType == "fixedHeader" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
303 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
304 nDiv.style.zIndex = s.oZIndexes.top;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
305 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
306 if ( sType == "fixedFooter" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
307 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
308 nDiv.style.zIndex = s.oZIndexes.bottom;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
309 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
310 if ( sType == "fixedLeft" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
311 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
312 nDiv.style.zIndex = s.oZIndexes.left;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
313 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
314 else if ( sType == "fixedRight" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
315 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
316 nDiv.style.zIndex = s.oZIndexes.right;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
317 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
318
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
319 /* remove margins since we are going to poistion it absolutely */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
320 nCTable.style.margin = "0";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
322 /* Insert the newly cloned table into the DOM, on top of the "real" header */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
323 nDiv.appendChild( nCTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
324 document.body.appendChild( nDiv );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
326 return {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
327 "nNode": nCTable,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
328 "nWrapper": nDiv,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
329 "sType": sType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
330 "sPosition": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
331 "sTop": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
332 "sLeft": "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
333 "fnClone": fnClone
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
334 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
335 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
336
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
337 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
338 * Function: _fnUpdatePositions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
339 * Purpose: Get the current positioning of the table in the DOM
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
340 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
341 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
342 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
343 _fnMeasure: function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
344 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
345 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
346 s = this.fnGetSettings(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
347 m = s.oMes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
348 jqTable = jQuery(s.nTable),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
349 oOffset = jqTable.offset(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
350 iParentScrollTop = this._fnSumScroll( s.nTable.parentNode, 'scrollTop' ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
351 iParentScrollLeft = this._fnSumScroll( s.nTable.parentNode, 'scrollLeft' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
352
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
353 m.iTableWidth = jqTable.outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
354 m.iTableHeight = jqTable.outerHeight();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
355 m.iTableLeft = oOffset.left + s.nTable.parentNode.scrollLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
356 m.iTableTop = oOffset.top + iParentScrollTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
357 m.iTableRight = m.iTableLeft + m.iTableWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
358 m.iTableRight = FixedHeader.oDoc.iWidth - m.iTableLeft - m.iTableWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
359 m.iTableBottom = FixedHeader.oDoc.iHeight - m.iTableTop - m.iTableHeight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
360 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
361
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
362 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
363 * Function: _fnSumScroll
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
364 * Purpose: Sum node parameters all the way to the top
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
365 * Returns: int: sum
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
366 * Inputs: node:n - node to consider
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
367 * string:side - scrollTop or scrollLeft
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
368 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
369 _fnSumScroll: function ( n, side )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
370 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
371 var i = n[side];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
372 while ( n = n.parentNode )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
373 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
374 if ( n.nodeName == 'HTML' || n.nodeName == 'BODY' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
375 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
376 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
378 i = n[side];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
379 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
380 return i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
381 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
382
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
383 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
384 * Function: _fnUpdatePositions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
385 * Purpose: Loop over the fixed elements for this table and update their positions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
386 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
387 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
388 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
389 _fnUpdatePositions: function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
390 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
391 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
392 this._fnMeasure();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
393
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
394 for ( var i=0, iLen=s.aoCache.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
395 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
396 if ( s.aoCache[i].sType == "fixedHeader" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
397 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
398 this._fnScrollFixedHeader( s.aoCache[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
399 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
400 else if ( s.aoCache[i].sType == "fixedFooter" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
401 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
402 this._fnScrollFixedFooter( s.aoCache[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
403 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
404 else if ( s.aoCache[i].sType == "fixedLeft" )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
405 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
406 this._fnScrollHorizontalLeft( s.aoCache[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
407 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
408 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
409 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
410 this._fnScrollHorizontalRight( s.aoCache[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
411 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
412 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
413 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
414
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
415 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
416 * Function: _fnUpdateClones
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
417 * Purpose: Loop over the fixed elements for this table and call their cloning functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
418 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
419 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
420 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
421 _fnUpdateClones: function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
422 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
423 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
424 for ( var i=0, iLen=s.aoCache.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
425 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
426 s.aoCache[i].fnClone.call( this, s.aoCache[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
427 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
428 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
429
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
430
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
431 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
432 * Scrolling functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
433 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
435 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
436 * Function: _fnScrollHorizontalLeft
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
437 * Purpose: Update the positioning of the scrolling elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
438 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
439 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
440 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
441 _fnScrollHorizontalRight: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
442 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
443 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
444 s = this.fnGetSettings(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
445 oMes = s.oMes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
446 oWin = FixedHeader.oWin,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
447 oDoc = FixedHeader.oDoc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
448 nTable = oCache.nWrapper,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
449 iFixedWidth = jQuery(nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
450
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
451 if ( oWin.iScrollRight < oMes.iTableRight )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
452 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
453 /* Fully right aligned */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
454 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
455 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
456 this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft+oMes.iTableWidth-iFixedWidth)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
457 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
458 else if ( oMes.iTableLeft < oDoc.iWidth-oWin.iScrollRight-iFixedWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
459 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
460 /* Middle */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
461 if ( s.bUseAbsPos )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
462 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
463 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
464 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
465 this._fnUpdateCache( oCache, 'sLeft', (oDoc.iWidth-oWin.iScrollRight-iFixedWidth)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
466 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
467 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
468 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
469 this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
470 this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop-oWin.iScrollTop)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
471 this._fnUpdateCache( oCache, 'sLeft', (oWin.iWidth-iFixedWidth)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
472 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
473 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
474 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
475 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
476 /* Fully left aligned */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
477 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
478 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
479 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
481 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
482
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
483 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
484 * Function: _fnScrollHorizontalLeft
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
485 * Purpose: Update the positioning of the scrolling elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
486 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
487 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
488 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
489 _fnScrollHorizontalLeft: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
490 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
491 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
492 s = this.fnGetSettings(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
493 oMes = s.oMes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
494 oWin = FixedHeader.oWin,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
495 oDoc = FixedHeader.oDoc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
496 nTable = oCache.nWrapper,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
497 iCellWidth = jQuery(nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
498
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
499 if ( oWin.iScrollLeft < oMes.iTableLeft )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
500 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
501 /* Fully left align */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
502 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
503 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
504 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
505 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
506 else if ( oWin.iScrollLeft < oMes.iTableLeft+oMes.iTableWidth-iCellWidth )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
507 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
508 /* Middle */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
509 if ( s.bUseAbsPos )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
510 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
511 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
512 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
513 this._fnUpdateCache( oCache, 'sLeft', oWin.iScrollLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
514 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
515 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
516 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
517 this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
518 this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop-oWin.iScrollTop)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
519 this._fnUpdateCache( oCache, 'sLeft', "0px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
520 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
521 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
522 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
523 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
524 /* Fully right align */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
525 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
526 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
527 this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft+oMes.iTableWidth-iCellWidth)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
528 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
529 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
530
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
531 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
532 * Function: _fnScrollFixedFooter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
533 * Purpose: Update the positioning of the scrolling elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
534 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
535 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
536 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
537 _fnScrollFixedFooter: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
538 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
539 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
540 s = this.fnGetSettings(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
541 oMes = s.oMes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
542 oWin = FixedHeader.oWin,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
543 oDoc = FixedHeader.oDoc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
544 nTable = oCache.nWrapper,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
545 iTheadHeight = jQuery("thead", s.nTable).outerHeight(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
546 iCellHeight = jQuery(nTable).outerHeight();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
547
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
548 if ( oWin.iScrollBottom < oMes.iTableBottom )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
549 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
550 /* Below */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
551 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
552 this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+oMes.iTableHeight-iCellHeight)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
553 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
554 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
555 else if ( oWin.iScrollBottom < oMes.iTableBottom+oMes.iTableHeight-iCellHeight-iTheadHeight )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
556 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
557 /* Middle */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
558 if ( s.bUseAbsPos )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
559 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
560 this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
561 this._fnUpdateCache( oCache, 'sTop', (oDoc.iHeight-oWin.iScrollBottom-iCellHeight)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
562 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
563 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
564 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
565 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
566 this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
567 this._fnUpdateCache( oCache, 'sTop', (oWin.iHeight-iCellHeight)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
568 this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
569 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
570 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
571 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
572 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
573 /* Above */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
574 this._fnUpdateCache( oCache, 'sPosition', 'absolute', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
575 this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iCellHeight)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
576 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
577 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
578 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
579
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
580 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
581 * Function: _fnScrollFixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
582 * Purpose: Update the positioning of the scrolling elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
583 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
584 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
585 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
586 _fnScrollFixedHeader: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
587 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
588 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
589 s = this.fnGetSettings(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
590 oMes = s.oMes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
591 oWin = FixedHeader.oWin,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
592 oDoc = FixedHeader.oDoc,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
593 nTable = oCache.nWrapper,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
594 iTbodyHeight = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
595 anTbodies = s.nTable.getElementsByTagName('tbody');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
596
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
597 for (var i = 0; i < anTbodies.length; ++i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
598 iTbodyHeight += anTbodies[i].offsetHeight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
599 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
600
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
601 if ( oMes.iTableTop > oWin.iScrollTop + s.oOffset.top )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
602 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
603 /* Above the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
604 this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
605 this._fnUpdateCache( oCache, 'sTop', oMes.iTableTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
606 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
607 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
608 else if ( oWin.iScrollTop + s.oOffset.top > oMes.iTableTop+iTbodyHeight )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
609 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
610 /* At the bottom of the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
611 this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
612 this._fnUpdateCache( oCache, 'sTop', (oMes.iTableTop+iTbodyHeight)+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
613 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
614 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
615 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
616 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
617 /* In the middle of the table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
618 if ( s.bUseAbsPos )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
619 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
620 this._fnUpdateCache( oCache, 'sPosition', "absolute", 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
621 this._fnUpdateCache( oCache, 'sTop', oWin.iScrollTop+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
622 this._fnUpdateCache( oCache, 'sLeft', oMes.iTableLeft+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
623 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
624 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
625 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
626 this._fnUpdateCache( oCache, 'sPosition', 'fixed', 'position', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
627 this._fnUpdateCache( oCache, 'sTop', s.oOffset.top+"px", 'top', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
628 this._fnUpdateCache( oCache, 'sLeft', (oMes.iTableLeft-oWin.iScrollLeft)+"px", 'left', nTable.style );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
629 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
631 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
632
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
633 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
634 * Function: _fnUpdateCache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
635 * Purpose: Check the cache and update cache and value if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
636 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
637 * Inputs: object:oCache - local cache object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
638 * string:sCache - cache property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
639 * string:sSet - value to set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
640 * string:sProperty - object property to set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
641 * object:oObj - object to update
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
642 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
643 _fnUpdateCache: function ( oCache, sCache, sSet, sProperty, oObj )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
644 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
645 if ( oCache[sCache] != sSet )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
646 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
647 oObj[sProperty] = sSet;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
648 oCache[sCache] = sSet;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
649 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
650 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
651
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
653
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
654 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
655 * Cloning functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
656 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
657
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
658 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
659 * Function: _fnCloneThead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
660 * Purpose: Clone the thead element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
661 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
662 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
663 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
664 _fnCloneThead: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
665 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
666 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
667 var nTable = oCache.nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
669 /* Set the wrapper width to match that of the cloned table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
670 oCache.nWrapper.style.width = jQuery(s.nTable).outerWidth()+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
671
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
672 /* Remove any children the cloned table has */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
673 while ( nTable.childNodes.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
674 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
675 jQuery('thead th', nTable).unbind( 'click' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
676 nTable.removeChild( nTable.childNodes[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
677 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
678
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
679 /* Clone the DataTables header */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
680 var nThead = jQuery('thead', s.nTable).clone(true)[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
681 nTable.appendChild( nThead );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
682
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
683 /* Copy the widths across - apparently a clone isn't good enough for this */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
684 jQuery("thead>tr th", s.nTable).each( function (i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
685 jQuery("thead>tr th:eq("+i+")", nTable).width( jQuery(this).width() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
686 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
688 jQuery("thead>tr td", s.nTable).each( function (i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
689 jQuery("thead>tr td:eq("+i+")", nTable).width( jQuery(this).width() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
690 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
691 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
692
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
693 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
694 * Function: _fnCloneTfoot
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
695 * Purpose: Clone the tfoot element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
696 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
697 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
698 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
699 _fnCloneTfoot: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
700 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
701 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
702 var nTable = oCache.nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
704 /* Set the wrapper width to match that of the cloned table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
705 oCache.nWrapper.style.width = jQuery(s.nTable).outerWidth()+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
706
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
707 /* Remove any children the cloned table has */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
708 while ( nTable.childNodes.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
709 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
710 nTable.removeChild( nTable.childNodes[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
711 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
712
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
713 /* Clone the DataTables footer */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
714 var nTfoot = jQuery('tfoot', s.nTable).clone(true)[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
715 nTable.appendChild( nTfoot );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
716
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
717 /* Copy the widths across - apparently a clone isn't good enough for this */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
718 jQuery("tfoot:eq(0)>tr th", s.nTable).each( function (i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
719 jQuery("tfoot:eq(0)>tr th:eq("+i+")", nTable).width( jQuery(this).width() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
720 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
722 jQuery("tfoot:eq(0)>tr td", s.nTable).each( function (i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
723 jQuery("tfoot:eq(0)>tr th:eq("+i+")", nTable)[0].style.width( jQuery(this).width() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
724 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
725 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
726
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
727 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
728 * Function: _fnCloneTLeft
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
729 * Purpose: Clone the left column
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
730 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
731 * Inputs: object:oCache - the cached values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
732 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
733 _fnCloneTLeft: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
734 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
735 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
736 var nTable = oCache.nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
737 var nBody = $('tbody', s.nTable)[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
738 var iCols = $('tbody tr:eq(0) td', s.nTable).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
739 var bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
740
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
741 /* Remove any children the cloned table has */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
742 while ( nTable.childNodes.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
743 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
744 nTable.removeChild( nTable.childNodes[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
745 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
746
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
747 /* Is this the most efficient way to do this - it looks horrible... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
748 nTable.appendChild( jQuery("thead", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
749 nTable.appendChild( jQuery("tbody", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
750 if ( s.bFooter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
751 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
752 nTable.appendChild( jQuery("tfoot", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
753 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
754
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
755 /* Remove unneeded cells */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
756 $('thead tr', nTable).each( function (k) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
757 $('th:gt(0)', this).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
758 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
759
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
760 $('tfoot tr', nTable).each( function (k) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
761 $('th:gt(0)', this).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
762 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
763
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
764 $('tbody tr', nTable).each( function (k) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
765 $('td:gt(0)', this).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
766 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
767
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
768 this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
769
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
770 var iWidth = jQuery('thead tr th:eq(0)', s.nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
771 nTable.style.width = iWidth+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
772 oCache.nWrapper.style.width = iWidth+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
773 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
774
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
775 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
776 * Function: _fnCloneTRight
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
777 * Purpose: Clone the right most colun
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
778 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
779 * Inputs: object:oCache - the cahced values for this fixed element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
780 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
781 _fnCloneTRight: function ( oCache )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
782 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
783 var s = this.fnGetSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
784 var nBody = $('tbody', s.nTable)[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
785 var nTable = oCache.nNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
786 var iCols = jQuery('tbody tr:eq(0) td', s.nTable).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
787 var bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
788
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
789 /* Remove any children the cloned table has */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
790 while ( nTable.childNodes.length > 0 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
791 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
792 nTable.removeChild( nTable.childNodes[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
793 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
794
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
795 /* Is this the most efficient way to do this - it looks horrible... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
796 nTable.appendChild( jQuery("thead", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
797 nTable.appendChild( jQuery("tbody", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
798 if ( s.bFooter )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
799 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
800 nTable.appendChild( jQuery("tfoot", s.nTable).clone(true)[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
801 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
802 jQuery('thead tr th:not(:nth-child('+iCols+'n))', nTable).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
803 jQuery('tfoot tr th:not(:nth-child('+iCols+'n))', nTable).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
804
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
805 /* Remove unneeded cells */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
806 $('tbody tr', nTable).each( function (k) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
807 $('td:lt('+(iCols-1)+')', this).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
808 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
809
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
810 this.fnEqualiseHeights( 'tbody', nBody.parentNode, nTable );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
811
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
812 var iWidth = jQuery('thead tr th:eq('+(iCols-1)+')', s.nTable).outerWidth();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
813 nTable.style.width = iWidth+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
814 oCache.nWrapper.style.width = iWidth+"px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
815 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
816
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
818 /**
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
819 * Equalise the heights of the rows in a given table node in a cross browser way. Note that this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
820 * is more or less lifted as is from FixedColumns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
821 * @method fnEqualiseHeights
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
822 * @returns void
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
823 * @param {string} parent Node type - thead, tbody or tfoot
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
824 * @param {element} original Original node to take the heights from
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
825 * @param {element} clone Copy the heights to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
826 * @private
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
827 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
828 "fnEqualiseHeights": function ( parent, original, clone )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
829 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
830 var that = this,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
831 jqBoxHack = $(parent+' tr:eq(0)', original).children(':eq(0)'),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
832 iBoxHack = jqBoxHack.outerHeight() - jqBoxHack.height(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
833 bRubbishOldIE = ($.browser.msie && ($.browser.version == "6.0" || $.browser.version == "7.0"));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
834
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
835 /* Remove cells which are not needed and copy the height from the original table */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
836 $(parent+' tr', clone).each( function (k) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
837 /* Can we use some kind of object detection here?! This is very nasty - damn browsers */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
838 if ( $.browser.mozilla || $.browser.opera )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
839 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
840 $(this).children().height( $(parent+' tr:eq('+k+')', original).outerHeight() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
841 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
842 else
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
843 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
844 $(this).children().height( $(parent+' tr:eq('+k+')', original).outerHeight() - iBoxHack );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
845 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
846
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
847 if ( !bRubbishOldIE )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
848 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
849 $(parent+' tr:eq('+k+')', original).height( $(parent+' tr:eq('+k+')', original).outerHeight() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
850 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
851 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
852 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
853 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
854
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
855
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
856 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
857 * Static properties and methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
858 * We use these for speed! This information is common to all instances of FixedHeader, so no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
859 * point if having them calculated and stored for each different instance.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
860 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
861
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
862 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
863 * Variable: oWin
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
864 * Purpose: Store information about the window positioning
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
865 * Scope: FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
866 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
867 FixedHeader.oWin = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
868 "iScrollTop": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
869 "iScrollRight": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
870 "iScrollBottom": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
871 "iScrollLeft": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
872 "iHeight": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
873 "iWidth": 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
874 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
875
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
876 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
877 * Variable: oDoc
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
878 * Purpose: Store information about the document size
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
879 * Scope: FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
880 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
881 FixedHeader.oDoc = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
882 "iHeight": 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
883 "iWidth": 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
884 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
885
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
886 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
887 * Variable: afnScroll
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
888 * Purpose: Array of functions that are to be used for the scrolling components
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
889 * Scope: FixedHeader
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
890 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
891 FixedHeader.afnScroll = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
892
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
893 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
894 * Function: fnMeasure
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
895 * Purpose: Update the measurements for the window and document
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
896 * Returns: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
897 * Inputs: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
898 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
899 FixedHeader.fnMeasure = function ()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
900 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
901 var
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
902 jqWin = jQuery(window),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
903 jqDoc = jQuery(document),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
904 oWin = FixedHeader.oWin,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
905 oDoc = FixedHeader.oDoc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
906
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
907 oDoc.iHeight = jqDoc.height();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
908 oDoc.iWidth = jqDoc.width();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
909
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
910 oWin.iHeight = jqWin.height();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
911 oWin.iWidth = jqWin.width();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
912 oWin.iScrollTop = jqWin.scrollTop();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
913 oWin.iScrollLeft = jqWin.scrollLeft();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
914 oWin.iScrollRight = oDoc.iWidth - oWin.iScrollLeft - oWin.iWidth;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
915 oWin.iScrollBottom = oDoc.iHeight - oWin.iScrollTop - oWin.iHeight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
916 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
917
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
918
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
919 FixedHeader.VERSION = "2.0.6";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
920 FixedHeader.prototype.VERSION = FixedHeader.VERSION;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
921
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
922
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
923 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
924 * Global processing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
925 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
926
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
927 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
928 * Just one 'scroll' event handler in FixedHeader, which calls the required components. This is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
929 * done as an optimisation, to reduce calculation and proagation time
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
930 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
931 jQuery(window).scroll( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
932 FixedHeader.fnMeasure();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
933 for ( var i=0, iLen=FixedHeader.afnScroll.length ; i<iLen ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
934 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
935 FixedHeader.afnScroll[i]();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
936 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
937 } );