mas01mj@640
|
1 /*
|
mas01mj@640
|
2 * File: jquery.dataTables.js
|
mas01mj@640
|
3 * Version: 1.5.2
|
mas01mj@640
|
4 * CVS: $Id$
|
mas01mj@640
|
5 * Description: Paginate, search and sort HTML tables
|
mas01mj@640
|
6 * Author: Allan Jardine (www.sprymedia.co.uk)
|
mas01mj@640
|
7 * Created: 28/3/2008
|
mas01mj@640
|
8 * Modified: $Date$ by $Author$
|
mas01mj@640
|
9 * Language: Javascript
|
mas01mj@640
|
10 * License: GPL v2 or BSD 3 point style
|
mas01mj@640
|
11 * Project: Mtaala
|
mas01mj@640
|
12 * Contact: allan.jardine@sprymedia.co.uk
|
mas01mj@640
|
13 *
|
mas01mj@640
|
14 * Copyright 2008-2009 Allan Jardine, all rights reserved.
|
mas01mj@640
|
15 *
|
mas01mj@640
|
16 * This source file is free software, under either the GPL v2 license or a
|
mas01mj@640
|
17 * BSD style license, as supplied with this software.
|
mas01mj@640
|
18 *
|
mas01mj@640
|
19 * This source file is distributed in the hope that it will be useful, but
|
mas01mj@640
|
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
mas01mj@640
|
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
mas01mj@640
|
22 *
|
mas01mj@640
|
23 * For details pleease refer to: http://www.datatables.net
|
mas01mj@640
|
24 */
|
mas01mj@640
|
25
|
mas01mj@640
|
26 /*
|
mas01mj@640
|
27 * When considering jsLint, we need to allow eval() as it it is used for reading cookies and
|
mas01mj@640
|
28 * building the dynamic multi-column sort functions.
|
mas01mj@640
|
29 */
|
mas01mj@640
|
30 /*jslint evil: true, undef: true, browser: true */
|
mas01mj@640
|
31 /*globals $, jQuery,_fnReadCookie,_fnProcessingDisplay,_fnDraw,_fnSort,_fnReDraw,_fnDetectType,_fnSortingClasses,_fnSettingsFromNode,_fnBuildSearchArray,_fnCalculateEnd,_fnFeatureHtmlProcessing,_fnFeatureHtmlPaginate,_fnFeatureHtmlInfo,_fnFeatureHtmlFilter,_fnFilter,_fnSaveState,_fnFilterColumn,_fnEscapeRegex,_fnFilterComplete,_fnFeatureHtmlLength,_fnGetDataMaster,_fnVisibleToColumnIndex,_fnDrawHead,_fnAddData,_fnGetTrNodes,_fnColumnIndexToVisible,_fnCreateCookie,_fnAddOptionsHtml,_fnMap,_fnClearTable,_fnDataToSearch,_fnReOrderIndex,_fnFilterCustom,_fnVisbleColumns,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnColumnOrdering,fnGetMaxLenString*/
|
mas01mj@640
|
32
|
mas01mj@640
|
33 (function($) {
|
mas01mj@640
|
34 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
35 * DataTables variables
|
mas01mj@640
|
36 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
mas01mj@640
|
37
|
mas01mj@640
|
38 /*
|
mas01mj@640
|
39 * Variable: dataTableSettings
|
mas01mj@640
|
40 * Purpose: Store the settings for each dataTables instance
|
mas01mj@640
|
41 * Scope: jQuery.fn
|
mas01mj@640
|
42 */
|
mas01mj@640
|
43 $.fn.dataTableSettings = [];
|
mas01mj@640
|
44
|
mas01mj@640
|
45 /*
|
mas01mj@640
|
46 * Variable: dataTableExt
|
mas01mj@640
|
47 * Purpose: Container for customisable parts of DataTables
|
mas01mj@640
|
48 * Scope: jQuery.fn
|
mas01mj@640
|
49 */
|
mas01mj@640
|
50 $.fn.dataTableExt = {};
|
mas01mj@640
|
51 var _oExt = $.fn.dataTableExt; /* Short reference for fast internal lookup */
|
mas01mj@640
|
52
|
mas01mj@640
|
53
|
mas01mj@640
|
54 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
55 * DataTables extensible objects
|
mas01mj@640
|
56 *
|
mas01mj@640
|
57 * The _oExt object is used to provide an area where user dfined plugins can be
|
mas01mj@640
|
58 * added to DataTables. The following properties of the object are used:
|
mas01mj@640
|
59 * oApi - Plug-in API functions
|
mas01mj@640
|
60 * aTypes - Auto-detection of types
|
mas01mj@640
|
61 * oSort - Sorting functions used by DataTables (based on the type)
|
mas01mj@640
|
62 * oPagination - Pagination functions for different input styles
|
mas01mj@640
|
63 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
mas01mj@640
|
64
|
mas01mj@640
|
65 /*
|
mas01mj@640
|
66 * Variable: sVersion
|
mas01mj@640
|
67 * Purpose: Version string for plug-ins to check compatibility
|
mas01mj@640
|
68 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
69 */
|
mas01mj@640
|
70 _oExt.sVersion = "1.5.2";
|
mas01mj@640
|
71
|
mas01mj@640
|
72 /*
|
mas01mj@640
|
73 * Variable: iApiIndex
|
mas01mj@640
|
74 * Purpose: Index for what 'this' index API functions should use
|
mas01mj@640
|
75 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
76 */
|
mas01mj@640
|
77 _oExt.iApiIndex = 0;
|
mas01mj@640
|
78
|
mas01mj@640
|
79 /*
|
mas01mj@640
|
80 * Variable: oApi
|
mas01mj@640
|
81 * Purpose: Container for plugin API functions
|
mas01mj@640
|
82 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
83 */
|
mas01mj@640
|
84 _oExt.oApi = { };
|
mas01mj@640
|
85
|
mas01mj@640
|
86 /*
|
mas01mj@640
|
87 * Variable: aFiltering
|
mas01mj@640
|
88 * Purpose: Container for plugin filtering functions
|
mas01mj@640
|
89 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
90 */
|
mas01mj@640
|
91 _oExt.afnFiltering = [ ];
|
mas01mj@640
|
92
|
mas01mj@640
|
93 /*
|
mas01mj@640
|
94 * Variable: aoFeatures
|
mas01mj@640
|
95 * Purpose: Container for plugin function functions
|
mas01mj@640
|
96 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
97 * Notes: Array of objects with the following parameters:
|
mas01mj@640
|
98 * fnInit: Function for initialisation of Feature. Takes oSettings and returns node
|
mas01mj@640
|
99 * cFeature: Character that will be matched in sDom - case sensitive
|
mas01mj@640
|
100 * sFeature: Feature name - just for completeness :-)
|
mas01mj@640
|
101 */
|
mas01mj@640
|
102 _oExt.aoFeatures = [ ];
|
mas01mj@640
|
103
|
mas01mj@640
|
104 /*
|
mas01mj@640
|
105 * Variable: ofnSearch
|
mas01mj@640
|
106 * Purpose: Container for custom filtering functions
|
mas01mj@640
|
107 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
108 * Notes: This is an object (the name should match the type) for custom filtering function,
|
mas01mj@640
|
109 * which can be used for live DOM checking or formatted text filtering
|
mas01mj@640
|
110 */
|
mas01mj@640
|
111 _oExt.ofnSearch = { };
|
mas01mj@640
|
112
|
mas01mj@640
|
113 /*
|
mas01mj@640
|
114 * Variable: oStdClasses
|
mas01mj@640
|
115 * Purpose: Storage for the various classes that DataTables uses
|
mas01mj@640
|
116 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
117 */
|
mas01mj@640
|
118 _oExt.oStdClasses = {
|
mas01mj@640
|
119 /* Two buttons buttons */
|
mas01mj@640
|
120 "sPagePrevEnabled": "paginate_enabled_previous",
|
mas01mj@640
|
121 "sPagePrevDisabled": "paginate_disabled_previous",
|
mas01mj@640
|
122 "sPageNextEnabled": "paginate_enabled_next",
|
mas01mj@640
|
123 "sPageNextDisabled": "paginate_disabled_next",
|
mas01mj@640
|
124 "sPageJUINext": "",
|
mas01mj@640
|
125 "sPageJUIPrev": "",
|
mas01mj@640
|
126
|
mas01mj@640
|
127 /* Full numbers paging buttons */
|
mas01mj@640
|
128 "sPageButton": "paginate_button",
|
mas01mj@640
|
129 "sPageButtonActive": "paginate_active",
|
mas01mj@640
|
130 "sPageButtonStaticActive": "paginate_button",
|
mas01mj@640
|
131 "sPageFirst": "first",
|
mas01mj@640
|
132 "sPagePrevious": "previous",
|
mas01mj@640
|
133 "sPageNext": "next",
|
mas01mj@640
|
134 "sPageLast": "last",
|
mas01mj@640
|
135
|
mas01mj@640
|
136 /* Stripping classes */
|
mas01mj@640
|
137 "sStripOdd": "odd",
|
mas01mj@640
|
138 "sStripEven": "even",
|
mas01mj@640
|
139
|
mas01mj@640
|
140 /* Empty row */
|
mas01mj@640
|
141 "sRowEmpty": "dataTables_empty",
|
mas01mj@640
|
142
|
mas01mj@640
|
143 /* Features */
|
mas01mj@640
|
144 "sWrapper": "dataTables_wrapper",
|
mas01mj@640
|
145 "sFilter": "dataTables_filter",
|
mas01mj@640
|
146 "sInfo": "dataTables_info",
|
mas01mj@640
|
147 "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
|
mas01mj@640
|
148 "sLength": "dataTables_length",
|
mas01mj@640
|
149 "sProcessing": "dataTables_processing",
|
mas01mj@640
|
150
|
mas01mj@640
|
151 /* Sorting */
|
mas01mj@640
|
152 "sSortAsc": "sorting_asc",
|
mas01mj@640
|
153 "sSortDesc": "sorting_desc",
|
mas01mj@640
|
154 "sSortable": "sorting",
|
mas01mj@640
|
155 "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
|
mas01mj@640
|
156 "sSortJUIAsc": "",
|
mas01mj@640
|
157 "sSortJUIDesc": "",
|
mas01mj@640
|
158 "sSortJUI": ""
|
mas01mj@640
|
159 };
|
mas01mj@640
|
160
|
mas01mj@640
|
161 /*
|
mas01mj@640
|
162 * Variable: oJUIClasses
|
mas01mj@640
|
163 * Purpose: Storage for the various classes that DataTables uses - jQuery UI suitable
|
mas01mj@640
|
164 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
165 */
|
mas01mj@640
|
166 _oExt.oJUIClasses = {
|
mas01mj@640
|
167 /* Two buttons buttons */
|
mas01mj@640
|
168 "sPagePrevEnabled": "fg-button ui-state-default ui-corner-left",
|
mas01mj@640
|
169 "sPagePrevDisabled": "fg-button ui-state-default ui-corner-left ui-state-disabled",
|
mas01mj@640
|
170 "sPageNextEnabled": "fg-button ui-state-default ui-corner-right",
|
mas01mj@640
|
171 "sPageNextDisabled": "fg-button ui-state-default ui-corner-right ui-state-disabled",
|
mas01mj@640
|
172 "sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
|
mas01mj@640
|
173 "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
|
mas01mj@640
|
174
|
mas01mj@640
|
175 /* Full numbers paging buttons */
|
mas01mj@640
|
176 "sPageButton": "fg-button ui-state-default",
|
mas01mj@640
|
177 "sPageButtonActive": "fg-button ui-state-default ui-state-disabled",
|
mas01mj@640
|
178 "sPageButtonStaticActive": "fg-button ui-state-default ui-state-disabled",
|
mas01mj@640
|
179 "sPageFirst": "first ui-corner-tl ui-corner-bl",
|
mas01mj@640
|
180 "sPagePrevious": "previous",
|
mas01mj@640
|
181 "sPageNext": "next",
|
mas01mj@640
|
182 "sPageLast": "last ui-corner-tr ui-corner-br",
|
mas01mj@640
|
183
|
mas01mj@640
|
184 /* Stripping classes */
|
mas01mj@640
|
185 "sStripOdd": "odd",
|
mas01mj@640
|
186 "sStripEven": "even",
|
mas01mj@640
|
187
|
mas01mj@640
|
188 /* Empty row */
|
mas01mj@640
|
189 "sRowEmpty": "dataTables_empty",
|
mas01mj@640
|
190
|
mas01mj@640
|
191 /* Features */
|
mas01mj@640
|
192 "sWrapper": "dataTables_wrapper",
|
mas01mj@640
|
193 "sFilter": "dataTables_filter",
|
mas01mj@640
|
194 "sInfo": "dataTables_info",
|
mas01mj@640
|
195 "sPaging": "dataTables_paginate fg-buttonset fg-buttonset-multi paging_", /* Note that the type is postfixed */
|
mas01mj@640
|
196 "sLength": "dataTables_length",
|
mas01mj@640
|
197 "sProcessing": "dataTables_processing",
|
mas01mj@640
|
198
|
mas01mj@640
|
199 /* Sorting */
|
mas01mj@640
|
200 "sSortAsc": "ui-state-default",
|
mas01mj@640
|
201 "sSortDesc": "ui-state-default",
|
mas01mj@640
|
202 "sSortable": "ui-state-default",
|
mas01mj@640
|
203 "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
|
mas01mj@640
|
204 "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
|
mas01mj@640
|
205 "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
|
mas01mj@640
|
206 "sSortJUI": "css_right ui-icon ui-icon-triangle-2-n-s"
|
mas01mj@640
|
207 };
|
mas01mj@640
|
208
|
mas01mj@640
|
209 /*
|
mas01mj@640
|
210 * Variable: oPagination
|
mas01mj@640
|
211 * Purpose: Container for the various type of pagination that dataTables supports
|
mas01mj@640
|
212 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
213 */
|
mas01mj@640
|
214 _oExt.oPagination = {
|
mas01mj@640
|
215 /*
|
mas01mj@640
|
216 * Variable: two_button
|
mas01mj@640
|
217 * Purpose: Standard two button (forward/back) pagination
|
mas01mj@640
|
218 * Scope: jQuery.fn.dataTableExt.oPagination
|
mas01mj@640
|
219 */
|
mas01mj@640
|
220 "two_button": {
|
mas01mj@640
|
221 /*
|
mas01mj@640
|
222 * Function: oPagination.two_button.fnInit
|
mas01mj@640
|
223 * Purpose: Initalise dom elements required for pagination with forward/back buttons only
|
mas01mj@640
|
224 * Returns: -
|
mas01mj@640
|
225 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
226 * function:fnCallbackDraw - draw function which must be called on update
|
mas01mj@640
|
227 */
|
mas01mj@640
|
228 "fnInit": function ( oSettings, fnCallbackDraw )
|
mas01mj@640
|
229 {
|
mas01mj@640
|
230 var nPaging = oSettings.anFeatures.p;
|
mas01mj@640
|
231
|
mas01mj@640
|
232 /* Store the next and previous elements in the oSettings object as they can be very
|
mas01mj@640
|
233 * usful for automation - particularly testing
|
mas01mj@640
|
234 */
|
mas01mj@640
|
235 if ( !oSettings.bJUI )
|
mas01mj@640
|
236 {
|
mas01mj@640
|
237 oSettings.nPrevious = document.createElement( 'div' );
|
mas01mj@640
|
238 oSettings.nNext = document.createElement( 'div' );
|
mas01mj@640
|
239 }
|
mas01mj@640
|
240 else
|
mas01mj@640
|
241 {
|
mas01mj@640
|
242 oSettings.nPrevious = document.createElement( 'a' );
|
mas01mj@640
|
243 oSettings.nNext = document.createElement( 'a' );
|
mas01mj@640
|
244
|
mas01mj@640
|
245 var nNextInner = document.createElement('span');
|
mas01mj@640
|
246 nNextInner.className = oSettings.oClasses.sPageJUINext;
|
mas01mj@640
|
247 oSettings.nNext.appendChild( nNextInner );
|
mas01mj@640
|
248
|
mas01mj@640
|
249 var nPreviousInner = document.createElement('span');
|
mas01mj@640
|
250 nPreviousInner.className = oSettings.oClasses.sPageJUIPrev;
|
mas01mj@640
|
251 oSettings.nPrevious.appendChild( nPreviousInner );
|
mas01mj@640
|
252 }
|
mas01mj@640
|
253
|
mas01mj@640
|
254 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
255 {
|
mas01mj@640
|
256 nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
|
mas01mj@640
|
257 oSettings.nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
|
mas01mj@640
|
258 oSettings.nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
|
mas01mj@640
|
259 }
|
mas01mj@640
|
260
|
mas01mj@640
|
261 oSettings.nPrevious.className = oSettings.oClasses.sPagePrevDisabled;
|
mas01mj@640
|
262 oSettings.nNext.className = oSettings.oClasses.sPageNextDisabled;
|
mas01mj@640
|
263
|
mas01mj@640
|
264 oSettings.nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
|
mas01mj@640
|
265 oSettings.nNext.title = oSettings.oLanguage.oPaginate.sNext;
|
mas01mj@640
|
266
|
mas01mj@640
|
267 nPaging.appendChild( oSettings.nPrevious );
|
mas01mj@640
|
268 nPaging.appendChild( oSettings.nNext );
|
mas01mj@640
|
269 $(nPaging).insertAfter( oSettings.nTable );
|
mas01mj@640
|
270
|
mas01mj@640
|
271 $(oSettings.nPrevious).click( function() {
|
mas01mj@640
|
272 oSettings._iDisplayStart -= oSettings._iDisplayLength;
|
mas01mj@640
|
273
|
mas01mj@640
|
274 /* Correct for underrun */
|
mas01mj@640
|
275 if ( oSettings._iDisplayStart < 0 )
|
mas01mj@640
|
276 {
|
mas01mj@640
|
277 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
278 }
|
mas01mj@640
|
279
|
mas01mj@640
|
280 fnCallbackDraw( oSettings );
|
mas01mj@640
|
281 } );
|
mas01mj@640
|
282
|
mas01mj@640
|
283 $(oSettings.nNext).click( function() {
|
mas01mj@640
|
284 /* Make sure we are not over running the display array */
|
mas01mj@640
|
285 if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
|
mas01mj@640
|
286 {
|
mas01mj@640
|
287 oSettings._iDisplayStart += oSettings._iDisplayLength;
|
mas01mj@640
|
288 }
|
mas01mj@640
|
289
|
mas01mj@640
|
290 fnCallbackDraw( oSettings );
|
mas01mj@640
|
291 } );
|
mas01mj@640
|
292
|
mas01mj@640
|
293 /* Take the brutal approach to cancelling text selection */
|
mas01mj@640
|
294 $(oSettings.nPrevious).bind( 'selectstart', function () { return false; } );
|
mas01mj@640
|
295 $(oSettings.nNext).bind( 'selectstart', function () { return false; } );
|
mas01mj@640
|
296 },
|
mas01mj@640
|
297
|
mas01mj@640
|
298 /*
|
mas01mj@640
|
299 * Function: oPagination.two_button.fnUpdate
|
mas01mj@640
|
300 * Purpose: Update the two button pagination at the end of the draw
|
mas01mj@640
|
301 * Returns: -
|
mas01mj@640
|
302 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
303 * function:fnCallbackDraw - draw function which must be called on update
|
mas01mj@640
|
304 */
|
mas01mj@640
|
305 "fnUpdate": function ( oSettings, fnCallbackDraw )
|
mas01mj@640
|
306 {
|
mas01mj@640
|
307 if ( !oSettings.anFeatures.p )
|
mas01mj@640
|
308 {
|
mas01mj@640
|
309 return;
|
mas01mj@640
|
310 }
|
mas01mj@640
|
311
|
mas01mj@640
|
312 oSettings.nPrevious.className =
|
mas01mj@640
|
313 ( oSettings._iDisplayStart === 0 ) ?
|
mas01mj@640
|
314 oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
|
mas01mj@640
|
315
|
mas01mj@640
|
316 oSettings.nNext.className =
|
mas01mj@640
|
317 ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
|
mas01mj@640
|
318 oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
|
mas01mj@640
|
319 }
|
mas01mj@640
|
320 },
|
mas01mj@640
|
321
|
mas01mj@640
|
322
|
mas01mj@640
|
323 /*
|
mas01mj@640
|
324 * Variable: iFullNumbersShowPages
|
mas01mj@640
|
325 * Purpose: Change the number of pages which can be seen
|
mas01mj@640
|
326 * Scope: jQuery.fn.dataTableExt.oPagination
|
mas01mj@640
|
327 */
|
mas01mj@640
|
328 "iFullNumbersShowPages": 5,
|
mas01mj@640
|
329
|
mas01mj@640
|
330 /*
|
mas01mj@640
|
331 * Variable: full_numbers
|
mas01mj@640
|
332 * Purpose: Full numbers pagination
|
mas01mj@640
|
333 * Scope: jQuery.fn.dataTableExt.oPagination
|
mas01mj@640
|
334 */
|
mas01mj@640
|
335 "full_numbers": {
|
mas01mj@640
|
336 /*
|
mas01mj@640
|
337 * Function: oPagination.full_numbers.fnInit
|
mas01mj@640
|
338 * Purpose: Initalise dom elements required for pagination with a list of the pages
|
mas01mj@640
|
339 * Returns: -
|
mas01mj@640
|
340 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
341 * function:fnCallbackDraw - draw function which must be called on update
|
mas01mj@640
|
342 */
|
mas01mj@640
|
343 "fnInit": function ( oSettings, fnCallbackDraw )
|
mas01mj@640
|
344 {
|
mas01mj@640
|
345 var nPaging = oSettings.anFeatures.p;
|
mas01mj@640
|
346 var nFirst = document.createElement( 'span' );
|
mas01mj@640
|
347 var nPrevious = document.createElement( 'span' );
|
mas01mj@640
|
348 var nList = document.createElement( 'span' );
|
mas01mj@640
|
349 var nNext = document.createElement( 'span' );
|
mas01mj@640
|
350 var nLast = document.createElement( 'span' );
|
mas01mj@640
|
351
|
mas01mj@640
|
352 nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst;
|
mas01mj@640
|
353 nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious;
|
mas01mj@640
|
354 nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext;
|
mas01mj@640
|
355 nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast;
|
mas01mj@640
|
356
|
mas01mj@640
|
357 var oClasses = oSettings.oClasses;
|
mas01mj@640
|
358 nFirst.className = oClasses.sPageButton+" "+oClasses.sPageFirst;
|
mas01mj@640
|
359 nPrevious.className = oClasses.sPageButton+" "+oClasses.sPagePrevious;
|
mas01mj@640
|
360 nNext.className= oClasses.sPageButton+" "+oClasses.sPageNext;
|
mas01mj@640
|
361 nLast.className = oClasses.sPageButton+" "+oClasses.sPageLast;
|
mas01mj@640
|
362
|
mas01mj@640
|
363 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
364 {
|
mas01mj@640
|
365 nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
|
mas01mj@640
|
366 nFirst.setAttribute( 'id', oSettings.sTableId+'_first' );
|
mas01mj@640
|
367 nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
|
mas01mj@640
|
368 nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
|
mas01mj@640
|
369 nLast.setAttribute( 'id', oSettings.sTableId+'_last' );
|
mas01mj@640
|
370 }
|
mas01mj@640
|
371
|
mas01mj@640
|
372 nPaging.appendChild( nFirst );
|
mas01mj@640
|
373 nPaging.appendChild( nPrevious );
|
mas01mj@640
|
374 nPaging.appendChild( nList );
|
mas01mj@640
|
375 nPaging.appendChild( nNext );
|
mas01mj@640
|
376 nPaging.appendChild( nLast );
|
mas01mj@640
|
377
|
mas01mj@640
|
378 $(nFirst).click( function () {
|
mas01mj@640
|
379 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
380 fnCallbackDraw( oSettings );
|
mas01mj@640
|
381 } );
|
mas01mj@640
|
382
|
mas01mj@640
|
383 $(nPrevious).click( function() {
|
mas01mj@640
|
384 oSettings._iDisplayStart -= oSettings._iDisplayLength;
|
mas01mj@640
|
385
|
mas01mj@640
|
386 /* Correct for underrun */
|
mas01mj@640
|
387 if ( oSettings._iDisplayStart < 0 )
|
mas01mj@640
|
388 {
|
mas01mj@640
|
389 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
390 }
|
mas01mj@640
|
391
|
mas01mj@640
|
392 fnCallbackDraw( oSettings );
|
mas01mj@640
|
393 } );
|
mas01mj@640
|
394
|
mas01mj@640
|
395 $(nNext).click( function() {
|
mas01mj@640
|
396 /* Make sure we are not over running the display array */
|
mas01mj@640
|
397 if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
|
mas01mj@640
|
398 {
|
mas01mj@640
|
399 oSettings._iDisplayStart += oSettings._iDisplayLength;
|
mas01mj@640
|
400 }
|
mas01mj@640
|
401
|
mas01mj@640
|
402 fnCallbackDraw( oSettings );
|
mas01mj@640
|
403 } );
|
mas01mj@640
|
404
|
mas01mj@640
|
405 $(nLast).click( function() {
|
mas01mj@640
|
406 var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
|
mas01mj@640
|
407 oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
|
mas01mj@640
|
408
|
mas01mj@640
|
409 fnCallbackDraw( oSettings );
|
mas01mj@640
|
410 } );
|
mas01mj@640
|
411
|
mas01mj@640
|
412 /* Take the brutal approach to cancelling text selection */
|
mas01mj@640
|
413 $('span', nPaging).bind( 'mousedown', function () { return false; } );
|
mas01mj@640
|
414 $('span', nPaging).bind( 'selectstart', function () { return false; } );
|
mas01mj@640
|
415
|
mas01mj@640
|
416 oSettings.nPaginateList = nList;
|
mas01mj@640
|
417 },
|
mas01mj@640
|
418
|
mas01mj@640
|
419 /*
|
mas01mj@640
|
420 * Function: oPagination.full_numbers.fnUpdate
|
mas01mj@640
|
421 * Purpose: Update the list of page buttons shows
|
mas01mj@640
|
422 * Returns: -
|
mas01mj@640
|
423 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
424 * function:fnCallbackDraw - draw function which must be called on update
|
mas01mj@640
|
425 */
|
mas01mj@640
|
426 "fnUpdate": function ( oSettings, fnCallbackDraw )
|
mas01mj@640
|
427 {
|
mas01mj@640
|
428 if ( !oSettings.anFeatures.p )
|
mas01mj@640
|
429 {
|
mas01mj@640
|
430 return;
|
mas01mj@640
|
431 }
|
mas01mj@640
|
432
|
mas01mj@640
|
433 var iPageCount = jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages;
|
mas01mj@640
|
434 var iPageCountHalf = Math.floor(iPageCount / 2);
|
mas01mj@640
|
435 var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
|
mas01mj@640
|
436 var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
|
mas01mj@640
|
437 var sList = "";
|
mas01mj@640
|
438 var iStartButton;
|
mas01mj@640
|
439 var iEndButton;
|
mas01mj@640
|
440 var oClasses = oSettings.oClasses;
|
mas01mj@640
|
441
|
mas01mj@640
|
442 if (iPages < iPageCount)
|
mas01mj@640
|
443 {
|
mas01mj@640
|
444 iStartButton = 1;
|
mas01mj@640
|
445 iEndButton = iPages;
|
mas01mj@640
|
446 }
|
mas01mj@640
|
447 else
|
mas01mj@640
|
448 {
|
mas01mj@640
|
449 if (iCurrentPage <= iPageCountHalf)
|
mas01mj@640
|
450 {
|
mas01mj@640
|
451 iStartButton = 1;
|
mas01mj@640
|
452 iEndButton = iPageCount;
|
mas01mj@640
|
453 }
|
mas01mj@640
|
454 else
|
mas01mj@640
|
455 {
|
mas01mj@640
|
456 if (iCurrentPage >= (iPages - iPageCountHalf))
|
mas01mj@640
|
457 {
|
mas01mj@640
|
458 iStartButton = iPages - iPageCount + 1;
|
mas01mj@640
|
459 iEndButton = iPages;
|
mas01mj@640
|
460 }
|
mas01mj@640
|
461 else
|
mas01mj@640
|
462 {
|
mas01mj@640
|
463 iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
|
mas01mj@640
|
464 iEndButton = iStartButton + iPageCount - 1;
|
mas01mj@640
|
465 }
|
mas01mj@640
|
466 }
|
mas01mj@640
|
467 }
|
mas01mj@640
|
468
|
mas01mj@640
|
469 for ( var i=iStartButton ; i<=iEndButton ; i++ )
|
mas01mj@640
|
470 {
|
mas01mj@640
|
471 if ( iCurrentPage != i )
|
mas01mj@640
|
472 {
|
mas01mj@640
|
473 sList += '<span class="'+oClasses.sPageButton+'">'+i+'</span>';
|
mas01mj@640
|
474 }
|
mas01mj@640
|
475 else
|
mas01mj@640
|
476 {
|
mas01mj@640
|
477 sList += '<span class="'+oClasses.sPageButtonActive+'">'+i+'</span>';
|
mas01mj@640
|
478 }
|
mas01mj@640
|
479 }
|
mas01mj@640
|
480
|
mas01mj@640
|
481 oSettings.nPaginateList.innerHTML = sList;
|
mas01mj@640
|
482
|
mas01mj@640
|
483 /* Take the brutal approach to cancelling text selection */
|
mas01mj@640
|
484 $('span', oSettings.nPaginateList).bind( 'mousedown', function () { return false; } );
|
mas01mj@640
|
485 $('span', oSettings.nPaginateList).bind( 'selectstart', function () { return false; } );
|
mas01mj@640
|
486
|
mas01mj@640
|
487 $('span', oSettings.nPaginateList).click( function() {
|
mas01mj@640
|
488 var iTarget = (this.innerHTML * 1) - 1;
|
mas01mj@640
|
489 oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength;
|
mas01mj@640
|
490
|
mas01mj@640
|
491 fnCallbackDraw( oSettings );
|
mas01mj@640
|
492 return false;
|
mas01mj@640
|
493 } );
|
mas01mj@640
|
494
|
mas01mj@640
|
495 /* Update the 'premanent botton's classes */
|
mas01mj@640
|
496 var nButtons = $('span', oSettings.anFeatures.p);
|
mas01mj@640
|
497 var nStatic = [ nButtons[0], nButtons[1], nButtons[nButtons.length-2], nButtons[nButtons.length-1] ];
|
mas01mj@640
|
498 $(nStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive );
|
mas01mj@640
|
499 if ( iCurrentPage == 1 )
|
mas01mj@640
|
500 {
|
mas01mj@640
|
501 nStatic[0].className += " "+oClasses.sPageButtonStaticActive;
|
mas01mj@640
|
502 nStatic[1].className += " "+oClasses.sPageButtonStaticActive;
|
mas01mj@640
|
503 }
|
mas01mj@640
|
504 else
|
mas01mj@640
|
505 {
|
mas01mj@640
|
506 nStatic[0].className += " "+oClasses.sPageButton;
|
mas01mj@640
|
507 nStatic[1].className += " "+oClasses.sPageButton;
|
mas01mj@640
|
508 }
|
mas01mj@640
|
509
|
mas01mj@640
|
510 if ( iCurrentPage == iPages )
|
mas01mj@640
|
511 {
|
mas01mj@640
|
512 nStatic[2].className += " "+oClasses.sPageButtonStaticActive;
|
mas01mj@640
|
513 nStatic[3].className += " "+oClasses.sPageButtonStaticActive;
|
mas01mj@640
|
514 }
|
mas01mj@640
|
515 else
|
mas01mj@640
|
516 {
|
mas01mj@640
|
517 nStatic[2].className += " "+oClasses.sPageButton;
|
mas01mj@640
|
518 nStatic[3].className += " "+oClasses.sPageButton;
|
mas01mj@640
|
519 }
|
mas01mj@640
|
520 }
|
mas01mj@640
|
521 }
|
mas01mj@640
|
522 };
|
mas01mj@640
|
523
|
mas01mj@640
|
524 /*
|
mas01mj@640
|
525 * Variable: oSort
|
mas01mj@640
|
526 * Purpose: Wrapper for the sorting functions that can be used in DataTables
|
mas01mj@640
|
527 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
528 * Notes: The functions provided in this object are basically standard javascript sort
|
mas01mj@640
|
529 * functions - they expect two inputs which they then compare and then return a priority
|
mas01mj@640
|
530 * result. For each sort method added, two functions need to be defined, an ascending sort and
|
mas01mj@640
|
531 * a descending sort.
|
mas01mj@640
|
532 */
|
mas01mj@640
|
533 _oExt.oSort = {
|
mas01mj@640
|
534 /*
|
mas01mj@640
|
535 * text sorting
|
mas01mj@640
|
536 */
|
mas01mj@640
|
537 "string-asc": function ( a, b )
|
mas01mj@640
|
538 {
|
mas01mj@640
|
539 var x = a.toLowerCase();
|
mas01mj@640
|
540 var y = b.toLowerCase();
|
mas01mj@640
|
541 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
mas01mj@640
|
542 },
|
mas01mj@640
|
543
|
mas01mj@640
|
544 "string-desc": function ( a, b )
|
mas01mj@640
|
545 {
|
mas01mj@640
|
546 var x = a.toLowerCase();
|
mas01mj@640
|
547 var y = b.toLowerCase();
|
mas01mj@640
|
548 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
mas01mj@640
|
549 },
|
mas01mj@640
|
550
|
mas01mj@640
|
551
|
mas01mj@640
|
552 /*
|
mas01mj@640
|
553 * html sorting (ignore html tags)
|
mas01mj@640
|
554 */
|
mas01mj@640
|
555 "html-asc": function ( a, b )
|
mas01mj@640
|
556 {
|
mas01mj@640
|
557 var x = a.replace( /<.*?>/g, "" ).toLowerCase();
|
mas01mj@640
|
558 var y = b.replace( /<.*?>/g, "" ).toLowerCase();
|
mas01mj@640
|
559 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
mas01mj@640
|
560 },
|
mas01mj@640
|
561
|
mas01mj@640
|
562 "html-desc": function ( a, b )
|
mas01mj@640
|
563 {
|
mas01mj@640
|
564 var x = a.replace( /<.*?>/g, "" ).toLowerCase();
|
mas01mj@640
|
565 var y = b.replace( /<.*?>/g, "" ).toLowerCase();
|
mas01mj@640
|
566 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
mas01mj@640
|
567 },
|
mas01mj@640
|
568
|
mas01mj@640
|
569
|
mas01mj@640
|
570 /*
|
mas01mj@640
|
571 * date sorting
|
mas01mj@640
|
572 */
|
mas01mj@640
|
573 "date-asc": function ( a, b )
|
mas01mj@640
|
574 {
|
mas01mj@640
|
575 var x = Date.parse( a );
|
mas01mj@640
|
576 var y = Date.parse( b );
|
mas01mj@640
|
577
|
mas01mj@640
|
578 if ( isNaN( x ) )
|
mas01mj@640
|
579 {
|
mas01mj@640
|
580 x = Date.parse( "01/01/1970 00:00:00" );
|
mas01mj@640
|
581 }
|
mas01mj@640
|
582 if ( isNaN( y ) )
|
mas01mj@640
|
583 {
|
mas01mj@640
|
584 y = Date.parse( "01/01/1970 00:00:00" );
|
mas01mj@640
|
585 }
|
mas01mj@640
|
586
|
mas01mj@640
|
587 return x - y;
|
mas01mj@640
|
588 },
|
mas01mj@640
|
589
|
mas01mj@640
|
590 "date-desc": function ( a, b )
|
mas01mj@640
|
591 {
|
mas01mj@640
|
592 var x = Date.parse( a );
|
mas01mj@640
|
593 var y = Date.parse( b );
|
mas01mj@640
|
594
|
mas01mj@640
|
595 if ( isNaN( x ) )
|
mas01mj@640
|
596 {
|
mas01mj@640
|
597 x = Date.parse( "01/01/1970 00:00:00" );
|
mas01mj@640
|
598 }
|
mas01mj@640
|
599 if ( isNaN( y ) )
|
mas01mj@640
|
600 {
|
mas01mj@640
|
601 y = Date.parse( "01/01/1970 00:00:00" );
|
mas01mj@640
|
602 }
|
mas01mj@640
|
603
|
mas01mj@640
|
604 return y - x;
|
mas01mj@640
|
605 },
|
mas01mj@640
|
606
|
mas01mj@640
|
607
|
mas01mj@640
|
608 /*
|
mas01mj@640
|
609 * numerical sorting
|
mas01mj@640
|
610 */
|
mas01mj@640
|
611 "numeric-asc": function ( a, b )
|
mas01mj@640
|
612 {
|
mas01mj@640
|
613 var x = a == "-" ? 0 : a;
|
mas01mj@640
|
614 var y = b == "-" ? 0 : b;
|
mas01mj@640
|
615 return x - y;
|
mas01mj@640
|
616 },
|
mas01mj@640
|
617
|
mas01mj@640
|
618 "numeric-desc": function ( a, b )
|
mas01mj@640
|
619 {
|
mas01mj@640
|
620 var x = a == "-" ? 0 : a;
|
mas01mj@640
|
621 var y = b == "-" ? 0 : b;
|
mas01mj@640
|
622 return y - x;
|
mas01mj@640
|
623 }
|
mas01mj@640
|
624 };
|
mas01mj@640
|
625
|
mas01mj@640
|
626
|
mas01mj@640
|
627 /*
|
mas01mj@640
|
628 * Variable: aTypes
|
mas01mj@640
|
629 * Purpose: Container for the various type of type detection that dataTables supports
|
mas01mj@640
|
630 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
631 * Notes: The functions in this array are expected to parse a string to see if it is a data
|
mas01mj@640
|
632 * type that it recognises. If so then the function should return the name of the type (a
|
mas01mj@640
|
633 * corresponding sort function should be defined!), if the type is not recognised then the
|
mas01mj@640
|
634 * function should return null such that the parser and move on to check the next type.
|
mas01mj@640
|
635 * Note that ordering is important in this array - the functions are processed linearly,
|
mas01mj@640
|
636 * starting at index 0.
|
mas01mj@640
|
637 */
|
mas01mj@640
|
638 _oExt.aTypes = [
|
mas01mj@640
|
639 /*
|
mas01mj@640
|
640 * Function: -
|
mas01mj@640
|
641 * Purpose: Check to see if a string is numeric
|
mas01mj@640
|
642 * Returns: string:'numeric' or null
|
mas01mj@640
|
643 * Inputs: string:sText - string to check
|
mas01mj@640
|
644 */
|
mas01mj@640
|
645 function ( sData )
|
mas01mj@640
|
646 {
|
mas01mj@640
|
647 /* Snaity check that we are dealing with a string or quick return for a number */
|
mas01mj@640
|
648 if ( typeof sData == 'number' )
|
mas01mj@640
|
649 {
|
mas01mj@640
|
650 return 'numeric';
|
mas01mj@640
|
651 }
|
mas01mj@640
|
652 else if ( typeof sData.charAt != 'function' )
|
mas01mj@640
|
653 {
|
mas01mj@640
|
654 return null;
|
mas01mj@640
|
655 }
|
mas01mj@640
|
656
|
mas01mj@640
|
657 var sValidFirstChars = "0123456789-";
|
mas01mj@640
|
658 var sValidChars = "0123456789.";
|
mas01mj@640
|
659 var Char;
|
mas01mj@640
|
660 var bDecimal = false;
|
mas01mj@640
|
661
|
mas01mj@640
|
662 /* Check for a valid first char (no period and allow negatives) */
|
mas01mj@640
|
663 Char = sData.charAt(0);
|
mas01mj@640
|
664 if (sValidFirstChars.indexOf(Char) == -1)
|
mas01mj@640
|
665 {
|
mas01mj@640
|
666 return null;
|
mas01mj@640
|
667 }
|
mas01mj@640
|
668
|
mas01mj@640
|
669 /* Check all the other characters are valid */
|
mas01mj@640
|
670 for ( var i=1 ; i<sData.length ; i++ )
|
mas01mj@640
|
671 {
|
mas01mj@640
|
672 Char = sData.charAt(i);
|
mas01mj@640
|
673 if (sValidChars.indexOf(Char) == -1)
|
mas01mj@640
|
674 {
|
mas01mj@640
|
675 return null;
|
mas01mj@640
|
676 }
|
mas01mj@640
|
677
|
mas01mj@640
|
678 /* Only allowed one decimal place... */
|
mas01mj@640
|
679 if ( Char == "." )
|
mas01mj@640
|
680 {
|
mas01mj@640
|
681 if ( bDecimal )
|
mas01mj@640
|
682 {
|
mas01mj@640
|
683 return null;
|
mas01mj@640
|
684 }
|
mas01mj@640
|
685 bDecimal = true;
|
mas01mj@640
|
686 }
|
mas01mj@640
|
687 }
|
mas01mj@640
|
688
|
mas01mj@640
|
689 return 'numeric';
|
mas01mj@640
|
690 },
|
mas01mj@640
|
691
|
mas01mj@640
|
692 /*
|
mas01mj@640
|
693 * Function: -
|
mas01mj@640
|
694 * Purpose: Check to see if a string is actually a formatted date
|
mas01mj@640
|
695 * Returns: string:'date' or null
|
mas01mj@640
|
696 * Inputs: string:sText - string to check
|
mas01mj@640
|
697 */
|
mas01mj@640
|
698 function ( sData )
|
mas01mj@640
|
699 {
|
mas01mj@640
|
700 var iParse = Date.parse(sData);
|
mas01mj@640
|
701 if ( iParse !== null && !isNaN(iParse) )
|
mas01mj@640
|
702 {
|
mas01mj@640
|
703 return 'date';
|
mas01mj@640
|
704 }
|
mas01mj@640
|
705 return null;
|
mas01mj@640
|
706 }
|
mas01mj@640
|
707 ];
|
mas01mj@640
|
708
|
mas01mj@640
|
709
|
mas01mj@640
|
710 /*
|
mas01mj@640
|
711 * Variable: _oExternConfig
|
mas01mj@640
|
712 * Purpose: Store information for DataTables to access globally about other instances
|
mas01mj@640
|
713 * Scope: jQuery.fn.dataTableExt
|
mas01mj@640
|
714 */
|
mas01mj@640
|
715 _oExt._oExternConfig = {
|
mas01mj@640
|
716 /* int:iNextUnique - next unique number for an instance */
|
mas01mj@640
|
717 "iNextUnique": 0
|
mas01mj@640
|
718 };
|
mas01mj@640
|
719
|
mas01mj@640
|
720
|
mas01mj@640
|
721 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
722 * DataTables prototype
|
mas01mj@640
|
723 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
mas01mj@640
|
724
|
mas01mj@640
|
725 /*
|
mas01mj@640
|
726 * Function: dataTable
|
mas01mj@640
|
727 * Purpose: DataTables information
|
mas01mj@640
|
728 * Returns: -
|
mas01mj@640
|
729 * Inputs: object:oInit - initalisation options for the table
|
mas01mj@640
|
730 */
|
mas01mj@640
|
731 $.fn.dataTable = function( oInit )
|
mas01mj@640
|
732 {
|
mas01mj@640
|
733 /*
|
mas01mj@640
|
734 * Variable: _aoSettings
|
mas01mj@640
|
735 * Purpose: Easy reference to data table settings
|
mas01mj@640
|
736 * Scope: jQuery.dataTable
|
mas01mj@640
|
737 */
|
mas01mj@640
|
738 var _aoSettings = $.fn.dataTableSettings;
|
mas01mj@640
|
739
|
mas01mj@640
|
740 /*
|
mas01mj@640
|
741 * Function: classSettings
|
mas01mj@640
|
742 * Purpose: Settings container function for all 'class' properties which are required
|
mas01mj@640
|
743 * by dataTables
|
mas01mj@640
|
744 * Returns: -
|
mas01mj@640
|
745 * Inputs: -
|
mas01mj@640
|
746 */
|
mas01mj@640
|
747 function classSettings ()
|
mas01mj@640
|
748 {
|
mas01mj@640
|
749 this.fnRecordsTotal = function ()
|
mas01mj@640
|
750 {
|
mas01mj@640
|
751 if ( this.oFeatures.bServerSide ) {
|
mas01mj@640
|
752 return this._iRecordsTotal;
|
mas01mj@640
|
753 } else {
|
mas01mj@640
|
754 return this.aiDisplayMaster.length;
|
mas01mj@640
|
755 }
|
mas01mj@640
|
756 };
|
mas01mj@640
|
757
|
mas01mj@640
|
758 this.fnRecordsDisplay = function ()
|
mas01mj@640
|
759 {
|
mas01mj@640
|
760 if ( this.oFeatures.bServerSide ) {
|
mas01mj@640
|
761 return this._iRecordsDisplay;
|
mas01mj@640
|
762 } else {
|
mas01mj@640
|
763 return this.aiDisplay.length;
|
mas01mj@640
|
764 }
|
mas01mj@640
|
765 };
|
mas01mj@640
|
766
|
mas01mj@640
|
767 this.fnDisplayEnd = function ()
|
mas01mj@640
|
768 {
|
mas01mj@640
|
769 if ( this.oFeatures.bServerSide ) {
|
mas01mj@640
|
770 return this._iDisplayStart + this.aiDisplay.length;
|
mas01mj@640
|
771 } else {
|
mas01mj@640
|
772 return this._iDisplayEnd;
|
mas01mj@640
|
773 }
|
mas01mj@640
|
774 };
|
mas01mj@640
|
775
|
mas01mj@640
|
776 /*
|
mas01mj@640
|
777 * Variable: sInstance
|
mas01mj@640
|
778 * Purpose: Unique idendifier for each instance of the DataTables object
|
mas01mj@640
|
779 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
780 */
|
mas01mj@640
|
781 this.sInstance = null;
|
mas01mj@640
|
782
|
mas01mj@640
|
783 /*
|
mas01mj@640
|
784 * Variable: oFeatures
|
mas01mj@640
|
785 * Purpose: Indicate the enablement of key dataTable features
|
mas01mj@640
|
786 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
787 */
|
mas01mj@640
|
788 this.oFeatures = {
|
mas01mj@640
|
789 "bPaginate": true,
|
mas01mj@640
|
790 "bLengthChange": true,
|
mas01mj@640
|
791 "bFilter": true,
|
mas01mj@640
|
792 "bSort": true,
|
mas01mj@640
|
793 "bInfo": true,
|
mas01mj@640
|
794 "bAutoWidth": true,
|
mas01mj@640
|
795 "bProcessing": false,
|
mas01mj@640
|
796 "bSortClasses": true,
|
mas01mj@640
|
797 "bStateSave": false,
|
mas01mj@640
|
798 "bServerSide": false
|
mas01mj@640
|
799 };
|
mas01mj@640
|
800
|
mas01mj@640
|
801 /*
|
mas01mj@640
|
802 * Variable: anFeatures
|
mas01mj@640
|
803 * Purpose: Array referencing the nodes which are used for the features
|
mas01mj@640
|
804 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
805 * Notes: The parameters of this object match what is allowed by sDom - i.e.
|
mas01mj@640
|
806 * 'l' - Length changing
|
mas01mj@640
|
807 * 'f' - Filtering input
|
mas01mj@640
|
808 * 't' - The table!
|
mas01mj@640
|
809 * 'i' - Information
|
mas01mj@640
|
810 * 'p' - Pagination
|
mas01mj@640
|
811 * 'r' - pRocessing
|
mas01mj@640
|
812 */
|
mas01mj@640
|
813 this.anFeatures = [];
|
mas01mj@640
|
814
|
mas01mj@640
|
815 /*
|
mas01mj@640
|
816 * Variable: oLanguage
|
mas01mj@640
|
817 * Purpose: Store the language strings used by dataTables
|
mas01mj@640
|
818 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
819 * Notes: The words in the format _VAR_ are variables which are dynamically replaced
|
mas01mj@640
|
820 * by javascript
|
mas01mj@640
|
821 */
|
mas01mj@640
|
822 this.oLanguage = {
|
mas01mj@640
|
823 "sProcessing": "Processing...",
|
mas01mj@640
|
824 "sLengthMenu": "Show _MENU_ entries",
|
mas01mj@640
|
825 "sZeroRecords": "No matching records found",
|
mas01mj@640
|
826 "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
|
mas01mj@640
|
827 "sInfoEmpty": "Showing 0 to 0 of 0 entries",
|
mas01mj@640
|
828 "sInfoFiltered": "(filtered from _MAX_ total entries)",
|
mas01mj@640
|
829 "sInfoPostFix": "",
|
mas01mj@640
|
830 "sSearch": "Search:",
|
mas01mj@640
|
831 "sUrl": "",
|
mas01mj@640
|
832 "oPaginate": {
|
mas01mj@640
|
833 "sFirst": "First",
|
mas01mj@640
|
834 "sPrevious": "Previous",
|
mas01mj@640
|
835 "sNext": "Next",
|
mas01mj@640
|
836 "sLast": "Last"
|
mas01mj@640
|
837 }
|
mas01mj@640
|
838 };
|
mas01mj@640
|
839
|
mas01mj@640
|
840 /*
|
mas01mj@640
|
841 * Variable: aoData
|
mas01mj@640
|
842 * Purpose: Store data information
|
mas01mj@640
|
843 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
844 * Notes: This is an array of objects with the following parameters:
|
mas01mj@640
|
845 * int: _iId - internal id for tracking
|
mas01mj@640
|
846 * array: _aData - internal data - used for sorting / filtering etc
|
mas01mj@640
|
847 * node: nTr - display node
|
mas01mj@640
|
848 * array node: _anHidden - hidden TD nodes
|
mas01mj@640
|
849 */
|
mas01mj@640
|
850 this.aoData = [];
|
mas01mj@640
|
851
|
mas01mj@640
|
852 /*
|
mas01mj@640
|
853 * Variable: aiDisplay
|
mas01mj@640
|
854 * Purpose: Array of indexes which are in the current display (after filtering etc)
|
mas01mj@640
|
855 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
856 */
|
mas01mj@640
|
857 this.aiDisplay = [];
|
mas01mj@640
|
858
|
mas01mj@640
|
859 /*
|
mas01mj@640
|
860 * Variable: aiDisplayMaster
|
mas01mj@640
|
861 * Purpose: Array of indexes for display - no filtering
|
mas01mj@640
|
862 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
863 */
|
mas01mj@640
|
864 this.aiDisplayMaster = [];
|
mas01mj@640
|
865
|
mas01mj@640
|
866 /*
|
mas01mj@640
|
867 * Variable: aoColumns
|
mas01mj@640
|
868 * Purpose: Store information about each column that is in use
|
mas01mj@640
|
869 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
870 */
|
mas01mj@640
|
871 this.aoColumns = [];
|
mas01mj@640
|
872
|
mas01mj@640
|
873 /*
|
mas01mj@640
|
874 * Variable: iNextId
|
mas01mj@640
|
875 * Purpose: Store the next unique id to be used for a new row
|
mas01mj@640
|
876 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
877 */
|
mas01mj@640
|
878 this.iNextId = 0;
|
mas01mj@640
|
879
|
mas01mj@640
|
880 /*
|
mas01mj@640
|
881 * Variable: asDataSearch
|
mas01mj@640
|
882 * Purpose: Search data array for regular expression searching
|
mas01mj@640
|
883 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
884 */
|
mas01mj@640
|
885 this.asDataSearch = [];
|
mas01mj@640
|
886
|
mas01mj@640
|
887 /*
|
mas01mj@640
|
888 * Variable: oPreviousSearch
|
mas01mj@640
|
889 * Purpose: Store the previous search incase we want to force a re-search
|
mas01mj@640
|
890 * or compare the old search to a new one
|
mas01mj@640
|
891 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
892 */
|
mas01mj@640
|
893 this.oPreviousSearch = {
|
mas01mj@640
|
894 "sSearch": "",
|
mas01mj@640
|
895 "bEscapeRegex": true
|
mas01mj@640
|
896 };
|
mas01mj@640
|
897
|
mas01mj@640
|
898 /*
|
mas01mj@640
|
899 * Variable: aoPreSearchCols
|
mas01mj@640
|
900 * Purpose: Store the previous search for each column
|
mas01mj@640
|
901 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
902 */
|
mas01mj@640
|
903 this.aoPreSearchCols = [];
|
mas01mj@640
|
904
|
mas01mj@640
|
905 /*
|
mas01mj@640
|
906 * Variable: aaSorting
|
mas01mj@640
|
907 * Purpose: Sorting information
|
mas01mj@640
|
908 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
909 */
|
mas01mj@640
|
910 this.aaSorting = [ [0, 'asc'] ];
|
mas01mj@640
|
911
|
mas01mj@640
|
912 /*
|
mas01mj@640
|
913 * Variable: aaSortingFixed
|
mas01mj@640
|
914 * Purpose: Sorting information that is always applied
|
mas01mj@640
|
915 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
916 */
|
mas01mj@640
|
917 this.aaSortingFixed = null;
|
mas01mj@640
|
918
|
mas01mj@640
|
919 /*
|
mas01mj@640
|
920 * Variable: asStripClasses
|
mas01mj@640
|
921 * Purpose: Classes to use for the striping of a table
|
mas01mj@640
|
922 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
923 */
|
mas01mj@640
|
924 this.asStripClasses = [];
|
mas01mj@640
|
925
|
mas01mj@640
|
926 /*
|
mas01mj@640
|
927 * Variable: fnRowCallback
|
mas01mj@640
|
928 * Purpose: Call this function every time a row is inserted (draw)
|
mas01mj@640
|
929 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
930 */
|
mas01mj@640
|
931 this.fnRowCallback = null;
|
mas01mj@640
|
932
|
mas01mj@640
|
933 /*
|
mas01mj@640
|
934 * Variable: fnHeaderCallback
|
mas01mj@640
|
935 * Purpose: Callback function for the header on each draw
|
mas01mj@640
|
936 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
937 */
|
mas01mj@640
|
938 this.fnHeaderCallback = null;
|
mas01mj@640
|
939
|
mas01mj@640
|
940 /*
|
mas01mj@640
|
941 * Variable: fnFooterCallback
|
mas01mj@640
|
942 * Purpose: Callback function for the footer on each draw
|
mas01mj@640
|
943 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
944 */
|
mas01mj@640
|
945 this.fnFooterCallback = null;
|
mas01mj@640
|
946
|
mas01mj@640
|
947 /*
|
mas01mj@640
|
948 * Variable: fnDrawCallback
|
mas01mj@640
|
949 * Purpose: Callback function for the whole table on each draw
|
mas01mj@640
|
950 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
951 */
|
mas01mj@640
|
952 this.fnDrawCallback = null;
|
mas01mj@640
|
953
|
mas01mj@640
|
954 /*
|
mas01mj@640
|
955 * Variable: fnInitComplete
|
mas01mj@640
|
956 * Purpose: Callback function for when the table has been initalised
|
mas01mj@640
|
957 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
958 */
|
mas01mj@640
|
959 this.fnInitComplete = null;
|
mas01mj@640
|
960
|
mas01mj@640
|
961 /*
|
mas01mj@640
|
962 * Variable: sTableId
|
mas01mj@640
|
963 * Purpose: Cache the table ID for quick access
|
mas01mj@640
|
964 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
965 */
|
mas01mj@640
|
966 this.sTableId = "";
|
mas01mj@640
|
967
|
mas01mj@640
|
968 /*
|
mas01mj@640
|
969 * Variable: nTable
|
mas01mj@640
|
970 * Purpose: Cache the table node for quick access
|
mas01mj@640
|
971 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
972 */
|
mas01mj@640
|
973 this.nTable = null;
|
mas01mj@640
|
974
|
mas01mj@640
|
975 /*
|
mas01mj@640
|
976 * Variable: iDefaultSortIndex
|
mas01mj@640
|
977 * Purpose: Sorting index which will be used by default
|
mas01mj@640
|
978 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
979 */
|
mas01mj@640
|
980 this.iDefaultSortIndex = 0;
|
mas01mj@640
|
981
|
mas01mj@640
|
982 /*
|
mas01mj@640
|
983 * Variable: bInitialised
|
mas01mj@640
|
984 * Purpose: Indicate if all required information has been read in
|
mas01mj@640
|
985 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
986 */
|
mas01mj@640
|
987 this.bInitialised = false;
|
mas01mj@640
|
988
|
mas01mj@640
|
989 /*
|
mas01mj@640
|
990 * Variable: aoOpenRows
|
mas01mj@640
|
991 * Purpose: Information about open rows
|
mas01mj@640
|
992 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
993 * Notes: Has the parameters 'nTr' and 'nParent'
|
mas01mj@640
|
994 */
|
mas01mj@640
|
995 this.aoOpenRows = [];
|
mas01mj@640
|
996
|
mas01mj@640
|
997 /*
|
mas01mj@640
|
998 * Variable: sDomPositioning
|
mas01mj@640
|
999 * Purpose: Dictate the positioning that the created elements will take
|
mas01mj@640
|
1000 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1001 * Notes: The following syntax is expected:
|
mas01mj@640
|
1002 * 'l' - Length changing
|
mas01mj@640
|
1003 * 'f' - Filtering input
|
mas01mj@640
|
1004 * 't' - The table!
|
mas01mj@640
|
1005 * 'i' - Information
|
mas01mj@640
|
1006 * 'p' - Pagination
|
mas01mj@640
|
1007 * 'r' - pRocessing
|
mas01mj@640
|
1008 * '<' and '>' - div elements
|
mas01mj@640
|
1009 * '<"class" and '>' - div with a class
|
mas01mj@640
|
1010 * Examples: '<"wrapper"flipt>', '<lf<t>ip>'
|
mas01mj@640
|
1011 */
|
mas01mj@640
|
1012 this.sDomPositioning = 'lfrtip';
|
mas01mj@640
|
1013
|
mas01mj@640
|
1014 /*
|
mas01mj@640
|
1015 * Variable: sPaginationType
|
mas01mj@640
|
1016 * Purpose: Note which type of sorting should be used
|
mas01mj@640
|
1017 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1018 */
|
mas01mj@640
|
1019 this.sPaginationType = "two_button";
|
mas01mj@640
|
1020
|
mas01mj@640
|
1021 /*
|
mas01mj@640
|
1022 * Variable: iCookieDuration
|
mas01mj@640
|
1023 * Purpose: The cookie duration (for bStateSave) in seconds - default 2 hours
|
mas01mj@640
|
1024 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1025 */
|
mas01mj@640
|
1026 this.iCookieDuration = 60 * 60 * 2;
|
mas01mj@640
|
1027
|
mas01mj@640
|
1028 /*
|
mas01mj@640
|
1029 * Variable: sAjaxSource
|
mas01mj@640
|
1030 * Purpose: Source url for AJAX data for the table
|
mas01mj@640
|
1031 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1032 */
|
mas01mj@640
|
1033 this.sAjaxSource = null;
|
mas01mj@640
|
1034
|
mas01mj@640
|
1035 /*
|
mas01mj@640
|
1036 * Variable: bAjaxDataGet
|
mas01mj@640
|
1037 * Purpose: Note if draw should be blocked while getting data
|
mas01mj@640
|
1038 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1039 */
|
mas01mj@640
|
1040 this.bAjaxDataGet = true;
|
mas01mj@640
|
1041
|
mas01mj@640
|
1042 /*
|
mas01mj@640
|
1043 * Variable: fnServerData
|
mas01mj@640
|
1044 * Purpose: Function to get the server-side data - can be overruled by the developer
|
mas01mj@640
|
1045 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1046 */
|
mas01mj@640
|
1047 this.fnServerData = $.getJSON;
|
mas01mj@640
|
1048
|
mas01mj@640
|
1049 /*
|
mas01mj@640
|
1050 * Variable: iServerDraw
|
mas01mj@640
|
1051 * Purpose: Counter and tracker for server-side processing draws
|
mas01mj@640
|
1052 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1053 */
|
mas01mj@640
|
1054 this.iServerDraw = 0;
|
mas01mj@640
|
1055
|
mas01mj@640
|
1056 /*
|
mas01mj@640
|
1057 * Variable: _iDisplayLength, _iDisplayStart, _iDisplayEnd
|
mas01mj@640
|
1058 * Purpose: Display length variables
|
mas01mj@640
|
1059 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1060 * Notes: These variable must NOT be used externally to get the data length. Rather, use
|
mas01mj@640
|
1061 * the fnRecordsTotal() (etc) functions.
|
mas01mj@640
|
1062 */
|
mas01mj@640
|
1063 this._iDisplayLength = 10;
|
mas01mj@640
|
1064 this._iDisplayStart = 0;
|
mas01mj@640
|
1065 this._iDisplayEnd = 10;
|
mas01mj@640
|
1066
|
mas01mj@640
|
1067 /*
|
mas01mj@640
|
1068 * Variable: _iRecordsTotal, _iRecordsDisplay
|
mas01mj@640
|
1069 * Purpose: Display length variables used for server side processing
|
mas01mj@640
|
1070 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1071 * Notes: These variable must NOT be used externally to get the data length. Rather, use
|
mas01mj@640
|
1072 * the fnRecordsTotal() (etc) functions.
|
mas01mj@640
|
1073 */
|
mas01mj@640
|
1074 this._iRecordsTotal = 0;
|
mas01mj@640
|
1075 this._iRecordsDisplay = 0;
|
mas01mj@640
|
1076
|
mas01mj@640
|
1077 /*
|
mas01mj@640
|
1078 * Variable: bJUI
|
mas01mj@640
|
1079 * Purpose: Should we add the markup needed for jQuery UI theming?
|
mas01mj@640
|
1080 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1081 */
|
mas01mj@640
|
1082 this.bJUI = false;
|
mas01mj@640
|
1083
|
mas01mj@640
|
1084 /*
|
mas01mj@640
|
1085 * Variable: bJUI
|
mas01mj@640
|
1086 * Purpose: Should we add the markup needed for jQuery UI theming?
|
mas01mj@640
|
1087 * Scope: jQuery.dataTable.classSettings
|
mas01mj@640
|
1088 */
|
mas01mj@640
|
1089 this.oClasses = _oExt.oStdClasses;
|
mas01mj@640
|
1090 }
|
mas01mj@640
|
1091
|
mas01mj@640
|
1092 /*
|
mas01mj@640
|
1093 * Variable: oApi
|
mas01mj@640
|
1094 * Purpose: Container for publicly exposed 'private' functions
|
mas01mj@640
|
1095 * Scope: jQuery.dataTable
|
mas01mj@640
|
1096 */
|
mas01mj@640
|
1097 this.oApi = {};
|
mas01mj@640
|
1098
|
mas01mj@640
|
1099
|
mas01mj@640
|
1100 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
1101 * API functions
|
mas01mj@640
|
1102 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
mas01mj@640
|
1103
|
mas01mj@640
|
1104 /*
|
mas01mj@640
|
1105 * Function: fnDraw
|
mas01mj@640
|
1106 * Purpose: Redraw the table
|
mas01mj@640
|
1107 * Returns: -
|
mas01mj@640
|
1108 * Inputs: -
|
mas01mj@640
|
1109 */
|
mas01mj@640
|
1110 this.fnDraw = function()
|
mas01mj@640
|
1111 {
|
mas01mj@640
|
1112 _fnReDraw( _fnSettingsFromNode( this[_oExt.iApiIndex] ) );
|
mas01mj@640
|
1113 };
|
mas01mj@640
|
1114
|
mas01mj@640
|
1115 /*
|
mas01mj@640
|
1116 * Function: fnFilter
|
mas01mj@640
|
1117 * Purpose: Filter the input based on data
|
mas01mj@640
|
1118 * Returns: -
|
mas01mj@640
|
1119 * Inputs: string:sInput - string to filter the table on
|
mas01mj@640
|
1120 * int:iColumn - optional - column to limit filtering to
|
mas01mj@640
|
1121 * bool:bEscapeRegex - optional - escape regex characters or not - default true
|
mas01mj@640
|
1122 */
|
mas01mj@640
|
1123 this.fnFilter = function( sInput, iColumn, bEscapeRegex )
|
mas01mj@640
|
1124 {
|
mas01mj@640
|
1125 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1126
|
mas01mj@640
|
1127 if ( typeof bEscapeRegex == 'undefined' )
|
mas01mj@640
|
1128 {
|
mas01mj@640
|
1129 bEscapeRegex = true;
|
mas01mj@640
|
1130 }
|
mas01mj@640
|
1131
|
mas01mj@640
|
1132 if ( typeof iColumn == "undefined" || iColumn === null )
|
mas01mj@640
|
1133 {
|
mas01mj@640
|
1134 /* Global filter */
|
mas01mj@640
|
1135 _fnFilterComplete( oSettings, {"sSearch":sInput, "bEscapeRegex": bEscapeRegex}, 1 );
|
mas01mj@640
|
1136 }
|
mas01mj@640
|
1137 else
|
mas01mj@640
|
1138 {
|
mas01mj@640
|
1139 /* Single column filter */
|
mas01mj@640
|
1140 oSettings.aoPreSearchCols[ iColumn ].sSearch = sInput;
|
mas01mj@640
|
1141 oSettings.aoPreSearchCols[ iColumn ].bEscapeRegex = bEscapeRegex;
|
mas01mj@640
|
1142 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
|
mas01mj@640
|
1143 }
|
mas01mj@640
|
1144 };
|
mas01mj@640
|
1145
|
mas01mj@640
|
1146 /*
|
mas01mj@640
|
1147 * Function: fnSettings
|
mas01mj@640
|
1148 * Purpose: Get the settings for a particular table for extern. manipulation
|
mas01mj@640
|
1149 * Returns: -
|
mas01mj@640
|
1150 * Inputs: -
|
mas01mj@640
|
1151 */
|
mas01mj@640
|
1152 this.fnSettings = function( nNode )
|
mas01mj@640
|
1153 {
|
mas01mj@640
|
1154 return _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1155 };
|
mas01mj@640
|
1156
|
mas01mj@640
|
1157 /*
|
mas01mj@640
|
1158 * Function: fnSort
|
mas01mj@640
|
1159 * Purpose: Sort the table by a particular row
|
mas01mj@640
|
1160 * Returns: -
|
mas01mj@640
|
1161 * Inputs: int:iCol - the data index to sort on. Note that this will
|
mas01mj@640
|
1162 * not match the 'display index' if you have hidden data entries
|
mas01mj@640
|
1163 */
|
mas01mj@640
|
1164 this.fnSort = function( aaSort )
|
mas01mj@640
|
1165 {
|
mas01mj@640
|
1166 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1167 oSettings.aaSorting = aaSort;
|
mas01mj@640
|
1168 _fnSort( oSettings );
|
mas01mj@640
|
1169 };
|
mas01mj@640
|
1170
|
mas01mj@640
|
1171 /*
|
mas01mj@640
|
1172 * Function: fnAddData
|
mas01mj@640
|
1173 * Purpose: Add new row(s) into the table
|
mas01mj@640
|
1174 * Returns: array int: array of indexes (aoData) which have been added (zero length on error)
|
mas01mj@640
|
1175 * Inputs: array:mData - the data to be added. The length must match
|
mas01mj@640
|
1176 * the original data from the DOM
|
mas01mj@640
|
1177 * or
|
mas01mj@640
|
1178 * array array:mData - 2D array of data to be added
|
mas01mj@640
|
1179 * bool:bRedraw - redraw the table or not - default true
|
mas01mj@640
|
1180 * Notes: Warning - the refilter here will cause the table to redraw
|
mas01mj@640
|
1181 * starting at zero
|
mas01mj@640
|
1182 * Notes: Thanks to Yekimov Denis for contributing the basis for this function!
|
mas01mj@640
|
1183 */
|
mas01mj@640
|
1184 this.fnAddData = function( mData, bRedraw )
|
mas01mj@640
|
1185 {
|
mas01mj@640
|
1186 var aiReturn = [];
|
mas01mj@640
|
1187 var iTest;
|
mas01mj@640
|
1188 if ( typeof bRedraw == 'undefined' )
|
mas01mj@640
|
1189 {
|
mas01mj@640
|
1190 bRedraw = true;
|
mas01mj@640
|
1191 }
|
mas01mj@640
|
1192
|
mas01mj@640
|
1193 /* Find settings from table node */
|
mas01mj@640
|
1194 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1195
|
mas01mj@640
|
1196 /* Check if we want to add multiple rows or not */
|
mas01mj@640
|
1197 if ( typeof mData[0] == "object" )
|
mas01mj@640
|
1198 {
|
mas01mj@640
|
1199 for ( var i=0 ; i<mData.length ; i++ )
|
mas01mj@640
|
1200 {
|
mas01mj@640
|
1201 iTest = _fnAddData( oSettings, mData[i] );
|
mas01mj@640
|
1202 if ( iTest == -1 )
|
mas01mj@640
|
1203 {
|
mas01mj@640
|
1204 return aiReturn;
|
mas01mj@640
|
1205 }
|
mas01mj@640
|
1206 aiReturn.push( iTest );
|
mas01mj@640
|
1207 }
|
mas01mj@640
|
1208 }
|
mas01mj@640
|
1209 else
|
mas01mj@640
|
1210 {
|
mas01mj@640
|
1211 iTest = _fnAddData( oSettings, mData );
|
mas01mj@640
|
1212 if ( iTest == -1 )
|
mas01mj@640
|
1213 {
|
mas01mj@640
|
1214 return aiReturn;
|
mas01mj@640
|
1215 }
|
mas01mj@640
|
1216 aiReturn.push( iTest );
|
mas01mj@640
|
1217 }
|
mas01mj@640
|
1218
|
mas01mj@640
|
1219 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
1220
|
mas01mj@640
|
1221 /* Rebuild the search */
|
mas01mj@640
|
1222 _fnBuildSearchArray( oSettings, 1 );
|
mas01mj@640
|
1223
|
mas01mj@640
|
1224 if ( bRedraw )
|
mas01mj@640
|
1225 {
|
mas01mj@640
|
1226 _fnReDraw( oSettings );
|
mas01mj@640
|
1227 }
|
mas01mj@640
|
1228 return aiReturn;
|
mas01mj@640
|
1229 };
|
mas01mj@640
|
1230
|
mas01mj@640
|
1231 /*
|
mas01mj@640
|
1232 * Function: fnDeleteRow
|
mas01mj@640
|
1233 * Purpose: Remove a row for the table
|
mas01mj@640
|
1234 * Returns: array:aReturn - the row that was deleted
|
mas01mj@640
|
1235 * Inputs: int:iIndex - index of aoData to be deleted
|
mas01mj@640
|
1236 * function:fnCallBack - callback function - default null
|
mas01mj@640
|
1237 * bool:bNullRow - remove the row information from aoData by setting the value to
|
mas01mj@640
|
1238 * null - default false
|
mas01mj@640
|
1239 * Notes: This function requires a little explanation - we don't actually delete the data
|
mas01mj@640
|
1240 * from aoData - rather we remove it's references from aiDisplayMastr and aiDisplay. This
|
mas01mj@640
|
1241 * in effect prevnts DataTables from drawing it (hence deleting it) - it could be restored
|
mas01mj@640
|
1242 * if you really wanted. The reason for this is that actually removing the aoData object
|
mas01mj@640
|
1243 * would mess up all the subsequent indexes in the display arrays (they could be ajusted -
|
mas01mj@640
|
1244 * but this appears to do what is required).
|
mas01mj@640
|
1245 */
|
mas01mj@640
|
1246 this.fnDeleteRow = function( iAODataIndex, fnCallBack, bNullRow )
|
mas01mj@640
|
1247 {
|
mas01mj@640
|
1248 /* Find settings from table node */
|
mas01mj@640
|
1249 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1250 var i;
|
mas01mj@640
|
1251
|
mas01mj@640
|
1252 /* Delete from the display master */
|
mas01mj@640
|
1253 for ( i=0 ; i<oSettings.aiDisplayMaster.length ; i++ )
|
mas01mj@640
|
1254 {
|
mas01mj@640
|
1255 if ( oSettings.aiDisplayMaster[i] == iAODataIndex )
|
mas01mj@640
|
1256 {
|
mas01mj@640
|
1257 oSettings.aiDisplayMaster.splice( i, 1 );
|
mas01mj@640
|
1258 break;
|
mas01mj@640
|
1259 }
|
mas01mj@640
|
1260 }
|
mas01mj@640
|
1261
|
mas01mj@640
|
1262 /* Delete from the current display index */
|
mas01mj@640
|
1263 for ( i=0 ; i<oSettings.aiDisplay.length ; i++ )
|
mas01mj@640
|
1264 {
|
mas01mj@640
|
1265 if ( oSettings.aiDisplay[i] == iAODataIndex )
|
mas01mj@640
|
1266 {
|
mas01mj@640
|
1267 oSettings.aiDisplay.splice( i, 1 );
|
mas01mj@640
|
1268 break;
|
mas01mj@640
|
1269 }
|
mas01mj@640
|
1270 }
|
mas01mj@640
|
1271
|
mas01mj@640
|
1272 /* Rebuild the search */
|
mas01mj@640
|
1273 _fnBuildSearchArray( oSettings, 1 );
|
mas01mj@640
|
1274
|
mas01mj@640
|
1275 /* If there is a user callback function - call it */
|
mas01mj@640
|
1276 if ( typeof fnCallBack == "function" )
|
mas01mj@640
|
1277 {
|
mas01mj@640
|
1278 fnCallBack.call( this );
|
mas01mj@640
|
1279 }
|
mas01mj@640
|
1280
|
mas01mj@640
|
1281 /* Check for an 'overflow' they case for dislaying the table */
|
mas01mj@640
|
1282 if ( oSettings._iDisplayStart >= oSettings.aiDisplay.length )
|
mas01mj@640
|
1283 {
|
mas01mj@640
|
1284 oSettings._iDisplayStart -= oSettings._iDisplayLength;
|
mas01mj@640
|
1285 if ( oSettings._iDisplayStart < 0 )
|
mas01mj@640
|
1286 {
|
mas01mj@640
|
1287 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
1288 }
|
mas01mj@640
|
1289 }
|
mas01mj@640
|
1290
|
mas01mj@640
|
1291 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
1292 _fnDraw( oSettings );
|
mas01mj@640
|
1293
|
mas01mj@640
|
1294 /* Return the data array from this row */
|
mas01mj@640
|
1295 var aData = oSettings.aoData[iAODataIndex]._aData.slice();
|
mas01mj@640
|
1296
|
mas01mj@640
|
1297 if ( typeof bNullRow != "undefined" && bNullRow === true )
|
mas01mj@640
|
1298 {
|
mas01mj@640
|
1299 oSettings.aoData[iAODataIndex] = null;
|
mas01mj@640
|
1300 }
|
mas01mj@640
|
1301
|
mas01mj@640
|
1302 return aData;
|
mas01mj@640
|
1303 };
|
mas01mj@640
|
1304
|
mas01mj@640
|
1305 /*
|
mas01mj@640
|
1306 * Function: fnClearTable
|
mas01mj@640
|
1307 * Purpose: Quickly and simply clear a table
|
mas01mj@640
|
1308 * Returns: -
|
mas01mj@640
|
1309 * Inputs: bool:bRedraw - redraw the table or not - default true
|
mas01mj@640
|
1310 * Notes: Thanks to Yekimov Denis for contributing the basis for this function!
|
mas01mj@640
|
1311 */
|
mas01mj@640
|
1312 this.fnClearTable = function( bRedraw )
|
mas01mj@640
|
1313 {
|
mas01mj@640
|
1314 /* Find settings from table node */
|
mas01mj@640
|
1315 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1316 _fnClearTable( oSettings );
|
mas01mj@640
|
1317
|
mas01mj@640
|
1318 if ( typeof bRedraw == 'undefined' || bRedraw )
|
mas01mj@640
|
1319 {
|
mas01mj@640
|
1320 _fnDraw( oSettings );
|
mas01mj@640
|
1321 }
|
mas01mj@640
|
1322 };
|
mas01mj@640
|
1323
|
mas01mj@640
|
1324 /*
|
mas01mj@640
|
1325 * Function: fnOpen
|
mas01mj@640
|
1326 * Purpose: Open a display row (append a row after the row in question)
|
mas01mj@640
|
1327 * Returns: -
|
mas01mj@640
|
1328 * Inputs: node:nTr - the table row to 'open'
|
mas01mj@640
|
1329 * string:sHtml - the HTML to put into the row
|
mas01mj@640
|
1330 * string:sClass - class to give the new cell
|
mas01mj@640
|
1331 */
|
mas01mj@640
|
1332 this.fnOpen = function( nTr, sHtml, sClass )
|
mas01mj@640
|
1333 {
|
mas01mj@640
|
1334 /* Find settings from table node */
|
mas01mj@640
|
1335 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1336
|
mas01mj@640
|
1337 /* the old open one if there is one */
|
mas01mj@640
|
1338 this.fnClose( nTr );
|
mas01mj@640
|
1339
|
mas01mj@640
|
1340
|
mas01mj@640
|
1341 var nNewRow = document.createElement("tr");
|
mas01mj@640
|
1342 var nNewCell = document.createElement("td");
|
mas01mj@640
|
1343 nNewRow.appendChild( nNewCell );
|
mas01mj@640
|
1344 nNewCell.className = sClass;
|
mas01mj@640
|
1345 nNewCell.colSpan = _fnVisbleColumns( oSettings );
|
mas01mj@640
|
1346 nNewCell.innerHTML = sHtml;
|
mas01mj@640
|
1347
|
mas01mj@640
|
1348 $(nNewRow).insertAfter(nTr);
|
mas01mj@640
|
1349
|
mas01mj@640
|
1350 /* No point in storing the row if using server-side processing since the nParent will be
|
mas01mj@640
|
1351 * nuked on a re-draw anyway
|
mas01mj@640
|
1352 */
|
mas01mj@640
|
1353 if ( !oSettings.oFeatures.bServerSide )
|
mas01mj@640
|
1354 {
|
mas01mj@640
|
1355 oSettings.aoOpenRows.push( {
|
mas01mj@640
|
1356 "nTr": nNewRow,
|
mas01mj@640
|
1357 "nParent": nTr
|
mas01mj@640
|
1358 } );
|
mas01mj@640
|
1359 }
|
mas01mj@640
|
1360 };
|
mas01mj@640
|
1361
|
mas01mj@640
|
1362 /*
|
mas01mj@640
|
1363 * Function: fnClose
|
mas01mj@640
|
1364 * Purpose: Close a display row
|
mas01mj@640
|
1365 * Returns: int: 0 (success) or 1 (failed)
|
mas01mj@640
|
1366 * Inputs: node:nTr - the table row to 'close'
|
mas01mj@640
|
1367 */
|
mas01mj@640
|
1368 this.fnClose = function( nTr )
|
mas01mj@640
|
1369 {
|
mas01mj@640
|
1370 /* Find settings from table node */
|
mas01mj@640
|
1371 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1372
|
mas01mj@640
|
1373 for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
|
mas01mj@640
|
1374 {
|
mas01mj@640
|
1375 if ( oSettings.aoOpenRows[i].nParent == nTr )
|
mas01mj@640
|
1376 {
|
mas01mj@640
|
1377 var nTrParent = oSettings.aoOpenRows[i].nTr.parentNode;
|
mas01mj@640
|
1378 if ( nTrParent )
|
mas01mj@640
|
1379 {
|
mas01mj@640
|
1380 /* Remove it if it is currently on display */
|
mas01mj@640
|
1381 nTrParent.removeChild( oSettings.aoOpenRows[i].nTr );
|
mas01mj@640
|
1382 }
|
mas01mj@640
|
1383 oSettings.aoOpenRows.splice( i, 1 );
|
mas01mj@640
|
1384 return 0;
|
mas01mj@640
|
1385 }
|
mas01mj@640
|
1386 }
|
mas01mj@640
|
1387 return 1;
|
mas01mj@640
|
1388 };
|
mas01mj@640
|
1389
|
mas01mj@640
|
1390 /*
|
mas01mj@640
|
1391 * Function: fnGetData
|
mas01mj@640
|
1392 * Purpose: Return an array with the data which is used to make up the table
|
mas01mj@640
|
1393 * Returns: array array string: 2d data array ([row][column]) or array string: 1d data array
|
mas01mj@640
|
1394 * or
|
mas01mj@640
|
1395 * array string (if iRow specified)
|
mas01mj@640
|
1396 * Inputs: int:iRow - optional - if present then the array returned will be the data for
|
mas01mj@640
|
1397 * the row with the index 'iRow'
|
mas01mj@640
|
1398 */
|
mas01mj@640
|
1399 this.fnGetData = function( iRow )
|
mas01mj@640
|
1400 {
|
mas01mj@640
|
1401 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1402
|
mas01mj@640
|
1403 if ( typeof iRow != 'undefined' )
|
mas01mj@640
|
1404 {
|
mas01mj@640
|
1405 return oSettings.aoData[iRow]._aData;
|
mas01mj@640
|
1406 }
|
mas01mj@640
|
1407 return _fnGetDataMaster( oSettings );
|
mas01mj@640
|
1408 };
|
mas01mj@640
|
1409
|
mas01mj@640
|
1410 /*
|
mas01mj@640
|
1411 * Function: fnGetNodes
|
mas01mj@640
|
1412 * Purpose: Return an array with the TR nodes used for drawing the table
|
mas01mj@640
|
1413 * Returns: array node: TR elements
|
mas01mj@640
|
1414 * or
|
mas01mj@640
|
1415 * node (if iRow specified)
|
mas01mj@640
|
1416 * Inputs: int:iRow - optional - if present then the array returned will be the node for
|
mas01mj@640
|
1417 * the row with the index 'iRow'
|
mas01mj@640
|
1418 */
|
mas01mj@640
|
1419 this.fnGetNodes = function( iRow )
|
mas01mj@640
|
1420 {
|
mas01mj@640
|
1421 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1422
|
mas01mj@640
|
1423 if ( typeof iRow != 'undefined' )
|
mas01mj@640
|
1424 {
|
mas01mj@640
|
1425 return oSettings.aoData[iRow].nTr;
|
mas01mj@640
|
1426 }
|
mas01mj@640
|
1427 return _fnGetTrNodes( oSettings );
|
mas01mj@640
|
1428 };
|
mas01mj@640
|
1429
|
mas01mj@640
|
1430 /*
|
mas01mj@640
|
1431 * Function: fnGetPosition
|
mas01mj@640
|
1432 * Purpose: Get the array indexes of a particular cell from it's DOM element
|
mas01mj@640
|
1433 * Returns: int: - row index, or array[ int, int ]: - row index and column index
|
mas01mj@640
|
1434 * Inputs: node:nNode - this can either be a TR or a TD in the table, the return is
|
mas01mj@640
|
1435 * dependent on this input
|
mas01mj@640
|
1436 */
|
mas01mj@640
|
1437 this.fnGetPosition = function( nNode )
|
mas01mj@640
|
1438 {
|
mas01mj@640
|
1439 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1440 var i;
|
mas01mj@640
|
1441
|
mas01mj@640
|
1442 if ( nNode.nodeName == "TR" )
|
mas01mj@640
|
1443 {
|
mas01mj@640
|
1444 for ( i=0 ; i<oSettings.aoData.length ; i++ )
|
mas01mj@640
|
1445 {
|
mas01mj@640
|
1446 if ( oSettings.aoData[i] !== null && oSettings.aoData[i].nTr == nNode )
|
mas01mj@640
|
1447 {
|
mas01mj@640
|
1448 return i;
|
mas01mj@640
|
1449 }
|
mas01mj@640
|
1450 }
|
mas01mj@640
|
1451 }
|
mas01mj@640
|
1452 else if ( nNode.nodeName == "TD" )
|
mas01mj@640
|
1453 {
|
mas01mj@640
|
1454 for ( i=0 ; i<oSettings.aoData.length ; i++ )
|
mas01mj@640
|
1455 {
|
mas01mj@640
|
1456 var iCorrector = 0;
|
mas01mj@640
|
1457 for ( var j=0 ; j<oSettings.aoColumns.length ; j++ )
|
mas01mj@640
|
1458 {
|
mas01mj@640
|
1459 if ( oSettings.aoColumns[j].bVisible )
|
mas01mj@640
|
1460 {
|
mas01mj@640
|
1461 //$('>td', oSettings.aoData[i].nTr)[j-iCorrector] == nNode )
|
mas01mj@640
|
1462 if ( oSettings.aoData[i] !== null &&
|
mas01mj@640
|
1463 oSettings.aoData[i].nTr.getElementsByTagName('td')[j-iCorrector] == nNode )
|
mas01mj@640
|
1464 {
|
mas01mj@640
|
1465 return [ i, j-iCorrector, j ];
|
mas01mj@640
|
1466 }
|
mas01mj@640
|
1467 }
|
mas01mj@640
|
1468 else
|
mas01mj@640
|
1469 {
|
mas01mj@640
|
1470 iCorrector++;
|
mas01mj@640
|
1471 }
|
mas01mj@640
|
1472 }
|
mas01mj@640
|
1473 }
|
mas01mj@640
|
1474 }
|
mas01mj@640
|
1475 return null;
|
mas01mj@640
|
1476 };
|
mas01mj@640
|
1477
|
mas01mj@640
|
1478 /*
|
mas01mj@640
|
1479 * Function: fnUpdate
|
mas01mj@640
|
1480 * Purpose: Update a table cell or row
|
mas01mj@640
|
1481 * Returns: int: 0 okay, 1 error
|
mas01mj@640
|
1482 * Inputs: array string 'or' string:mData - data to update the cell/row with
|
mas01mj@640
|
1483 * int:iRow - the row (from aoData) to update
|
mas01mj@640
|
1484 * int:iColumn - the column to update
|
mas01mj@640
|
1485 * bool:bRedraw - redraw the table or not - default true
|
mas01mj@640
|
1486 */
|
mas01mj@640
|
1487 this.fnUpdate = function( mData, iRow, iColumn, bRedraw )
|
mas01mj@640
|
1488 {
|
mas01mj@640
|
1489 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1490 var iVisibleColumn;
|
mas01mj@640
|
1491 var sDisplay;
|
mas01mj@640
|
1492 if ( typeof bRedraw == 'undefined' )
|
mas01mj@640
|
1493 {
|
mas01mj@640
|
1494 bRedraw = true;
|
mas01mj@640
|
1495 }
|
mas01mj@640
|
1496
|
mas01mj@640
|
1497 if ( typeof mData != 'object' )
|
mas01mj@640
|
1498 {
|
mas01mj@640
|
1499 sDisplay = mData;
|
mas01mj@640
|
1500 oSettings.aoData[iRow]._aData[iColumn] = sDisplay;
|
mas01mj@640
|
1501
|
mas01mj@640
|
1502 if ( oSettings.aoColumns[iColumn].fnRender !== null )
|
mas01mj@640
|
1503 {
|
mas01mj@640
|
1504 sDisplay = oSettings.aoColumns[iColumn].fnRender( {
|
mas01mj@640
|
1505 "iDataRow": iRow,
|
mas01mj@640
|
1506 "iDataColumn": iColumn,
|
mas01mj@640
|
1507 "aData": oSettings.aoData[iRow]._aData
|
mas01mj@640
|
1508 } );
|
mas01mj@640
|
1509
|
mas01mj@640
|
1510 if ( oSettings.aoColumns[iColumn].bUseRendered )
|
mas01mj@640
|
1511 {
|
mas01mj@640
|
1512 oSettings.aoData[iRow]._aData[iColumn] = sDisplay;
|
mas01mj@640
|
1513 }
|
mas01mj@640
|
1514 }
|
mas01mj@640
|
1515
|
mas01mj@640
|
1516 iVisibleColumn = _fnColumnIndexToVisible( oSettings, iColumn );
|
mas01mj@640
|
1517 if ( iVisibleColumn !== null )
|
mas01mj@640
|
1518 {
|
mas01mj@640
|
1519 oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
|
mas01mj@640
|
1520 sDisplay;
|
mas01mj@640
|
1521 }
|
mas01mj@640
|
1522 }
|
mas01mj@640
|
1523 else
|
mas01mj@640
|
1524 {
|
mas01mj@640
|
1525 if ( mData.length != oSettings.aoColumns.length )
|
mas01mj@640
|
1526 {
|
mas01mj@640
|
1527 alert( 'Warning: An array passed to fnUpdate must have the same number of columns as '+
|
mas01mj@640
|
1528 'the table in question - in this case '+oSettings.aoColumns.length );
|
mas01mj@640
|
1529 return 1;
|
mas01mj@640
|
1530 }
|
mas01mj@640
|
1531
|
mas01mj@640
|
1532 for ( var i=0 ; i<mData.length ; i++ )
|
mas01mj@640
|
1533 {
|
mas01mj@640
|
1534 sDisplay = mData[i];
|
mas01mj@640
|
1535 oSettings.aoData[iRow]._aData[i] = sDisplay;
|
mas01mj@640
|
1536
|
mas01mj@640
|
1537 if ( oSettings.aoColumns[i].fnRender !== null )
|
mas01mj@640
|
1538 {
|
mas01mj@640
|
1539 sDisplay = oSettings.aoColumns[i].fnRender( {
|
mas01mj@640
|
1540 "iDataRow": iRow,
|
mas01mj@640
|
1541 "iDataColumn": i,
|
mas01mj@640
|
1542 "aData": oSettings.aoData[iRow]._aData
|
mas01mj@640
|
1543 } );
|
mas01mj@640
|
1544
|
mas01mj@640
|
1545 if ( oSettings.aoColumns[i].bUseRendered )
|
mas01mj@640
|
1546 {
|
mas01mj@640
|
1547 oSettings.aoData[iRow]._aData[i] = sDisplay;
|
mas01mj@640
|
1548 }
|
mas01mj@640
|
1549 }
|
mas01mj@640
|
1550
|
mas01mj@640
|
1551 iVisibleColumn = _fnColumnIndexToVisible( oSettings, i );
|
mas01mj@640
|
1552 if ( iVisibleColumn !== null )
|
mas01mj@640
|
1553 {
|
mas01mj@640
|
1554 oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
|
mas01mj@640
|
1555 sDisplay;
|
mas01mj@640
|
1556 }
|
mas01mj@640
|
1557 }
|
mas01mj@640
|
1558 }
|
mas01mj@640
|
1559
|
mas01mj@640
|
1560 /* Update the search array */
|
mas01mj@640
|
1561 _fnBuildSearchArray( oSettings, 1 );
|
mas01mj@640
|
1562
|
mas01mj@640
|
1563 /* Redraw the table */
|
mas01mj@640
|
1564 if ( bRedraw )
|
mas01mj@640
|
1565 {
|
mas01mj@640
|
1566 _fnReDraw( oSettings );
|
mas01mj@640
|
1567 }
|
mas01mj@640
|
1568 return 0;
|
mas01mj@640
|
1569 };
|
mas01mj@640
|
1570
|
mas01mj@640
|
1571
|
mas01mj@640
|
1572 /*
|
mas01mj@640
|
1573 * Function: fnShowColoumn
|
mas01mj@640
|
1574 * Purpose: Show a particular column
|
mas01mj@640
|
1575 * Returns: -
|
mas01mj@640
|
1576 * Inputs: int:iCol - the column whose display should be changed
|
mas01mj@640
|
1577 * bool:bShow - show (true) or hide (false) the column
|
mas01mj@640
|
1578 */
|
mas01mj@640
|
1579 this.fnSetColumnVis = function ( iCol, bShow )
|
mas01mj@640
|
1580 {
|
mas01mj@640
|
1581 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
|
mas01mj@640
|
1582 var i, iLen;
|
mas01mj@640
|
1583 var iColumns = oSettings.aoColumns.length;
|
mas01mj@640
|
1584 var nTd;
|
mas01mj@640
|
1585
|
mas01mj@640
|
1586 /* No point in doing anything if we are requesting what is already true */
|
mas01mj@640
|
1587 if ( oSettings.aoColumns[iCol].bVisible == bShow )
|
mas01mj@640
|
1588 {
|
mas01mj@640
|
1589 return;
|
mas01mj@640
|
1590 }
|
mas01mj@640
|
1591
|
mas01mj@640
|
1592 var nTrHead = $('thead tr', oSettings.nTable)[0];
|
mas01mj@640
|
1593 var nTrFoot = $('tfoot tr', oSettings.nTable)[0];
|
mas01mj@640
|
1594 var anTheadTh = [];
|
mas01mj@640
|
1595 var anTfootTh = [];
|
mas01mj@640
|
1596 for ( i=0 ; i<iColumns ; i++ )
|
mas01mj@640
|
1597 {
|
mas01mj@640
|
1598 anTheadTh.push( oSettings.aoColumns[i].nTh );
|
mas01mj@640
|
1599 anTfootTh.push( oSettings.aoColumns[i].nTf );
|
mas01mj@640
|
1600 }
|
mas01mj@640
|
1601
|
mas01mj@640
|
1602 /* Show the column */
|
mas01mj@640
|
1603 if ( bShow )
|
mas01mj@640
|
1604 {
|
mas01mj@640
|
1605 var iInsert = 0;
|
mas01mj@640
|
1606 for ( i=0 ; i<iCol ; i++ )
|
mas01mj@640
|
1607 {
|
mas01mj@640
|
1608 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
1609 {
|
mas01mj@640
|
1610 iInsert++;
|
mas01mj@640
|
1611 }
|
mas01mj@640
|
1612 }
|
mas01mj@640
|
1613
|
mas01mj@640
|
1614 /* Need to decide if we should use appendChild or insertBefore */
|
mas01mj@640
|
1615 if ( iInsert >= _fnVisbleColumns( oSettings ) )
|
mas01mj@640
|
1616 {
|
mas01mj@640
|
1617 nTrHead.appendChild( anTheadTh[iCol] );
|
mas01mj@640
|
1618 if ( nTrFoot )
|
mas01mj@640
|
1619 {
|
mas01mj@640
|
1620 nTrFoot.appendChild( anTfootTh[iCol] );
|
mas01mj@640
|
1621 }
|
mas01mj@640
|
1622
|
mas01mj@640
|
1623 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
mas01mj@640
|
1624 {
|
mas01mj@640
|
1625 nTd = oSettings.aoData[i]._anHidden[iCol];
|
mas01mj@640
|
1626 oSettings.aoData[i].nTr.appendChild( nTd );
|
mas01mj@640
|
1627 }
|
mas01mj@640
|
1628 }
|
mas01mj@640
|
1629 else
|
mas01mj@640
|
1630 {
|
mas01mj@640
|
1631 /* Which coloumn should we be inserting before? */
|
mas01mj@640
|
1632 var iBefore;
|
mas01mj@640
|
1633 for ( i=iCol ; i<iColumns ; i++ )
|
mas01mj@640
|
1634 {
|
mas01mj@640
|
1635 iBefore = _fnColumnIndexToVisible( oSettings, i );
|
mas01mj@640
|
1636 if ( iBefore !== null )
|
mas01mj@640
|
1637 {
|
mas01mj@640
|
1638 break;
|
mas01mj@640
|
1639 }
|
mas01mj@640
|
1640 }
|
mas01mj@640
|
1641
|
mas01mj@640
|
1642 nTrHead.insertBefore( anTheadTh[iCol], nTrHead.getElementsByTagName('th')[iBefore] );
|
mas01mj@640
|
1643 if ( nTrFoot )
|
mas01mj@640
|
1644 {
|
mas01mj@640
|
1645 nTrFoot.insertBefore( anTfootTh[iCol], nTrFoot.getElementsByTagName('th')[iBefore] );
|
mas01mj@640
|
1646 }
|
mas01mj@640
|
1647
|
mas01mj@640
|
1648 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
mas01mj@640
|
1649 {
|
mas01mj@640
|
1650 nTd = oSettings.aoData[i]._anHidden[iCol];
|
mas01mj@640
|
1651 oSettings.aoData[i].nTr.insertBefore( nTd, oSettings.aoData[i].nTr.getElementsByTagName('td')[iBefore] );
|
mas01mj@640
|
1652 }
|
mas01mj@640
|
1653 }
|
mas01mj@640
|
1654
|
mas01mj@640
|
1655 oSettings.aoColumns[iCol].bVisible = true;
|
mas01mj@640
|
1656 }
|
mas01mj@640
|
1657 else
|
mas01mj@640
|
1658 {
|
mas01mj@640
|
1659 /* Remove a column from display */
|
mas01mj@640
|
1660 nTrHead.removeChild( anTheadTh[iCol] );
|
mas01mj@640
|
1661 if ( nTrFoot )
|
mas01mj@640
|
1662 {
|
mas01mj@640
|
1663 nTrFoot.removeChild( anTfootTh[iCol] );
|
mas01mj@640
|
1664 }
|
mas01mj@640
|
1665
|
mas01mj@640
|
1666 var iVisCol = _fnColumnIndexToVisible(oSettings, iCol);
|
mas01mj@640
|
1667 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
|
mas01mj@640
|
1668 {
|
mas01mj@640
|
1669 nTd = oSettings.aoData[i].nTr.getElementsByTagName('td')[ iVisCol ];
|
mas01mj@640
|
1670 oSettings.aoData[i]._anHidden[iCol] = nTd;
|
mas01mj@640
|
1671 nTd.parentNode.removeChild( nTd );
|
mas01mj@640
|
1672 }
|
mas01mj@640
|
1673
|
mas01mj@640
|
1674 oSettings.aoColumns[iCol].bVisible = false;
|
mas01mj@640
|
1675 }
|
mas01mj@640
|
1676
|
mas01mj@640
|
1677 /* If there are any 'open' rows, then we need to alter the colspan for this col change */
|
mas01mj@640
|
1678 for ( i=0, iLen=oSettings.aoOpenRows.length ; i<iLen ; i++ )
|
mas01mj@640
|
1679 {
|
mas01mj@640
|
1680 oSettings.aoOpenRows[i].nTr.colSpan = _fnVisbleColumns( oSettings );
|
mas01mj@640
|
1681 }
|
mas01mj@640
|
1682
|
mas01mj@640
|
1683 /* Since there is no redraw done here, we need to save the state manually */
|
mas01mj@640
|
1684 _fnSaveState( oSettings );
|
mas01mj@640
|
1685 };
|
mas01mj@640
|
1686
|
mas01mj@640
|
1687
|
mas01mj@640
|
1688 /*
|
mas01mj@640
|
1689 * Plugin API functions
|
mas01mj@640
|
1690 *
|
mas01mj@640
|
1691 * This call will add the functions which are defined in _oExt.oApi to the
|
mas01mj@640
|
1692 * DataTables object, providing a rather nice way to allow plug-in API functions. Note that
|
mas01mj@640
|
1693 * this is done here, so that API function can actually override the built in API functions if
|
mas01mj@640
|
1694 * required for a particular purpose.
|
mas01mj@640
|
1695 */
|
mas01mj@640
|
1696
|
mas01mj@640
|
1697 /*
|
mas01mj@640
|
1698 * Function: _fnExternApiFunc
|
mas01mj@640
|
1699 * Purpose: Create a wrapper function for exporting an internal func to an external API func
|
mas01mj@640
|
1700 * Returns: function: - wrapped function
|
mas01mj@640
|
1701 * Inputs: string:sFunc - API function name
|
mas01mj@640
|
1702 */
|
mas01mj@640
|
1703 function _fnExternApiFunc (sFunc)
|
mas01mj@640
|
1704 {
|
mas01mj@640
|
1705 return function() {
|
mas01mj@640
|
1706 var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
|
mas01mj@640
|
1707 Array.prototype.slice.call(arguments) );
|
mas01mj@640
|
1708 return _oExt.oApi[sFunc].apply( this, aArgs );
|
mas01mj@640
|
1709 };
|
mas01mj@640
|
1710 }
|
mas01mj@640
|
1711
|
mas01mj@640
|
1712 for ( var sFunc in _oExt.oApi )
|
mas01mj@640
|
1713 {
|
mas01mj@640
|
1714 if ( sFunc )
|
mas01mj@640
|
1715 {
|
mas01mj@640
|
1716 /*
|
mas01mj@640
|
1717 * Function: anon
|
mas01mj@640
|
1718 * Purpose: Wrap the plug-in API functions in order to provide the settings as 1st arg
|
mas01mj@640
|
1719 * and execute in this scope
|
mas01mj@640
|
1720 * Returns: -
|
mas01mj@640
|
1721 * Inputs: -
|
mas01mj@640
|
1722 */
|
mas01mj@640
|
1723 this[sFunc] = _fnExternApiFunc(sFunc);
|
mas01mj@640
|
1724 }
|
mas01mj@640
|
1725 }
|
mas01mj@640
|
1726
|
mas01mj@640
|
1727
|
mas01mj@640
|
1728
|
mas01mj@640
|
1729 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
1730 * Local functions
|
mas01mj@640
|
1731 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
mas01mj@640
|
1732
|
mas01mj@640
|
1733 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
1734 * Initalisation
|
mas01mj@640
|
1735 */
|
mas01mj@640
|
1736
|
mas01mj@640
|
1737 /*
|
mas01mj@640
|
1738 * Function: _fnInitalise
|
mas01mj@640
|
1739 * Purpose: Draw the table for the first time, adding all required features
|
mas01mj@640
|
1740 * Returns: -
|
mas01mj@640
|
1741 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
1742 */
|
mas01mj@640
|
1743 function _fnInitalise ( oSettings )
|
mas01mj@640
|
1744 {
|
mas01mj@640
|
1745 /* Ensure that the table data is fully initialised */
|
mas01mj@640
|
1746 if ( oSettings.bInitialised === false )
|
mas01mj@640
|
1747 {
|
mas01mj@640
|
1748 setTimeout( function(){ _fnInitalise( oSettings ); }, 200 );
|
mas01mj@640
|
1749 return;
|
mas01mj@640
|
1750 }
|
mas01mj@640
|
1751
|
mas01mj@640
|
1752 /* Show the display HTML options */
|
mas01mj@640
|
1753 _fnAddOptionsHtml( oSettings );
|
mas01mj@640
|
1754
|
mas01mj@640
|
1755 /* Draw the headers for the table */
|
mas01mj@640
|
1756 _fnDrawHead( oSettings );
|
mas01mj@640
|
1757
|
mas01mj@640
|
1758 /* If there is default sorting required - let's do it. The sort function
|
mas01mj@640
|
1759 * will do the drawing for us. Otherwise we draw the table
|
mas01mj@640
|
1760 */
|
mas01mj@640
|
1761 if ( oSettings.oFeatures.bSort )
|
mas01mj@640
|
1762 {
|
mas01mj@640
|
1763 _fnSort( oSettings, false );
|
mas01mj@640
|
1764 /*
|
mas01mj@640
|
1765 * Add the sorting classes to the header and the body (if needed).
|
mas01mj@640
|
1766 * Reason for doing it here after the first draw is to stop classes being applied to the
|
mas01mj@640
|
1767 * 'static' table.
|
mas01mj@640
|
1768 */
|
mas01mj@640
|
1769 _fnSortingClasses( oSettings );
|
mas01mj@640
|
1770 }
|
mas01mj@640
|
1771 else
|
mas01mj@640
|
1772 {
|
mas01mj@640
|
1773 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
1774 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
1775 _fnDraw( oSettings );
|
mas01mj@640
|
1776 }
|
mas01mj@640
|
1777
|
mas01mj@640
|
1778 /* if there is an ajax source */
|
mas01mj@640
|
1779 if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
|
mas01mj@640
|
1780 {
|
mas01mj@640
|
1781 _fnProcessingDisplay( oSettings, true );
|
mas01mj@640
|
1782
|
mas01mj@640
|
1783 $.getJSON( oSettings.sAjaxSource, null, function(json) {
|
mas01mj@640
|
1784
|
mas01mj@640
|
1785 /* Got the data - add it to the table */
|
mas01mj@640
|
1786 for ( var i=0 ; i<json.aaData.length ; i++ )
|
mas01mj@640
|
1787 {
|
mas01mj@640
|
1788 _fnAddData( oSettings, json.aaData[i] );
|
mas01mj@640
|
1789 }
|
mas01mj@640
|
1790
|
mas01mj@640
|
1791 /* Reset the init display for cookie saving. We've already done a filter, and
|
mas01mj@640
|
1792 * therefore cleared it before. So we need to make it appear 'fresh'
|
mas01mj@640
|
1793 */
|
mas01mj@640
|
1794 oSettings.iInitDisplayStart = oSettings._iDisplayStart;
|
mas01mj@640
|
1795
|
mas01mj@640
|
1796 if ( oSettings.oFeatures.bSort )
|
mas01mj@640
|
1797 {
|
mas01mj@640
|
1798 _fnSort( oSettings );
|
mas01mj@640
|
1799 }
|
mas01mj@640
|
1800 else
|
mas01mj@640
|
1801 {
|
mas01mj@640
|
1802 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
1803 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
1804 _fnDraw( oSettings );
|
mas01mj@640
|
1805 }
|
mas01mj@640
|
1806 _fnProcessingDisplay( oSettings, false );
|
mas01mj@640
|
1807
|
mas01mj@640
|
1808 /* Run the init callback if there is one */
|
mas01mj@640
|
1809 if ( typeof oSettings.fnInitComplete == 'function' )
|
mas01mj@640
|
1810 {
|
mas01mj@640
|
1811 oSettings.fnInitComplete( oSettings, json );
|
mas01mj@640
|
1812 }
|
mas01mj@640
|
1813 } );
|
mas01mj@640
|
1814 return;
|
mas01mj@640
|
1815 }
|
mas01mj@640
|
1816
|
mas01mj@640
|
1817 /* Run the init callback if there is one */
|
mas01mj@640
|
1818 if ( typeof oSettings.fnInitComplete == 'function' )
|
mas01mj@640
|
1819 {
|
mas01mj@640
|
1820 oSettings.fnInitComplete( oSettings );
|
mas01mj@640
|
1821 }
|
mas01mj@640
|
1822 _fnProcessingDisplay( oSettings, false );
|
mas01mj@640
|
1823 }
|
mas01mj@640
|
1824
|
mas01mj@640
|
1825 /*
|
mas01mj@640
|
1826 * Function: _fnLanguageProcess
|
mas01mj@640
|
1827 * Purpose: Copy language variables from remote object to a local one
|
mas01mj@640
|
1828 * Returns: -
|
mas01mj@640
|
1829 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
1830 * object:oLanguage - Language information
|
mas01mj@640
|
1831 * bool:bInit - init once complete
|
mas01mj@640
|
1832 */
|
mas01mj@640
|
1833 function _fnLanguageProcess( oSettings, oLanguage, bInit )
|
mas01mj@640
|
1834 {
|
mas01mj@640
|
1835 _fnMap( oSettings.oLanguage, oLanguage, 'sProcessing' );
|
mas01mj@640
|
1836 _fnMap( oSettings.oLanguage, oLanguage, 'sLengthMenu' );
|
mas01mj@640
|
1837 _fnMap( oSettings.oLanguage, oLanguage, 'sZeroRecords' );
|
mas01mj@640
|
1838 _fnMap( oSettings.oLanguage, oLanguage, 'sInfo' );
|
mas01mj@640
|
1839 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoEmpty' );
|
mas01mj@640
|
1840 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoFiltered' );
|
mas01mj@640
|
1841 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoPostFix' );
|
mas01mj@640
|
1842 _fnMap( oSettings.oLanguage, oLanguage, 'sSearch' );
|
mas01mj@640
|
1843
|
mas01mj@640
|
1844 if ( typeof oLanguage.oPaginate != 'undefined' )
|
mas01mj@640
|
1845 {
|
mas01mj@640
|
1846 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sFirst' );
|
mas01mj@640
|
1847 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sPrevious' );
|
mas01mj@640
|
1848 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sNext' );
|
mas01mj@640
|
1849 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sLast' );
|
mas01mj@640
|
1850 }
|
mas01mj@640
|
1851
|
mas01mj@640
|
1852 if ( bInit )
|
mas01mj@640
|
1853 {
|
mas01mj@640
|
1854 _fnInitalise( oSettings );
|
mas01mj@640
|
1855 }
|
mas01mj@640
|
1856 }
|
mas01mj@640
|
1857
|
mas01mj@640
|
1858 /*
|
mas01mj@640
|
1859 * Function: _fnAddColumn
|
mas01mj@640
|
1860 * Purpose: Add a column to the list used for the table
|
mas01mj@640
|
1861 * Returns: -
|
mas01mj@640
|
1862 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
1863 * object:oOptions - object with sType, bVisible and bSearchable
|
mas01mj@640
|
1864 * node:nTh - the th element for this column
|
mas01mj@640
|
1865 * Notes: All options in enter column can be over-ridden by the user
|
mas01mj@640
|
1866 * initialisation of dataTables
|
mas01mj@640
|
1867 */
|
mas01mj@640
|
1868 function _fnAddColumn( oSettings, oOptions, nTh )
|
mas01mj@640
|
1869 {
|
mas01mj@640
|
1870 oSettings.aoColumns[ oSettings.aoColumns.length++ ] = {
|
mas01mj@640
|
1871 "sType": null,
|
mas01mj@640
|
1872 "_bAutoType": true,
|
mas01mj@640
|
1873 "bVisible": true,
|
mas01mj@640
|
1874 "bSearchable": true,
|
mas01mj@640
|
1875 "bSortable": true,
|
mas01mj@640
|
1876 "sTitle": nTh ? nTh.innerHTML : '',
|
mas01mj@640
|
1877 "sName": '',
|
mas01mj@640
|
1878 "sWidth": null,
|
mas01mj@640
|
1879 "sClass": null,
|
mas01mj@640
|
1880 "fnRender": null,
|
mas01mj@640
|
1881 "bUseRendered": true,
|
mas01mj@640
|
1882 "iDataSort": oSettings.aoColumns.length-1,
|
mas01mj@640
|
1883 "nTh": nTh ? nTh : document.createElement('th'),
|
mas01mj@640
|
1884 "nTf": null
|
mas01mj@640
|
1885 };
|
mas01mj@640
|
1886
|
mas01mj@640
|
1887 /* User specified column options */
|
mas01mj@640
|
1888 var iLength = oSettings.aoColumns.length-1;
|
mas01mj@640
|
1889 if ( typeof oOptions != 'undefined' && oOptions !== null )
|
mas01mj@640
|
1890 {
|
mas01mj@640
|
1891 var oCol = oSettings.aoColumns[ iLength ];
|
mas01mj@640
|
1892
|
mas01mj@640
|
1893 if ( typeof oOptions.sType != 'undefined' )
|
mas01mj@640
|
1894 {
|
mas01mj@640
|
1895 oCol.sType = oOptions.sType;
|
mas01mj@640
|
1896 oCol._bAutoType = false;
|
mas01mj@640
|
1897 }
|
mas01mj@640
|
1898
|
mas01mj@640
|
1899 _fnMap( oCol, oOptions, "bVisible" );
|
mas01mj@640
|
1900 _fnMap( oCol, oOptions, "bSearchable" );
|
mas01mj@640
|
1901 _fnMap( oCol, oOptions, "bSortable" );
|
mas01mj@640
|
1902 _fnMap( oCol, oOptions, "sTitle" );
|
mas01mj@640
|
1903 _fnMap( oCol, oOptions, "sName" );
|
mas01mj@640
|
1904 _fnMap( oCol, oOptions, "sWidth" );
|
mas01mj@640
|
1905 _fnMap( oCol, oOptions, "sClass" );
|
mas01mj@640
|
1906 _fnMap( oCol, oOptions, "fnRender" );
|
mas01mj@640
|
1907 _fnMap( oCol, oOptions, "bUseRendered" );
|
mas01mj@640
|
1908 _fnMap( oCol, oOptions, "iDataSort" );
|
mas01mj@640
|
1909 }
|
mas01mj@640
|
1910
|
mas01mj@640
|
1911 /* Add a column specific filter */
|
mas01mj@640
|
1912 if ( typeof oSettings.aoPreSearchCols[ iLength ] == 'undefined' ||
|
mas01mj@640
|
1913 oSettings.aoPreSearchCols[ iLength ] === null )
|
mas01mj@640
|
1914 {
|
mas01mj@640
|
1915 oSettings.aoPreSearchCols[ iLength ] = {
|
mas01mj@640
|
1916 "sSearch": "",
|
mas01mj@640
|
1917 "bEscapeRegex": true
|
mas01mj@640
|
1918 };
|
mas01mj@640
|
1919 }
|
mas01mj@640
|
1920 else if ( typeof oSettings.aoPreSearchCols[ iLength ].bEscapeRegex == 'undefined' )
|
mas01mj@640
|
1921 {
|
mas01mj@640
|
1922 /* Don't require that the user must specify bEscapeRegex */
|
mas01mj@640
|
1923 oSettings.aoPreSearchCols[ iLength ].bEscapeRegex = true;
|
mas01mj@640
|
1924 }
|
mas01mj@640
|
1925 }
|
mas01mj@640
|
1926
|
mas01mj@640
|
1927 /*
|
mas01mj@640
|
1928 * Function: _fnAddData
|
mas01mj@640
|
1929 * Purpose: Add a data array to the table, creating DOM node etc
|
mas01mj@640
|
1930 * Returns: int: - >=0 if successful (index of new aoData entry), -1 if failed
|
mas01mj@640
|
1931 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
1932 * array:aData - data array to be added
|
mas01mj@640
|
1933 */
|
mas01mj@640
|
1934 function _fnAddData ( oSettings, aData )
|
mas01mj@640
|
1935 {
|
mas01mj@640
|
1936 /* Sanity check the length of the new array */
|
mas01mj@640
|
1937 if ( aData.length != oSettings.aoColumns.length )
|
mas01mj@640
|
1938 {
|
mas01mj@640
|
1939 alert( "Warning - added data does not match known number of columns" );
|
mas01mj@640
|
1940 return -1;
|
mas01mj@640
|
1941 }
|
mas01mj@640
|
1942
|
mas01mj@640
|
1943 /* Create the object for storing information about this new row */
|
mas01mj@640
|
1944 var iThisIndex = oSettings.aoData.length;
|
mas01mj@640
|
1945 oSettings.aoData.push( {
|
mas01mj@640
|
1946 "_iId": oSettings.iNextId++,
|
mas01mj@640
|
1947 "_aData": aData.slice(),
|
mas01mj@640
|
1948 "nTr": document.createElement('tr'),
|
mas01mj@640
|
1949 "_anHidden": []
|
mas01mj@640
|
1950 } );
|
mas01mj@640
|
1951
|
mas01mj@640
|
1952 /* Create the cells */
|
mas01mj@640
|
1953 var nTd;
|
mas01mj@640
|
1954 for ( var i=0 ; i<aData.length ; i++ )
|
mas01mj@640
|
1955 {
|
mas01mj@640
|
1956 nTd = document.createElement('td');
|
mas01mj@640
|
1957
|
mas01mj@640
|
1958 if ( typeof oSettings.aoColumns[i].fnRender == 'function' )
|
mas01mj@640
|
1959 {
|
mas01mj@640
|
1960 var sRendered = oSettings.aoColumns[i].fnRender( {
|
mas01mj@640
|
1961 "iDataRow": iThisIndex,
|
mas01mj@640
|
1962 "iDataColumn": i,
|
mas01mj@640
|
1963 "aData": aData
|
mas01mj@640
|
1964 } );
|
mas01mj@640
|
1965 nTd.innerHTML = sRendered;
|
mas01mj@640
|
1966 if ( oSettings.aoColumns[i].bUseRendered )
|
mas01mj@640
|
1967 {
|
mas01mj@640
|
1968 /* Use the rendered data for filtering/sorting */
|
mas01mj@640
|
1969 oSettings.aoData[iThisIndex]._aData[i] = sRendered;
|
mas01mj@640
|
1970 }
|
mas01mj@640
|
1971 }
|
mas01mj@640
|
1972 else
|
mas01mj@640
|
1973 {
|
mas01mj@640
|
1974 nTd.innerHTML = aData[i];
|
mas01mj@640
|
1975 }
|
mas01mj@640
|
1976
|
mas01mj@640
|
1977 if ( oSettings.aoColumns[i].sClass !== null )
|
mas01mj@640
|
1978 {
|
mas01mj@640
|
1979 nTd.className = oSettings.aoColumns[i].sClass;
|
mas01mj@640
|
1980 }
|
mas01mj@640
|
1981
|
mas01mj@640
|
1982 /* See if we should auto-detect the column type */
|
mas01mj@640
|
1983 if ( oSettings.aoColumns[i]._bAutoType && oSettings.aoColumns[i].sType != 'string' )
|
mas01mj@640
|
1984 {
|
mas01mj@640
|
1985 /* Attempt to auto detect the type - same as _fnGatherData() */
|
mas01mj@640
|
1986 if ( oSettings.aoColumns[i].sType === null )
|
mas01mj@640
|
1987 {
|
mas01mj@640
|
1988 oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
|
mas01mj@640
|
1989 }
|
mas01mj@640
|
1990 else if ( oSettings.aoColumns[i].sType == "date" ||
|
mas01mj@640
|
1991 oSettings.aoColumns[i].sType == "numeric" )
|
mas01mj@640
|
1992 {
|
mas01mj@640
|
1993 oSettings.aoColumns[i].sType = _fnDetectType( aData[i] );
|
mas01mj@640
|
1994 }
|
mas01mj@640
|
1995 }
|
mas01mj@640
|
1996
|
mas01mj@640
|
1997 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
1998 {
|
mas01mj@640
|
1999 oSettings.aoData[iThisIndex].nTr.appendChild( nTd );
|
mas01mj@640
|
2000 }
|
mas01mj@640
|
2001 else
|
mas01mj@640
|
2002 {
|
mas01mj@640
|
2003 oSettings.aoData[iThisIndex]._anHidden[i] = nTd;
|
mas01mj@640
|
2004 }
|
mas01mj@640
|
2005 }
|
mas01mj@640
|
2006
|
mas01mj@640
|
2007 /* Add to the display array */
|
mas01mj@640
|
2008 oSettings.aiDisplayMaster.push( iThisIndex );
|
mas01mj@640
|
2009 return iThisIndex;
|
mas01mj@640
|
2010 }
|
mas01mj@640
|
2011
|
mas01mj@640
|
2012 /*
|
mas01mj@640
|
2013 * Function: _fnGatherData
|
mas01mj@640
|
2014 * Purpose: Read in the data from the target table
|
mas01mj@640
|
2015 * Returns: -
|
mas01mj@640
|
2016 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2017 */
|
mas01mj@640
|
2018 function _fnGatherData( oSettings )
|
mas01mj@640
|
2019 {
|
mas01mj@640
|
2020 var iLoop;
|
mas01mj@640
|
2021 var i, j;
|
mas01mj@640
|
2022
|
mas01mj@640
|
2023 /*
|
mas01mj@640
|
2024 * Process by row first
|
mas01mj@640
|
2025 * Add the data object for the whole table - storing the tr node. Note - no point in getting
|
mas01mj@640
|
2026 * DOM based data if we are going to go and replace it with Ajax source data.
|
mas01mj@640
|
2027 */
|
mas01mj@640
|
2028 if ( oSettings.sAjaxSource === null )
|
mas01mj@640
|
2029 {
|
mas01mj@640
|
2030 $('tbody:eq(0)>tr', oSettings.nTable).each( function() {
|
mas01mj@640
|
2031 var iThisIndex = oSettings.aoData.length;
|
mas01mj@640
|
2032 oSettings.aoData.push( {
|
mas01mj@640
|
2033 "_iId": oSettings.iNextId++,
|
mas01mj@640
|
2034 "_aData": [],
|
mas01mj@640
|
2035 "nTr": this,
|
mas01mj@640
|
2036 "_anHidden": []
|
mas01mj@640
|
2037 } );
|
mas01mj@640
|
2038
|
mas01mj@640
|
2039 oSettings.aiDisplayMaster.push( iThisIndex );
|
mas01mj@640
|
2040
|
mas01mj@640
|
2041 /* Add the data for this column */
|
mas01mj@640
|
2042 var aLocalData = oSettings.aoData[iThisIndex]._aData;
|
mas01mj@640
|
2043 $('td', this).each( function( i ) {
|
mas01mj@640
|
2044 aLocalData[i] = this.innerHTML;
|
mas01mj@640
|
2045 } );
|
mas01mj@640
|
2046 } );
|
mas01mj@640
|
2047 }
|
mas01mj@640
|
2048
|
mas01mj@640
|
2049 /*
|
mas01mj@640
|
2050 * Now process by column
|
mas01mj@640
|
2051 */
|
mas01mj@640
|
2052 var iCorrector = 0;
|
mas01mj@640
|
2053 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
2054 {
|
mas01mj@640
|
2055 /* Get the title of the column - unless there is a user set one */
|
mas01mj@640
|
2056 if ( oSettings.aoColumns[i].sTitle === null )
|
mas01mj@640
|
2057 {
|
mas01mj@640
|
2058 oSettings.aoColumns[i].sTitle = oSettings.aoColumns[i].nTh.innerHTML;
|
mas01mj@640
|
2059 }
|
mas01mj@640
|
2060
|
mas01mj@640
|
2061 var bAutoType = oSettings.aoColumns[i]._bAutoType;
|
mas01mj@640
|
2062 var bRender = typeof oSettings.aoColumns[i].fnRender == 'function';
|
mas01mj@640
|
2063 var bClass = oSettings.aoColumns[i].sClass !== null;
|
mas01mj@640
|
2064 var bVisible = oSettings.aoColumns[i].bVisible;
|
mas01mj@640
|
2065
|
mas01mj@640
|
2066 /* A single loop to rule them all (and be more efficient) */
|
mas01mj@640
|
2067 if ( bAutoType || bRender || bClass || !bVisible )
|
mas01mj@640
|
2068 {
|
mas01mj@640
|
2069 iLoop = oSettings.aoData.length;
|
mas01mj@640
|
2070 for ( j=0 ; j<iLoop ; j++ )
|
mas01mj@640
|
2071 {
|
mas01mj@640
|
2072 var nCellNode = oSettings.aoData[j].nTr.getElementsByTagName('td')[ i-iCorrector ];
|
mas01mj@640
|
2073
|
mas01mj@640
|
2074 if ( bAutoType )
|
mas01mj@640
|
2075 {
|
mas01mj@640
|
2076 if ( oSettings.aoColumns[i].sType === null )
|
mas01mj@640
|
2077 {
|
mas01mj@640
|
2078 oSettings.aoColumns[i].sType = _fnDetectType( oSettings.aoData[j]._aData[i] );
|
mas01mj@640
|
2079 }
|
mas01mj@640
|
2080 else if ( oSettings.aoColumns[i].sType == "date" ||
|
mas01mj@640
|
2081 oSettings.aoColumns[i].sType == "numeric" )
|
mas01mj@640
|
2082 {
|
mas01mj@640
|
2083 /* If type is date or numeric - ensure that all collected data
|
mas01mj@640
|
2084 * in the column is of the same type
|
mas01mj@640
|
2085 */
|
mas01mj@640
|
2086 oSettings.aoColumns[i].sType = _fnDetectType( oSettings.aoData[j]._aData[i] );
|
mas01mj@640
|
2087 }
|
mas01mj@640
|
2088 /* The else would be 'type = string' we don't want to do anything
|
mas01mj@640
|
2089 * if that is the case
|
mas01mj@640
|
2090 */
|
mas01mj@640
|
2091 }
|
mas01mj@640
|
2092
|
mas01mj@640
|
2093 if ( bRender )
|
mas01mj@640
|
2094 {
|
mas01mj@640
|
2095 var sRendered = oSettings.aoColumns[i].fnRender( {
|
mas01mj@640
|
2096 "iDataRow": j,
|
mas01mj@640
|
2097 "iDataColumn": i,
|
mas01mj@640
|
2098 "aData": oSettings.aoData[j]._aData
|
mas01mj@640
|
2099 } );
|
mas01mj@640
|
2100 nCellNode.innerHTML = sRendered;
|
mas01mj@640
|
2101 if ( oSettings.aoColumns[i].bUseRendered )
|
mas01mj@640
|
2102 {
|
mas01mj@640
|
2103 /* Use the rendered data for filtering/sorting */
|
mas01mj@640
|
2104 oSettings.aoData[j]._aData[i] = sRendered;
|
mas01mj@640
|
2105 }
|
mas01mj@640
|
2106 }
|
mas01mj@640
|
2107
|
mas01mj@640
|
2108 if ( bClass )
|
mas01mj@640
|
2109 {
|
mas01mj@640
|
2110 nCellNode.className += ' '+oSettings.aoColumns[i].sClass;
|
mas01mj@640
|
2111 }
|
mas01mj@640
|
2112
|
mas01mj@640
|
2113 if ( !bVisible )
|
mas01mj@640
|
2114 {
|
mas01mj@640
|
2115 oSettings.aoData[j]._anHidden[i] = nCellNode;
|
mas01mj@640
|
2116 nCellNode.parentNode.removeChild( nCellNode );
|
mas01mj@640
|
2117 }
|
mas01mj@640
|
2118 }
|
mas01mj@640
|
2119
|
mas01mj@640
|
2120 /* Keep an index corrector for the next loop */
|
mas01mj@640
|
2121 if ( !bVisible )
|
mas01mj@640
|
2122 {
|
mas01mj@640
|
2123 iCorrector++;
|
mas01mj@640
|
2124 }
|
mas01mj@640
|
2125 }
|
mas01mj@640
|
2126 }
|
mas01mj@640
|
2127 }
|
mas01mj@640
|
2128
|
mas01mj@640
|
2129
|
mas01mj@640
|
2130
|
mas01mj@640
|
2131 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
2132 * Drawing functions
|
mas01mj@640
|
2133 */
|
mas01mj@640
|
2134
|
mas01mj@640
|
2135 /*
|
mas01mj@640
|
2136 * Function: _fnDrawHead
|
mas01mj@640
|
2137 * Purpose: Create the HTML header for the table
|
mas01mj@640
|
2138 * Returns: -
|
mas01mj@640
|
2139 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2140 */
|
mas01mj@640
|
2141 function _fnDrawHead( oSettings )
|
mas01mj@640
|
2142 {
|
mas01mj@640
|
2143 var i, nTh, iLen;
|
mas01mj@640
|
2144 var iThs = oSettings.nTable.getElementsByTagName('thead')[0].getElementsByTagName('th').length;
|
mas01mj@640
|
2145 var iCorrector = 0;
|
mas01mj@640
|
2146
|
mas01mj@640
|
2147 /* If there is a header in place - then use it - otherwise it's going to get nuked... */
|
mas01mj@640
|
2148 if ( iThs !== 0 )
|
mas01mj@640
|
2149 {
|
mas01mj@640
|
2150 /* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
|
mas01mj@640
|
2151 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
mas01mj@640
|
2152 {
|
mas01mj@640
|
2153 //oSettings.aoColumns[i].nTh = nThs[i];
|
mas01mj@640
|
2154 nTh = oSettings.aoColumns[i].nTh;
|
mas01mj@640
|
2155
|
mas01mj@640
|
2156 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
2157 {
|
mas01mj@640
|
2158 /* Set width */
|
mas01mj@640
|
2159 if ( oSettings.aoColumns[i].sWidth !== null )
|
mas01mj@640
|
2160 {
|
mas01mj@640
|
2161 nTh.style.width = oSettings.aoColumns[i].sWidth;
|
mas01mj@640
|
2162 }
|
mas01mj@640
|
2163
|
mas01mj@640
|
2164 /* Set the title of the column if it is user defined (not what was auto detected) */
|
mas01mj@640
|
2165 if ( oSettings.aoColumns[i].sTitle != nTh.innerHTML )
|
mas01mj@640
|
2166 {
|
mas01mj@640
|
2167 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
|
mas01mj@640
|
2168 }
|
mas01mj@640
|
2169 }
|
mas01mj@640
|
2170 else
|
mas01mj@640
|
2171 {
|
mas01mj@640
|
2172 nTh.parentNode.removeChild( nTh );
|
mas01mj@640
|
2173 iCorrector++;
|
mas01mj@640
|
2174 }
|
mas01mj@640
|
2175 }
|
mas01mj@640
|
2176 }
|
mas01mj@640
|
2177 else
|
mas01mj@640
|
2178 {
|
mas01mj@640
|
2179 /* We don't have a header in the DOM - so we are going to have to create one */
|
mas01mj@640
|
2180 var nTr = document.createElement( "tr" );
|
mas01mj@640
|
2181
|
mas01mj@640
|
2182 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
mas01mj@640
|
2183 {
|
mas01mj@640
|
2184 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
2185 {
|
mas01mj@640
|
2186 nTh = oSettings.aoColumns[i].nTh;
|
mas01mj@640
|
2187
|
mas01mj@640
|
2188 if ( oSettings.aoColumns[i].sClass !== null )
|
mas01mj@640
|
2189 {
|
mas01mj@640
|
2190 nTh.className = oSettings.aoColumns[i].sClass;
|
mas01mj@640
|
2191 }
|
mas01mj@640
|
2192
|
mas01mj@640
|
2193 if ( oSettings.aoColumns[i].sWidth !== null )
|
mas01mj@640
|
2194 {
|
mas01mj@640
|
2195 nTh.style.width = oSettings.aoColumns[i].sWidth;
|
mas01mj@640
|
2196 }
|
mas01mj@640
|
2197
|
mas01mj@640
|
2198 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
|
mas01mj@640
|
2199 nTr.appendChild( nTh );
|
mas01mj@640
|
2200 }
|
mas01mj@640
|
2201 }
|
mas01mj@640
|
2202 $('thead', oSettings.nTable).html( '' )[0].appendChild( nTr );
|
mas01mj@640
|
2203 }
|
mas01mj@640
|
2204
|
mas01mj@640
|
2205 /* Add the extra markup needed by jQuery UI's themes */
|
mas01mj@640
|
2206 if ( oSettings.bJUI )
|
mas01mj@640
|
2207 {
|
mas01mj@640
|
2208 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
mas01mj@640
|
2209 {
|
mas01mj@640
|
2210 var nSpan = document.createElement('span');
|
mas01mj@640
|
2211 oSettings.aoColumns[i].nTh.appendChild( nSpan );
|
mas01mj@640
|
2212 }
|
mas01mj@640
|
2213 }
|
mas01mj@640
|
2214
|
mas01mj@640
|
2215 /* Add sort listener */
|
mas01mj@640
|
2216 if ( oSettings.oFeatures.bSort )
|
mas01mj@640
|
2217 {
|
mas01mj@640
|
2218 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
2219 {
|
mas01mj@640
|
2220 if ( oSettings.aoColumns[i].bSortable === false )
|
mas01mj@640
|
2221 {
|
mas01mj@640
|
2222 continue;
|
mas01mj@640
|
2223 }
|
mas01mj@640
|
2224
|
mas01mj@640
|
2225 $(oSettings.aoColumns[i].nTh).click( function (e) {
|
mas01mj@640
|
2226 var iDataIndex;
|
mas01mj@640
|
2227 /* Find which column we are sorting on - can't use index() due to colspan etc */
|
mas01mj@640
|
2228 for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
2229 {
|
mas01mj@640
|
2230 if ( oSettings.aoColumns[i].nTh == this )
|
mas01mj@640
|
2231 {
|
mas01mj@640
|
2232 iDataIndex = i;
|
mas01mj@640
|
2233 break;
|
mas01mj@640
|
2234 }
|
mas01mj@640
|
2235 }
|
mas01mj@640
|
2236
|
mas01mj@640
|
2237 /* If the column is not sortable - don't to anything */
|
mas01mj@640
|
2238 if ( oSettings.aoColumns[iDataIndex].bSortable === false )
|
mas01mj@640
|
2239 {
|
mas01mj@640
|
2240 return;
|
mas01mj@640
|
2241 }
|
mas01mj@640
|
2242
|
mas01mj@640
|
2243 /*
|
mas01mj@640
|
2244 * This is a little bit odd I admit... I declare a temporary function inside the scope of
|
mas01mj@640
|
2245 * _fnDrawHead and the click handler in order that the code presented here can be used
|
mas01mj@640
|
2246 * twice - once for when bProcessing is enabled, and another time for when it is
|
mas01mj@640
|
2247 * disabled, as we need to perform slightly different actions.
|
mas01mj@640
|
2248 * Basically the issue here is that the Javascript engine in modern browsers don't
|
mas01mj@640
|
2249 * appear to allow the rendering engine to update the display while it is still excuting
|
mas01mj@640
|
2250 * it's thread (well - it does but only after long intervals). This means that the
|
mas01mj@640
|
2251 * 'processing' display doesn't appear for a table sort. To break the js thread up a bit
|
mas01mj@640
|
2252 * I force an execution break by using setTimeout - but this breaks the expected
|
mas01mj@640
|
2253 * thread continuation for the end-developer's point of view (their code would execute
|
mas01mj@640
|
2254 * too early), so we on;y do it when we absolutely have to.
|
mas01mj@640
|
2255 */
|
mas01mj@640
|
2256 var fnInnerSorting = function () {
|
mas01mj@640
|
2257 if ( e.shiftKey )
|
mas01mj@640
|
2258 {
|
mas01mj@640
|
2259 /* If the shift key is pressed then we are multipe column sorting */
|
mas01mj@640
|
2260 var bFound = false;
|
mas01mj@640
|
2261 for ( var i=0 ; i<oSettings.aaSorting.length ; i++ )
|
mas01mj@640
|
2262 {
|
mas01mj@640
|
2263 if ( oSettings.aaSorting[i][0] == iDataIndex )
|
mas01mj@640
|
2264 {
|
mas01mj@640
|
2265 if ( oSettings.aaSorting[i][1] == "asc" )
|
mas01mj@640
|
2266 {
|
mas01mj@640
|
2267 oSettings.aaSorting[i][1] = "desc";
|
mas01mj@640
|
2268 }
|
mas01mj@640
|
2269 else
|
mas01mj@640
|
2270 {
|
mas01mj@640
|
2271 oSettings.aaSorting.splice( i, 1 );
|
mas01mj@640
|
2272 }
|
mas01mj@640
|
2273 bFound = true;
|
mas01mj@640
|
2274 break;
|
mas01mj@640
|
2275 }
|
mas01mj@640
|
2276 }
|
mas01mj@640
|
2277
|
mas01mj@640
|
2278 if ( bFound === false )
|
mas01mj@640
|
2279 {
|
mas01mj@640
|
2280 oSettings.aaSorting.push( [ iDataIndex, "asc" ] );
|
mas01mj@640
|
2281 }
|
mas01mj@640
|
2282 }
|
mas01mj@640
|
2283 else
|
mas01mj@640
|
2284 {
|
mas01mj@640
|
2285 /* If no shift key then single column sort */
|
mas01mj@640
|
2286 if ( oSettings.aaSorting.length == 1 && oSettings.aaSorting[0][0] == iDataIndex )
|
mas01mj@640
|
2287 {
|
mas01mj@640
|
2288 oSettings.aaSorting[0][1] = oSettings.aaSorting[0][1]=="asc" ? "desc" : "asc";
|
mas01mj@640
|
2289 }
|
mas01mj@640
|
2290 else
|
mas01mj@640
|
2291 {
|
mas01mj@640
|
2292 oSettings.aaSorting.splice( 0, oSettings.aaSorting.length );
|
mas01mj@640
|
2293 oSettings.aaSorting.push( [ iDataIndex, "asc" ] );
|
mas01mj@640
|
2294 }
|
mas01mj@640
|
2295 }
|
mas01mj@640
|
2296
|
mas01mj@640
|
2297 /* Run the sort */
|
mas01mj@640
|
2298 _fnSort( oSettings );
|
mas01mj@640
|
2299 }; /* /fnInnerSorting */
|
mas01mj@640
|
2300
|
mas01mj@640
|
2301 if ( !oSettings.oFeatures.bProcessing )
|
mas01mj@640
|
2302 {
|
mas01mj@640
|
2303 fnInnerSorting();
|
mas01mj@640
|
2304 }
|
mas01mj@640
|
2305 else
|
mas01mj@640
|
2306 {
|
mas01mj@640
|
2307 _fnProcessingDisplay( oSettings, true );
|
mas01mj@640
|
2308 setTimeout( function() {
|
mas01mj@640
|
2309 fnInnerSorting();
|
mas01mj@640
|
2310 if ( !oSettings.oFeatures.bServerSide )
|
mas01mj@640
|
2311 {
|
mas01mj@640
|
2312 _fnProcessingDisplay( oSettings, false );
|
mas01mj@640
|
2313 }
|
mas01mj@640
|
2314 }, 0 );
|
mas01mj@640
|
2315 }
|
mas01mj@640
|
2316 } ); /* /click */
|
mas01mj@640
|
2317 } /* For each column */
|
mas01mj@640
|
2318
|
mas01mj@640
|
2319 /* Take the brutal approach to cancelling text selection due to the shift key */
|
mas01mj@640
|
2320 $('thead th', oSettings.nTable).mousedown( function (e) {
|
mas01mj@640
|
2321 if ( e.shiftKey )
|
mas01mj@640
|
2322 {
|
mas01mj@640
|
2323 this.onselectstart = function() { return false; };
|
mas01mj@640
|
2324 return false;
|
mas01mj@640
|
2325 }
|
mas01mj@640
|
2326 } );
|
mas01mj@640
|
2327 } /* /if feature sort */
|
mas01mj@640
|
2328
|
mas01mj@640
|
2329 /* Set an absolute width for the table such that pagination doesn't
|
mas01mj@640
|
2330 * cause the table to resize
|
mas01mj@640
|
2331 */
|
mas01mj@640
|
2332 if ( oSettings.oFeatures.bAutoWidth )
|
mas01mj@640
|
2333 {
|
mas01mj@640
|
2334 oSettings.nTable.style.width = oSettings.nTable.offsetWidth+"px";
|
mas01mj@640
|
2335 }
|
mas01mj@640
|
2336
|
mas01mj@640
|
2337 /* Cache the footer elements */
|
mas01mj@640
|
2338 var nTfoot = oSettings.nTable.getElementsByTagName('tfoot');
|
mas01mj@640
|
2339 if ( nTfoot.length !== 0 )
|
mas01mj@640
|
2340 {
|
mas01mj@640
|
2341 iCorrector = 0;
|
mas01mj@640
|
2342 var nTfs = nTfoot[0].getElementsByTagName('th');
|
mas01mj@640
|
2343 for ( i=0, iLen=nTfs.length ; i<iLen ; i++ )
|
mas01mj@640
|
2344 {
|
mas01mj@640
|
2345 oSettings.aoColumns[i].nTf = nTfs[i-iCorrector];
|
mas01mj@640
|
2346 if ( !oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
2347 {
|
mas01mj@640
|
2348 nTfs[i-iCorrector].parentNode.removeChild( nTfs[i-iCorrector] );
|
mas01mj@640
|
2349 iCorrector++;
|
mas01mj@640
|
2350 }
|
mas01mj@640
|
2351 }
|
mas01mj@640
|
2352 }
|
mas01mj@640
|
2353 }
|
mas01mj@640
|
2354
|
mas01mj@640
|
2355 /*
|
mas01mj@640
|
2356 * Function: _fnDraw
|
mas01mj@640
|
2357 * Purpose: Insert the required TR nodes into the table for display
|
mas01mj@640
|
2358 * Returns: -
|
mas01mj@640
|
2359 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2360 */
|
mas01mj@640
|
2361 function _fnDraw( oSettings )
|
mas01mj@640
|
2362 {
|
mas01mj@640
|
2363 var i;
|
mas01mj@640
|
2364 var anRows = [];
|
mas01mj@640
|
2365 var iRowCount = 0;
|
mas01mj@640
|
2366 var bRowError = false;
|
mas01mj@640
|
2367 var iStrips = oSettings.asStripClasses.length;
|
mas01mj@640
|
2368 var iOpenRows = oSettings.aoOpenRows.length;
|
mas01mj@640
|
2369
|
mas01mj@640
|
2370 /* If we are dealing with Ajax - do it here */
|
mas01mj@640
|
2371 if ( oSettings.oFeatures.bServerSide &&
|
mas01mj@640
|
2372 !_fnAjaxUpdate( oSettings ) )
|
mas01mj@640
|
2373 {
|
mas01mj@640
|
2374 return;
|
mas01mj@640
|
2375 }
|
mas01mj@640
|
2376
|
mas01mj@640
|
2377 if ( oSettings.aiDisplay.length !== 0 )
|
mas01mj@640
|
2378 {
|
mas01mj@640
|
2379 var iStart = oSettings._iDisplayStart;
|
mas01mj@640
|
2380 var iEnd = oSettings._iDisplayEnd;
|
mas01mj@640
|
2381
|
mas01mj@640
|
2382 if ( oSettings.oFeatures.bServerSide )
|
mas01mj@640
|
2383 {
|
mas01mj@640
|
2384 iStart = 0;
|
mas01mj@640
|
2385 iEnd = oSettings.aoData.length;
|
mas01mj@640
|
2386 }
|
mas01mj@640
|
2387
|
mas01mj@640
|
2388 for ( var j=iStart ; j<iEnd ; j++ )
|
mas01mj@640
|
2389 {
|
mas01mj@640
|
2390 var nRow = oSettings.aoData[ oSettings.aiDisplay[j] ].nTr;
|
mas01mj@640
|
2391
|
mas01mj@640
|
2392 /* Remove any old stripping classes and then add the new one */
|
mas01mj@640
|
2393 if ( iStrips !== 0 )
|
mas01mj@640
|
2394 {
|
mas01mj@640
|
2395 $(nRow).removeClass( oSettings.asStripClasses.join(' ') );
|
mas01mj@640
|
2396 $(nRow).addClass( oSettings.asStripClasses[ iRowCount % iStrips ] );
|
mas01mj@640
|
2397 }
|
mas01mj@640
|
2398
|
mas01mj@640
|
2399 /* Custom row callback function - might want to manipule the row */
|
mas01mj@640
|
2400 if ( typeof oSettings.fnRowCallback == "function" )
|
mas01mj@640
|
2401 {
|
mas01mj@640
|
2402 nRow = oSettings.fnRowCallback( nRow,
|
mas01mj@640
|
2403 oSettings.aoData[ oSettings.aiDisplay[j] ]._aData, iRowCount, j );
|
mas01mj@640
|
2404 if ( !nRow && !bRowError )
|
mas01mj@640
|
2405 {
|
mas01mj@640
|
2406 alert( "Error: A node was not returned by fnRowCallback" );
|
mas01mj@640
|
2407 bRowError = true;
|
mas01mj@640
|
2408 }
|
mas01mj@640
|
2409 }
|
mas01mj@640
|
2410
|
mas01mj@640
|
2411 anRows.push( nRow );
|
mas01mj@640
|
2412 iRowCount++;
|
mas01mj@640
|
2413
|
mas01mj@640
|
2414 /* If there is an open row - and it is attached to this parent - attach it on redraw */
|
mas01mj@640
|
2415 if ( iOpenRows !== 0 )
|
mas01mj@640
|
2416 {
|
mas01mj@640
|
2417 for ( var k=0 ; k<iOpenRows ; k++ )
|
mas01mj@640
|
2418 {
|
mas01mj@640
|
2419 if ( nRow == oSettings.aoOpenRows[k].nParent )
|
mas01mj@640
|
2420 {
|
mas01mj@640
|
2421 anRows.push( oSettings.aoOpenRows[k].nTr );
|
mas01mj@640
|
2422 }
|
mas01mj@640
|
2423 }
|
mas01mj@640
|
2424 }
|
mas01mj@640
|
2425 }
|
mas01mj@640
|
2426 }
|
mas01mj@640
|
2427 else
|
mas01mj@640
|
2428 {
|
mas01mj@640
|
2429 /* Table is empty - create a row with an empty message in it */
|
mas01mj@640
|
2430 anRows[ 0 ] = document.createElement( 'tr' );
|
mas01mj@640
|
2431
|
mas01mj@640
|
2432 if ( typeof oSettings.asStripClasses[0] != 'undefined' )
|
mas01mj@640
|
2433 {
|
mas01mj@640
|
2434 anRows[ 0 ].className = oSettings.asStripClasses[0];
|
mas01mj@640
|
2435 }
|
mas01mj@640
|
2436
|
mas01mj@640
|
2437 var nTd = document.createElement( 'td' );
|
mas01mj@640
|
2438 nTd.setAttribute( 'valign', "top" );
|
mas01mj@640
|
2439 nTd.colSpan = oSettings.aoColumns.length;
|
mas01mj@640
|
2440 nTd.className = oSettings.oClasses.sRowEmpty;
|
mas01mj@640
|
2441 nTd.innerHTML = oSettings.oLanguage.sZeroRecords;
|
mas01mj@640
|
2442
|
mas01mj@640
|
2443 anRows[ iRowCount ].appendChild( nTd );
|
mas01mj@640
|
2444 }
|
mas01mj@640
|
2445
|
mas01mj@640
|
2446 /* Callback the header and footer custom funcation if there is one */
|
mas01mj@640
|
2447 if ( typeof oSettings.fnHeaderCallback == 'function' )
|
mas01mj@640
|
2448 {
|
mas01mj@640
|
2449 oSettings.fnHeaderCallback( $('thead tr', oSettings.nTable)[0],
|
mas01mj@640
|
2450 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
|
mas01mj@640
|
2451 oSettings.aiDisplay );
|
mas01mj@640
|
2452 }
|
mas01mj@640
|
2453
|
mas01mj@640
|
2454 if ( typeof oSettings.fnFooterCallback == 'function' )
|
mas01mj@640
|
2455 {
|
mas01mj@640
|
2456 oSettings.fnFooterCallback( $('tfoot tr', oSettings.nTable)[0],
|
mas01mj@640
|
2457 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
|
mas01mj@640
|
2458 oSettings.aiDisplay );
|
mas01mj@640
|
2459 }
|
mas01mj@640
|
2460
|
mas01mj@640
|
2461 /*
|
mas01mj@640
|
2462 * Need to remove any old row from the display - note we can't just empty the tbody using
|
mas01mj@640
|
2463 * .html('') since this will unbind the jQuery event handlers (even although the node still
|
mas01mj@640
|
2464 * exists!) - note the initially odd ':eq(0)>tr' expression. This basically ensures that we
|
mas01mj@640
|
2465 * only get tr elements of the tbody that the data table has been initialised on. If there
|
mas01mj@640
|
2466 * are nested tables then we don't want to remove those elements.
|
mas01mj@640
|
2467 */
|
mas01mj@640
|
2468 var nTrs = $('tbody:eq(0)>tr', oSettings.nTable);
|
mas01mj@640
|
2469 for ( i=0 ; i<nTrs.length ; i++ )
|
mas01mj@640
|
2470 {
|
mas01mj@640
|
2471 nTrs[i].parentNode.removeChild( nTrs[i] );
|
mas01mj@640
|
2472 }
|
mas01mj@640
|
2473
|
mas01mj@640
|
2474 /* Put the draw table into the dom */
|
mas01mj@640
|
2475 var nBody = $('tbody:eq(0)', oSettings.nTable);
|
mas01mj@640
|
2476 if ( nBody[0] )
|
mas01mj@640
|
2477 {
|
mas01mj@640
|
2478 for ( i=0 ; i<anRows.length ; i++ )
|
mas01mj@640
|
2479 {
|
mas01mj@640
|
2480 nBody[0].appendChild( anRows[i] );
|
mas01mj@640
|
2481 }
|
mas01mj@640
|
2482 }
|
mas01mj@640
|
2483
|
mas01mj@640
|
2484 /* Update the pagination display buttons */
|
mas01mj@640
|
2485 if ( oSettings.oFeatures.bPaginate )
|
mas01mj@640
|
2486 {
|
mas01mj@640
|
2487 _oExt.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) {
|
mas01mj@640
|
2488 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
2489 _fnDraw( oSettings );
|
mas01mj@640
|
2490 } );
|
mas01mj@640
|
2491 }
|
mas01mj@640
|
2492
|
mas01mj@640
|
2493 /* Show information about the table */
|
mas01mj@640
|
2494 if ( oSettings.oFeatures.bInfo && oSettings.anFeatures.i )
|
mas01mj@640
|
2495 {
|
mas01mj@640
|
2496 /* Update the information */
|
mas01mj@640
|
2497 if ( oSettings.fnRecordsDisplay() === 0 &&
|
mas01mj@640
|
2498 oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
|
mas01mj@640
|
2499 {
|
mas01mj@640
|
2500 oSettings.anFeatures.i.innerHTML =
|
mas01mj@640
|
2501 oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix;
|
mas01mj@640
|
2502 }
|
mas01mj@640
|
2503 else if ( oSettings.fnRecordsDisplay() === 0 )
|
mas01mj@640
|
2504 {
|
mas01mj@640
|
2505 oSettings.anFeatures.i.innerHTML = oSettings.oLanguage.sInfoEmpty +' '+
|
mas01mj@640
|
2506 oSettings.oLanguage.sInfoFiltered.replace('_MAX_',
|
mas01mj@640
|
2507 oSettings.fnRecordsTotal())+ oSettings.oLanguage.sInfoPostFix;
|
mas01mj@640
|
2508 }
|
mas01mj@640
|
2509 else if ( oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
|
mas01mj@640
|
2510 {
|
mas01mj@640
|
2511 oSettings.anFeatures.i.innerHTML =
|
mas01mj@640
|
2512 oSettings.oLanguage.sInfo.
|
mas01mj@640
|
2513 replace('_START_',oSettings._iDisplayStart+1).
|
mas01mj@640
|
2514 replace('_END_',oSettings.fnDisplayEnd()).
|
mas01mj@640
|
2515 replace('_TOTAL_',oSettings.fnRecordsDisplay())+
|
mas01mj@640
|
2516 oSettings.oLanguage.sInfoPostFix;
|
mas01mj@640
|
2517 }
|
mas01mj@640
|
2518 else
|
mas01mj@640
|
2519 {
|
mas01mj@640
|
2520 oSettings.anFeatures.i.innerHTML =
|
mas01mj@640
|
2521 oSettings.oLanguage.sInfo.
|
mas01mj@640
|
2522 replace('_START_',oSettings._iDisplayStart+1).
|
mas01mj@640
|
2523 replace('_END_',oSettings.fnDisplayEnd()).
|
mas01mj@640
|
2524 replace('_TOTAL_',oSettings.fnRecordsDisplay()) +' '+
|
mas01mj@640
|
2525 oSettings.oLanguage.sInfoFiltered.replace('_MAX_', oSettings.fnRecordsTotal())+
|
mas01mj@640
|
2526 oSettings.oLanguage.sInfoPostFix;
|
mas01mj@640
|
2527 }
|
mas01mj@640
|
2528 }
|
mas01mj@640
|
2529
|
mas01mj@640
|
2530 /* Alter the sorting classes to take account of the changes */
|
mas01mj@640
|
2531 if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort )
|
mas01mj@640
|
2532 {
|
mas01mj@640
|
2533 _fnSortingClasses( oSettings );
|
mas01mj@640
|
2534 }
|
mas01mj@640
|
2535
|
mas01mj@640
|
2536 /* Save the table state on each draw */
|
mas01mj@640
|
2537 _fnSaveState( oSettings );
|
mas01mj@640
|
2538
|
mas01mj@640
|
2539 /* Drawing is finished - call the callback if there is one */
|
mas01mj@640
|
2540 if ( typeof oSettings.fnDrawCallback == 'function' )
|
mas01mj@640
|
2541 {
|
mas01mj@640
|
2542 oSettings.fnDrawCallback( oSettings );
|
mas01mj@640
|
2543 }
|
mas01mj@640
|
2544 }
|
mas01mj@640
|
2545
|
mas01mj@640
|
2546 /*
|
mas01mj@640
|
2547 * Function: _fnReDraw
|
mas01mj@640
|
2548 * Purpose: Redraw the table - taking account of the various features which are enabled
|
mas01mj@640
|
2549 * Returns: -
|
mas01mj@640
|
2550 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2551 */
|
mas01mj@640
|
2552 function _fnReDraw( oSettings )
|
mas01mj@640
|
2553 {
|
mas01mj@640
|
2554 if ( oSettings.oFeatures.bSort )
|
mas01mj@640
|
2555 {
|
mas01mj@640
|
2556 /* Sorting will refilter and draw for us */
|
mas01mj@640
|
2557 _fnSort( oSettings, oSettings.oPreviousSearch );
|
mas01mj@640
|
2558 }
|
mas01mj@640
|
2559 else if ( oSettings.oFeatures.bFilter )
|
mas01mj@640
|
2560 {
|
mas01mj@640
|
2561 /* Filtering will redraw for us */
|
mas01mj@640
|
2562 _fnFilterComplete( oSettings, oSettings.oPreviousSearch );
|
mas01mj@640
|
2563 }
|
mas01mj@640
|
2564 else
|
mas01mj@640
|
2565 {
|
mas01mj@640
|
2566 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
2567 _fnDraw( oSettings );
|
mas01mj@640
|
2568 }
|
mas01mj@640
|
2569 }
|
mas01mj@640
|
2570
|
mas01mj@640
|
2571 /*
|
mas01mj@640
|
2572 * Function: _fnAjaxUpdate
|
mas01mj@640
|
2573 * Purpose: Update the table using an Ajax call
|
mas01mj@640
|
2574 * Returns: bool: block the table drawing or not
|
mas01mj@640
|
2575 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2576 */
|
mas01mj@640
|
2577 function _fnAjaxUpdate( oSettings )
|
mas01mj@640
|
2578 {
|
mas01mj@640
|
2579 if ( oSettings.bAjaxDataGet )
|
mas01mj@640
|
2580 {
|
mas01mj@640
|
2581 _fnProcessingDisplay( oSettings, true );
|
mas01mj@640
|
2582 var iColumns = oSettings.aoColumns.length;
|
mas01mj@640
|
2583 var aoData = [];
|
mas01mj@640
|
2584 var i;
|
mas01mj@640
|
2585
|
mas01mj@640
|
2586 /* Paging and general */
|
mas01mj@640
|
2587 oSettings.iServerDraw++;
|
mas01mj@640
|
2588 aoData.push( { "name": "sEcho", "value": oSettings.iServerDraw } );
|
mas01mj@640
|
2589 aoData.push( { "name": "iColumns", "value": iColumns } );
|
mas01mj@640
|
2590 aoData.push( { "name": "sColumns", "value": _fnColumnOrdering(oSettings) } );
|
mas01mj@640
|
2591 aoData.push( { "name": "iDisplayStart", "value": oSettings._iDisplayStart } );
|
mas01mj@640
|
2592 aoData.push( { "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
|
mas01mj@640
|
2593 oSettings._iDisplayLength : -1 } );
|
mas01mj@640
|
2594
|
mas01mj@640
|
2595 /* Filtering */
|
mas01mj@640
|
2596 if ( oSettings.oFeatures.bFilter !== false )
|
mas01mj@640
|
2597 {
|
mas01mj@640
|
2598 aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
|
mas01mj@640
|
2599 aoData.push( { "name": "bEscapeRegex", "value": oSettings.oPreviousSearch.bEscapeRegex } );
|
mas01mj@640
|
2600 for ( i=0 ; i<iColumns ; i++ )
|
mas01mj@640
|
2601 {
|
mas01mj@640
|
2602 aoData.push( { "name": "sSearch_"+i, "value": oSettings.aoPreSearchCols[i].sSearch } );
|
mas01mj@640
|
2603 aoData.push( { "name": "bEscapeRegex_"+i, "value": oSettings.aoPreSearchCols[i].bEscapeRegex } );
|
mas01mj@640
|
2604 }
|
mas01mj@640
|
2605 }
|
mas01mj@640
|
2606
|
mas01mj@640
|
2607 /* Sorting */
|
mas01mj@640
|
2608 if ( oSettings.oFeatures.bSort !== false )
|
mas01mj@640
|
2609 {
|
mas01mj@640
|
2610 var iFixed = oSettings.aaSortingFixed !== null ? oSettings.aaSortingFixed.length : 0;
|
mas01mj@640
|
2611 var iUser = oSettings.aaSorting.length;
|
mas01mj@640
|
2612 aoData.push( { "name": "iSortingCols", "value": iFixed+iUser } );
|
mas01mj@640
|
2613 for ( i=0 ; i<iFixed ; i++ )
|
mas01mj@640
|
2614 {
|
mas01mj@640
|
2615 aoData.push( { "name": "iSortCol_"+i, "value": oSettings.aaSortingFixed[i][0] } );
|
mas01mj@640
|
2616 aoData.push( { "name": "iSortDir_"+i, "value": oSettings.aaSortingFixed[i][1] } );
|
mas01mj@640
|
2617 }
|
mas01mj@640
|
2618
|
mas01mj@640
|
2619 for ( i=0 ; i<iUser ; i++ )
|
mas01mj@640
|
2620 {
|
mas01mj@640
|
2621 aoData.push( { "name": "iSortCol_"+(i+iFixed), "value": oSettings.aaSorting[i][0] } );
|
mas01mj@640
|
2622 aoData.push( { "name": "iSortDir_"+(i+iFixed), "value": oSettings.aaSorting[i][1] } );
|
mas01mj@640
|
2623 }
|
mas01mj@640
|
2624 }
|
mas01mj@640
|
2625
|
mas01mj@640
|
2626 oSettings.fnServerData( oSettings.sAjaxSource, aoData, function(json) {
|
mas01mj@640
|
2627 _fnAjaxUpdateDraw( oSettings, json );
|
mas01mj@640
|
2628 } );
|
mas01mj@640
|
2629 return false;
|
mas01mj@640
|
2630 }
|
mas01mj@640
|
2631 else
|
mas01mj@640
|
2632 {
|
mas01mj@640
|
2633 return true;
|
mas01mj@640
|
2634 }
|
mas01mj@640
|
2635 }
|
mas01mj@640
|
2636
|
mas01mj@640
|
2637 /*
|
mas01mj@640
|
2638 * Function: _fnAjaxUpdateDraw
|
mas01mj@640
|
2639 * Purpose: Data the data from the server (nuking the old) and redraw the table
|
mas01mj@640
|
2640 * Returns: -
|
mas01mj@640
|
2641 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2642 * object:json - json data return from the server.
|
mas01mj@640
|
2643 * The following must be defined:
|
mas01mj@640
|
2644 * iTotalRecords, iTotalDisplayRecords, aaData
|
mas01mj@640
|
2645 * The following may be defined:
|
mas01mj@640
|
2646 * sColumns
|
mas01mj@640
|
2647 */
|
mas01mj@640
|
2648 function _fnAjaxUpdateDraw ( oSettings, json )
|
mas01mj@640
|
2649 {
|
mas01mj@640
|
2650 if ( typeof json.sEcho != 'undefined' )
|
mas01mj@640
|
2651 {
|
mas01mj@640
|
2652 /* Protect against old returns over-writing a new one. Possible when you get
|
mas01mj@640
|
2653 * very fast interaction, and later queires are completed much faster
|
mas01mj@640
|
2654 */
|
mas01mj@640
|
2655 if ( json.sEcho*1 < oSettings.iServerDraw )
|
mas01mj@640
|
2656 {
|
mas01mj@640
|
2657 return;
|
mas01mj@640
|
2658 }
|
mas01mj@640
|
2659 else
|
mas01mj@640
|
2660 {
|
mas01mj@640
|
2661 oSettings.iServerDraw = json.sEcho * 1;
|
mas01mj@640
|
2662 }
|
mas01mj@640
|
2663 }
|
mas01mj@640
|
2664
|
mas01mj@640
|
2665 _fnClearTable( oSettings );
|
mas01mj@640
|
2666 oSettings._iRecordsTotal = json.iTotalRecords;
|
mas01mj@640
|
2667 oSettings._iRecordsDisplay = json.iTotalDisplayRecords;
|
mas01mj@640
|
2668
|
mas01mj@640
|
2669 /* Determine if reordering is required */
|
mas01mj@640
|
2670 var sOrdering = _fnColumnOrdering(oSettings);
|
mas01mj@640
|
2671 var bReOrder = (json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering );
|
mas01mj@640
|
2672 if ( bReOrder )
|
mas01mj@640
|
2673 {
|
mas01mj@640
|
2674 var aiIndex = _fnReOrderIndex( oSettings, json.sColumns );
|
mas01mj@640
|
2675 }
|
mas01mj@640
|
2676
|
mas01mj@640
|
2677 for ( var i=0, iLen=json.aaData.length ; i<iLen ; i++ )
|
mas01mj@640
|
2678 {
|
mas01mj@640
|
2679 if ( bReOrder )
|
mas01mj@640
|
2680 {
|
mas01mj@640
|
2681 /* If we need to re-order, then create a new array with the correct order and add it */
|
mas01mj@640
|
2682 var aData = [];
|
mas01mj@640
|
2683 for ( var j=0, jLen=oSettings.aoColumns.length ; j<jLen ; j++ )
|
mas01mj@640
|
2684 {
|
mas01mj@640
|
2685 aData.push( json.aaData[i][ aiIndex[j] ] );
|
mas01mj@640
|
2686 }
|
mas01mj@640
|
2687 _fnAddData( oSettings, aData );
|
mas01mj@640
|
2688 }
|
mas01mj@640
|
2689 else
|
mas01mj@640
|
2690 {
|
mas01mj@640
|
2691 /* No re-order required, sever got it "right" - just straight add */
|
mas01mj@640
|
2692 _fnAddData( oSettings, json.aaData[i] );
|
mas01mj@640
|
2693 }
|
mas01mj@640
|
2694 }
|
mas01mj@640
|
2695 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
2696
|
mas01mj@640
|
2697 oSettings.bAjaxDataGet = false;
|
mas01mj@640
|
2698 _fnDraw( oSettings );
|
mas01mj@640
|
2699 oSettings.bAjaxDataGet = true;
|
mas01mj@640
|
2700 _fnProcessingDisplay( oSettings, false );
|
mas01mj@640
|
2701 }
|
mas01mj@640
|
2702
|
mas01mj@640
|
2703 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
2704 * Options (features) HTML
|
mas01mj@640
|
2705 */
|
mas01mj@640
|
2706
|
mas01mj@640
|
2707 /*
|
mas01mj@640
|
2708 * Function: _fnAddOptionsHtml
|
mas01mj@640
|
2709 * Purpose: Add the options to the page HTML for the table
|
mas01mj@640
|
2710 * Returns: -
|
mas01mj@640
|
2711 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2712 */
|
mas01mj@640
|
2713 function _fnAddOptionsHtml ( oSettings )
|
mas01mj@640
|
2714 {
|
mas01mj@640
|
2715 /*
|
mas01mj@640
|
2716 * Create a temporary, empty, div which we can later on replace with what we have generated
|
mas01mj@640
|
2717 * we do it this way to rendering the 'options' html offline - speed :-)
|
mas01mj@640
|
2718 */
|
mas01mj@640
|
2719 var nHolding = document.createElement( 'div' );
|
mas01mj@640
|
2720 oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
|
mas01mj@640
|
2721
|
mas01mj@640
|
2722 /*
|
mas01mj@640
|
2723 * All DataTables are wrapped in a div - this is not currently optional - backwards
|
mas01mj@640
|
2724 * compatability. It can be removed if you don't want it.
|
mas01mj@640
|
2725 */
|
mas01mj@640
|
2726 var nWrapper = document.createElement( 'div' );
|
mas01mj@640
|
2727 nWrapper.className = oSettings.oClasses.sWrapper;
|
mas01mj@640
|
2728 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
2729 {
|
mas01mj@640
|
2730 nWrapper.setAttribute( 'id', oSettings.sTableId+'_wrapper' );
|
mas01mj@640
|
2731 }
|
mas01mj@640
|
2732
|
mas01mj@640
|
2733 /* Track where we want to insert the option */
|
mas01mj@640
|
2734 var nInsertNode = nWrapper;
|
mas01mj@640
|
2735
|
mas01mj@640
|
2736 /* IE don't treat strings as arrays */
|
mas01mj@640
|
2737 var sDom = oSettings.sDomPositioning.split('');
|
mas01mj@640
|
2738
|
mas01mj@640
|
2739 /* Loop over the user set positioning and place the elements as needed */
|
mas01mj@640
|
2740 var nTmp;
|
mas01mj@640
|
2741 for ( var i=0 ; i<sDom.length ; i++ )
|
mas01mj@640
|
2742 {
|
mas01mj@640
|
2743 var cOption = sDom[i];
|
mas01mj@640
|
2744
|
mas01mj@640
|
2745 if ( cOption == '<' )
|
mas01mj@640
|
2746 {
|
mas01mj@640
|
2747 /* New container div */
|
mas01mj@640
|
2748 var nNewNode = document.createElement( 'div' );
|
mas01mj@640
|
2749
|
mas01mj@640
|
2750 /* Check to see if we should append a class name to the container */
|
mas01mj@640
|
2751 var cNext = sDom[i+1];
|
mas01mj@640
|
2752 if ( cNext == "'" || cNext == '"' )
|
mas01mj@640
|
2753 {
|
mas01mj@640
|
2754 var sClass = "";
|
mas01mj@640
|
2755 var j = 2;
|
mas01mj@640
|
2756 while ( sDom[i+j] != cNext )
|
mas01mj@640
|
2757 {
|
mas01mj@640
|
2758 sClass += sDom[i+j];
|
mas01mj@640
|
2759 j++;
|
mas01mj@640
|
2760 }
|
mas01mj@640
|
2761 nNewNode.className = sClass;
|
mas01mj@640
|
2762 i += j; /* Move along the position array */
|
mas01mj@640
|
2763 }
|
mas01mj@640
|
2764
|
mas01mj@640
|
2765 nInsertNode.appendChild( nNewNode );
|
mas01mj@640
|
2766 nInsertNode = nNewNode;
|
mas01mj@640
|
2767 }
|
mas01mj@640
|
2768 else if ( cOption == '>' )
|
mas01mj@640
|
2769 {
|
mas01mj@640
|
2770 /* End container div */
|
mas01mj@640
|
2771 nInsertNode = nInsertNode.parentNode;
|
mas01mj@640
|
2772 }
|
mas01mj@640
|
2773 else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
|
mas01mj@640
|
2774 {
|
mas01mj@640
|
2775 /* Length */
|
mas01mj@640
|
2776 nTmp = _fnFeatureHtmlLength( oSettings );
|
mas01mj@640
|
2777 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2778 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2779 }
|
mas01mj@640
|
2780 else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
|
mas01mj@640
|
2781 {
|
mas01mj@640
|
2782 /* Filter */
|
mas01mj@640
|
2783 nTmp = _fnFeatureHtmlFilter( oSettings );
|
mas01mj@640
|
2784 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2785 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2786 }
|
mas01mj@640
|
2787 else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
|
mas01mj@640
|
2788 {
|
mas01mj@640
|
2789 /* pRocessing */
|
mas01mj@640
|
2790 nTmp = _fnFeatureHtmlProcessing( oSettings );
|
mas01mj@640
|
2791 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2792 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2793 }
|
mas01mj@640
|
2794 else if ( cOption == 't' )
|
mas01mj@640
|
2795 {
|
mas01mj@640
|
2796 /* Table */
|
mas01mj@640
|
2797 oSettings.anFeatures[cOption] = oSettings.nTable;
|
mas01mj@640
|
2798 nInsertNode.appendChild( oSettings.nTable );
|
mas01mj@640
|
2799 }
|
mas01mj@640
|
2800 else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
|
mas01mj@640
|
2801 {
|
mas01mj@640
|
2802 /* Info */
|
mas01mj@640
|
2803 nTmp = _fnFeatureHtmlInfo( oSettings );
|
mas01mj@640
|
2804 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2805 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2806 }
|
mas01mj@640
|
2807 else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
|
mas01mj@640
|
2808 {
|
mas01mj@640
|
2809 /* Pagination */
|
mas01mj@640
|
2810 nTmp = _fnFeatureHtmlPaginate( oSettings );
|
mas01mj@640
|
2811 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2812 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2813 }
|
mas01mj@640
|
2814 else if ( _oExt.aoFeatures.length !== 0 )
|
mas01mj@640
|
2815 {
|
mas01mj@640
|
2816 var aoFeatures = _oExt.aoFeatures;
|
mas01mj@640
|
2817 for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
|
mas01mj@640
|
2818 {
|
mas01mj@640
|
2819 if ( cOption == aoFeatures[k].cFeature )
|
mas01mj@640
|
2820 {
|
mas01mj@640
|
2821 nTmp = aoFeatures[k].fnInit( oSettings );
|
mas01mj@640
|
2822 oSettings.anFeatures[cOption] = nTmp;
|
mas01mj@640
|
2823 nInsertNode.appendChild( nTmp );
|
mas01mj@640
|
2824 break;
|
mas01mj@640
|
2825 }
|
mas01mj@640
|
2826 }
|
mas01mj@640
|
2827 }
|
mas01mj@640
|
2828 }
|
mas01mj@640
|
2829
|
mas01mj@640
|
2830 /* Built our DOM structure - replace the holding div with what we want */
|
mas01mj@640
|
2831 nHolding.parentNode.replaceChild( nWrapper, nHolding );
|
mas01mj@640
|
2832 }
|
mas01mj@640
|
2833
|
mas01mj@640
|
2834 /*
|
mas01mj@640
|
2835 * Function: _fnFeatureHtmlFilter
|
mas01mj@640
|
2836 * Purpose: Generate the node required for filtering text
|
mas01mj@640
|
2837 * Returns: node
|
mas01mj@640
|
2838 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2839 */
|
mas01mj@640
|
2840 function _fnFeatureHtmlFilter ( oSettings )
|
mas01mj@640
|
2841 {
|
mas01mj@640
|
2842 var nFilter = document.createElement( 'div' );
|
mas01mj@640
|
2843 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
2844 {
|
mas01mj@640
|
2845 nFilter.setAttribute( 'id', oSettings.sTableId+'_filter' );
|
mas01mj@640
|
2846 }
|
mas01mj@640
|
2847 nFilter.className = oSettings.oClasses.sFilter;
|
mas01mj@640
|
2848 var sSpace = oSettings.oLanguage.sSearch==="" ? "" : " ";
|
mas01mj@640
|
2849 nFilter.innerHTML = oSettings.oLanguage.sSearch+sSpace+'<input type="text" />';
|
mas01mj@640
|
2850
|
mas01mj@640
|
2851 var jqFilter = $("input", nFilter);
|
mas01mj@640
|
2852 jqFilter.val( oSettings.oPreviousSearch.sSearch.replace('"','"') );
|
mas01mj@640
|
2853 jqFilter.keyup( function(e) {
|
mas01mj@640
|
2854 _fnFilterComplete( oSettings, {
|
mas01mj@640
|
2855 "sSearch": this.value,
|
mas01mj@640
|
2856 "bEscapeRegex": oSettings.oPreviousSearch.bEscapeRegex
|
mas01mj@640
|
2857 } );
|
mas01mj@640
|
2858
|
mas01mj@640
|
2859 /* Prevent default */
|
mas01mj@640
|
2860 return false;
|
mas01mj@640
|
2861 } );
|
mas01mj@640
|
2862
|
mas01mj@640
|
2863 return nFilter;
|
mas01mj@640
|
2864 }
|
mas01mj@640
|
2865
|
mas01mj@640
|
2866 /*
|
mas01mj@640
|
2867 * Function: _fnFeatureHtmlInfo
|
mas01mj@640
|
2868 * Purpose: Generate the node required for the info display
|
mas01mj@640
|
2869 * Returns: node
|
mas01mj@640
|
2870 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2871 */
|
mas01mj@640
|
2872 function _fnFeatureHtmlInfo ( oSettings )
|
mas01mj@640
|
2873 {
|
mas01mj@640
|
2874 var nInfo = document.createElement( 'div' );
|
mas01mj@640
|
2875 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
2876 {
|
mas01mj@640
|
2877 nInfo.setAttribute( 'id', oSettings.sTableId+'_info' );
|
mas01mj@640
|
2878 }
|
mas01mj@640
|
2879 nInfo.className = oSettings.oClasses.sInfo;
|
mas01mj@640
|
2880 return nInfo;
|
mas01mj@640
|
2881 }
|
mas01mj@640
|
2882
|
mas01mj@640
|
2883 /*
|
mas01mj@640
|
2884 * Function: _fnFeatureHtmlPaginate
|
mas01mj@640
|
2885 * Purpose: Generate the node required for default pagination
|
mas01mj@640
|
2886 * Returns: node
|
mas01mj@640
|
2887 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2888 */
|
mas01mj@640
|
2889 function _fnFeatureHtmlPaginate ( oSettings )
|
mas01mj@640
|
2890 {
|
mas01mj@640
|
2891 var nPaginate = document.createElement( 'div' );
|
mas01mj@640
|
2892 nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType;
|
mas01mj@640
|
2893 oSettings.anFeatures.p = nPaginate; /* Need this stored in order to call paging plug-ins */
|
mas01mj@640
|
2894
|
mas01mj@640
|
2895 _oExt.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, function( oSettings ) {
|
mas01mj@640
|
2896 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
2897 _fnDraw( oSettings );
|
mas01mj@640
|
2898 } );
|
mas01mj@640
|
2899 return nPaginate;
|
mas01mj@640
|
2900 }
|
mas01mj@640
|
2901
|
mas01mj@640
|
2902 /*
|
mas01mj@640
|
2903 * Function: _fnFeatureHtmlLength
|
mas01mj@640
|
2904 * Purpose: Generate the node required for user display length changing
|
mas01mj@640
|
2905 * Returns: node
|
mas01mj@640
|
2906 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2907 */
|
mas01mj@640
|
2908 function _fnFeatureHtmlLength ( oSettings )
|
mas01mj@640
|
2909 {
|
mas01mj@640
|
2910 /* This can be overruled by not using the _MENU_ var/macro in the language variable */
|
mas01mj@640
|
2911 var sName = (oSettings.sTableId === "") ? "" : 'name="'+oSettings.sTableId+'_length"';
|
mas01mj@640
|
2912 var sStdMenu =
|
mas01mj@640
|
2913 '<select size="1" '+sName+'>'+
|
mas01mj@640
|
2914 '<option value="10">10</option>'+
|
mas01mj@640
|
2915 '<option value="25">25</option>'+
|
mas01mj@640
|
2916 '<option value="50">50</option>'+
|
mas01mj@640
|
2917 '<option value="100">100</option>'+
|
mas01mj@640
|
2918 '</select>';
|
mas01mj@640
|
2919
|
mas01mj@640
|
2920 var nLength = document.createElement( 'div' );
|
mas01mj@640
|
2921 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
2922 {
|
mas01mj@640
|
2923 nLength.setAttribute( 'id', oSettings.sTableId+'_length' );
|
mas01mj@640
|
2924 }
|
mas01mj@640
|
2925 nLength.className = oSettings.oClasses.sLength;
|
mas01mj@640
|
2926 nLength.innerHTML = oSettings.oLanguage.sLengthMenu.replace( '_MENU_', sStdMenu );
|
mas01mj@640
|
2927
|
mas01mj@640
|
2928 /*
|
mas01mj@640
|
2929 * Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
|
mas01mj@640
|
2930 * and Stefan Skopnik for fixing the fix!
|
mas01mj@640
|
2931 */
|
mas01mj@640
|
2932 $('select option[value="'+oSettings._iDisplayLength+'"]',nLength).attr("selected",true);
|
mas01mj@640
|
2933
|
mas01mj@640
|
2934 $('select', nLength).change( function(e) {
|
mas01mj@640
|
2935 oSettings._iDisplayLength = parseInt($(this).val(), 10);
|
mas01mj@640
|
2936
|
mas01mj@640
|
2937 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
2938
|
mas01mj@640
|
2939 /* If we have space to show extra rows (backing up from the end point - then do so */
|
mas01mj@640
|
2940 if ( oSettings._iDisplayEnd == oSettings.aiDisplay.length )
|
mas01mj@640
|
2941 {
|
mas01mj@640
|
2942 oSettings._iDisplayStart = oSettings._iDisplayEnd - oSettings._iDisplayLength;
|
mas01mj@640
|
2943 if ( oSettings._iDisplayStart < 0 )
|
mas01mj@640
|
2944 {
|
mas01mj@640
|
2945 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
2946 }
|
mas01mj@640
|
2947 }
|
mas01mj@640
|
2948
|
mas01mj@640
|
2949 if ( oSettings._iDisplayLength == -1 )
|
mas01mj@640
|
2950 {
|
mas01mj@640
|
2951 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
2952 }
|
mas01mj@640
|
2953
|
mas01mj@640
|
2954 _fnDraw( oSettings );
|
mas01mj@640
|
2955 } );
|
mas01mj@640
|
2956
|
mas01mj@640
|
2957 return nLength;
|
mas01mj@640
|
2958 }
|
mas01mj@640
|
2959
|
mas01mj@640
|
2960 /*
|
mas01mj@640
|
2961 * Function: _fnFeatureHtmlProcessing
|
mas01mj@640
|
2962 * Purpose: Generate the node required for the processing node
|
mas01mj@640
|
2963 * Returns: node
|
mas01mj@640
|
2964 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2965 */
|
mas01mj@640
|
2966 function _fnFeatureHtmlProcessing ( oSettings )
|
mas01mj@640
|
2967 {
|
mas01mj@640
|
2968 var nProcessing = document.createElement( 'div' );
|
mas01mj@640
|
2969
|
mas01mj@640
|
2970 if ( oSettings.sTableId !== '' )
|
mas01mj@640
|
2971 {
|
mas01mj@640
|
2972 nProcessing.setAttribute( 'id', oSettings.sTableId+'_processing' );
|
mas01mj@640
|
2973 }
|
mas01mj@640
|
2974 nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
|
mas01mj@640
|
2975 nProcessing.className = oSettings.oClasses.sProcessing;
|
mas01mj@640
|
2976 oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable );
|
mas01mj@640
|
2977
|
mas01mj@640
|
2978 return nProcessing;
|
mas01mj@640
|
2979 }
|
mas01mj@640
|
2980
|
mas01mj@640
|
2981 /*
|
mas01mj@640
|
2982 * Function: _fnProcessingDisplay
|
mas01mj@640
|
2983 * Purpose: Display or hide the processing indicator
|
mas01mj@640
|
2984 * Returns: -
|
mas01mj@640
|
2985 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
2986 * bool:
|
mas01mj@640
|
2987 * true - show the processing indicator
|
mas01mj@640
|
2988 * false - don't show
|
mas01mj@640
|
2989 */
|
mas01mj@640
|
2990 function _fnProcessingDisplay ( oSettings, bShow )
|
mas01mj@640
|
2991 {
|
mas01mj@640
|
2992 if ( oSettings.oFeatures.bProcessing )
|
mas01mj@640
|
2993 {
|
mas01mj@640
|
2994 oSettings.anFeatures.r.style.visibility = bShow ? "visible" : "hidden";
|
mas01mj@640
|
2995 }
|
mas01mj@640
|
2996 }
|
mas01mj@640
|
2997
|
mas01mj@640
|
2998
|
mas01mj@640
|
2999
|
mas01mj@640
|
3000 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
3001 * Filtering
|
mas01mj@640
|
3002 */
|
mas01mj@640
|
3003
|
mas01mj@640
|
3004 /*
|
mas01mj@640
|
3005 * Function: _fnFilterComplete
|
mas01mj@640
|
3006 * Purpose: Filter the table using both the global filter and column based filtering
|
mas01mj@640
|
3007 * Returns: -
|
mas01mj@640
|
3008 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3009 * object:oSearch: search information
|
mas01mj@640
|
3010 * int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
|
mas01mj@640
|
3011 */
|
mas01mj@640
|
3012 function _fnFilterComplete ( oSettings, oInput, iForce )
|
mas01mj@640
|
3013 {
|
mas01mj@640
|
3014 /* Filter on everything */
|
mas01mj@640
|
3015 _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bEscapeRegex );
|
mas01mj@640
|
3016
|
mas01mj@640
|
3017 /* Now do the individual column filter */
|
mas01mj@640
|
3018 for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
mas01mj@640
|
3019 {
|
mas01mj@640
|
3020 _fnFilterColumn( oSettings, oSettings.aoPreSearchCols[i].sSearch, i,
|
mas01mj@640
|
3021 oSettings.aoPreSearchCols[i].bEscapeRegex );
|
mas01mj@640
|
3022 }
|
mas01mj@640
|
3023
|
mas01mj@640
|
3024 /* Custom filtering */
|
mas01mj@640
|
3025 if ( _oExt.afnFiltering.length !== 0 )
|
mas01mj@640
|
3026 {
|
mas01mj@640
|
3027 _fnFilterCustom( oSettings );
|
mas01mj@640
|
3028 }
|
mas01mj@640
|
3029
|
mas01mj@640
|
3030 /* Redraw the table */
|
mas01mj@640
|
3031 if ( typeof oSettings.iInitDisplayStart != 'undefined' && oSettings.iInitDisplayStart != -1 )
|
mas01mj@640
|
3032 {
|
mas01mj@640
|
3033 oSettings._iDisplayStart = oSettings.iInitDisplayStart;
|
mas01mj@640
|
3034 oSettings.iInitDisplayStart = -1;
|
mas01mj@640
|
3035 }
|
mas01mj@640
|
3036 else
|
mas01mj@640
|
3037 {
|
mas01mj@640
|
3038 oSettings._iDisplayStart = 0;
|
mas01mj@640
|
3039 }
|
mas01mj@640
|
3040 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
3041 _fnDraw( oSettings );
|
mas01mj@640
|
3042
|
mas01mj@640
|
3043 /* Rebuild search array 'offline' */
|
mas01mj@640
|
3044 _fnBuildSearchArray( oSettings, 0 );
|
mas01mj@640
|
3045 }
|
mas01mj@640
|
3046
|
mas01mj@640
|
3047 /*
|
mas01mj@640
|
3048 * Function: _fnFilterCustom
|
mas01mj@640
|
3049 * Purpose: Apply custom filtering functions
|
mas01mj@640
|
3050 * Returns: -
|
mas01mj@640
|
3051 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3052 */
|
mas01mj@640
|
3053 function _fnFilterCustom( oSettings )
|
mas01mj@640
|
3054 {
|
mas01mj@640
|
3055 var afnFilters = _oExt.afnFiltering;
|
mas01mj@640
|
3056 for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
|
mas01mj@640
|
3057 {
|
mas01mj@640
|
3058 var iCorrector = 0;
|
mas01mj@640
|
3059 for ( var j=0, jLen=oSettings.aiDisplay.length ; j<jLen ; j++ )
|
mas01mj@640
|
3060 {
|
mas01mj@640
|
3061 var iDisIndex = oSettings.aiDisplay[j-iCorrector];
|
mas01mj@640
|
3062
|
mas01mj@640
|
3063 /* Check if we should use this row based on the filtering function */
|
mas01mj@640
|
3064 if ( !afnFilters[i]( oSettings, oSettings.aoData[iDisIndex]._aData, iDisIndex ) )
|
mas01mj@640
|
3065 {
|
mas01mj@640
|
3066 oSettings.aiDisplay.splice( j-iCorrector, 1 );
|
mas01mj@640
|
3067 iCorrector++;
|
mas01mj@640
|
3068 }
|
mas01mj@640
|
3069 }
|
mas01mj@640
|
3070 }
|
mas01mj@640
|
3071 }
|
mas01mj@640
|
3072
|
mas01mj@640
|
3073 /*
|
mas01mj@640
|
3074 * Function: _fnFilterColumn
|
mas01mj@640
|
3075 * Purpose: Filter the table on a per-column basis
|
mas01mj@640
|
3076 * Returns: -
|
mas01mj@640
|
3077 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3078 * string:sInput - string to filter on
|
mas01mj@640
|
3079 * int:iColumn - column to filter
|
mas01mj@640
|
3080 * bool:bEscapeRegex - escape regex or not
|
mas01mj@640
|
3081 */
|
mas01mj@640
|
3082 function _fnFilterColumn ( oSettings, sInput, iColumn, bEscapeRegex )
|
mas01mj@640
|
3083 {
|
mas01mj@640
|
3084 if ( sInput === "" )
|
mas01mj@640
|
3085 {
|
mas01mj@640
|
3086 return;
|
mas01mj@640
|
3087 }
|
mas01mj@640
|
3088
|
mas01mj@640
|
3089 var iIndexCorrector = 0;
|
mas01mj@640
|
3090 var sRegexMatch = bEscapeRegex ? _fnEscapeRegex( sInput ) : sInput;
|
mas01mj@640
|
3091 var rpSearch = new RegExp( sRegexMatch, "i" );
|
mas01mj@640
|
3092
|
mas01mj@640
|
3093 for ( var i=oSettings.aiDisplay.length-1 ; i>=0 ; i-- )
|
mas01mj@640
|
3094 {
|
mas01mj@640
|
3095 var sData = _fnDataToSearch( oSettings.aoData[ oSettings.aiDisplay[i] ]._aData[iColumn],
|
mas01mj@640
|
3096 oSettings.aoColumns[iColumn].sType );
|
mas01mj@640
|
3097 if ( ! rpSearch.test( sData ) )
|
mas01mj@640
|
3098 {
|
mas01mj@640
|
3099 oSettings.aiDisplay.splice( i, 1 );
|
mas01mj@640
|
3100 iIndexCorrector++;
|
mas01mj@640
|
3101 }
|
mas01mj@640
|
3102 }
|
mas01mj@640
|
3103 }
|
mas01mj@640
|
3104
|
mas01mj@640
|
3105 /*
|
mas01mj@640
|
3106 * Function: _fnFilter
|
mas01mj@640
|
3107 * Purpose: Filter the data table based on user input and draw the table
|
mas01mj@640
|
3108 * Returns: -
|
mas01mj@640
|
3109 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3110 * string:sInput - string to filter on
|
mas01mj@640
|
3111 * int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
|
mas01mj@640
|
3112 * bool:bEscapeRegex - escape regex or not
|
mas01mj@640
|
3113 */
|
mas01mj@640
|
3114 function _fnFilter( oSettings, sInput, iForce, bEscapeRegex )
|
mas01mj@640
|
3115 {
|
mas01mj@640
|
3116 var i;
|
mas01mj@640
|
3117
|
mas01mj@640
|
3118 /* Check if we are forcing or not - optional parameter */
|
mas01mj@640
|
3119 if ( typeof iForce == 'undefined' || iForce === null )
|
mas01mj@640
|
3120 {
|
mas01mj@640
|
3121 iForce = 0;
|
mas01mj@640
|
3122 }
|
mas01mj@640
|
3123
|
mas01mj@640
|
3124 /* Need to take account of custom filtering functions always */
|
mas01mj@640
|
3125 if ( _oExt.afnFiltering.length !== 0 )
|
mas01mj@640
|
3126 {
|
mas01mj@640
|
3127 iForce = 1;
|
mas01mj@640
|
3128 }
|
mas01mj@640
|
3129
|
mas01mj@640
|
3130 /* Generate the regular expression to use. Something along the lines of:
|
mas01mj@640
|
3131 * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
|
mas01mj@640
|
3132 */
|
mas01mj@640
|
3133 var asSearch = bEscapeRegex ?
|
mas01mj@640
|
3134 _fnEscapeRegex( sInput ).split( ' ' ) :
|
mas01mj@640
|
3135 sInput.split( ' ' );
|
mas01mj@640
|
3136 var sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
|
mas01mj@640
|
3137 var rpSearch = new RegExp( sRegExpString, "i" ); /* case insensitive */
|
mas01mj@640
|
3138
|
mas01mj@640
|
3139 /*
|
mas01mj@640
|
3140 * If the input is blank - we want the full data set
|
mas01mj@640
|
3141 */
|
mas01mj@640
|
3142 if ( sInput.length <= 0 )
|
mas01mj@640
|
3143 {
|
mas01mj@640
|
3144 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
mas01mj@640
|
3145 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
3146 }
|
mas01mj@640
|
3147 else
|
mas01mj@640
|
3148 {
|
mas01mj@640
|
3149 /*
|
mas01mj@640
|
3150 * We are starting a new search or the new search string is smaller
|
mas01mj@640
|
3151 * then the old one (i.e. delete). Search from the master array
|
mas01mj@640
|
3152 */
|
mas01mj@640
|
3153 if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
|
mas01mj@640
|
3154 oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
|
mas01mj@640
|
3155 sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0 )
|
mas01mj@640
|
3156 {
|
mas01mj@640
|
3157 /* Nuke the old display array - we are going to rebuild it */
|
mas01mj@640
|
3158 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
|
mas01mj@640
|
3159
|
mas01mj@640
|
3160 /* Force a rebuild of the search array */
|
mas01mj@640
|
3161 _fnBuildSearchArray( oSettings, 1 );
|
mas01mj@640
|
3162
|
mas01mj@640
|
3163 /* Search through all records to populate the search array
|
mas01mj@640
|
3164 * The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
|
mas01mj@640
|
3165 * mapping
|
mas01mj@640
|
3166 */
|
mas01mj@640
|
3167 for ( i=0 ; i<oSettings.aiDisplayMaster.length ; i++ )
|
mas01mj@640
|
3168 {
|
mas01mj@640
|
3169 if ( rpSearch.test(oSettings.asDataSearch[i]) )
|
mas01mj@640
|
3170 {
|
mas01mj@640
|
3171 oSettings.aiDisplay.push( oSettings.aiDisplayMaster[i] );
|
mas01mj@640
|
3172 }
|
mas01mj@640
|
3173 }
|
mas01mj@640
|
3174 }
|
mas01mj@640
|
3175 else
|
mas01mj@640
|
3176 {
|
mas01mj@640
|
3177 /* Using old search array - refine it - do it this way for speed
|
mas01mj@640
|
3178 * Don't have to search the whole master array again
|
mas01mj@640
|
3179 */
|
mas01mj@640
|
3180 var iIndexCorrector = 0;
|
mas01mj@640
|
3181
|
mas01mj@640
|
3182 /* Search the current results */
|
mas01mj@640
|
3183 for ( i=0 ; i<oSettings.asDataSearch.length ; i++ )
|
mas01mj@640
|
3184 {
|
mas01mj@640
|
3185 if ( ! rpSearch.test(oSettings.asDataSearch[i]) )
|
mas01mj@640
|
3186 {
|
mas01mj@640
|
3187 oSettings.aiDisplay.splice( i-iIndexCorrector, 1 );
|
mas01mj@640
|
3188 iIndexCorrector++;
|
mas01mj@640
|
3189 }
|
mas01mj@640
|
3190 }
|
mas01mj@640
|
3191 }
|
mas01mj@640
|
3192 }
|
mas01mj@640
|
3193 oSettings.oPreviousSearch.sSearch = sInput;
|
mas01mj@640
|
3194 oSettings.oPreviousSearch.bEscapeRegex = bEscapeRegex;
|
mas01mj@640
|
3195 }
|
mas01mj@640
|
3196
|
mas01mj@640
|
3197
|
mas01mj@640
|
3198
|
mas01mj@640
|
3199 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
3200 * Sorting
|
mas01mj@640
|
3201 */
|
mas01mj@640
|
3202
|
mas01mj@640
|
3203 /*
|
mas01mj@640
|
3204 * Function: _fnSort
|
mas01mj@640
|
3205 * Purpose: Change the order of the table
|
mas01mj@640
|
3206 * Returns: -
|
mas01mj@640
|
3207 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3208 * bool:bApplyClasses - optional - should we apply classes or not
|
mas01mj@640
|
3209 * Notes: We always sort the master array and then apply a filter again
|
mas01mj@640
|
3210 * if it is needed. This probably isn't optimal - but atm I can't think
|
mas01mj@640
|
3211 * of any other way which is (each has disadvantages)
|
mas01mj@640
|
3212 */
|
mas01mj@640
|
3213 function _fnSort ( oSettings, bApplyClasses )
|
mas01mj@640
|
3214 {
|
mas01mj@640
|
3215 /*
|
mas01mj@640
|
3216 * Funny one this - we want to sort aiDisplayMaster - but according to aoData[]._aData
|
mas01mj@640
|
3217 *
|
mas01mj@640
|
3218 * function _fnSortText ( a, b )
|
mas01mj@640
|
3219 * {
|
mas01mj@640
|
3220 * var iTest;
|
mas01mj@640
|
3221 * var oSort = _oExt.oSort;
|
mas01mj@640
|
3222 *
|
mas01mj@640
|
3223 * iTest = oSort['string-asc']( aoData[ a ]._aData[ COL ], aoData[ b ]._aData[ COL ] );
|
mas01mj@640
|
3224 * if ( iTest === 0 )
|
mas01mj@640
|
3225 * ...
|
mas01mj@640
|
3226 * }
|
mas01mj@640
|
3227 */
|
mas01mj@640
|
3228
|
mas01mj@640
|
3229 /* Here is what we are looking to achieve here (custom sort functions add complication...)
|
mas01mj@640
|
3230 * function _fnSortText ( a, b )
|
mas01mj@640
|
3231 * {
|
mas01mj@640
|
3232 * var iTest;
|
mas01mj@640
|
3233 * var oSort = _oExt.oSort;
|
mas01mj@640
|
3234 * iTest = oSort['string-asc']( a[0], b[0] );
|
mas01mj@640
|
3235 * if ( iTest === 0 )
|
mas01mj@640
|
3236 * iTest = oSort['string-asc']( a[1], b[1] );
|
mas01mj@640
|
3237 * if ( iTest === 0 )
|
mas01mj@640
|
3238 * iTest = oSort['string-asc']( a[2], b[2] );
|
mas01mj@640
|
3239 *
|
mas01mj@640
|
3240 * return iTest;
|
mas01mj@640
|
3241 * }
|
mas01mj@640
|
3242 */
|
mas01mj@640
|
3243 var aaSort = [];
|
mas01mj@640
|
3244 var oSort = _oExt.oSort;
|
mas01mj@640
|
3245 var aoData = oSettings.aoData;
|
mas01mj@640
|
3246 var iDataSort;
|
mas01mj@640
|
3247 var iDataType;
|
mas01mj@640
|
3248 var i;
|
mas01mj@640
|
3249
|
mas01mj@640
|
3250 if ( oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null )
|
mas01mj@640
|
3251 {
|
mas01mj@640
|
3252 if ( oSettings.aaSortingFixed !== null )
|
mas01mj@640
|
3253 {
|
mas01mj@640
|
3254 aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
|
mas01mj@640
|
3255 }
|
mas01mj@640
|
3256 else
|
mas01mj@640
|
3257 {
|
mas01mj@640
|
3258 aaSort = oSettings.aaSorting.slice();
|
mas01mj@640
|
3259 }
|
mas01mj@640
|
3260
|
mas01mj@640
|
3261 if ( !window.runtime )
|
mas01mj@640
|
3262 {
|
mas01mj@640
|
3263 var fnLocalSorting;
|
mas01mj@640
|
3264 var sDynamicSort = "fnLocalSorting = function(a,b){"+
|
mas01mj@640
|
3265 "var iTest;";
|
mas01mj@640
|
3266
|
mas01mj@640
|
3267 for ( i=0 ; i<aaSort.length-1 ; i++ )
|
mas01mj@640
|
3268 {
|
mas01mj@640
|
3269 iDataSort = oSettings.aoColumns[ aaSort[i][0] ].iDataSort;
|
mas01mj@640
|
3270 iDataType = oSettings.aoColumns[ iDataSort ].sType;
|
mas01mj@640
|
3271 sDynamicSort += "iTest = oSort['"+iDataType+"-"+aaSort[i][1]+"']"+
|
mas01mj@640
|
3272 "( aoData[a]._aData["+iDataSort+"], aoData[b]._aData["+iDataSort+"] ); if ( iTest === 0 )";
|
mas01mj@640
|
3273 }
|
mas01mj@640
|
3274
|
mas01mj@640
|
3275 iDataSort = oSettings.aoColumns[ aaSort[aaSort.length-1][0] ].iDataSort;
|
mas01mj@640
|
3276 iDataType = oSettings.aoColumns[ iDataSort ].sType;
|
mas01mj@640
|
3277 sDynamicSort += "iTest = oSort['"+iDataType+"-"+aaSort[aaSort.length-1][1]+"']"+
|
mas01mj@640
|
3278 "( aoData[a]._aData["+iDataSort+"], aoData[b]._aData["+iDataSort+"] ); return iTest;}";
|
mas01mj@640
|
3279
|
mas01mj@640
|
3280 /* The eval has to be done to a variable for IE */
|
mas01mj@640
|
3281 eval( sDynamicSort );
|
mas01mj@640
|
3282 oSettings.aiDisplayMaster.sort( fnLocalSorting );
|
mas01mj@640
|
3283 }
|
mas01mj@640
|
3284 else
|
mas01mj@640
|
3285 {
|
mas01mj@640
|
3286 /*
|
mas01mj@640
|
3287 * Support for Adobe AIR - AIR doesn't allow eval with a function
|
mas01mj@640
|
3288 * Note that for reasonable sized data sets this method is around 1.5 times slower than
|
mas01mj@640
|
3289 * the eval above (hence why it is not used all the time). Oddly enough, it is ever so
|
mas01mj@640
|
3290 * slightly faster for very small sets (presumably the eval has overhead).
|
mas01mj@640
|
3291 * Single column (1083 records) - eval: 32mS AIR: 38mS
|
mas01mj@640
|
3292 * Two columns (1083 records) - eval: 55mS AIR: 66mS
|
mas01mj@640
|
3293 */
|
mas01mj@640
|
3294
|
mas01mj@640
|
3295 /* Build a cached array so the sort doesn't have to process this stuff on every call */
|
mas01mj@640
|
3296 var aAirSort = [];
|
mas01mj@640
|
3297 var iLen = aaSort.length;
|
mas01mj@640
|
3298 for ( i=0 ; i<iLen ; i++ )
|
mas01mj@640
|
3299 {
|
mas01mj@640
|
3300 iDataSort = oSettings.aoColumns[ aaSort[i][0] ].iDataSort;
|
mas01mj@640
|
3301 aAirSort.push( [
|
mas01mj@640
|
3302 iDataSort,
|
mas01mj@640
|
3303 oSettings.aoColumns[ iDataSort ].sType+'-'+aaSort[i][1]
|
mas01mj@640
|
3304 ] );
|
mas01mj@640
|
3305 }
|
mas01mj@640
|
3306
|
mas01mj@640
|
3307 oSettings.aiDisplayMaster.sort( function (a,b) {
|
mas01mj@640
|
3308 var iTest;
|
mas01mj@640
|
3309 for ( var i=0 ; i<iLen ; i++ )
|
mas01mj@640
|
3310 {
|
mas01mj@640
|
3311 iTest = oSort[ aAirSort[i][1] ]( aoData[a]._aData[aAirSort[i][0]], aoData[b]._aData[aAirSort[i][0]] );
|
mas01mj@640
|
3312 if ( iTest !== 0 )
|
mas01mj@640
|
3313 {
|
mas01mj@640
|
3314 return iTest;
|
mas01mj@640
|
3315 }
|
mas01mj@640
|
3316 }
|
mas01mj@640
|
3317 return 0;
|
mas01mj@640
|
3318 } );
|
mas01mj@640
|
3319 }
|
mas01mj@640
|
3320 }
|
mas01mj@640
|
3321
|
mas01mj@640
|
3322 /* Alter the sorting classes to take account of the changes */
|
mas01mj@640
|
3323 if ( typeof bApplyClasses == 'undefined' || bApplyClasses )
|
mas01mj@640
|
3324 {
|
mas01mj@640
|
3325 _fnSortingClasses( oSettings );
|
mas01mj@640
|
3326 }
|
mas01mj@640
|
3327
|
mas01mj@640
|
3328 /* Copy the master data into the draw array and re-draw */
|
mas01mj@640
|
3329 if ( oSettings.oFeatures.bFilter )
|
mas01mj@640
|
3330 {
|
mas01mj@640
|
3331 /* _fnFilter() will redraw the table for us */
|
mas01mj@640
|
3332 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
|
mas01mj@640
|
3333 }
|
mas01mj@640
|
3334 else
|
mas01mj@640
|
3335 {
|
mas01mj@640
|
3336 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
3337 oSettings._iDisplayStart = 0; /* reset display back to page 0 */
|
mas01mj@640
|
3338 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
3339 _fnDraw( oSettings );
|
mas01mj@640
|
3340 }
|
mas01mj@640
|
3341 }
|
mas01mj@640
|
3342
|
mas01mj@640
|
3343 /*
|
mas01mj@640
|
3344 * Function: _fnSortingClasses
|
mas01mj@640
|
3345 * Purpose: Set the sortting classes on the header
|
mas01mj@640
|
3346 * Returns: -
|
mas01mj@640
|
3347 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3348 */
|
mas01mj@640
|
3349 function _fnSortingClasses( oSettings )
|
mas01mj@640
|
3350 {
|
mas01mj@640
|
3351 var i, j, iFound;
|
mas01mj@640
|
3352 var aaSort, sClass;
|
mas01mj@640
|
3353 var iColumns = oSettings.aoColumns.length;
|
mas01mj@640
|
3354 var oClasses = oSettings.oClasses;
|
mas01mj@640
|
3355
|
mas01mj@640
|
3356 for ( i=0 ; i<iColumns ; i++ )
|
mas01mj@640
|
3357 {
|
mas01mj@640
|
3358 $(oSettings.aoColumns[i].nTh).removeClass( oClasses.sSortAsc +" "+ oClasses.sSortDesc +
|
mas01mj@640
|
3359 " "+ oClasses.sSortable );
|
mas01mj@640
|
3360 }
|
mas01mj@640
|
3361
|
mas01mj@640
|
3362 if ( oSettings.aaSortingFixed !== null )
|
mas01mj@640
|
3363 {
|
mas01mj@640
|
3364 aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
|
mas01mj@640
|
3365 }
|
mas01mj@640
|
3366 else
|
mas01mj@640
|
3367 {
|
mas01mj@640
|
3368 aaSort = oSettings.aaSorting.slice();
|
mas01mj@640
|
3369 }
|
mas01mj@640
|
3370
|
mas01mj@640
|
3371 /* Apply the required classes to the header */
|
mas01mj@640
|
3372 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
3373 {
|
mas01mj@640
|
3374 if ( oSettings.aoColumns[i].bSortable && oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
3375 {
|
mas01mj@640
|
3376 sClass = oClasses.sSortable;
|
mas01mj@640
|
3377 iFound = -1;
|
mas01mj@640
|
3378 for ( j=0 ; j<aaSort.length ; j++ )
|
mas01mj@640
|
3379 {
|
mas01mj@640
|
3380 if ( aaSort[j][0] == i )
|
mas01mj@640
|
3381 {
|
mas01mj@640
|
3382 sClass = ( aaSort[j][1] == "asc" ) ?
|
mas01mj@640
|
3383 oClasses.sSortAsc : oClasses.sSortDesc;
|
mas01mj@640
|
3384 iFound = j;
|
mas01mj@640
|
3385 break;
|
mas01mj@640
|
3386 }
|
mas01mj@640
|
3387 }
|
mas01mj@640
|
3388 $(oSettings.aoColumns[i].nTh).addClass( sClass );
|
mas01mj@640
|
3389
|
mas01mj@640
|
3390 if ( oSettings.bJUI )
|
mas01mj@640
|
3391 {
|
mas01mj@640
|
3392 /* jQuery UI uses extra markup */
|
mas01mj@640
|
3393 var jqSpan = $("span", oSettings.aoColumns[i].nTh);
|
mas01mj@640
|
3394 jqSpan.removeClass(oClasses.sSortJUIAsc +" "+ oClasses.sSortJUIDesc +" "+
|
mas01mj@640
|
3395 oClasses.sSortJUI);
|
mas01mj@640
|
3396
|
mas01mj@640
|
3397 var sSpanClass;
|
mas01mj@640
|
3398 if ( iFound == -1 )
|
mas01mj@640
|
3399 {
|
mas01mj@640
|
3400 sSpanClass = oClasses.sSortJUI;
|
mas01mj@640
|
3401 }
|
mas01mj@640
|
3402 else if ( aaSort[iFound][1] == "asc" )
|
mas01mj@640
|
3403 {
|
mas01mj@640
|
3404 sSpanClass = oClasses.sSortJUIAsc;
|
mas01mj@640
|
3405 }
|
mas01mj@640
|
3406 else
|
mas01mj@640
|
3407 {
|
mas01mj@640
|
3408 sSpanClass = oClasses.sSortJUIDesc;
|
mas01mj@640
|
3409 }
|
mas01mj@640
|
3410
|
mas01mj@640
|
3411 jqSpan.addClass( sSpanClass );
|
mas01mj@640
|
3412 }
|
mas01mj@640
|
3413 }
|
mas01mj@640
|
3414 }
|
mas01mj@640
|
3415
|
mas01mj@640
|
3416 /*
|
mas01mj@640
|
3417 * Apply the required classes to the table body
|
mas01mj@640
|
3418 * Note that this is given as a feature switch since it can significantly slow down a sort
|
mas01mj@640
|
3419 * on large data sets (adding and removing of classes is always slow at the best of times..)
|
mas01mj@640
|
3420 */
|
mas01mj@640
|
3421 if ( oSettings.oFeatures.bSortClasses )
|
mas01mj@640
|
3422 {
|
mas01mj@640
|
3423 var nTrs = _fnGetTrNodes( oSettings );
|
mas01mj@640
|
3424 sClass = oClasses.sSortColumn;
|
mas01mj@640
|
3425 $('td', nTrs).removeClass( sClass+"1 "+sClass+"2 "+sClass+"3" );
|
mas01mj@640
|
3426
|
mas01mj@640
|
3427 var iClass = 1;
|
mas01mj@640
|
3428 for ( i=0 ; i<aaSort.length ; i++ )
|
mas01mj@640
|
3429 {
|
mas01mj@640
|
3430 var iVis = _fnColumnIndexToVisible(oSettings, aaSort[i][0]);
|
mas01mj@640
|
3431 if ( iVis !== null )
|
mas01mj@640
|
3432 {
|
mas01mj@640
|
3433 /* Limit the number of classes to three */
|
mas01mj@640
|
3434 if ( iClass <= 2 )
|
mas01mj@640
|
3435 {
|
mas01mj@640
|
3436 $('td:eq('+iVis+')', nTrs).addClass( sClass+iClass );
|
mas01mj@640
|
3437 }
|
mas01mj@640
|
3438 else
|
mas01mj@640
|
3439 {
|
mas01mj@640
|
3440 $('td:eq('+iVis+')', nTrs).addClass( sClass+'3' );
|
mas01mj@640
|
3441 }
|
mas01mj@640
|
3442 iClass++;
|
mas01mj@640
|
3443 }
|
mas01mj@640
|
3444 }
|
mas01mj@640
|
3445 }
|
mas01mj@640
|
3446 }
|
mas01mj@640
|
3447
|
mas01mj@640
|
3448 /*
|
mas01mj@640
|
3449 * Function: _fnVisibleToColumnIndex
|
mas01mj@640
|
3450 * Purpose: Covert the index of a visible column to the index in the data array (take account
|
mas01mj@640
|
3451 * of hidden columns)
|
mas01mj@640
|
3452 * Returns: int:i - the data index
|
mas01mj@640
|
3453 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3454 */
|
mas01mj@640
|
3455 function _fnVisibleToColumnIndex( oSettings, iMatch )
|
mas01mj@640
|
3456 {
|
mas01mj@640
|
3457 var iColumn = -1;
|
mas01mj@640
|
3458
|
mas01mj@640
|
3459 for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
3460 {
|
mas01mj@640
|
3461 if ( oSettings.aoColumns[i].bVisible === true )
|
mas01mj@640
|
3462 {
|
mas01mj@640
|
3463 iColumn++;
|
mas01mj@640
|
3464 }
|
mas01mj@640
|
3465
|
mas01mj@640
|
3466 if ( iColumn == iMatch )
|
mas01mj@640
|
3467 {
|
mas01mj@640
|
3468 return i;
|
mas01mj@640
|
3469 }
|
mas01mj@640
|
3470 }
|
mas01mj@640
|
3471
|
mas01mj@640
|
3472 return null;
|
mas01mj@640
|
3473 }
|
mas01mj@640
|
3474
|
mas01mj@640
|
3475 /*
|
mas01mj@640
|
3476 * Function: _fnColumnIndexToVisible
|
mas01mj@640
|
3477 * Purpose: Covert the index of an index in the data array and convert it to the visible
|
mas01mj@640
|
3478 * column index (take account of hidden columns)
|
mas01mj@640
|
3479 * Returns: int:i - the data index
|
mas01mj@640
|
3480 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3481 */
|
mas01mj@640
|
3482 function _fnColumnIndexToVisible( oSettings, iMatch )
|
mas01mj@640
|
3483 {
|
mas01mj@640
|
3484 var iVisible = -1;
|
mas01mj@640
|
3485 for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
3486 {
|
mas01mj@640
|
3487 if ( oSettings.aoColumns[i].bVisible === true )
|
mas01mj@640
|
3488 {
|
mas01mj@640
|
3489 iVisible++;
|
mas01mj@640
|
3490 }
|
mas01mj@640
|
3491
|
mas01mj@640
|
3492 if ( i == iMatch )
|
mas01mj@640
|
3493 {
|
mas01mj@640
|
3494 return oSettings.aoColumns[i].bVisible === true ? iVisible : null;
|
mas01mj@640
|
3495 }
|
mas01mj@640
|
3496 }
|
mas01mj@640
|
3497
|
mas01mj@640
|
3498 return null;
|
mas01mj@640
|
3499 }
|
mas01mj@640
|
3500
|
mas01mj@640
|
3501 /*
|
mas01mj@640
|
3502 * Function: _fnVisbleColumns
|
mas01mj@640
|
3503 * Purpose: Get the number of visible columns
|
mas01mj@640
|
3504 * Returns: int:i - the number of visible columns
|
mas01mj@640
|
3505 * Inputs: object:oS - dataTables settings object
|
mas01mj@640
|
3506 */
|
mas01mj@640
|
3507 function _fnVisbleColumns( oS )
|
mas01mj@640
|
3508 {
|
mas01mj@640
|
3509 var iVis = 0;
|
mas01mj@640
|
3510 for ( var i=0 ; i<oS.aoColumns.length ; i++ )
|
mas01mj@640
|
3511 {
|
mas01mj@640
|
3512 if ( oS.aoColumns[i].bVisible === true )
|
mas01mj@640
|
3513 {
|
mas01mj@640
|
3514 iVis++;
|
mas01mj@640
|
3515 }
|
mas01mj@640
|
3516 }
|
mas01mj@640
|
3517 return iVis;
|
mas01mj@640
|
3518 }
|
mas01mj@640
|
3519
|
mas01mj@640
|
3520 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
3521 * Support functions
|
mas01mj@640
|
3522 */
|
mas01mj@640
|
3523
|
mas01mj@640
|
3524 /*
|
mas01mj@640
|
3525 * Function: _fnBuildSearchArray
|
mas01mj@640
|
3526 * Purpose: Create an array which can be quickly search through
|
mas01mj@640
|
3527 * Returns: -
|
mas01mj@640
|
3528 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3529 * int:iMaster - use the master data array - optional
|
mas01mj@640
|
3530 */
|
mas01mj@640
|
3531 function _fnBuildSearchArray ( oSettings, iMaster )
|
mas01mj@640
|
3532 {
|
mas01mj@640
|
3533 /* Clear out the old data */
|
mas01mj@640
|
3534 oSettings.asDataSearch.splice( 0, oSettings.asDataSearch.length );
|
mas01mj@640
|
3535
|
mas01mj@640
|
3536 var aArray = (typeof iMaster != 'undefined' && iMaster == 1) ?
|
mas01mj@640
|
3537 oSettings.aiDisplayMaster : oSettings.aiDisplay;
|
mas01mj@640
|
3538
|
mas01mj@640
|
3539 for ( var i=0, iLen=aArray.length ; i<iLen ; i++ )
|
mas01mj@640
|
3540 {
|
mas01mj@640
|
3541 oSettings.asDataSearch[i] = '';
|
mas01mj@640
|
3542 for ( var j=0, jLen=oSettings.aoColumns.length ; j<jLen ; j++ )
|
mas01mj@640
|
3543 {
|
mas01mj@640
|
3544 if ( oSettings.aoColumns[j].bSearchable )
|
mas01mj@640
|
3545 {
|
mas01mj@640
|
3546 var sData = oSettings.aoData[ aArray[i] ]._aData[j];
|
mas01mj@640
|
3547 oSettings.asDataSearch[i] += _fnDataToSearch( sData, oSettings.aoColumns[j].sType )+' ';
|
mas01mj@640
|
3548 }
|
mas01mj@640
|
3549 }
|
mas01mj@640
|
3550 }
|
mas01mj@640
|
3551 }
|
mas01mj@640
|
3552
|
mas01mj@640
|
3553 /*
|
mas01mj@640
|
3554 * Function: _fnDataToSearch
|
mas01mj@640
|
3555 * Purpose: Convert raw data into something that the user can search on
|
mas01mj@640
|
3556 * Returns: string: - search string
|
mas01mj@640
|
3557 * Inputs: string:sData - data to be modified
|
mas01mj@640
|
3558 * string:sType - data type
|
mas01mj@640
|
3559 */
|
mas01mj@640
|
3560 function _fnDataToSearch ( sData, sType )
|
mas01mj@640
|
3561 {
|
mas01mj@640
|
3562
|
mas01mj@640
|
3563 if ( typeof _oExt.ofnSearch[sType] == "function" )
|
mas01mj@640
|
3564 {
|
mas01mj@640
|
3565 return _oExt.ofnSearch[sType]( sData );
|
mas01mj@640
|
3566 }
|
mas01mj@640
|
3567 else if ( sType == "html" )
|
mas01mj@640
|
3568 {
|
mas01mj@640
|
3569 return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
|
mas01mj@640
|
3570 }
|
mas01mj@640
|
3571 else if ( typeof sData == "string" )
|
mas01mj@640
|
3572 {
|
mas01mj@640
|
3573 return sData.replace(/\n/g," ");
|
mas01mj@640
|
3574 }
|
mas01mj@640
|
3575 return sData;
|
mas01mj@640
|
3576 }
|
mas01mj@640
|
3577
|
mas01mj@640
|
3578 /*
|
mas01mj@640
|
3579 * Function: _fnCalculateEnd
|
mas01mj@640
|
3580 * Purpose: Rcalculate the end point based on the start point
|
mas01mj@640
|
3581 * Returns: -
|
mas01mj@640
|
3582 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3583 */
|
mas01mj@640
|
3584 function _fnCalculateEnd( oSettings )
|
mas01mj@640
|
3585 {
|
mas01mj@640
|
3586 if ( oSettings.oFeatures.bPaginate === false )
|
mas01mj@640
|
3587 {
|
mas01mj@640
|
3588 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
|
mas01mj@640
|
3589 }
|
mas01mj@640
|
3590 else
|
mas01mj@640
|
3591 {
|
mas01mj@640
|
3592 /* Set the end point of the display - based on how many elements there are
|
mas01mj@640
|
3593 * still to display
|
mas01mj@640
|
3594 */
|
mas01mj@640
|
3595 if ( oSettings._iDisplayStart + oSettings._iDisplayLength > oSettings.aiDisplay.length ||
|
mas01mj@640
|
3596 oSettings._iDisplayLength == -1 )
|
mas01mj@640
|
3597 {
|
mas01mj@640
|
3598 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
|
mas01mj@640
|
3599 }
|
mas01mj@640
|
3600 else
|
mas01mj@640
|
3601 {
|
mas01mj@640
|
3602 oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
|
mas01mj@640
|
3603 }
|
mas01mj@640
|
3604 }
|
mas01mj@640
|
3605 }
|
mas01mj@640
|
3606
|
mas01mj@640
|
3607 /*
|
mas01mj@640
|
3608 * Function: _fnConvertToWidth
|
mas01mj@640
|
3609 * Purpose: Convert a CSS unit width to pixels (e.g. 2em)
|
mas01mj@640
|
3610 * Returns: int:iWidth - width in pixels
|
mas01mj@640
|
3611 * Inputs: string:sWidth - width to be converted
|
mas01mj@640
|
3612 * node:nParent - parent to get the with for (required for
|
mas01mj@640
|
3613 * relative widths) - optional
|
mas01mj@640
|
3614 */
|
mas01mj@640
|
3615 function _fnConvertToWidth ( sWidth, nParent )
|
mas01mj@640
|
3616 {
|
mas01mj@640
|
3617 if ( !sWidth || sWidth === null || sWidth === '' )
|
mas01mj@640
|
3618 {
|
mas01mj@640
|
3619 return 0;
|
mas01mj@640
|
3620 }
|
mas01mj@640
|
3621
|
mas01mj@640
|
3622 if ( typeof nParent == "undefined" )
|
mas01mj@640
|
3623 {
|
mas01mj@640
|
3624 nParent = document.getElementsByTagName('body')[0];
|
mas01mj@640
|
3625 }
|
mas01mj@640
|
3626
|
mas01mj@640
|
3627 var iWidth;
|
mas01mj@640
|
3628 var nTmp = document.createElement( "div" );
|
mas01mj@640
|
3629 nTmp.style.width = sWidth;
|
mas01mj@640
|
3630
|
mas01mj@640
|
3631 nParent.appendChild( nTmp );
|
mas01mj@640
|
3632 iWidth = nTmp.offsetWidth;
|
mas01mj@640
|
3633 nParent.removeChild( nTmp );
|
mas01mj@640
|
3634
|
mas01mj@640
|
3635 return ( iWidth );
|
mas01mj@640
|
3636 }
|
mas01mj@640
|
3637
|
mas01mj@640
|
3638 /*
|
mas01mj@640
|
3639 * Function: _fnCalculateColumnWidths
|
mas01mj@640
|
3640 * Purpose: Calculate the width of columns for the table
|
mas01mj@640
|
3641 * Returns: -
|
mas01mj@640
|
3642 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3643 */
|
mas01mj@640
|
3644 function _fnCalculateColumnWidths ( oSettings )
|
mas01mj@640
|
3645 {
|
mas01mj@640
|
3646 var iTableWidth = oSettings.nTable.offsetWidth;
|
mas01mj@640
|
3647 var iTotalUserIpSize = 0;
|
mas01mj@640
|
3648 var iTmpWidth;
|
mas01mj@640
|
3649 var iVisibleColumns = 0;
|
mas01mj@640
|
3650 var iColums = oSettings.aoColumns.length;
|
mas01mj@640
|
3651 var i;
|
mas01mj@640
|
3652 var oHeaders = $('thead th', oSettings.nTable);
|
mas01mj@640
|
3653
|
mas01mj@640
|
3654 /* Convert any user input sizes into pixel sizes */
|
mas01mj@640
|
3655 for ( i=0 ; i<iColums ; i++ )
|
mas01mj@640
|
3656 {
|
mas01mj@640
|
3657 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
3658 {
|
mas01mj@640
|
3659 iVisibleColumns++;
|
mas01mj@640
|
3660
|
mas01mj@640
|
3661 if ( oSettings.aoColumns[i].sWidth !== null )
|
mas01mj@640
|
3662 {
|
mas01mj@640
|
3663 iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidth,
|
mas01mj@640
|
3664 oSettings.nTable.parentNode );
|
mas01mj@640
|
3665
|
mas01mj@640
|
3666 /* Total up the user defined widths for later calculations */
|
mas01mj@640
|
3667 iTotalUserIpSize += iTmpWidth;
|
mas01mj@640
|
3668
|
mas01mj@640
|
3669 oSettings.aoColumns[i].sWidth = iTmpWidth+"px";
|
mas01mj@640
|
3670 }
|
mas01mj@640
|
3671 }
|
mas01mj@640
|
3672 }
|
mas01mj@640
|
3673
|
mas01mj@640
|
3674 /* If the number of columns in the DOM equals the number that we
|
mas01mj@640
|
3675 * have to process in dataTables, then we can use the offsets that are
|
mas01mj@640
|
3676 * created by the web-browser. No custom sizes can be set in order for
|
mas01mj@640
|
3677 * this to happen
|
mas01mj@640
|
3678 */
|
mas01mj@640
|
3679 if ( iColums == oHeaders.length && iTotalUserIpSize === 0 && iVisibleColumns == iColums )
|
mas01mj@640
|
3680 {
|
mas01mj@640
|
3681 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
3682 {
|
mas01mj@640
|
3683 oSettings.aoColumns[i].sWidth = oHeaders[i].offsetWidth+"px";
|
mas01mj@640
|
3684 }
|
mas01mj@640
|
3685 }
|
mas01mj@640
|
3686 else
|
mas01mj@640
|
3687 {
|
mas01mj@640
|
3688 /* Otherwise we are going to have to do some calculations to get
|
mas01mj@640
|
3689 * the width of each column. Construct a 1 row table with the maximum
|
mas01mj@640
|
3690 * string sizes in the data, and any user defined widths
|
mas01mj@640
|
3691 */
|
mas01mj@640
|
3692 var nCalcTmp = oSettings.nTable.cloneNode( false );
|
mas01mj@640
|
3693 nCalcTmp.setAttribute( "id", '' );
|
mas01mj@640
|
3694
|
mas01mj@640
|
3695 var sTableTmp = '<table class="'+nCalcTmp.className+'">';
|
mas01mj@640
|
3696 var sCalcHead = "<tr>";
|
mas01mj@640
|
3697 var sCalcHtml = "<tr>";
|
mas01mj@640
|
3698
|
mas01mj@640
|
3699 /* Construct a tempory table which we will inject (invisibly) into
|
mas01mj@640
|
3700 * the dom - to let the browser do all the hard word
|
mas01mj@640
|
3701 */
|
mas01mj@640
|
3702 for ( i=0 ; i<iColums ; i++ )
|
mas01mj@640
|
3703 {
|
mas01mj@640
|
3704 if ( oSettings.aoColumns[i].bVisible )
|
mas01mj@640
|
3705 {
|
mas01mj@640
|
3706 sCalcHead += '<th>'+oSettings.aoColumns[i].sTitle+'</th>';
|
mas01mj@640
|
3707
|
mas01mj@640
|
3708 if ( oSettings.aoColumns[i].sWidth !== null )
|
mas01mj@640
|
3709 {
|
mas01mj@640
|
3710 var sWidth = '';
|
mas01mj@640
|
3711 if ( oSettings.aoColumns[i].sWidth !== null )
|
mas01mj@640
|
3712 {
|
mas01mj@640
|
3713 sWidth = ' style="width:'+oSettings.aoColumns[i].sWidth+';"';
|
mas01mj@640
|
3714 }
|
mas01mj@640
|
3715
|
mas01mj@640
|
3716 sCalcHtml += '<td'+sWidth+' tag_index="'+i+'">'+fnGetMaxLenString( oSettings, i)+'</td>';
|
mas01mj@640
|
3717 }
|
mas01mj@640
|
3718 else
|
mas01mj@640
|
3719 {
|
mas01mj@640
|
3720 sCalcHtml += '<td tag_index="'+i+'">'+fnGetMaxLenString( oSettings, i)+'</td>';
|
mas01mj@640
|
3721 }
|
mas01mj@640
|
3722 }
|
mas01mj@640
|
3723 }
|
mas01mj@640
|
3724
|
mas01mj@640
|
3725 sCalcHead += "</tr>";
|
mas01mj@640
|
3726 sCalcHtml += "</tr>";
|
mas01mj@640
|
3727
|
mas01mj@640
|
3728 /* Create the tmp table node (thank you jQuery) */
|
mas01mj@640
|
3729 nCalcTmp = $( sTableTmp + sCalcHead + sCalcHtml +'</table>' )[0];
|
mas01mj@640
|
3730 nCalcTmp.style.width = iTableWidth + "px";
|
mas01mj@640
|
3731 nCalcTmp.style.visibility = "hidden";
|
mas01mj@640
|
3732 nCalcTmp.style.position = "absolute"; /* Try to aviod scroll bar */
|
mas01mj@640
|
3733
|
mas01mj@640
|
3734 oSettings.nTable.parentNode.appendChild( nCalcTmp );
|
mas01mj@640
|
3735
|
mas01mj@640
|
3736 var oNodes = $("td", nCalcTmp);
|
mas01mj@640
|
3737 var iIndex;
|
mas01mj@640
|
3738
|
mas01mj@640
|
3739 /* Gather in the browser calculated widths for the rows */
|
mas01mj@640
|
3740 for ( i=0 ; i<oNodes.length ; i++ )
|
mas01mj@640
|
3741 {
|
mas01mj@640
|
3742 iIndex = oNodes[i].getAttribute('tag_index');
|
mas01mj@640
|
3743
|
mas01mj@640
|
3744 oSettings.aoColumns[iIndex].sWidth = $("td", nCalcTmp)[i].offsetWidth +"px";
|
mas01mj@640
|
3745 }
|
mas01mj@640
|
3746
|
mas01mj@640
|
3747 oSettings.nTable.parentNode.removeChild( nCalcTmp );
|
mas01mj@640
|
3748 }
|
mas01mj@640
|
3749 }
|
mas01mj@640
|
3750
|
mas01mj@640
|
3751 /*
|
mas01mj@640
|
3752 * Function: fnGetMaxLenString
|
mas01mj@640
|
3753 * Purpose: Get the maximum strlen for each data column
|
mas01mj@640
|
3754 * Returns: string: - max strlens for each column
|
mas01mj@640
|
3755 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3756 * int:iCol - column of interest
|
mas01mj@640
|
3757 */
|
mas01mj@640
|
3758 function fnGetMaxLenString( oSettings, iCol )
|
mas01mj@640
|
3759 {
|
mas01mj@640
|
3760 var iMax = 0;
|
mas01mj@640
|
3761 var iMaxIndex = -1;
|
mas01mj@640
|
3762
|
mas01mj@640
|
3763 for ( var i=0 ; i<oSettings.aoData.length ; i++ )
|
mas01mj@640
|
3764 {
|
mas01mj@640
|
3765 if ( oSettings.aoData[i]._aData[iCol].length > iMax )
|
mas01mj@640
|
3766 {
|
mas01mj@640
|
3767 iMax = oSettings.aoData[i]._aData[iCol].length;
|
mas01mj@640
|
3768 iMaxIndex = i;
|
mas01mj@640
|
3769 }
|
mas01mj@640
|
3770 }
|
mas01mj@640
|
3771
|
mas01mj@640
|
3772 if ( iMaxIndex >= 0 )
|
mas01mj@640
|
3773 {
|
mas01mj@640
|
3774 return oSettings.aoData[iMaxIndex]._aData[iCol];
|
mas01mj@640
|
3775 }
|
mas01mj@640
|
3776 return '';
|
mas01mj@640
|
3777 }
|
mas01mj@640
|
3778
|
mas01mj@640
|
3779 /*
|
mas01mj@640
|
3780 * Function: _fnArrayCmp
|
mas01mj@640
|
3781 * Purpose: Compare two arrays
|
mas01mj@640
|
3782 * Returns: 0 if match, 1 if length is different, 2 if no match
|
mas01mj@640
|
3783 * Inputs: array:aArray1 - first array
|
mas01mj@640
|
3784 * array:aArray2 - second array
|
mas01mj@640
|
3785 */
|
mas01mj@640
|
3786 function _fnArrayCmp( aArray1, aArray2 )
|
mas01mj@640
|
3787 {
|
mas01mj@640
|
3788 if ( aArray1.length != aArray2.length )
|
mas01mj@640
|
3789 {
|
mas01mj@640
|
3790 return 1;
|
mas01mj@640
|
3791 }
|
mas01mj@640
|
3792
|
mas01mj@640
|
3793 for ( var i=0 ; i<aArray1.length ; i++ )
|
mas01mj@640
|
3794 {
|
mas01mj@640
|
3795 if ( aArray1[i] != aArray2[i] )
|
mas01mj@640
|
3796 {
|
mas01mj@640
|
3797 return 2;
|
mas01mj@640
|
3798 }
|
mas01mj@640
|
3799 }
|
mas01mj@640
|
3800
|
mas01mj@640
|
3801 return 0;
|
mas01mj@640
|
3802 }
|
mas01mj@640
|
3803
|
mas01mj@640
|
3804 /*
|
mas01mj@640
|
3805 * Function: _fnDetectType
|
mas01mj@640
|
3806 * Purpose: Get the sort type based on an input string
|
mas01mj@640
|
3807 * Returns: string: - type (defaults to 'string' if no type can be detected)
|
mas01mj@640
|
3808 * Inputs: string:sData - data we wish to know the type of
|
mas01mj@640
|
3809 * Notes: This function makes use of the DataTables plugin objct _oExt
|
mas01mj@640
|
3810 * (.aTypes) such that new types can easily be added.
|
mas01mj@640
|
3811 */
|
mas01mj@640
|
3812 function _fnDetectType( sData )
|
mas01mj@640
|
3813 {
|
mas01mj@640
|
3814 var aTypes = _oExt.aTypes;
|
mas01mj@640
|
3815 var iLen = aTypes.length;
|
mas01mj@640
|
3816
|
mas01mj@640
|
3817 for ( var i=0 ; i<iLen ; i++ )
|
mas01mj@640
|
3818 {
|
mas01mj@640
|
3819 var sType = aTypes[i]( sData );
|
mas01mj@640
|
3820 if ( sType !== null )
|
mas01mj@640
|
3821 {
|
mas01mj@640
|
3822 return sType;
|
mas01mj@640
|
3823 }
|
mas01mj@640
|
3824 }
|
mas01mj@640
|
3825
|
mas01mj@640
|
3826 return 'string';
|
mas01mj@640
|
3827 }
|
mas01mj@640
|
3828
|
mas01mj@640
|
3829 /*
|
mas01mj@640
|
3830 * Function: _fnSettingsFromNode
|
mas01mj@640
|
3831 * Purpose: Return the settings object for a particular table
|
mas01mj@640
|
3832 * Returns: object: Settings object - or null if not found
|
mas01mj@640
|
3833 * Inputs: node:nTable - table we are using as a dataTable
|
mas01mj@640
|
3834 */
|
mas01mj@640
|
3835 function _fnSettingsFromNode ( nTable )
|
mas01mj@640
|
3836 {
|
mas01mj@640
|
3837 for ( var i=0 ; i<_aoSettings.length ; i++ )
|
mas01mj@640
|
3838 {
|
mas01mj@640
|
3839 if ( _aoSettings[i].nTable == nTable )
|
mas01mj@640
|
3840 {
|
mas01mj@640
|
3841 return _aoSettings[i];
|
mas01mj@640
|
3842 }
|
mas01mj@640
|
3843 }
|
mas01mj@640
|
3844
|
mas01mj@640
|
3845 return null;
|
mas01mj@640
|
3846 }
|
mas01mj@640
|
3847
|
mas01mj@640
|
3848 /*
|
mas01mj@640
|
3849 * Function: _fnGetDataMaster
|
mas01mj@640
|
3850 * Purpose: Return an array with the full table data
|
mas01mj@640
|
3851 * Returns: array array:aData - Master data array
|
mas01mj@640
|
3852 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3853 */
|
mas01mj@640
|
3854 function _fnGetDataMaster ( oSettings )
|
mas01mj@640
|
3855 {
|
mas01mj@640
|
3856 var aData = [];
|
mas01mj@640
|
3857 var iLen = oSettings.aoData.length;
|
mas01mj@640
|
3858 for ( var i=0 ; i<iLen; i++ )
|
mas01mj@640
|
3859 {
|
mas01mj@640
|
3860 if ( oSettings.aoData[i] === null )
|
mas01mj@640
|
3861 {
|
mas01mj@640
|
3862 aData.push( null );
|
mas01mj@640
|
3863 }
|
mas01mj@640
|
3864 else
|
mas01mj@640
|
3865 {
|
mas01mj@640
|
3866 aData.push( oSettings.aoData[i]._aData );
|
mas01mj@640
|
3867 }
|
mas01mj@640
|
3868 }
|
mas01mj@640
|
3869 return aData;
|
mas01mj@640
|
3870 }
|
mas01mj@640
|
3871
|
mas01mj@640
|
3872 /*
|
mas01mj@640
|
3873 * Function: _fnGetTrNodes
|
mas01mj@640
|
3874 * Purpose: Return an array with the TR nodes for the table
|
mas01mj@640
|
3875 * Returns: array array:aData - TR array
|
mas01mj@640
|
3876 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3877 */
|
mas01mj@640
|
3878 function _fnGetTrNodes ( oSettings )
|
mas01mj@640
|
3879 {
|
mas01mj@640
|
3880 var aNodes = [];
|
mas01mj@640
|
3881 var iLen = oSettings.aoData.length;
|
mas01mj@640
|
3882 for ( var i=0 ; i<iLen ; i++ )
|
mas01mj@640
|
3883 {
|
mas01mj@640
|
3884 if ( oSettings.aoData[i] === null )
|
mas01mj@640
|
3885 {
|
mas01mj@640
|
3886 aNodes.push( null );
|
mas01mj@640
|
3887 }
|
mas01mj@640
|
3888 else
|
mas01mj@640
|
3889 {
|
mas01mj@640
|
3890 aNodes.push( oSettings.aoData[i].nTr );
|
mas01mj@640
|
3891 }
|
mas01mj@640
|
3892 }
|
mas01mj@640
|
3893 return aNodes;
|
mas01mj@640
|
3894 }
|
mas01mj@640
|
3895
|
mas01mj@640
|
3896 /*
|
mas01mj@640
|
3897 * Function: _fnEscapeRegex
|
mas01mj@640
|
3898 * Purpose: scape a string stuch that it can be used in a regular expression
|
mas01mj@640
|
3899 * Returns: string: - escaped string
|
mas01mj@640
|
3900 * Inputs: string:sVal - string to escape
|
mas01mj@640
|
3901 */
|
mas01mj@640
|
3902 function _fnEscapeRegex ( sVal )
|
mas01mj@640
|
3903 {
|
mas01mj@640
|
3904 var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^' ];
|
mas01mj@640
|
3905 var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
|
mas01mj@640
|
3906 return sVal.replace(reReplace, '\\$1');
|
mas01mj@640
|
3907 }
|
mas01mj@640
|
3908
|
mas01mj@640
|
3909 /*
|
mas01mj@640
|
3910 * Function: _fnReOrderIndex
|
mas01mj@640
|
3911 * Purpose: Figure out how to reorder a display list
|
mas01mj@640
|
3912 * Returns: array int:aiReturn - index list for reordering
|
mas01mj@640
|
3913 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3914 */
|
mas01mj@640
|
3915 function _fnReOrderIndex ( oSettings, sColumns )
|
mas01mj@640
|
3916 {
|
mas01mj@640
|
3917 var aColumns = sColumns.split(',');
|
mas01mj@640
|
3918 var aiReturn = [];
|
mas01mj@640
|
3919
|
mas01mj@640
|
3920 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
mas01mj@640
|
3921 {
|
mas01mj@640
|
3922 for ( var j=0 ; j<iLen ; j++ )
|
mas01mj@640
|
3923 {
|
mas01mj@640
|
3924 if ( oSettings.aoColumns[i].sName == aColumns[j] )
|
mas01mj@640
|
3925 {
|
mas01mj@640
|
3926 aiReturn.push( j );
|
mas01mj@640
|
3927 break;
|
mas01mj@640
|
3928 }
|
mas01mj@640
|
3929 }
|
mas01mj@640
|
3930 }
|
mas01mj@640
|
3931
|
mas01mj@640
|
3932 return aiReturn;
|
mas01mj@640
|
3933 }
|
mas01mj@640
|
3934
|
mas01mj@640
|
3935 /*
|
mas01mj@640
|
3936 * Function: _fnColumnOrdering
|
mas01mj@640
|
3937 * Purpose: Get the column ordering that DataTables expects
|
mas01mj@640
|
3938 * Returns: string: - comma separated list of names
|
mas01mj@640
|
3939 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3940 */
|
mas01mj@640
|
3941 function _fnColumnOrdering ( oSettings )
|
mas01mj@640
|
3942 {
|
mas01mj@640
|
3943 var sNames = '';
|
mas01mj@640
|
3944 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
|
mas01mj@640
|
3945 {
|
mas01mj@640
|
3946 sNames += oSettings.aoColumns[i].sName+',';
|
mas01mj@640
|
3947 }
|
mas01mj@640
|
3948 if ( sNames.length == iLen )
|
mas01mj@640
|
3949 {
|
mas01mj@640
|
3950 return "";
|
mas01mj@640
|
3951 }
|
mas01mj@640
|
3952 return sNames.slice(0, -1);
|
mas01mj@640
|
3953 }
|
mas01mj@640
|
3954
|
mas01mj@640
|
3955 /*
|
mas01mj@640
|
3956 * Function: _fnClearTable
|
mas01mj@640
|
3957 * Purpose: Nuke the table
|
mas01mj@640
|
3958 * Returns: -
|
mas01mj@640
|
3959 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3960 */
|
mas01mj@640
|
3961 function _fnClearTable( oSettings )
|
mas01mj@640
|
3962 {
|
mas01mj@640
|
3963 oSettings.aoData.length = 0;
|
mas01mj@640
|
3964 oSettings.aiDisplayMaster.length = 0;
|
mas01mj@640
|
3965 oSettings.aiDisplay.length = 0;
|
mas01mj@640
|
3966 _fnCalculateEnd( oSettings );
|
mas01mj@640
|
3967 }
|
mas01mj@640
|
3968
|
mas01mj@640
|
3969 /*
|
mas01mj@640
|
3970 * Function: _fnSaveState
|
mas01mj@640
|
3971 * Purpose: Save the state of a table in a cookie such that the page can be reloaded
|
mas01mj@640
|
3972 * Returns: -
|
mas01mj@640
|
3973 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
3974 */
|
mas01mj@640
|
3975 function _fnSaveState ( oSettings )
|
mas01mj@640
|
3976 {
|
mas01mj@640
|
3977 if ( !oSettings.oFeatures.bStateSave )
|
mas01mj@640
|
3978 {
|
mas01mj@640
|
3979 return;
|
mas01mj@640
|
3980 }
|
mas01mj@640
|
3981
|
mas01mj@640
|
3982 /* Store the interesting variables */
|
mas01mj@640
|
3983 var i;
|
mas01mj@640
|
3984 var sValue = "{";
|
mas01mj@640
|
3985 sValue += '"iStart": '+oSettings._iDisplayStart+',';
|
mas01mj@640
|
3986 sValue += '"iEnd": '+oSettings._iDisplayEnd+',';
|
mas01mj@640
|
3987 sValue += '"iLength": '+oSettings._iDisplayLength+',';
|
mas01mj@640
|
3988 sValue += '"sFilter": "'+oSettings.oPreviousSearch.sSearch.replace('"','\\"')+'",';
|
mas01mj@640
|
3989 sValue += '"sFilterEsc": '+oSettings.oPreviousSearch.bEscapeRegex+',';
|
mas01mj@640
|
3990
|
mas01mj@640
|
3991 sValue += '"aaSorting": [ ';
|
mas01mj@640
|
3992 for ( i=0 ; i<oSettings.aaSorting.length ; i++ )
|
mas01mj@640
|
3993 {
|
mas01mj@640
|
3994 sValue += "["+oSettings.aaSorting[i][0]+",'"+oSettings.aaSorting[i][1]+"'],";
|
mas01mj@640
|
3995 }
|
mas01mj@640
|
3996 sValue = sValue.substring(0, sValue.length-1);
|
mas01mj@640
|
3997 sValue += "],";
|
mas01mj@640
|
3998
|
mas01mj@640
|
3999 sValue += '"aaSearchCols": [ ';
|
mas01mj@640
|
4000 for ( i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
|
mas01mj@640
|
4001 {
|
mas01mj@640
|
4002 sValue += "['"+oSettings.aoPreSearchCols[i].sSearch.replace("'","\'")+
|
mas01mj@640
|
4003 "',"+oSettings.aoPreSearchCols[i].bEscapeRegex+"],";
|
mas01mj@640
|
4004 }
|
mas01mj@640
|
4005 sValue = sValue.substring(0, sValue.length-1);
|
mas01mj@640
|
4006 sValue += "],";
|
mas01mj@640
|
4007
|
mas01mj@640
|
4008 sValue += '"abVisCols": [ ';
|
mas01mj@640
|
4009 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
|
mas01mj@640
|
4010 {
|
mas01mj@640
|
4011 sValue += oSettings.aoColumns[i].bVisible+",";
|
mas01mj@640
|
4012 }
|
mas01mj@640
|
4013 sValue = sValue.substring(0, sValue.length-1);
|
mas01mj@640
|
4014 sValue += "]";
|
mas01mj@640
|
4015
|
mas01mj@640
|
4016 sValue += "}";
|
mas01mj@640
|
4017 _fnCreateCookie( "SpryMedia_DataTables_"+oSettings.sInstance, sValue,
|
mas01mj@640
|
4018 oSettings.iCookieDuration );
|
mas01mj@640
|
4019 }
|
mas01mj@640
|
4020
|
mas01mj@640
|
4021 /*
|
mas01mj@640
|
4022 * Function: _fnLoadState
|
mas01mj@640
|
4023 * Purpose: Attempt to load a saved table state from a cookie
|
mas01mj@640
|
4024 * Returns: -
|
mas01mj@640
|
4025 * Inputs: object:oSettings - dataTables settings object
|
mas01mj@640
|
4026 * object:oInit - DataTables init object so we can override settings
|
mas01mj@640
|
4027 */
|
mas01mj@640
|
4028 function _fnLoadState ( oSettings, oInit )
|
mas01mj@640
|
4029 {
|
mas01mj@640
|
4030 if ( !oSettings.oFeatures.bStateSave )
|
mas01mj@640
|
4031 {
|
mas01mj@640
|
4032 return;
|
mas01mj@640
|
4033 }
|
mas01mj@640
|
4034
|
mas01mj@640
|
4035 var oData;
|
mas01mj@640
|
4036 var sData = _fnReadCookie( "SpryMedia_DataTables_"+oSettings.sInstance );
|
mas01mj@640
|
4037 if ( sData !== null && sData !== '' )
|
mas01mj@640
|
4038 {
|
mas01mj@640
|
4039 /* Try/catch the JSON eval - if it is bad then we ignore it */
|
mas01mj@640
|
4040 try
|
mas01mj@640
|
4041 {
|
mas01mj@640
|
4042 /* Use the JSON library for safety - if it is available */
|
mas01mj@640
|
4043 if ( typeof JSON == 'object' && typeof JSON.parse == 'function' )
|
mas01mj@640
|
4044 {
|
mas01mj@640
|
4045 /* DT 1.4.0 used single quotes for a string - JSON.parse doesn't allow this and throws
|
mas01mj@640
|
4046 * an error. So for now we can do this. This can be removed in future it is just to
|
mas01mj@640
|
4047 * allow the tranfrer to 1.4.1+ to occur
|
mas01mj@640
|
4048 */
|
mas01mj@640
|
4049 oData = JSON.parse( sData.replace(/'/g, '"') );
|
mas01mj@640
|
4050 }
|
mas01mj@640
|
4051 else
|
mas01mj@640
|
4052 {
|
mas01mj@640
|
4053 oData = eval( '('+sData+')' );
|
mas01mj@640
|
4054 }
|
mas01mj@640
|
4055 }
|
mas01mj@640
|
4056 catch( e )
|
mas01mj@640
|
4057 {
|
mas01mj@640
|
4058 return;
|
mas01mj@640
|
4059 }
|
mas01mj@640
|
4060
|
mas01mj@640
|
4061 /* Restore key features */
|
mas01mj@640
|
4062 oSettings._iDisplayStart = oData.iStart;
|
mas01mj@640
|
4063 oSettings.iInitDisplayStart = oData.iStart;
|
mas01mj@640
|
4064 oSettings._iDisplayEnd = oData.iEnd;
|
mas01mj@640
|
4065 oSettings._iDisplayLength = oData.iLength;
|
mas01mj@640
|
4066 oSettings.oPreviousSearch.sSearch = oData.sFilter;
|
mas01mj@640
|
4067 oSettings.aaSorting = oData.aaSorting.slice();
|
mas01mj@640
|
4068
|
mas01mj@640
|
4069 /* Search filtering - global reference added in 1.4.1 */
|
mas01mj@640
|
4070 if ( typeof oData.sFilterEsc != 'undefined' )
|
mas01mj@640
|
4071 {
|
mas01mj@640
|
4072 oSettings.oPreviousSearch.bEscapeRegex = oData.sFilterEsc;
|
mas01mj@640
|
4073 }
|
mas01mj@640
|
4074
|
mas01mj@640
|
4075 /* Column filtering - added in 1.5.0 beta 6 */
|
mas01mj@640
|
4076 if ( typeof oData.aaSearchCols != 'undefined' )
|
mas01mj@640
|
4077 {
|
mas01mj@640
|
4078 for ( var i=0 ; i<oData.aaSearchCols.length ; i++ )
|
mas01mj@640
|
4079 {
|
mas01mj@640
|
4080 oSettings.aoPreSearchCols[i] = {
|
mas01mj@640
|
4081 "sSearch": oData.aaSearchCols[i][0],
|
mas01mj@640
|
4082 "bEscapeRegex": oData.aaSearchCols[i][1]
|
mas01mj@640
|
4083 };
|
mas01mj@640
|
4084 }
|
mas01mj@640
|
4085 }
|
mas01mj@640
|
4086
|
mas01mj@640
|
4087 /* Column visibility state - added in 1.5.0 beta 10 */
|
mas01mj@640
|
4088 if ( typeof oData.abVisCols != 'undefined' )
|
mas01mj@640
|
4089 {
|
mas01mj@640
|
4090 /* We need to override the settings in oInit for this */
|
mas01mj@640
|
4091 if ( typeof oInit.aoColumns == 'undefined' )
|
mas01mj@640
|
4092 {
|
mas01mj@640
|
4093 oInit.aoColumns = [];
|
mas01mj@640
|
4094 }
|
mas01mj@640
|
4095
|
mas01mj@640
|
4096 for ( i=0 ; i<oData.abVisCols.length ; i++ )
|
mas01mj@640
|
4097 {
|
mas01mj@640
|
4098 if ( typeof oInit.aoColumns[i] == 'undefined' || oInit.aoColumns[i] === null )
|
mas01mj@640
|
4099 {
|
mas01mj@640
|
4100 oInit.aoColumns[i] = {};
|
mas01mj@640
|
4101 }
|
mas01mj@640
|
4102
|
mas01mj@640
|
4103 oInit.aoColumns[i].bVisible = oData.abVisCols[i];
|
mas01mj@640
|
4104 }
|
mas01mj@640
|
4105 }
|
mas01mj@640
|
4106 }
|
mas01mj@640
|
4107 }
|
mas01mj@640
|
4108
|
mas01mj@640
|
4109 /*
|
mas01mj@640
|
4110 * Function: _fnCreateCookie
|
mas01mj@640
|
4111 * Purpose: Create a new cookie with a value to store the state of a table
|
mas01mj@640
|
4112 * Returns: -
|
mas01mj@640
|
4113 * Inputs: string:sName - name of the cookie to create
|
mas01mj@640
|
4114 * string:sValue - the value the cookie should take
|
mas01mj@640
|
4115 * int:iSecs - duration of the cookie
|
mas01mj@640
|
4116 */
|
mas01mj@640
|
4117 function _fnCreateCookie ( sName, sValue, iSecs )
|
mas01mj@640
|
4118 {
|
mas01mj@640
|
4119 var date = new Date();
|
mas01mj@640
|
4120 date.setTime( date.getTime()+(iSecs*1000) );
|
mas01mj@640
|
4121
|
mas01mj@640
|
4122 /*
|
mas01mj@640
|
4123 * Shocking but true - it would appear IE has major issues with having the path being
|
mas01mj@640
|
4124 * set to anything but root. We need the cookie to be available based on the path, so we
|
mas01mj@640
|
4125 * have to append the pathname to the cookie name. Appalling.
|
mas01mj@640
|
4126 */
|
mas01mj@640
|
4127 sName += '_'+window.location.pathname.replace(/[\/:]/g,"").toLowerCase();
|
mas01mj@640
|
4128
|
mas01mj@640
|
4129 document.cookie = sName+"="+sValue+"; expires="+date.toGMTString()+"; path=/";
|
mas01mj@640
|
4130 }
|
mas01mj@640
|
4131
|
mas01mj@640
|
4132 /*
|
mas01mj@640
|
4133 * Function: _fnReadCookie
|
mas01mj@640
|
4134 * Purpose: Read an old cookie to get a cookie with an old table state
|
mas01mj@640
|
4135 * Returns: string: - contents of the cookie - or null if no cookie with that name found
|
mas01mj@640
|
4136 * Inputs: string:sName - name of the cookie to read
|
mas01mj@640
|
4137 */
|
mas01mj@640
|
4138 function _fnReadCookie ( sName )
|
mas01mj@640
|
4139 {
|
mas01mj@640
|
4140 var sNameEQ = sName +'_'+ window.location.pathname.replace(/[\/:]/g,"").toLowerCase() + "=";
|
mas01mj@640
|
4141 var sCookieContents = document.cookie.split(';');
|
mas01mj@640
|
4142
|
mas01mj@640
|
4143 for( var i=0 ; i<sCookieContents.length ; i++ )
|
mas01mj@640
|
4144 {
|
mas01mj@640
|
4145 var c = sCookieContents[i];
|
mas01mj@640
|
4146
|
mas01mj@640
|
4147 while (c.charAt(0)==' ')
|
mas01mj@640
|
4148 {
|
mas01mj@640
|
4149 c = c.substring(1,c.length);
|
mas01mj@640
|
4150 }
|
mas01mj@640
|
4151
|
mas01mj@640
|
4152 if (c.indexOf(sNameEQ) === 0)
|
mas01mj@640
|
4153 {
|
mas01mj@640
|
4154 return c.substring(sNameEQ.length,c.length);
|
mas01mj@640
|
4155 }
|
mas01mj@640
|
4156 }
|
mas01mj@640
|
4157 return null;
|
mas01mj@640
|
4158 }
|
mas01mj@640
|
4159
|
mas01mj@640
|
4160 /*
|
mas01mj@640
|
4161 * Function: _fnGetUniqueThs
|
mas01mj@640
|
4162 * Purpose: Get an array of unique th elements, one for each column
|
mas01mj@640
|
4163 * Returns: array node:aReturn - list of unique ths
|
mas01mj@640
|
4164 * Inputs: node:nThead - The thead element for the table
|
mas01mj@640
|
4165 */
|
mas01mj@640
|
4166 function _fnGetUniqueThs ( nThead )
|
mas01mj@640
|
4167 {
|
mas01mj@640
|
4168 var nTrs = nThead.getElementsByTagName('tr');
|
mas01mj@640
|
4169
|
mas01mj@640
|
4170 /* Nice simple case */
|
mas01mj@640
|
4171 if ( nTrs.length == 1 )
|
mas01mj@640
|
4172 {
|
mas01mj@640
|
4173 return nTrs[0].getElementsByTagName('th');
|
mas01mj@640
|
4174 }
|
mas01mj@640
|
4175
|
mas01mj@640
|
4176 /* Otherwise we need to figure out the layout array to get the nodes */
|
mas01mj@640
|
4177 var aLayout = [], aReturn = [];
|
mas01mj@640
|
4178 var ROWSPAN = 2, COLSPAN = 3, TDELEM = 4;
|
mas01mj@640
|
4179 var i, j, k, iLen, jLen, iColumnShifted;
|
mas01mj@640
|
4180 var fnShiftCol = function ( a, i, j ) {
|
mas01mj@640
|
4181 while ( typeof a[i][j] != 'undefined' ) {
|
mas01mj@640
|
4182 j++;
|
mas01mj@640
|
4183 }
|
mas01mj@640
|
4184 return j;
|
mas01mj@640
|
4185 };
|
mas01mj@640
|
4186 var fnAddRow = function ( i ) {
|
mas01mj@640
|
4187 if ( typeof aLayout[i] == 'undefined' ) {
|
mas01mj@640
|
4188 aLayout[i] = [];
|
mas01mj@640
|
4189 }
|
mas01mj@640
|
4190 };
|
mas01mj@640
|
4191
|
mas01mj@640
|
4192 /* Calculate a layout array */
|
mas01mj@640
|
4193 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
|
mas01mj@640
|
4194 {
|
mas01mj@640
|
4195 fnAddRow( i );
|
mas01mj@640
|
4196 var iColumn = 0;
|
mas01mj@640
|
4197 var nTds = [];
|
mas01mj@640
|
4198
|
mas01mj@640
|
4199 for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
|
mas01mj@640
|
4200 {
|
mas01mj@640
|
4201 if ( nTrs[i].childNodes[j].nodeName == "TD" || nTrs[i].childNodes[j].nodeName == "TH" )
|
mas01mj@640
|
4202 {
|
mas01mj@640
|
4203 nTds.push( nTrs[i].childNodes[j] );
|
mas01mj@640
|
4204 }
|
mas01mj@640
|
4205 }
|
mas01mj@640
|
4206
|
mas01mj@640
|
4207 for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
|
mas01mj@640
|
4208 {
|
mas01mj@640
|
4209 var iColspan = nTds[j].getAttribute('colspan') * 1;
|
mas01mj@640
|
4210 var iRowspan = nTds[j].getAttribute('rowspan') * 1;
|
mas01mj@640
|
4211
|
mas01mj@640
|
4212 if ( !iColspan || iColspan===0 || iColspan===1 )
|
mas01mj@640
|
4213 {
|
mas01mj@640
|
4214 iColumnShifted = fnShiftCol( aLayout, i, iColumn );
|
mas01mj@640
|
4215 aLayout[i][iColumnShifted] = (nTds[j].nodeName=="TD") ? TDELEM : nTds[j];
|
mas01mj@640
|
4216 if ( iRowspan || iRowspan===0 || iRowspan===1 )
|
mas01mj@640
|
4217 {
|
mas01mj@640
|
4218 for ( k=1 ; k<iRowspan ; k++ )
|
mas01mj@640
|
4219 {
|
mas01mj@640
|
4220 fnAddRow( i+k );
|
mas01mj@640
|
4221 aLayout[i+k][iColumnShifted] = ROWSPAN;
|
mas01mj@640
|
4222 }
|
mas01mj@640
|
4223 }
|
mas01mj@640
|
4224 iColumn++;
|
mas01mj@640
|
4225 }
|
mas01mj@640
|
4226 else
|
mas01mj@640
|
4227 {
|
mas01mj@640
|
4228 iColumnShifted = fnShiftCol( aLayout, i, iColumn );
|
mas01mj@640
|
4229 for ( k=0 ; k<iColspan ; k++ )
|
mas01mj@640
|
4230 {
|
mas01mj@640
|
4231 aLayout[i][iColumnShifted+k] = COLSPAN;
|
mas01mj@640
|
4232 }
|
mas01mj@640
|
4233 iColumn += iColspan;
|
mas01mj@640
|
4234 }
|
mas01mj@640
|
4235 }
|
mas01mj@640
|
4236 }
|
mas01mj@640
|
4237
|
mas01mj@640
|
4238 /* Convert the layout array into a node array
|
mas01mj@640
|
4239 * Note the use of aLayout[0] in the outloop, we want the outer loop to occur the same
|
mas01mj@640
|
4240 * number of times as there are columns. Unusual having nested loops this way around
|
mas01mj@640
|
4241 * but is what we need here.
|
mas01mj@640
|
4242 */
|
mas01mj@640
|
4243 for ( i=0, iLen=aLayout[0].length ; i<iLen ; i++ )
|
mas01mj@640
|
4244 {
|
mas01mj@640
|
4245 for ( j=0, jLen=aLayout.length ; j<jLen ; j++ )
|
mas01mj@640
|
4246 {
|
mas01mj@640
|
4247 if ( typeof aLayout[j][i] == 'object' )
|
mas01mj@640
|
4248 {
|
mas01mj@640
|
4249 aReturn.push( aLayout[j][i] );
|
mas01mj@640
|
4250 }
|
mas01mj@640
|
4251 }
|
mas01mj@640
|
4252 }
|
mas01mj@640
|
4253
|
mas01mj@640
|
4254 return aReturn;
|
mas01mj@640
|
4255 }
|
mas01mj@640
|
4256
|
mas01mj@640
|
4257 /*
|
mas01mj@640
|
4258 * Function: _fnMap
|
mas01mj@640
|
4259 * Purpose: See if a property is defined on one object, if so assign it to the other object
|
mas01mj@640
|
4260 * Returns: - (done by reference)
|
mas01mj@640
|
4261 * Inputs: object:oRet - target object
|
mas01mj@640
|
4262 * object:oSrc - source object
|
mas01mj@640
|
4263 * string:sName - property
|
mas01mj@640
|
4264 * string:sMappedName - name to map too - optional, sName used if not given
|
mas01mj@640
|
4265 */
|
mas01mj@640
|
4266 function _fnMap( oRet, oSrc, sName, sMappedName )
|
mas01mj@640
|
4267 {
|
mas01mj@640
|
4268 if ( typeof sMappedName == 'undefined' )
|
mas01mj@640
|
4269 {
|
mas01mj@640
|
4270 sMappedName = sName;
|
mas01mj@640
|
4271 }
|
mas01mj@640
|
4272 if ( typeof oSrc[sName] != 'undefined' )
|
mas01mj@640
|
4273 {
|
mas01mj@640
|
4274 oRet[sMappedName] = oSrc[sName];
|
mas01mj@640
|
4275 }
|
mas01mj@640
|
4276 }
|
mas01mj@640
|
4277
|
mas01mj@640
|
4278 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
4279 * API
|
mas01mj@640
|
4280 *
|
mas01mj@640
|
4281 * I'm not overly happy with this solution - I'd much rather that there was a way of getting
|
mas01mj@640
|
4282 * a list of all the private functions and do what we need to dynamically - but that doesn't
|
mas01mj@640
|
4283 * appear to be possible. Bonkers. A better solution would be to provide a 'bind' type object
|
mas01mj@640
|
4284 * To do - bind type method in DTs 1.6.
|
mas01mj@640
|
4285 */
|
mas01mj@640
|
4286 this.oApi._fnInitalise = _fnInitalise;
|
mas01mj@640
|
4287 this.oApi._fnLanguageProcess = _fnLanguageProcess;
|
mas01mj@640
|
4288 this.oApi._fnAddColumn = _fnAddColumn;
|
mas01mj@640
|
4289 this.oApi._fnAddData = _fnAddData;
|
mas01mj@640
|
4290 this.oApi._fnGatherData = _fnGatherData;
|
mas01mj@640
|
4291 this.oApi._fnDrawHead = _fnDrawHead;
|
mas01mj@640
|
4292 this.oApi._fnDraw = _fnDraw;
|
mas01mj@640
|
4293 this.oApi._fnAjaxUpdate = _fnAjaxUpdate;
|
mas01mj@640
|
4294 this.oApi._fnAddOptionsHtml = _fnAddOptionsHtml;
|
mas01mj@640
|
4295 this.oApi._fnFeatureHtmlFilter = _fnFeatureHtmlFilter;
|
mas01mj@640
|
4296 this.oApi._fnFeatureHtmlInfo = _fnFeatureHtmlInfo;
|
mas01mj@640
|
4297 this.oApi._fnFeatureHtmlPaginate = _fnFeatureHtmlPaginate;
|
mas01mj@640
|
4298 this.oApi._fnFeatureHtmlLength = _fnFeatureHtmlLength;
|
mas01mj@640
|
4299 this.oApi._fnFeatureHtmlProcessing = _fnFeatureHtmlProcessing;
|
mas01mj@640
|
4300 this.oApi._fnProcessingDisplay = _fnProcessingDisplay;
|
mas01mj@640
|
4301 this.oApi._fnFilterComplete = _fnFilterComplete;
|
mas01mj@640
|
4302 this.oApi._fnFilterColumn = _fnFilterColumn;
|
mas01mj@640
|
4303 this.oApi._fnFilter = _fnFilter;
|
mas01mj@640
|
4304 this.oApi._fnSortingClasses = _fnSortingClasses;
|
mas01mj@640
|
4305 this.oApi._fnVisibleToColumnIndex = _fnVisibleToColumnIndex;
|
mas01mj@640
|
4306 this.oApi._fnColumnIndexToVisible = _fnColumnIndexToVisible;
|
mas01mj@640
|
4307 this.oApi._fnVisbleColumns = _fnVisbleColumns;
|
mas01mj@640
|
4308 this.oApi._fnBuildSearchArray = _fnBuildSearchArray;
|
mas01mj@640
|
4309 this.oApi._fnDataToSearch = _fnDataToSearch;
|
mas01mj@640
|
4310 this.oApi._fnCalculateEnd = _fnCalculateEnd;
|
mas01mj@640
|
4311 this.oApi._fnConvertToWidth = _fnConvertToWidth;
|
mas01mj@640
|
4312 this.oApi._fnCalculateColumnWidths = _fnCalculateColumnWidths;
|
mas01mj@640
|
4313 this.oApi._fnArrayCmp = _fnArrayCmp;
|
mas01mj@640
|
4314 this.oApi._fnDetectType = _fnDetectType;
|
mas01mj@640
|
4315 this.oApi._fnGetDataMaster = _fnGetDataMaster;
|
mas01mj@640
|
4316 this.oApi._fnGetTrNodes = _fnGetTrNodes;
|
mas01mj@640
|
4317 this.oApi._fnEscapeRegex = _fnEscapeRegex;
|
mas01mj@640
|
4318 this.oApi._fnReOrderIndex = _fnReOrderIndex;
|
mas01mj@640
|
4319 this.oApi._fnColumnOrdering = _fnColumnOrdering;
|
mas01mj@640
|
4320 this.oApi._fnClearTable = _fnClearTable;
|
mas01mj@640
|
4321 this.oApi._fnSaveState = _fnSaveState;
|
mas01mj@640
|
4322 this.oApi._fnLoadState = _fnLoadState;
|
mas01mj@640
|
4323 this.oApi._fnCreateCookie = _fnCreateCookie;
|
mas01mj@640
|
4324 this.oApi._fnReadCookie = _fnReadCookie;
|
mas01mj@640
|
4325 this.oApi._fnGetUniqueThs = _fnGetUniqueThs;
|
mas01mj@640
|
4326
|
mas01mj@640
|
4327 /* Want to be able to reference "this" inside the this.each function */
|
mas01mj@640
|
4328 var _that = this;
|
mas01mj@640
|
4329
|
mas01mj@640
|
4330
|
mas01mj@640
|
4331 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
mas01mj@640
|
4332 * Constructor
|
mas01mj@640
|
4333 */
|
mas01mj@640
|
4334 return this.each(function()
|
mas01mj@640
|
4335 {
|
mas01mj@640
|
4336 /* Make a complete and independent copy of the settings object */
|
mas01mj@640
|
4337 var oSettings = new classSettings();
|
mas01mj@640
|
4338 _aoSettings.push( oSettings );
|
mas01mj@640
|
4339
|
mas01mj@640
|
4340 var i=0, iLen;
|
mas01mj@640
|
4341 var bInitHandedOff = false;
|
mas01mj@640
|
4342 var bUsePassedData = false;
|
mas01mj@640
|
4343
|
mas01mj@640
|
4344 /* Set the id */
|
mas01mj@640
|
4345 var sId = this.getAttribute( 'id' );
|
mas01mj@640
|
4346 if ( sId !== null )
|
mas01mj@640
|
4347 {
|
mas01mj@640
|
4348 oSettings.sTableId = sId;
|
mas01mj@640
|
4349 oSettings.sInstance = sId;
|
mas01mj@640
|
4350 }
|
mas01mj@640
|
4351 else
|
mas01mj@640
|
4352 {
|
mas01mj@640
|
4353 oSettings.sInstance = _oExt._oExternConfig.iNextUnique ++;
|
mas01mj@640
|
4354 }
|
mas01mj@640
|
4355
|
mas01mj@640
|
4356 /* Set the table node */
|
mas01mj@640
|
4357 oSettings.nTable = this;
|
mas01mj@640
|
4358
|
mas01mj@640
|
4359 /* Bind the API functions to the settings, so we can perform actions whenever oSettings is
|
mas01mj@640
|
4360 * available
|
mas01mj@640
|
4361 */
|
mas01mj@640
|
4362 oSettings.oApi = _that.oApi;
|
mas01mj@640
|
4363
|
mas01mj@640
|
4364 /* Store the features that we have available */
|
mas01mj@640
|
4365 if ( typeof oInit != 'undefined' && oInit !== null )
|
mas01mj@640
|
4366 {
|
mas01mj@640
|
4367 _fnMap( oSettings.oFeatures, oInit, "bPaginate" );
|
mas01mj@640
|
4368 _fnMap( oSettings.oFeatures, oInit, "bLengthChange" );
|
mas01mj@640
|
4369 _fnMap( oSettings.oFeatures, oInit, "bFilter" );
|
mas01mj@640
|
4370 _fnMap( oSettings.oFeatures, oInit, "bSort" );
|
mas01mj@640
|
4371 _fnMap( oSettings.oFeatures, oInit, "bInfo" );
|
mas01mj@640
|
4372 _fnMap( oSettings.oFeatures, oInit, "bProcessing" );
|
mas01mj@640
|
4373 _fnMap( oSettings.oFeatures, oInit, "bAutoWidth" );
|
mas01mj@640
|
4374 _fnMap( oSettings.oFeatures, oInit, "bSortClasses" );
|
mas01mj@640
|
4375 _fnMap( oSettings.oFeatures, oInit, "bServerSide" );
|
mas01mj@640
|
4376 _fnMap( oSettings, oInit, "asStripClasses" );
|
mas01mj@640
|
4377 _fnMap( oSettings, oInit, "fnRowCallback" );
|
mas01mj@640
|
4378 _fnMap( oSettings, oInit, "fnHeaderCallback" );
|
mas01mj@640
|
4379 _fnMap( oSettings, oInit, "fnFooterCallback" );
|
mas01mj@640
|
4380 _fnMap( oSettings, oInit, "fnDrawCallback" );
|
mas01mj@640
|
4381 _fnMap( oSettings, oInit, "fnInitComplete" );
|
mas01mj@640
|
4382 _fnMap( oSettings, oInit, "fnServerData" );
|
mas01mj@640
|
4383 _fnMap( oSettings, oInit, "aaSorting" );
|
mas01mj@640
|
4384 _fnMap( oSettings, oInit, "aaSortingFixed" );
|
mas01mj@640
|
4385 _fnMap( oSettings, oInit, "sPaginationType" );
|
mas01mj@640
|
4386 _fnMap( oSettings, oInit, "sAjaxSource" );
|
mas01mj@640
|
4387 _fnMap( oSettings, oInit, "sDom", "sDomPositioning" );
|
mas01mj@640
|
4388 _fnMap( oSettings, oInit, "oSearch", "oPreviousSearch" );
|
mas01mj@640
|
4389 _fnMap( oSettings, oInit, "aoSearchCols", "aoPreSearchCols" );
|
mas01mj@640
|
4390 _fnMap( oSettings, oInit, "iDisplayLength", "_iDisplayLength" );
|
mas01mj@640
|
4391 _fnMap( oSettings, oInit, "bJQueryUI", "bJUI" );
|
mas01mj@640
|
4392
|
mas01mj@640
|
4393 if ( typeof oInit.bJQueryUI != 'undefined' )
|
mas01mj@640
|
4394 {
|
mas01mj@640
|
4395 /* Use the JUI classes object for display. You could clone the oStdClasses object if
|
mas01mj@640
|
4396 * you want to have multiple tables with multiple independent classes
|
mas01mj@640
|
4397 */
|
mas01mj@640
|
4398 oSettings.oClasses = _oExt.oJUIClasses;
|
mas01mj@640
|
4399
|
mas01mj@640
|
4400 if ( typeof oInit.sDom == 'undefined' )
|
mas01mj@640
|
4401 {
|
mas01mj@640
|
4402 /* Set the DOM to use a layout suitable for jQuery UI's theming */
|
mas01mj@640
|
4403 oSettings.sDomPositioning =
|
mas01mj@640
|
4404 '<"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>'+
|
mas01mj@640
|
4405 't'+
|
mas01mj@640
|
4406 '<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>';
|
mas01mj@640
|
4407 }
|
mas01mj@640
|
4408 }
|
mas01mj@640
|
4409
|
mas01mj@640
|
4410 if ( typeof oInit.iDisplayStart != 'undefined' &&
|
mas01mj@640
|
4411 typeof oSettings.iInitDisplayStart == 'undefined' ) {
|
mas01mj@640
|
4412 /* Display start point, taking into account the save saving */
|
mas01mj@640
|
4413 oSettings.iInitDisplayStart = oInit.iDisplayStart;
|
mas01mj@640
|
4414 oSettings._iDisplayStart = oInit.iDisplayStart;
|
mas01mj@640
|
4415 }
|
mas01mj@640
|
4416
|
mas01mj@640
|
4417 /* Must be done after everything which can be overridden by a cookie! */
|
mas01mj@640
|
4418 if ( typeof oInit.bStateSave != 'undefined' )
|
mas01mj@640
|
4419 {
|
mas01mj@640
|
4420 oSettings.oFeatures.bStateSave = oInit.bStateSave;
|
mas01mj@640
|
4421 _fnLoadState( oSettings, oInit );
|
mas01mj@640
|
4422 }
|
mas01mj@640
|
4423
|
mas01mj@640
|
4424 if ( typeof oInit.aaData != 'undefined' ) {
|
mas01mj@640
|
4425 bUsePassedData = true;
|
mas01mj@640
|
4426 }
|
mas01mj@640
|
4427
|
mas01mj@640
|
4428 /* Backwards compatability */
|
mas01mj@640
|
4429 /* aoColumns / aoData - remove at some point... */
|
mas01mj@640
|
4430 if ( typeof oInit != 'undefined' && typeof oInit.aoData != 'undefined' )
|
mas01mj@640
|
4431 {
|
mas01mj@640
|
4432 oInit.aoColumns = oInit.aoData;
|
mas01mj@640
|
4433 }
|
mas01mj@640
|
4434
|
mas01mj@640
|
4435 /* Language definitions */
|
mas01mj@640
|
4436 if ( typeof oInit.oLanguage != 'undefined' )
|
mas01mj@640
|
4437 {
|
mas01mj@640
|
4438 if ( typeof oInit.oLanguage.sUrl != 'undefined' && oInit.oLanguage.sUrl !== "" )
|
mas01mj@640
|
4439 {
|
mas01mj@640
|
4440 /* Get the language definitions from a file */
|
mas01mj@640
|
4441 oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
|
mas01mj@640
|
4442 $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
|
mas01mj@640
|
4443 _fnLanguageProcess( oSettings, json, true ); } );
|
mas01mj@640
|
4444 bInitHandedOff = true;
|
mas01mj@640
|
4445 }
|
mas01mj@640
|
4446 else
|
mas01mj@640
|
4447 {
|
mas01mj@640
|
4448 _fnLanguageProcess( oSettings, oInit.oLanguage, false );
|
mas01mj@640
|
4449 }
|
mas01mj@640
|
4450 }
|
mas01mj@640
|
4451 /* Warning: The _fnLanguageProcess function is async to the remainder of this function due
|
mas01mj@640
|
4452 * to the XHR. We use _bInitialised in _fnLanguageProcess() to check this the processing
|
mas01mj@640
|
4453 * below is complete. The reason for spliting it like this is optimisation - we can fire
|
mas01mj@640
|
4454 * off the XHR (if needed) and then continue processing the data.
|
mas01mj@640
|
4455 */
|
mas01mj@640
|
4456 }
|
mas01mj@640
|
4457
|
mas01mj@640
|
4458 /* Add the strip classes now that we know which classes to apply - unless overruled */
|
mas01mj@640
|
4459 if ( typeof oInit == 'undefined' || typeof oInit.asStripClasses == 'undefined' )
|
mas01mj@640
|
4460 {
|
mas01mj@640
|
4461 oSettings.asStripClasses.push( oSettings.oClasses.sStripOdd );
|
mas01mj@640
|
4462 oSettings.asStripClasses.push( oSettings.oClasses.sStripEven );
|
mas01mj@640
|
4463 }
|
mas01mj@640
|
4464
|
mas01mj@640
|
4465 /* See if we should load columns automatically or use defined ones - a bit messy this... */
|
mas01mj@640
|
4466 var nThead = this.getElementsByTagName('thead');
|
mas01mj@640
|
4467 var nThs = nThead.length===0 ? null : _fnGetUniqueThs( nThead[0] );
|
mas01mj@640
|
4468 var bUseCols = typeof oInit != 'undefined' && typeof oInit.aoColumns != 'undefined';
|
mas01mj@640
|
4469 for ( i=0, iLen=bUseCols ? oInit.aoColumns.length : nThs.length ; i<iLen ; i++ )
|
mas01mj@640
|
4470 {
|
mas01mj@640
|
4471 var col = bUseCols ? oInit.aoColumns[i] : null;
|
mas01mj@640
|
4472 var n = nThs ? nThs[i] : null;
|
mas01mj@640
|
4473 _fnAddColumn( oSettings, col, n );
|
mas01mj@640
|
4474 }
|
mas01mj@640
|
4475
|
mas01mj@640
|
4476 /* Sanity check that there is a thead and tfoot. If not let's just create them */
|
mas01mj@640
|
4477 if ( this.getElementsByTagName('thead').length === 0 )
|
mas01mj@640
|
4478 {
|
mas01mj@640
|
4479 this.appendChild( document.createElement( 'thead' ) );
|
mas01mj@640
|
4480 }
|
mas01mj@640
|
4481
|
mas01mj@640
|
4482 if ( this.getElementsByTagName('tbody').length === 0 )
|
mas01mj@640
|
4483 {
|
mas01mj@640
|
4484 this.appendChild( document.createElement( 'tbody' ) );
|
mas01mj@640
|
4485 }
|
mas01mj@640
|
4486
|
mas01mj@640
|
4487 /* Check if there is data passing into the constructor */
|
mas01mj@640
|
4488 if ( bUsePassedData )
|
mas01mj@640
|
4489 {
|
mas01mj@640
|
4490 for ( i=0 ; i<oInit.aaData.length ; i++ )
|
mas01mj@640
|
4491 {
|
mas01mj@640
|
4492 _fnAddData( oSettings, oInit.aaData[ i ] );
|
mas01mj@640
|
4493 }
|
mas01mj@640
|
4494 }
|
mas01mj@640
|
4495 else
|
mas01mj@640
|
4496 {
|
mas01mj@640
|
4497 /* Grab the data from the page */
|
mas01mj@640
|
4498 _fnGatherData( oSettings );
|
mas01mj@640
|
4499 }
|
mas01mj@640
|
4500
|
mas01mj@640
|
4501 /* Copy the data index array */
|
mas01mj@640
|
4502 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
mas01mj@640
|
4503
|
mas01mj@640
|
4504 /* Calculate sizes for columns */
|
mas01mj@640
|
4505 if ( oSettings.oFeatures.bAutoWidth )
|
mas01mj@640
|
4506 {
|
mas01mj@640
|
4507 _fnCalculateColumnWidths( oSettings );
|
mas01mj@640
|
4508 }
|
mas01mj@640
|
4509
|
mas01mj@640
|
4510 /* Initialisation complete - table can be drawn */
|
mas01mj@640
|
4511 oSettings.bInitialised = true;
|
mas01mj@640
|
4512
|
mas01mj@640
|
4513 /* Check if we need to initialise the table (it might not have been handed off to the
|
mas01mj@640
|
4514 * language processor)
|
mas01mj@640
|
4515 */
|
mas01mj@640
|
4516 if ( bInitHandedOff === false )
|
mas01mj@640
|
4517 {
|
mas01mj@640
|
4518 _fnInitalise( oSettings );
|
mas01mj@640
|
4519 }
|
mas01mj@640
|
4520 });
|
mas01mj@640
|
4521 };
|
mas01mj@640
|
4522 })(jQuery);
|