annotate gis_gui/lib/jquery.dataTables.js @ 222:b636b0417aab

implement Google Search
author fknauft
date Fri, 01 Apr 2011 10:53:06 +0200
parents 7f008e782563
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2 * File: jquery.dataTables.js
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3 * Version: 1.6.2
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4 * CVS: $Id$
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5 * Description: Paginate, search and sort HTML tables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
6 * Author: Allan Jardine (www.sprymedia.co.uk)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
7 * Created: 28/3/2008
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
8 * Modified: $Date$ by $Author$
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
9 * Language: Javascript
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
10 * License: GPL v2 or BSD 3 point style
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
11 * Project: Mtaala
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
12 * Contact: allan.jardine@sprymedia.co.uk
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
13 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
14 * Copyright 2008-2010 Allan Jardine, all rights reserved.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
15 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
16 * This source file is free software, under either the GPL v2 license or a
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
17 * BSD style license, as supplied with this software.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
18 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
19 * This source file is distributed in the hope that it will be useful, but
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
22 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
23 * For details pleease refer to: http://www.datatables.net
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
24 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
25
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
26 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
27 * When considering jsLint, we need to allow eval() as it it is used for reading cookies and
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
28 * building the dynamic multi-column sort functions.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
29 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
30 /*jslint evil: true, undef: true, browser: true */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
31 /*globals $, jQuery,_fnReadCookie,_fnProcessingDisplay,_fnDraw,_fnSort,_fnReDraw,_fnDetectType,_fnSortingClasses,_fnSettingsFromNode,_fnBuildSearchArray,_fnCalculateEnd,_fnFeatureHtmlProcessing,_fnFeatureHtmlPaginate,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlFilter,_fnFilter,_fnSaveState,_fnFilterColumn,_fnEscapeRegex,_fnFilterComplete,_fnFeatureHtmlLength,_fnGetDataMaster,_fnVisibleToColumnIndex,_fnDrawHead,_fnAddData,_fnGetTrNodes,_fnGetTdNodes,_fnColumnIndexToVisible,_fnCreateCookie,_fnAddOptionsHtml,_fnMap,_fnClearTable,_fnDataToSearch,_fnReOrderIndex,_fnFilterCustom,_fnNodeToDataIndex,_fnVisbleColumns,_fnAjaxUpdate,_fnAjaxUpdateDraw,_fnColumnOrdering,fnGetMaxLenString,_fnSortAttachListener,_fnPageChange*/
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
32
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
33 (function($) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
34 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
35 * Section - DataTables variables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
36 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
37
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
38 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
39 * Variable: dataTableSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
40 * Purpose: Store the settings for each dataTables instance
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
41 * Scope: jQuery.fn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
42 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
43 $.fn.dataTableSettings = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
44 var _aoSettings = $.fn.dataTableSettings; /* Short reference for fast internal lookup */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
45
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
46 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
47 * Variable: dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
48 * Purpose: Container for customisable parts of DataTables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
49 * Scope: jQuery.fn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
50 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
51 $.fn.dataTableExt = {};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
52 var _oExt = $.fn.dataTableExt;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
53
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
54
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
55 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
56 * Section - DataTables extensible objects
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
57 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
58 * The _oExt object is used to provide an area where user dfined plugins can be
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
59 * added to DataTables. The following properties of the object are used:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
60 * oApi - Plug-in API functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
61 * aTypes - Auto-detection of types
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
62 * oSort - Sorting functions used by DataTables (based on the type)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
63 * oPagination - Pagination functions for different input styles
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
64 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
65
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
66 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
67 * Variable: sVersion
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
68 * Purpose: Version string for plug-ins to check compatibility
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
69 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
70 * Notes: Allowed format is a.b.c.d.e where:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
71 * a:int, b:int, c:int, d:string(dev|beta), e:int. d and e are optional
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
72 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
73 _oExt.sVersion = "1.6.2";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
74
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
75 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
76 * Variable: iApiIndex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
77 * Purpose: Index for what 'this' index API functions should use
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
78 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
79 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
80 _oExt.iApiIndex = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
81
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
82 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
83 * Variable: oApi
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
84 * Purpose: Container for plugin API functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
85 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
86 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
87 _oExt.oApi = { };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
88
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
89 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
90 * Variable: aFiltering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
91 * Purpose: Container for plugin filtering functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
92 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
93 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
94 _oExt.afnFiltering = [ ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
95
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
96 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
97 * Variable: aoFeatures
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
98 * Purpose: Container for plugin function functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
99 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
100 * Notes: Array of objects with the following parameters:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
101 * fnInit: Function for initialisation of Feature. Takes oSettings and returns node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
102 * cFeature: Character that will be matched in sDom - case sensitive
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
103 * sFeature: Feature name - just for completeness :-)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
104 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
105 _oExt.aoFeatures = [ ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
106
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
107 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
108 * Variable: ofnSearch
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
109 * Purpose: Container for custom filtering functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
110 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
111 * Notes: This is an object (the name should match the type) for custom filtering function,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
112 * which can be used for live DOM checking or formatted text filtering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
113 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
114 _oExt.ofnSearch = { };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
115
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
116 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
117 * Variable: afnSortData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
118 * Purpose: Container for custom sorting data source functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
119 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
120 * Notes: Array (associative) of functions which is run prior to a column of this
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
121 * 'SortDataType' being sorted upon.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
122 * Function input parameters:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
123 * object:oSettings- DataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
124 * int:iColumn - Target column number
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
125 * Return value: Array of data which exactly matched the full data set size for the column to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
126 * be sorted upon
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
127 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
128 _oExt.afnSortData = [ ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
129
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
130 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
131 * Variable: oStdClasses
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
132 * Purpose: Storage for the various classes that DataTables uses
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
133 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
134 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
135 _oExt.oStdClasses = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
136 /* Two buttons buttons */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
137 "sPagePrevEnabled": "paginate_enabled_previous",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
138 "sPagePrevDisabled": "paginate_disabled_previous",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
139 "sPageNextEnabled": "paginate_enabled_next",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
140 "sPageNextDisabled": "paginate_disabled_next",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
141 "sPageJUINext": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
142 "sPageJUIPrev": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
143
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
144 /* Full numbers paging buttons */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
145 "sPageButton": "paginate_button",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
146 "sPageButtonActive": "paginate_active",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
147 "sPageButtonStaticDisabled": "paginate_button",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
148 "sPageFirst": "first",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
149 "sPagePrevious": "previous",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
150 "sPageNext": "next",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
151 "sPageLast": "last",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
152
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
153 /* Stripping classes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
154 "sStripOdd": "odd",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
155 "sStripEven": "even",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
156
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
157 /* Empty row */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
158 "sRowEmpty": "dataTables_empty",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
159
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
160 /* Features */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
161 "sWrapper": "dataTables_wrapper",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
162 "sFilter": "dataTables_filter",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
163 "sInfo": "dataTables_info",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
164 "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
165 "sLength": "dataTables_length",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
166 "sProcessing": "dataTables_processing",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
167
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
168 /* Sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
169 "sSortAsc": "sorting_asc",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
170 "sSortDesc": "sorting_desc",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
171 "sSortable": "sorting", /* Sortable in both directions */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
172 "sSortableAsc": "sorting_asc_disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
173 "sSortableDesc": "sorting_desc_disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
174 "sSortableNone": "sorting_disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
175 "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
176 "sSortJUIAsc": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
177 "sSortJUIDesc": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
178 "sSortJUI": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
179 "sSortJUIAscAllowed": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
180 "sSortJUIDescAllowed": ""
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
181 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
182
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
183 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
184 * Variable: oJUIClasses
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
185 * Purpose: Storage for the various classes that DataTables uses - jQuery UI suitable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
186 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
187 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
188 _oExt.oJUIClasses = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
189 /* Two buttons buttons */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
190 "sPagePrevEnabled": "fg-button ui-state-default ui-corner-left",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
191 "sPagePrevDisabled": "fg-button ui-state-default ui-corner-left ui-state-disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
192 "sPageNextEnabled": "fg-button ui-state-default ui-corner-right",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
193 "sPageNextDisabled": "fg-button ui-state-default ui-corner-right ui-state-disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
194 "sPageJUINext": "ui-icon ui-icon-circle-arrow-e",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
195 "sPageJUIPrev": "ui-icon ui-icon-circle-arrow-w",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
196
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
197 /* Full numbers paging buttons */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
198 "sPageButton": "fg-button ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
199 "sPageButtonActive": "fg-button ui-state-default ui-state-disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
200 "sPageButtonStaticDisabled": "fg-button ui-state-default ui-state-disabled",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
201 "sPageFirst": "first ui-corner-tl ui-corner-bl",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
202 "sPagePrevious": "previous",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
203 "sPageNext": "next",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
204 "sPageLast": "last ui-corner-tr ui-corner-br",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
205
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
206 /* Stripping classes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
207 "sStripOdd": "odd",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
208 "sStripEven": "even",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
209
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
210 /* Empty row */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
211 "sRowEmpty": "dataTables_empty",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
212
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
213 /* Features */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
214 "sWrapper": "dataTables_wrapper",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
215 "sFilter": "dataTables_filter",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
216 "sInfo": "dataTables_info",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
217 "sPaging": "dataTables_paginate fg-buttonset fg-buttonset-multi paging_", /* Note that the type is postfixed */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
218 "sLength": "dataTables_length",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
219 "sProcessing": "dataTables_processing",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
220
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
221 /* Sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
222 "sSortAsc": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
223 "sSortDesc": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
224 "sSortable": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
225 "sSortableAsc": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
226 "sSortableDesc": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
227 "sSortableNone": "ui-state-default",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
228 "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
229 "sSortJUIAsc": "css_right ui-icon ui-icon-triangle-1-n",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
230 "sSortJUIDesc": "css_right ui-icon ui-icon-triangle-1-s",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
231 "sSortJUI": "css_right ui-icon ui-icon-carat-2-n-s",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
232 "sSortJUIAscAllowed": "css_right ui-icon ui-icon-carat-1-n",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
233 "sSortJUIDescAllowed": "css_right ui-icon ui-icon-carat-1-s"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
234 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
235
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
236 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
237 * Variable: oPagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
238 * Purpose: Container for the various type of pagination that dataTables supports
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
239 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
240 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
241 _oExt.oPagination = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
242 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
243 * Variable: two_button
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
244 * Purpose: Standard two button (forward/back) pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
245 * Scope: jQuery.fn.dataTableExt.oPagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
246 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
247 "two_button": {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
248 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
249 * Function: oPagination.two_button.fnInit
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
250 * Purpose: Initalise dom elements required for pagination with forward/back buttons only
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
251 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
252 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
253 * node:nPaging - the DIV which contains this pagination control
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
254 * function:fnCallbackDraw - draw function which must be called on update
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
255 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
256 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
257 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
258 var nPrevious, nNext, nPreviousInner, nNextInner;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
259
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
260 /* Store the next and previous elements in the oSettings object as they can be very
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
261 * usful for automation - particularly testing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
262 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
263 if ( !oSettings.bJUI )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
264 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
265 nPrevious = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
266 nNext = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
267 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
268 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
269 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
270 nPrevious = document.createElement( 'a' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
271 nNext = document.createElement( 'a' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
272
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
273 nNextInner = document.createElement('span');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
274 nNextInner.className = oSettings.oClasses.sPageJUINext;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
275 nNext.appendChild( nNextInner );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
276
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
277 nPreviousInner = document.createElement('span');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
278 nPreviousInner.className = oSettings.oClasses.sPageJUIPrev;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
279 nPrevious.appendChild( nPreviousInner );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
280 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
281
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
282 nPrevious.className = oSettings.oClasses.sPagePrevDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
283 nNext.className = oSettings.oClasses.sPageNextDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
284
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
285 nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
286 nNext.title = oSettings.oLanguage.oPaginate.sNext;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
287
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
288 nPaging.appendChild( nPrevious );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
289 nPaging.appendChild( nNext );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
290
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
291 $(nPrevious).click( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
292 if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
293 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
294 /* Only draw when the page has actually changed */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
295 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
296 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
297 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
298
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
299 $(nNext).click( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
300 if ( oSettings.oApi._fnPageChange( oSettings, "next" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
301 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
302 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
303 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
304 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
305
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
306 /* Take the brutal approach to cancelling text selection */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
307 $(nPrevious).bind( 'selectstart', function () { return false; } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
308 $(nNext).bind( 'selectstart', function () { return false; } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
309
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
310 /* ID the first elements only */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
311 if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
312 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
313 nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
314 nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
315 nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
316 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
317 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
318
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
319 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
320 * Function: oPagination.two_button.fnUpdate
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
321 * Purpose: Update the two button pagination at the end of the draw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
322 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
323 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
324 * function:fnCallbackDraw - draw function to call on page change
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
325 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
326 "fnUpdate": function ( oSettings, fnCallbackDraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
327 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
328 if ( !oSettings.aanFeatures.p )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
329 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
330 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
331 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
332
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
333 /* Loop over each instance of the pager */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
334 var an = oSettings.aanFeatures.p;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
335 for ( var i=0, iLen=an.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
336 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
337 if ( an[i].childNodes.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
338 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
339 an[i].childNodes[0].className =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
340 ( oSettings._iDisplayStart === 0 ) ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
341 oSettings.oClasses.sPagePrevDisabled : oSettings.oClasses.sPagePrevEnabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
342
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
343 an[i].childNodes[1].className =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
344 ( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
345 oSettings.oClasses.sPageNextDisabled : oSettings.oClasses.sPageNextEnabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
346 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
347 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
348 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
349 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
350
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
351
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
352 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
353 * Variable: iFullNumbersShowPages
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
354 * Purpose: Change the number of pages which can be seen
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
355 * Scope: jQuery.fn.dataTableExt.oPagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
356 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
357 "iFullNumbersShowPages": 5,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
358
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
359 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
360 * Variable: full_numbers
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
361 * Purpose: Full numbers pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
362 * Scope: jQuery.fn.dataTableExt.oPagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
363 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
364 "full_numbers": {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
365 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
366 * Function: oPagination.full_numbers.fnInit
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
367 * Purpose: Initalise dom elements required for pagination with a list of the pages
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
368 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
369 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
370 * node:nPaging - the DIV which contains this pagination control
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
371 * function:fnCallbackDraw - draw function which must be called on update
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
372 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
373 "fnInit": function ( oSettings, nPaging, fnCallbackDraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
374 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
375 var nFirst = document.createElement( 'span' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
376 var nPrevious = document.createElement( 'span' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
377 var nList = document.createElement( 'span' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
378 var nNext = document.createElement( 'span' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
379 var nLast = document.createElement( 'span' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
380
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
381 nFirst.innerHTML = oSettings.oLanguage.oPaginate.sFirst;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
382 nPrevious.innerHTML = oSettings.oLanguage.oPaginate.sPrevious;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
383 nNext.innerHTML = oSettings.oLanguage.oPaginate.sNext;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
384 nLast.innerHTML = oSettings.oLanguage.oPaginate.sLast;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
385
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
386 var oClasses = oSettings.oClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
387 nFirst.className = oClasses.sPageButton+" "+oClasses.sPageFirst;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
388 nPrevious.className = oClasses.sPageButton+" "+oClasses.sPagePrevious;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
389 nNext.className= oClasses.sPageButton+" "+oClasses.sPageNext;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
390 nLast.className = oClasses.sPageButton+" "+oClasses.sPageLast;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
391
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
392 nPaging.appendChild( nFirst );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
393 nPaging.appendChild( nPrevious );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
394 nPaging.appendChild( nList );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
395 nPaging.appendChild( nNext );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
396 nPaging.appendChild( nLast );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
397
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
398 $(nFirst).click( function () {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
399 if ( oSettings.oApi._fnPageChange( oSettings, "first" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
400 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
401 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
402 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
403 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
404
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
405 $(nPrevious).click( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
406 if ( oSettings.oApi._fnPageChange( oSettings, "previous" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
407 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
408 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
409 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
410 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
411
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
412 $(nNext).click( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
413 if ( oSettings.oApi._fnPageChange( oSettings, "next" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
414 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
415 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
416 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
417 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
418
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
419 $(nLast).click( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
420 if ( oSettings.oApi._fnPageChange( oSettings, "last" ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
421 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
422 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
423 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
424 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
425
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
426 /* Take the brutal approach to cancelling text selection */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
427 $('span', nPaging)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
428 .bind( 'mousedown', function () { return false; } )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
429 .bind( 'selectstart', function () { return false; } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
430
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
431 /* ID the first elements only */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
432 if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.p == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
433 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
434 nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
435 nFirst.setAttribute( 'id', oSettings.sTableId+'_first' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
436 nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
437 nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
438 nLast.setAttribute( 'id', oSettings.sTableId+'_last' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
439 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
440 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
441
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
442 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
443 * Function: oPagination.full_numbers.fnUpdate
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
444 * Purpose: Update the list of page buttons shows
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
445 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
446 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
447 * function:fnCallbackDraw - draw function to call on page change
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
448 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
449 "fnUpdate": function ( oSettings, fnCallbackDraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
450 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
451 if ( !oSettings.aanFeatures.p )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
452 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
453 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
454 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
455
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
456 var iPageCount = _oExt.oPagination.iFullNumbersShowPages;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
457 var iPageCountHalf = Math.floor(iPageCount / 2);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
458 var iPages = Math.ceil((oSettings.fnRecordsDisplay()) / oSettings._iDisplayLength);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
459 var iCurrentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength) + 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
460 var sList = "";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
461 var iStartButton, iEndButton, i, iLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
462 var oClasses = oSettings.oClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
463
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
464 /* Pages calculation */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
465 if (iPages < iPageCount)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
466 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
467 iStartButton = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
468 iEndButton = iPages;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
469 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
470 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
471 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
472 if (iCurrentPage <= iPageCountHalf)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
473 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
474 iStartButton = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
475 iEndButton = iPageCount;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
476 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
477 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
478 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
479 if (iCurrentPage >= (iPages - iPageCountHalf))
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
480 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
481 iStartButton = iPages - iPageCount + 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
482 iEndButton = iPages;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
483 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
484 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
485 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
486 iStartButton = iCurrentPage - Math.ceil(iPageCount / 2) + 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
487 iEndButton = iStartButton + iPageCount - 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
488 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
489 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
490 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
491
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
492 /* Build the dynamic list */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
493 for ( i=iStartButton ; i<=iEndButton ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
494 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
495 if ( iCurrentPage != i )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
496 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
497 sList += '<span class="'+oClasses.sPageButton+'">'+i+'</span>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
498 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
499 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
500 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
501 sList += '<span class="'+oClasses.sPageButtonActive+'">'+i+'</span>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
502 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
503 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
504
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
505 /* Loop over each instance of the pager */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
506 var an = oSettings.aanFeatures.p;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
507 var anButtons, anStatic, nPaginateList;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
508 var fnClick = function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
509 /* Use the information in the element to jump to the required page */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
510 var iTarget = (this.innerHTML * 1) - 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
511 oSettings._iDisplayStart = iTarget * oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
512 fnCallbackDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
513 return false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
514 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
515 var fnFalse = function () { return false; };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
516
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
517 for ( i=0, iLen=an.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
518 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
519 if ( an[i].childNodes.length === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
520 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
521 continue;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
522 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
523
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
524 /* Build up the dynamic list forst - html and listeners */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
525 nPaginateList = an[i].childNodes[2];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
526 nPaginateList.innerHTML = sList;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
527
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
528 $('span', nPaginateList).click( fnClick ).bind( 'mousedown', fnFalse )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
529 .bind( 'selectstart', fnFalse );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
530
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
531 /* Update the 'premanent botton's classes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
532 anButtons = an[i].getElementsByTagName('span');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
533 anStatic = [
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
534 anButtons[0], anButtons[1],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
535 anButtons[anButtons.length-2], anButtons[anButtons.length-1]
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
536 ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
537 $(anStatic).removeClass( oClasses.sPageButton+" "+oClasses.sPageButtonActive+" "+oClasses.sPageButtonStaticDisabled );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
538 if ( iCurrentPage == 1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
539 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
540 anStatic[0].className += " "+oClasses.sPageButtonStaticDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
541 anStatic[1].className += " "+oClasses.sPageButtonStaticDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
542 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
543 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
544 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
545 anStatic[0].className += " "+oClasses.sPageButton;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
546 anStatic[1].className += " "+oClasses.sPageButton;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
547 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
548
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
549 if ( iPages === 0 || iCurrentPage == iPages || oSettings._iDisplayLength == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
550 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
551 anStatic[2].className += " "+oClasses.sPageButtonStaticDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
552 anStatic[3].className += " "+oClasses.sPageButtonStaticDisabled;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
553 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
554 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
555 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
556 anStatic[2].className += " "+oClasses.sPageButton;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
557 anStatic[3].className += " "+oClasses.sPageButton;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
558 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
559 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
560 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
561 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
562 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
563
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
564 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
565 * Variable: oSort
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
566 * Purpose: Wrapper for the sorting functions that can be used in DataTables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
567 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
568 * Notes: The functions provided in this object are basically standard javascript sort
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
569 * functions - they expect two inputs which they then compare and then return a priority
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
570 * result. For each sort method added, two functions need to be defined, an ascending sort and
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
571 * a descending sort.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
572 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
573 _oExt.oSort = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
574 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
575 * text sorting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
576 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
577 "string-asc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
578 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
579 var x = a.toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
580 var y = b.toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
581 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
582 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
583
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
584 "string-desc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
585 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
586 var x = a.toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
587 var y = b.toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
588 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
589 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
590
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
591
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
592 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
593 * html sorting (ignore html tags)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
594 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
595 "html-asc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
596 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
597 var x = a.replace( /<.*?>/g, "" ).toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
598 var y = b.replace( /<.*?>/g, "" ).toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
599 return ((x < y) ? -1 : ((x > y) ? 1 : 0));
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
600 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
601
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
602 "html-desc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
603 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
604 var x = a.replace( /<.*?>/g, "" ).toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
605 var y = b.replace( /<.*?>/g, "" ).toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
606 return ((x < y) ? 1 : ((x > y) ? -1 : 0));
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
607 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
608
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
609
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
610 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
611 * date sorting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
612 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
613 "date-asc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
614 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
615 var x = Date.parse( a );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
616 var y = Date.parse( b );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
617
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
618 if ( isNaN( x ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
619 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
620 x = Date.parse( "01/01/1970 00:00:00" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
621 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
622 if ( isNaN( y ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
623 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
624 y = Date.parse( "01/01/1970 00:00:00" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
625 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
626
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
627 return x - y;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
628 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
629
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
630 "date-desc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
631 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
632 var x = Date.parse( a );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
633 var y = Date.parse( b );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
634
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
635 if ( isNaN( x ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
636 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
637 x = Date.parse( "01/01/1970 00:00:00" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
638 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
639 if ( isNaN( y ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
640 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
641 y = Date.parse( "01/01/1970 00:00:00" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
642 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
643
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
644 return y - x;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
645 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
646
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
647
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
648 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
649 * numerical sorting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
650 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
651 "numeric-asc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
652 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
653 var x = a == "-" ? 0 : a;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
654 var y = b == "-" ? 0 : b;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
655 return x - y;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
656 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
657
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
658 "numeric-desc": function ( a, b )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
659 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
660 var x = a == "-" ? 0 : a;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
661 var y = b == "-" ? 0 : b;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
662 return y - x;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
663 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
664 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
665
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
666
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
667 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
668 * Variable: aTypes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
669 * Purpose: Container for the various type of type detection that dataTables supports
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
670 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
671 * Notes: The functions in this array are expected to parse a string to see if it is a data
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
672 * type that it recognises. If so then the function should return the name of the type (a
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
673 * corresponding sort function should be defined!), if the type is not recognised then the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
674 * function should return null such that the parser and move on to check the next type.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
675 * Note that ordering is important in this array - the functions are processed linearly,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
676 * starting at index 0.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
677 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
678 _oExt.aTypes = [
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
679 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
680 * Function: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
681 * Purpose: Check to see if a string is numeric
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
682 * Returns: string:'numeric' or null
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
683 * Inputs: string:sText - string to check
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
684 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
685 function ( sData )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
686 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
687 /* Sanity check that we are dealing with a string or quick return for a number */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
688 if ( typeof sData == 'number' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
689 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
690 return 'numeric';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
691 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
692 else if ( typeof sData.charAt != 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
693 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
694 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
695 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
696
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
697 var sValidFirstChars = "0123456789-";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
698 var sValidChars = "0123456789.";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
699 var Char;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
700 var bDecimal = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
701
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
702 /* Check for a valid first char (no period and allow negatives) */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
703 Char = sData.charAt(0);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
704 if (sValidFirstChars.indexOf(Char) == -1)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
705 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
706 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
707 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
708
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
709 /* Check all the other characters are valid */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
710 for ( var i=1 ; i<sData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
711 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
712 Char = sData.charAt(i);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
713 if (sValidChars.indexOf(Char) == -1)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
714 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
715 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
716 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
717
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
718 /* Only allowed one decimal place... */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
719 if ( Char == "." )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
720 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
721 if ( bDecimal )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
722 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
723 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
724 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
725 bDecimal = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
726 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
727 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
728
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
729 return 'numeric';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
730 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
731
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
732 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
733 * Function: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
734 * Purpose: Check to see if a string is actually a formatted date
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
735 * Returns: string:'date' or null
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
736 * Inputs: string:sText - string to check
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
737 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
738 function ( sData )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
739 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
740 var iParse = Date.parse(sData);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
741 if ( iParse !== null && !isNaN(iParse) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
742 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
743 return 'date';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
744 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
745 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
746 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
747 ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
748
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
749
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
750 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
751 * Variable: _oExternConfig
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
752 * Purpose: Store information for DataTables to access globally about other instances
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
753 * Scope: jQuery.fn.dataTableExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
754 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
755 _oExt._oExternConfig = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
756 /* int:iNextUnique - next unique number for an instance */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
757 "iNextUnique": 0
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
758 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
759
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
760
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
761 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
762 * Section - DataTables prototype
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
763 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
764
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
765 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
766 * Function: dataTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
767 * Purpose: DataTables information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
768 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
769 * Inputs: object:oInit - initalisation options for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
770 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
771 $.fn.dataTable = function( oInit )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
772 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
773 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
774 * Function: classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
775 * Purpose: Settings container function for all 'class' properties which are required
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
776 * by dataTables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
777 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
778 * Inputs: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
779 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
780 function classSettings ()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
781 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
782 this.fnRecordsTotal = function ()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
783 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
784 if ( this.oFeatures.bServerSide ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
785 return this._iRecordsTotal;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
786 } else {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
787 return this.aiDisplayMaster.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
788 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
789 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
790
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
791 this.fnRecordsDisplay = function ()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
792 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
793 if ( this.oFeatures.bServerSide ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
794 return this._iRecordsDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
795 } else {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
796 return this.aiDisplay.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
797 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
798 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
799
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
800 this.fnDisplayEnd = function ()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
801 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
802 if ( this.oFeatures.bServerSide ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
803 return this._iDisplayStart + this.aiDisplay.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
804 } else {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
805 return this._iDisplayEnd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
806 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
807 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
808
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
809 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
810 * Variable: sInstance
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
811 * Purpose: Unique idendifier for each instance of the DataTables object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
812 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
813 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
814 this.sInstance = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
815
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
816 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
817 * Variable: oFeatures
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
818 * Purpose: Indicate the enablement of key dataTable features
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
819 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
820 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
821 this.oFeatures = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
822 "bPaginate": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
823 "bLengthChange": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
824 "bFilter": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
825 "bSort": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
826 "bInfo": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
827 "bAutoWidth": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
828 "bProcessing": false,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
829 "bSortClasses": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
830 "bStateSave": false,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
831 "bServerSide": false
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
832 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
833
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
834 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
835 * Variable: aanFeatures
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
836 * Purpose: Array referencing the nodes which are used for the features
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
837 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
838 * Notes: The parameters of this object match what is allowed by sDom - i.e.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
839 * 'l' - Length changing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
840 * 'f' - Filtering input
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
841 * 't' - The table!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
842 * 'i' - Information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
843 * 'p' - Pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
844 * 'r' - pRocessing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
845 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
846 this.aanFeatures = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
847
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
848 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
849 * Variable: oLanguage
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
850 * Purpose: Store the language strings used by dataTables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
851 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
852 * Notes: The words in the format _VAR_ are variables which are dynamically replaced
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
853 * by javascript
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
854 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
855 this.oLanguage = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
856 "sProcessing": "Processing...",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
857 "sLengthMenu": "Show _MENU_ entries",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
858 "sZeroRecords": "No matching records found",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
859 "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
860 "sInfoEmpty": "Showing 0 to 0 of 0 entries",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
861 "sInfoFiltered": "(filtered from _MAX_ total entries)",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
862 "sInfoPostFix": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
863 "sSearch": "Search:",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
864 "sUrl": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
865 "oPaginate": {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
866 "sFirst": "First",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
867 "sPrevious": "Previous",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
868 "sNext": "Next",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
869 "sLast": "Last"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
870 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
871 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
872
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
873 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
874 * Variable: aoData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
875 * Purpose: Store data information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
876 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
877 * Notes: This is an array of objects with the following parameters:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
878 * int: _iId - internal id for tracking
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
879 * array: _aData - internal data - used for sorting / filtering etc
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
880 * node: nTr - display node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
881 * array node: _anHidden - hidden TD nodes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
882 * string: _sRowStripe
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
883 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
884 this.aoData = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
885
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
886 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
887 * Variable: aiDisplay
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
888 * Purpose: Array of indexes which are in the current display (after filtering etc)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
889 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
890 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
891 this.aiDisplay = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
892
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
893 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
894 * Variable: aiDisplayMaster
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
895 * Purpose: Array of indexes for display - no filtering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
896 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
897 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
898 this.aiDisplayMaster = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
899
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
900 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
901 * Variable: aoColumns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
902 * Purpose: Store information about each column that is in use
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
903 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
904 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
905 this.aoColumns = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
906
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
907 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
908 * Variable: iNextId
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
909 * Purpose: Store the next unique id to be used for a new row
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
910 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
911 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
912 this.iNextId = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
913
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
914 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
915 * Variable: asDataSearch
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
916 * Purpose: Search data array for regular expression searching
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
917 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
918 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
919 this.asDataSearch = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
920
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
921 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
922 * Variable: oPreviousSearch
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
923 * Purpose: Store the previous search incase we want to force a re-search
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
924 * or compare the old search to a new one
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
925 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
926 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
927 this.oPreviousSearch = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
928 "sSearch": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
929 "bEscapeRegex": true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
930 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
931
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
932 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
933 * Variable: aoPreSearchCols
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
934 * Purpose: Store the previous search for each column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
935 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
936 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
937 this.aoPreSearchCols = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
938
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
939 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
940 * Variable: aaSorting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
941 * Purpose: Sorting information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
942 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
943 * Notes: Index 0 - column number
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
944 * Index 1 - current sorting direction
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
945 * Index 2 - index of asSorting for this column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
946 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
947 this.aaSorting = [ [0, 'asc', 0] ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
948
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
949 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
950 * Variable: aaSortingFixed
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
951 * Purpose: Sorting information that is always applied
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
952 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
953 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
954 this.aaSortingFixed = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
955
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
956 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
957 * Variable: asStripClasses
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
958 * Purpose: Classes to use for the striping of a table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
959 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
960 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
961 this.asStripClasses = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
962
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
963 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
964 * Variable: fnRowCallback
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
965 * Purpose: Call this function every time a row is inserted (draw)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
966 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
967 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
968 this.fnRowCallback = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
969
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
970 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
971 * Variable: fnHeaderCallback
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
972 * Purpose: Callback function for the header on each draw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
973 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
974 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
975 this.fnHeaderCallback = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
976
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
977 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
978 * Variable: fnFooterCallback
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
979 * Purpose: Callback function for the footer on each draw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
980 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
981 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
982 this.fnFooterCallback = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
983
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
984 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
985 * Variable: aoDrawCallback
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
986 * Purpose: Array of callback functions for draw callback functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
987 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
988 * Notes: Each array element is an object with the following parameters:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
989 * function:fn - function to call
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
990 * string:sName - name callback (feature). useful for arranging array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
991 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
992 this.aoDrawCallback = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
993
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
994 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
995 * Variable: fnInitComplete
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
996 * Purpose: Callback function for when the table has been initalised
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
997 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
998 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
999 this.fnInitComplete = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1000
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1001 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1002 * Variable: sTableId
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1003 * Purpose: Cache the table ID for quick access
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1004 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1005 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1006 this.sTableId = "";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1007
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1008 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1009 * Variable: nTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1010 * Purpose: Cache the table node for quick access
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1011 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1012 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1013 this.nTable = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1014
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1015 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1016 * Variable: iDefaultSortIndex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1017 * Purpose: Sorting index which will be used by default
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1018 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1019 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1020 this.iDefaultSortIndex = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1021
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1022 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1023 * Variable: bInitialised
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1024 * Purpose: Indicate if all required information has been read in
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1025 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1026 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1027 this.bInitialised = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1028
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1029 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1030 * Variable: aoOpenRows
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1031 * Purpose: Information about open rows
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1032 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1033 * Notes: Has the parameters 'nTr' and 'nParent'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1034 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1035 this.aoOpenRows = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1036
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1037 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1038 * Variable: sDom
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1039 * Purpose: Dictate the positioning that the created elements will take
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1040 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1041 * Notes:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1042 * The following options are allowed:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1043 * 'l' - Length changing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1044 * 'f' - Filtering input
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1045 * 't' - The table!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1046 * 'i' - Information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1047 * 'p' - Pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1048 * 'r' - pRocessing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1049 * The following constants are allowed:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1050 * 'H' - jQueryUI theme "header" classes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1051 * 'F' - jQueryUI theme "footer" classes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1052 * The following syntax is expected:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1053 * '<' and '>' - div elements
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1054 * '<"class" and '>' - div with a class
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1055 * Examples:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1056 * '<"wrapper"flipt>', '<lf<t>ip>'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1057 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1058 this.sDom = 'lfrtip';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1059
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1060 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1061 * Variable: sPaginationType
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1062 * Purpose: Note which type of sorting should be used
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1063 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1064 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1065 this.sPaginationType = "two_button";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1066
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1067 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1068 * Variable: iCookieDuration
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1069 * Purpose: The cookie duration (for bStateSave) in seconds - default 2 hours
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1070 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1071 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1072 this.iCookieDuration = 60 * 60 * 2;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1073
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1074 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1075 * Variable: sAjaxSource
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1076 * Purpose: Source url for AJAX data for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1077 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1078 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1079 this.sAjaxSource = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1080
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1081 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1082 * Variable: bAjaxDataGet
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1083 * Purpose: Note if draw should be blocked while getting data
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1084 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1085 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1086 this.bAjaxDataGet = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1087
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1088 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1089 * Variable: fnServerData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1090 * Purpose: Function to get the server-side data - can be overruled by the developer
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1091 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1092 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1093 this.fnServerData = $.getJSON;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1094
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1095 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1096 * Variable: iServerDraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1097 * Purpose: Counter and tracker for server-side processing draws
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1098 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1099 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1100 this.iServerDraw = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1101
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1102 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1103 * Variable: _iDisplayLength, _iDisplayStart, _iDisplayEnd
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1104 * Purpose: Display length variables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1105 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1106 * Notes: These variable must NOT be used externally to get the data length. Rather, use
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1107 * the fnRecordsTotal() (etc) functions.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1108 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1109 this._iDisplayLength = 10;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1110 this._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1111 this._iDisplayEnd = 10;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1112
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1113 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1114 * Variable: _iRecordsTotal, _iRecordsDisplay
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1115 * Purpose: Display length variables used for server side processing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1116 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1117 * Notes: These variable must NOT be used externally to get the data length. Rather, use
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1118 * the fnRecordsTotal() (etc) functions.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1119 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1120 this._iRecordsTotal = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1121 this._iRecordsDisplay = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1122
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1123 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1124 * Variable: bJUI
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1125 * Purpose: Should we add the markup needed for jQuery UI theming?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1126 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1127 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1128 this.bJUI = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1129
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1130 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1131 * Variable: bJUI
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1132 * Purpose: Should we add the markup needed for jQuery UI theming?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1133 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1134 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1135 this.oClasses = _oExt.oStdClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1136
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1137 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1138 * Variable: bFiltered and bSorted
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1139 * Purpose: Flag to allow callback functions to see what action has been performed
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1140 * Scope: jQuery.dataTable.classSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1141 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1142 this.bFiltered = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1143 this.bSorted = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1144 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1145
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1146 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1147 * Variable: oApi
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1148 * Purpose: Container for publicly exposed 'private' functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1149 * Scope: jQuery.dataTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1150 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1151 this.oApi = {};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1152
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1153
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1154 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1155 * Section - API functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1156 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1157
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1158 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1159 * Function: fnDraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1160 * Purpose: Redraw the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1161 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1162 * Inputs: bool:bComplete - Refilter and resort (if enabled) the table before the draw.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1163 * Optional: default - true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1164 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1165 this.fnDraw = function( bComplete )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1166 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1167 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1168 if ( typeof bComplete != 'undefined' && bComplete === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1169 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1170 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1171 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1172 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1173 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1174 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1175 _fnReDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1176 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1177 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1178
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1179 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1180 * Function: fnFilter
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1181 * Purpose: Filter the input based on data
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1182 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1183 * Inputs: string:sInput - string to filter the table on
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1184 * int:iColumn - optional - column to limit filtering to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1185 * bool:bEscapeRegex - optional - escape regex characters or not - default true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1186 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1187 this.fnFilter = function( sInput, iColumn, bEscapeRegex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1188 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1189 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1190
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1191 if ( typeof bEscapeRegex == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1192 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1193 bEscapeRegex = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1194 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1195
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1196 if ( typeof iColumn == "undefined" || iColumn === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1197 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1198 /* Global filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1199 _fnFilterComplete( oSettings, {"sSearch":sInput, "bEscapeRegex": bEscapeRegex}, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1200 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1201 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1202 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1203 /* Single column filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1204 oSettings.aoPreSearchCols[ iColumn ].sSearch = sInput;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1205 oSettings.aoPreSearchCols[ iColumn ].bEscapeRegex = bEscapeRegex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1206 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1207 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1208 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1209
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1210 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1211 * Function: fnSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1212 * Purpose: Get the settings for a particular table for extern. manipulation
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1213 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1214 * Inputs: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1215 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1216 this.fnSettings = function( nNode )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1217 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1218 return _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1219 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1220
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1221 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1222 * Function: fnVersionCheck
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1223 * Purpose: Check a version string against this version of DataTables. Useful for plug-ins
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1224 * Returns: bool:true -this version of DataTables is greater or equal to the required version
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1225 * false -this version of DataTales is not suitable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1226 * Inputs: string:sVersion - the version to check against. May be in the following formats:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1227 * "a", "a.b" or "a.b.c"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1228 * Notes: This function will only check the first three parts of a version string. It is
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1229 * assumed that beta and dev versions will meet the requirements. This might change in future
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1230 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1231 this.fnVersionCheck = function( sVersion )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1232 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1233 /* This is cheap, but very effective */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1234 var fnZPad = function (Zpad, count)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1235 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1236 while(Zpad.length < count) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1237 Zpad += '0';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1238 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1239 return Zpad;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1240 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1241 var aThis = _oExt.sVersion.split('.');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1242 var aThat = sVersion.split('.');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1243 var sThis = '', sThat = '';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1244
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1245 for ( var i=0, iLen=aThat.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1246 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1247 sThis += fnZPad( aThis[i], 3 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1248 sThat += fnZPad( aThat[i], 3 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1249 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1250
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1251 return parseInt(sThis, 10) >= parseInt(sThat, 10);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1252 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1253
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1254 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1255 * Function: fnSort
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1256 * Purpose: Sort the table by a particular row
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1257 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1258 * Inputs: int:iCol - the data index to sort on. Note that this will
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1259 * not match the 'display index' if you have hidden data entries
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1260 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1261 this.fnSort = function( aaSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1262 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1263 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1264 oSettings.aaSorting = aaSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1265 _fnSort( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1266 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1267
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1268 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1269 * Function: fnSortListener
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1270 * Purpose: Attach a sort listener to an element for a given column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1271 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1272 * Inputs: node:nNode - the element to attach the sort listener to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1273 * int:iColumn - the column that a click on this node will sort on
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1274 * function:fnCallback - callback function when sort is run - optional
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1275 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1276 this.fnSortListener = function( nNode, iColumn, fnCallback )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1277 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1278 _fnSortAttachListener( _fnSettingsFromNode( this[_oExt.iApiIndex] ), nNode, iColumn,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1279 fnCallback );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1280 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1281
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1282 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1283 * Function: fnAddData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1284 * Purpose: Add new row(s) into the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1285 * Returns: array int: array of indexes (aoData) which have been added (zero length on error)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1286 * Inputs: array:mData - the data to be added. The length must match
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1287 * the original data from the DOM
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1288 * or
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1289 * array array:mData - 2D array of data to be added
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1290 * bool:bRedraw - redraw the table or not - default true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1291 * Notes: Warning - the refilter here will cause the table to redraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1292 * starting at zero
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1293 * Notes: Thanks to Yekimov Denis for contributing the basis for this function!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1294 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1295 this.fnAddData = function( mData, bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1296 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1297 if ( mData.length === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1298 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1299 return [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1300 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1301
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1302 var aiReturn = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1303 var iTest;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1304
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1305 /* Find settings from table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1306 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1307
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1308 /* Check if we want to add multiple rows or not */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1309 if ( typeof mData[0] == "object" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1310 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1311 for ( var i=0 ; i<mData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1312 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1313 iTest = _fnAddData( oSettings, mData[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1314 if ( iTest == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1315 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1316 return aiReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1317 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1318 aiReturn.push( iTest );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1319 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1320 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1321 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1322 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1323 iTest = _fnAddData( oSettings, mData );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1324 if ( iTest == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1325 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1326 return aiReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1327 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1328 aiReturn.push( iTest );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1329 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1330
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1331 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1332
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1333 /* Rebuild the search */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1334 _fnBuildSearchArray( oSettings, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1335
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1336 if ( typeof bRedraw == 'undefined' || bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1337 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1338 _fnReDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1339 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1340 return aiReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1341 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1342
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1343 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1344 * Function: fnDeleteRow
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1345 * Purpose: Remove a row for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1346 * Returns: array:aReturn - the row that was deleted
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1347 * Inputs: mixed:mTarget -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1348 * int: - index of aoData to be deleted, or
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1349 * node(TR): - TR element you want to delete
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1350 * function:fnCallBack - callback function - default null
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1351 * bool:bNullRow - remove the row information from aoData by setting the value to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1352 * null - default false
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1353 * Notes: This function requires a little explanation - we don't actually delete the data
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1354 * from aoData - rather we remove it's references from aiDisplayMastr and aiDisplay. This
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1355 * in effect prevnts DataTables from drawing it (hence deleting it) - it could be restored
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1356 * if you really wanted. The reason for this is that actually removing the aoData object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1357 * would mess up all the subsequent indexes in the display arrays (they could be ajusted -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1358 * but this appears to do what is required).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1359 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1360 this.fnDeleteRow = function( mTarget, fnCallBack, bNullRow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1361 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1362 /* Find settings from table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1363 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1364 var i, iAODataIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1365
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1366 iAODataIndex = (typeof mTarget == 'object') ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1367 _fnNodeToDataIndex(oSettings, mTarget) : mTarget;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1368
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1369 /* Delete from the display master */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1370 for ( i=0 ; i<oSettings.aiDisplayMaster.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1371 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1372 if ( oSettings.aiDisplayMaster[i] == iAODataIndex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1373 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1374 oSettings.aiDisplayMaster.splice( i, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1375 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1376 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1377 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1378
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1379 /* Delete from the current display index */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1380 for ( i=0 ; i<oSettings.aiDisplay.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1381 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1382 if ( oSettings.aiDisplay[i] == iAODataIndex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1383 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1384 oSettings.aiDisplay.splice( i, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1385 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1386 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1387 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1388
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1389 /* Rebuild the search */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1390 _fnBuildSearchArray( oSettings, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1391
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1392 /* If there is a user callback function - call it */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1393 if ( typeof fnCallBack == "function" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1394 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1395 fnCallBack.call( this );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1396 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1397
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1398 /* Check for an 'overflow' they case for dislaying the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1399 if ( oSettings._iDisplayStart >= oSettings.aiDisplay.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1400 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1401 oSettings._iDisplayStart -= oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1402 if ( oSettings._iDisplayStart < 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1403 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1404 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1405 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1406 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1407
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1408 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1409 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1410
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1411 /* Return the data array from this row */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1412 var aData = oSettings.aoData[iAODataIndex]._aData.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1413
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1414 if ( typeof bNullRow != "undefined" && bNullRow === true )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1415 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1416 oSettings.aoData[iAODataIndex] = null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1417 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1418
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1419 return aData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1420 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1421
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1422 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1423 * Function: fnClearTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1424 * Purpose: Quickly and simply clear a table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1425 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1426 * Inputs: bool:bRedraw - redraw the table or not - default true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1427 * Notes: Thanks to Yekimov Denis for contributing the basis for this function!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1428 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1429 this.fnClearTable = function( bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1430 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1431 /* Find settings from table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1432 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1433 _fnClearTable( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1434
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1435 if ( typeof bRedraw == 'undefined' || bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1436 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1437 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1438 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1439 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1440
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1441 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1442 * Function: fnOpen
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1443 * Purpose: Open a display row (append a row after the row in question)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1444 * Returns: node:nNewRow - the row opened
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1445 * Inputs: node:nTr - the table row to 'open'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1446 * string:sHtml - the HTML to put into the row
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1447 * string:sClass - class to give the new cell
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1448 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1449 this.fnOpen = function( nTr, sHtml, sClass )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1450 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1451 /* Find settings from table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1452 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1453
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1454 /* the old open one if there is one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1455 this.fnClose( nTr );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1456
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1457 var nNewRow = document.createElement("tr");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1458 var nNewCell = document.createElement("td");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1459 nNewRow.appendChild( nNewCell );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1460 nNewCell.className = sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1461 nNewCell.colSpan = _fnVisbleColumns( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1462 nNewCell.innerHTML = sHtml;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1463
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1464 /* If the nTr isn't on the page at the moment - then we don't insert at the moment */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1465 var nTrs = $('tbody tr', oSettings.nTable);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1466 if ( $.inArray(nTr, nTrs) != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1467 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1468 $(nNewRow).insertAfter(nTr);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1469 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1470
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1471 /* No point in storing the row if using server-side processing since the nParent will be
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1472 * nuked on a re-draw anyway
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1473 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1474 if ( !oSettings.oFeatures.bServerSide )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1475 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1476 oSettings.aoOpenRows.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1477 "nTr": nNewRow,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1478 "nParent": nTr
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1479 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1480 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1481
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1482 return nNewRow;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1483 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1484
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1485 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1486 * Function: fnClose
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1487 * Purpose: Close a display row
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1488 * Returns: int: 0 (success) or 1 (failed)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1489 * Inputs: node:nTr - the table row to 'close'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1490 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1491 this.fnClose = function( nTr )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1492 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1493 /* Find settings from table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1494 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1495
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1496 for ( var i=0 ; i<oSettings.aoOpenRows.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1497 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1498 if ( oSettings.aoOpenRows[i].nParent == nTr )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1499 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1500 var nTrParent = oSettings.aoOpenRows[i].nTr.parentNode;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1501 if ( nTrParent )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1502 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1503 /* Remove it if it is currently on display */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1504 nTrParent.removeChild( oSettings.aoOpenRows[i].nTr );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1505 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1506 oSettings.aoOpenRows.splice( i, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1507 return 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1508 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1509 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1510 return 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1511 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1512
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1513 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1514 * Function: fnGetData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1515 * Purpose: Return an array with the data which is used to make up the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1516 * Returns: array array string: 2d data array ([row][column]) or array string: 1d data array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1517 * or
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1518 * array string (if iRow specified)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1519 * Inputs: mixed:mRow - optional - if not present, then the full 2D array for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1520 * if given then:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1521 * int: - return 1D array for aoData entry of this index
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1522 * node(TR): - return 1D array for this TR element
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1523 * Inputs: int:iRow - optional - if present then the array returned will be the data for
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1524 * the row with the index 'iRow'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1525 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1526 this.fnGetData = function( mRow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1527 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1528 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1529
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1530 if ( typeof mRow != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1531 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1532 var iRow = (typeof mRow == 'object') ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1533 _fnNodeToDataIndex(oSettings, mRow) : mRow;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1534 return oSettings.aoData[iRow]._aData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1535 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1536 return _fnGetDataMaster( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1537 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1538
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1539 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1540 * Function: fnGetNodes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1541 * Purpose: Return an array with the TR nodes used for drawing the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1542 * Returns: array node: TR elements
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1543 * or
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1544 * node (if iRow specified)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1545 * Inputs: int:iRow - optional - if present then the array returned will be the node for
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1546 * the row with the index 'iRow'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1547 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1548 this.fnGetNodes = function( iRow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1549 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1550 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1551
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1552 if ( typeof iRow != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1553 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1554 return oSettings.aoData[iRow].nTr;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1555 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1556 return _fnGetTrNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1557 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1558
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1559 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1560 * Function: fnGetPosition
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1561 * Purpose: Get the array indexes of a particular cell from it's DOM element
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1562 * Returns: int: - row index, or array[ int, int, int ]: - row index, column index (visible)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1563 * and column index including hidden columns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1564 * Inputs: node:nNode - this can either be a TR or a TD in the table, the return is
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1565 * dependent on this input
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1566 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1567 this.fnGetPosition = function( nNode )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1568 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1569 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1570 var i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1571
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1572 if ( nNode.nodeName == "TR" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1573 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1574 return _fnNodeToDataIndex(oSettings, nNode);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1575 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1576 else if ( nNode.nodeName == "TD" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1577 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1578 var iDataIndex = _fnNodeToDataIndex(oSettings, nNode.parentNode);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1579 var iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1580 for ( var j=0 ; j<oSettings.aoColumns.length ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1581 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1582 if ( oSettings.aoColumns[j].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1583 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1584 if ( oSettings.aoData[iDataIndex].nTr.getElementsByTagName('td')[j-iCorrector] == nNode )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1585 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1586 return [ iDataIndex, j-iCorrector, j ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1587 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1588 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1589 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1590 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1591 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1592 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1593 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1594 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1595 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1596 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1597
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1598 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1599 * Function: fnUpdate
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1600 * Purpose: Update a table cell or row
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1601 * Returns: int: 0 okay, 1 error
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1602 * Inputs: array string 'or' string:mData - data to update the cell/row with
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1603 * mixed:mRow -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1604 * int: - index of aoData to be updated, or
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1605 * node(TR): - TR element you want to update
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1606 * int:iColumn - the column to update - optional (not used of mData is 2D)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1607 * bool:bRedraw - redraw the table or not - default true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1608 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1609 this.fnUpdate = function( mData, mRow, iColumn, bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1610 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1611 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1612 var iVisibleColumn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1613 var sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1614 var iRow = (typeof mRow == 'object') ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1615 _fnNodeToDataIndex(oSettings, mRow) : mRow;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1616
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1617 if ( typeof mData != 'object' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1618 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1619 sDisplay = mData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1620 oSettings.aoData[iRow]._aData[iColumn] = sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1621
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1622 if ( oSettings.aoColumns[iColumn].fnRender !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1623 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1624 sDisplay = oSettings.aoColumns[iColumn].fnRender( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1625 "iDataRow": iRow,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1626 "iDataColumn": iColumn,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1627 "aData": oSettings.aoData[iRow]._aData,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1628 "oSettings": oSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1629 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1630
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1631 if ( oSettings.aoColumns[iColumn].bUseRendered )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1632 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1633 oSettings.aoData[iRow]._aData[iColumn] = sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1634 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1635 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1636
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1637 iVisibleColumn = _fnColumnIndexToVisible( oSettings, iColumn );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1638 if ( iVisibleColumn !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1639 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1640 oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1641 sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1642 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1643 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1644 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1645 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1646 if ( mData.length != oSettings.aoColumns.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1647 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1648 alert( 'DataTables warning: An array passed to fnUpdate must have the same number of '+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1649 'columns as the table in question - in this case '+oSettings.aoColumns.length );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1650 return 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1651 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1652
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1653 for ( var i=0 ; i<mData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1654 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1655 sDisplay = mData[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1656 oSettings.aoData[iRow]._aData[i] = sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1657
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1658 if ( oSettings.aoColumns[i].fnRender !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1659 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1660 sDisplay = oSettings.aoColumns[i].fnRender( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1661 "iDataRow": iRow,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1662 "iDataColumn": i,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1663 "aData": oSettings.aoData[iRow]._aData,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1664 "oSettings": oSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1665 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1666
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1667 if ( oSettings.aoColumns[i].bUseRendered )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1668 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1669 oSettings.aoData[iRow]._aData[i] = sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1670 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1671 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1672
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1673 iVisibleColumn = _fnColumnIndexToVisible( oSettings, i );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1674 if ( iVisibleColumn !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1675 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1676 oSettings.aoData[iRow].nTr.getElementsByTagName('td')[iVisibleColumn].innerHTML =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1677 sDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1678 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1679 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1680 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1681
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1682 /* Update the search array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1683 _fnBuildSearchArray( oSettings, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1684
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1685 /* Redraw the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1686 if ( typeof bRedraw != 'undefined' && bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1687 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1688 _fnReDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1689 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1690 return 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1691 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1692
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1693
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1694 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1695 * Function: fnShowColoumn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1696 * Purpose: Show a particular column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1697 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1698 * Inputs: int:iCol - the column whose display should be changed
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1699 * bool:bShow - show (true) or hide (false) the column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1700 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1701 this.fnSetColumnVis = function ( iCol, bShow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1702 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1703 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1704 var i, iLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1705 var iColumns = oSettings.aoColumns.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1706 var nTd, anTds;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1707
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1708 /* No point in doing anything if we are requesting what is already true */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1709 if ( oSettings.aoColumns[iCol].bVisible == bShow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1710 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1711 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1712 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1713
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1714 var nTrHead = $('thead:eq(0)>tr', oSettings.nTable)[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1715 var nTrFoot = $('tfoot:eq(0)>tr', oSettings.nTable)[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1716 var anTheadTh = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1717 var anTfootTh = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1718 for ( i=0 ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1719 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1720 anTheadTh.push( oSettings.aoColumns[i].nTh );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1721 anTfootTh.push( oSettings.aoColumns[i].nTf );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1722 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1723
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1724 /* Show the column */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1725 if ( bShow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1726 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1727 var iInsert = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1728 for ( i=0 ; i<iCol ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1729 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1730 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1731 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1732 iInsert++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1733 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1734 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1735
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1736 /* Need to decide if we should use appendChild or insertBefore */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1737 if ( iInsert >= _fnVisbleColumns( oSettings ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1738 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1739 nTrHead.appendChild( anTheadTh[iCol] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1740 if ( nTrFoot )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1741 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1742 nTrFoot.appendChild( anTfootTh[iCol] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1743 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1744
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1745 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1746 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1747 nTd = oSettings.aoData[i]._anHidden[iCol];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1748 oSettings.aoData[i].nTr.appendChild( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1749 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1750 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1751 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1752 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1753 /* Which coloumn should we be inserting before? */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1754 var iBefore;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1755 for ( i=iCol ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1756 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1757 iBefore = _fnColumnIndexToVisible( oSettings, i );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1758 if ( iBefore !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1759 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1760 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1761 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1762 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1763
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1764 nTrHead.insertBefore( anTheadTh[iCol], nTrHead.getElementsByTagName('th')[iBefore] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1765 if ( nTrFoot )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1766 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1767 nTrFoot.insertBefore( anTfootTh[iCol], nTrFoot.getElementsByTagName('th')[iBefore] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1768 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1769
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1770 anTds = _fnGetTdNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1771 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1772 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1773 nTd = oSettings.aoData[i]._anHidden[iCol];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1774 oSettings.aoData[i].nTr.insertBefore( nTd, $('>td:eq('+iBefore+')',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1775 oSettings.aoData[i].nTr)[0] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1776 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1777 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1778
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1779 oSettings.aoColumns[iCol].bVisible = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1780 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1781 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1782 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1783 /* Remove a column from display */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1784 nTrHead.removeChild( anTheadTh[iCol] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1785 if ( nTrFoot )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1786 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1787 nTrFoot.removeChild( anTfootTh[iCol] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1788 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1789
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1790 anTds = _fnGetTdNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1791 for ( i=0, iLen=oSettings.aoData.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1792 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1793 nTd = anTds[ ( i*oSettings.aoColumns.length) + iCol ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1794 oSettings.aoData[i]._anHidden[iCol] = nTd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1795 nTd.parentNode.removeChild( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1796 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1797
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1798 oSettings.aoColumns[iCol].bVisible = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1799 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1800
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1801 /* If there are any 'open' rows, then we need to alter the colspan for this col change */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1802 for ( i=0, iLen=oSettings.aoOpenRows.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1803 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1804 oSettings.aoOpenRows[i].nTr.colSpan = _fnVisbleColumns( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1805 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1806
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1807 /* Since there is no redraw done here, we need to save the state manually */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1808 _fnSaveState( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1809 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1810
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1811 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1812 * Function: fnPageChange
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1813 * Purpose: Change the pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1814 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1815 * Inputs: string:sAction - paging action to take: "first", "previous", "next" or "last"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1816 * bool:bRedraw - redraw the table or not - optional - default true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1817 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1818 this.fnPageChange = function ( sAction, bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1819 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1820 var oSettings = _fnSettingsFromNode( this[_oExt.iApiIndex] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1821 _fnPageChange( oSettings, sAction );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1822 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1823
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1824 if ( typeof bRedraw == 'undefined' || bRedraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1825 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1826 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1827 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1828 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1829
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1830
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1831 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1832 * Plugin API functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1833 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1834 * This call will add the functions which are defined in _oExt.oApi to the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1835 * DataTables object, providing a rather nice way to allow plug-in API functions. Note that
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1836 * this is done here, so that API function can actually override the built in API functions if
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1837 * required for a particular purpose.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1838 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1839
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1840 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1841 * Function: _fnExternApiFunc
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1842 * Purpose: Create a wrapper function for exporting an internal func to an external API func
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1843 * Returns: function: - wrapped function
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1844 * Inputs: string:sFunc - API function name
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1845 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1846 function _fnExternApiFunc (sFunc)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1847 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1848 return function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1849 var aArgs = [_fnSettingsFromNode(this[_oExt.iApiIndex])].concat(
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1850 Array.prototype.slice.call(arguments) );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1851 return _oExt.oApi[sFunc].apply( this, aArgs );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1852 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1853 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1854
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1855 for ( var sFunc in _oExt.oApi )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1856 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1857 if ( sFunc )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1858 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1859 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1860 * Function: anon
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1861 * Purpose: Wrap the plug-in API functions in order to provide the settings as 1st arg
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1862 * and execute in this scope
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1863 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1864 * Inputs: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1865 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1866 this[sFunc] = _fnExternApiFunc(sFunc);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1867 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1868 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1869
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1870
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1871
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1872 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1873 * Section - Local functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1874 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1875
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1876 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1877 * Section - Initalisation
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1878 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1879
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1880 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1881 * Function: _fnInitalise
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1882 * Purpose: Draw the table for the first time, adding all required features
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1883 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1884 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1885 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1886 function _fnInitalise ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1887 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1888 /* Ensure that the table data is fully initialised */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1889 if ( oSettings.bInitialised === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1890 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1891 setTimeout( function(){ _fnInitalise( oSettings ); }, 200 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1892 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1893 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1894
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1895 /* Show the display HTML options */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1896 _fnAddOptionsHtml( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1897
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1898 /* Draw the headers for the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1899 _fnDrawHead( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1900
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1901 /* If there is default sorting required - let's do it. The sort function
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1902 * will do the drawing for us. Otherwise we draw the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1903 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1904 if ( oSettings.oFeatures.bSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1905 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1906 _fnSort( oSettings, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1907 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1908 * Add the sorting classes to the header and the body (if needed).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1909 * Reason for doing it here after the first draw is to stop classes being applied to the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1910 * 'static' table.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1911 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1912 _fnSortingClasses( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1913 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1914 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1915 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1916 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1917 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1918 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1919 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1920
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1921 /* if there is an ajax source */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1922 if ( oSettings.sAjaxSource !== null && !oSettings.oFeatures.bServerSide )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1923 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1924 _fnProcessingDisplay( oSettings, true );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1925
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1926 oSettings.fnServerData( oSettings.sAjaxSource, null, function(json) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1927
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1928 /* Got the data - add it to the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1929 for ( var i=0 ; i<json.aaData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1930 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1931 _fnAddData( oSettings, json.aaData[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1932 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1933
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1934 /* Reset the init display for cookie saving. We've already done a filter, and
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1935 * therefore cleared it before. So we need to make it appear 'fresh'
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1936 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1937 oSettings.iInitDisplayStart = oSettings._iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1938
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1939 if ( oSettings.oFeatures.bSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1940 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1941 _fnSort( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1942 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1943 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1944 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1945 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1946 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1947 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1948 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1949
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1950 _fnProcessingDisplay( oSettings, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1951
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1952 /* Run the init callback if there is one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1953 if ( typeof oSettings.fnInitComplete == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1954 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1955 oSettings.fnInitComplete( oSettings, json );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1956 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1957 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1958 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1959 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1960
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1961 /* Run the init callback if there is one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1962 if ( typeof oSettings.fnInitComplete == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1963 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1964 oSettings.fnInitComplete( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1965 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1966
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1967 if ( !oSettings.oFeatures.bServerSide )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1968 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1969 _fnProcessingDisplay( oSettings, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1970 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1971 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1972
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1973 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1974 * Function: _fnLanguageProcess
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1975 * Purpose: Copy language variables from remote object to a local one
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1976 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1977 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1978 * object:oLanguage - Language information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1979 * bool:bInit - init once complete
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1980 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1981 function _fnLanguageProcess( oSettings, oLanguage, bInit )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1982 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1983 _fnMap( oSettings.oLanguage, oLanguage, 'sProcessing' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1984 _fnMap( oSettings.oLanguage, oLanguage, 'sLengthMenu' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1985 _fnMap( oSettings.oLanguage, oLanguage, 'sZeroRecords' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1986 _fnMap( oSettings.oLanguage, oLanguage, 'sInfo' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1987 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoEmpty' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1988 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoFiltered' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1989 _fnMap( oSettings.oLanguage, oLanguage, 'sInfoPostFix' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1990 _fnMap( oSettings.oLanguage, oLanguage, 'sSearch' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1991
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1992 if ( typeof oLanguage.oPaginate != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1993 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1994 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sFirst' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1995 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sPrevious' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1996 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sNext' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1997 _fnMap( oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sLast' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1998 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
1999
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2000 if ( bInit )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2001 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2002 _fnInitalise( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2003 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2004 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2005
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2006 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2007 * Function: _fnAddColumn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2008 * Purpose: Add a column to the list used for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2009 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2010 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2011 * object:oOptions - object with sType, bVisible and bSearchable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2012 * node:nTh - the th element for this column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2013 * Notes: All options in enter column can be over-ridden by the user
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2014 * initialisation of dataTables
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2015 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2016 function _fnAddColumn( oSettings, oOptions, nTh )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2017 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2018 oSettings.aoColumns[ oSettings.aoColumns.length++ ] = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2019 "sType": null,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2020 "_bAutoType": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2021 "bVisible": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2022 "bSearchable": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2023 "bSortable": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2024 "asSorting": [ 'asc', 'desc' ],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2025 "sSortingClass": oSettings.oClasses.sSortable,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2026 "sSortingClassJUI": oSettings.oClasses.sSortJUI,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2027 "sTitle": nTh ? nTh.innerHTML : '',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2028 "sName": '',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2029 "sWidth": null,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2030 "sClass": null,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2031 "fnRender": null,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2032 "bUseRendered": true,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2033 "iDataSort": oSettings.aoColumns.length-1,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2034 "sSortDataType": 'std',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2035 "nTh": nTh ? nTh : document.createElement('th'),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2036 "nTf": null
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2037 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2038
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2039 var iLength = oSettings.aoColumns.length-1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2040 var oCol = oSettings.aoColumns[ iLength ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2041
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2042 /* User specified column options */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2043 if ( typeof oOptions != 'undefined' && oOptions !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2044 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2045 if ( typeof oOptions.sType != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2046 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2047 oCol.sType = oOptions.sType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2048 oCol._bAutoType = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2049 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2050
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2051 _fnMap( oCol, oOptions, "bVisible" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2052 _fnMap( oCol, oOptions, "bSearchable" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2053 _fnMap( oCol, oOptions, "bSortable" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2054 _fnMap( oCol, oOptions, "sTitle" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2055 _fnMap( oCol, oOptions, "sName" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2056 _fnMap( oCol, oOptions, "sWidth" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2057 _fnMap( oCol, oOptions, "sClass" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2058 _fnMap( oCol, oOptions, "fnRender" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2059 _fnMap( oCol, oOptions, "bUseRendered" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2060 _fnMap( oCol, oOptions, "iDataSort" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2061 _fnMap( oCol, oOptions, "asSorting" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2062 _fnMap( oCol, oOptions, "sSortDataType" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2063 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2064
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2065 /* Feature sorting overrides column specific when off */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2066 if ( !oSettings.oFeatures.bSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2067 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2068 oCol.bSortable = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2069 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2070
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2071 /* Check that the class assignment is correct for sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2072 if ( !oCol.bSortable ||
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2073 ($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2074 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2075 oCol.sSortingClass = oSettings.oClasses.sSortableNone;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2076 oCol.sSortingClassJUI = "";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2077 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2078 else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2079 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2080 oCol.sSortingClass = oSettings.oClasses.sSortableAsc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2081 oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIAscAllowed;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2082 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2083 else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2084 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2085 oCol.sSortingClass = oSettings.oClasses.sSortableDesc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2086 oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIDescAllowed;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2087 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2088
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2089 /* Add a column specific filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2090 if ( typeof oSettings.aoPreSearchCols[ iLength ] == 'undefined' ||
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2091 oSettings.aoPreSearchCols[ iLength ] === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2092 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2093 oSettings.aoPreSearchCols[ iLength ] = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2094 "sSearch": "",
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2095 "bEscapeRegex": true
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2096 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2097 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2098 else if ( typeof oSettings.aoPreSearchCols[ iLength ].bEscapeRegex == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2099 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2100 /* Don't require that the user must specify bEscapeRegex */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2101 oSettings.aoPreSearchCols[ iLength ].bEscapeRegex = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2102 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2103 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2104
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2105 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2106 * Function: _fnAddData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2107 * Purpose: Add a data array to the table, creating DOM node etc
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2108 * Returns: int: - >=0 if successful (index of new aoData entry), -1 if failed
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2109 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2110 * array:aData - data array to be added
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2111 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2112 function _fnAddData ( oSettings, aData )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2113 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2114 /* Sanity check the length of the new array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2115 if ( aData.length != oSettings.aoColumns.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2116 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2117 alert( "DataTables warning: Added data does not match known number of columns" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2118 return -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2119 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2120
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2121 /* Create the object for storing information about this new row */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2122 var iThisIndex = oSettings.aoData.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2123 oSettings.aoData.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2124 "nTr": document.createElement('tr'),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2125 "_iId": oSettings.iNextId++,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2126 "_aData": aData.slice(),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2127 "_anHidden": [],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2128 "_sRowStripe": ''
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2129 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2130
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2131 /* Create the cells */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2132 var nTd, sThisType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2133 for ( var i=0 ; i<aData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2134 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2135 nTd = document.createElement('td');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2136
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2137 if ( typeof oSettings.aoColumns[i].fnRender == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2138 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2139 var sRendered = oSettings.aoColumns[i].fnRender( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2140 "iDataRow": iThisIndex,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2141 "iDataColumn": i,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2142 "aData": aData,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2143 "oSettings": oSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2144 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2145 nTd.innerHTML = sRendered;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2146 if ( oSettings.aoColumns[i].bUseRendered )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2147 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2148 /* Use the rendered data for filtering/sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2149 oSettings.aoData[iThisIndex]._aData[i] = sRendered;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2150 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2151 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2152 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2153 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2154 nTd.innerHTML = aData[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2155 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2156
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2157 if ( oSettings.aoColumns[i].sClass !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2158 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2159 nTd.className = oSettings.aoColumns[i].sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2160 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2161
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2162 /* See if we should auto-detect the column type */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2163 if ( oSettings.aoColumns[i]._bAutoType && oSettings.aoColumns[i].sType != 'string' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2164 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2165 /* Attempt to auto detect the type - same as _fnGatherData() */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2166 sThisType = _fnDetectType( oSettings.aoData[iThisIndex]._aData[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2167 if ( oSettings.aoColumns[i].sType === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2168 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2169 oSettings.aoColumns[i].sType = sThisType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2170 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2171 else if ( oSettings.aoColumns[i].sType != sThisType )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2172 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2173 /* String is always the 'fallback' option */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2174 oSettings.aoColumns[i].sType = 'string';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2175 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2176 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2177
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2178 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2179 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2180 oSettings.aoData[iThisIndex].nTr.appendChild( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2181 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2182 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2183 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2184 oSettings.aoData[iThisIndex]._anHidden[i] = nTd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2185 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2186 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2187
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2188 /* Add to the display array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2189 oSettings.aiDisplayMaster.push( iThisIndex );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2190 return iThisIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2191 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2192
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2193 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2194 * Function: _fnGatherData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2195 * Purpose: Read in the data from the target table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2196 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2197 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2198 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2199 function _fnGatherData( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2200 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2201 var iLoop, i, iLen, j, jLen, jInner,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2202 nTds, nTrs, nTd, aLocalData, iThisIndex,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2203 iRow, iRows, iColumn, iColumns;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2204
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2205 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2206 * Process by row first
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2207 * Add the data object for the whole table - storing the tr node. Note - no point in getting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2208 * DOM based data if we are going to go and replace it with Ajax source data.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2209 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2210 if ( oSettings.sAjaxSource === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2211 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2212 nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2213 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2214 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2215 if ( nTrs[i].nodeName == "TR" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2216 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2217 iThisIndex = oSettings.aoData.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2218 oSettings.aoData.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2219 "nTr": nTrs[i],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2220 "_iId": oSettings.iNextId++,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2221 "_aData": [],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2222 "_anHidden": [],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2223 "_sRowStripe": ''
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2224 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2225
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2226 oSettings.aiDisplayMaster.push( iThisIndex );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2227
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2228 aLocalData = oSettings.aoData[iThisIndex]._aData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2229 nTds = nTrs[i].childNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2230 jInner = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2231
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2232 for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2233 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2234 if ( nTds[j].nodeName == "TD" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2235 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2236 aLocalData[jInner] = nTds[j].innerHTML;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2237 jInner++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2238 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2239 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2240 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2241 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2242 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2243
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2244 /* Gather in the TD elements of the Table - note that this is basically the same as
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2245 * fnGetTdNodes, but that function takes account of hidden columns, which we haven't yet
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2246 * setup!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2247 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2248 nTrs = _fnGetTrNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2249 nTds = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2250 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2251 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2252 for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2253 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2254 nTd = nTrs[i].childNodes[j];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2255 if ( nTd.nodeName == "TD" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2256 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2257 nTds.push( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2258 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2259 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2260 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2261
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2262 /* Sanity check */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2263 if ( nTds.length != nTrs.length * oSettings.aoColumns.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2264 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2265 alert( "DataTables warning: Unexpected number of TD elements. Expected "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2266 (nTrs.length * oSettings.aoColumns.length)+" and got "+nTds.length+". DataTables does "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2267 "not support rowspan / colspan in the table body, and there must be one cell for each "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2268 "row/column combination." );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2269 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2270
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2271 /* Now process by column */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2272 for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2273 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2274 /* Get the title of the column - unless there is a user set one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2275 if ( oSettings.aoColumns[iColumn].sTitle === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2276 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2277 oSettings.aoColumns[iColumn].sTitle = oSettings.aoColumns[iColumn].nTh.innerHTML;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2278 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2279
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2280 var
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2281 bAutoType = oSettings.aoColumns[iColumn]._bAutoType,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2282 bRender = typeof oSettings.aoColumns[iColumn].fnRender == 'function',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2283 bClass = oSettings.aoColumns[iColumn].sClass !== null,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2284 bVisible = oSettings.aoColumns[iColumn].bVisible,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2285 nCell, sThisType, sRendered;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2286
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2287 /* A single loop to rule them all (and be more efficient) */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2288 if ( bAutoType || bRender || bClass || !bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2289 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2290 for ( iRow=0, iRows=oSettings.aoData.length ; iRow<iRows ; iRow++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2291 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2292 nCell = nTds[ (iRow*iColumns) + iColumn ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2293
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2294 /* Type detection */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2295 if ( bAutoType )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2296 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2297 if ( oSettings.aoColumns[iColumn].sType != 'string' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2298 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2299 sThisType = _fnDetectType( oSettings.aoData[iRow]._aData[iColumn] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2300 if ( oSettings.aoColumns[iColumn].sType === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2301 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2302 oSettings.aoColumns[iColumn].sType = sThisType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2303 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2304 else if ( oSettings.aoColumns[iColumn].sType != sThisType )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2305 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2306 /* String is always the 'fallback' option */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2307 oSettings.aoColumns[iColumn].sType = 'string';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2308 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2309 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2310 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2311
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2312 /* Rendering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2313 if ( bRender )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2314 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2315 sRendered = oSettings.aoColumns[iColumn].fnRender( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2316 "iDataRow": iRow,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2317 "iDataColumn": iColumn,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2318 "aData": oSettings.aoData[iRow]._aData,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2319 "oSettings": oSettings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2320 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2321 nCell.innerHTML = sRendered;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2322 if ( oSettings.aoColumns[iColumn].bUseRendered )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2323 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2324 /* Use the rendered data for filtering/sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2325 oSettings.aoData[iRow]._aData[iColumn] = sRendered;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2326 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2327 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2328
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2329 /* Classes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2330 if ( bClass )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2331 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2332 nCell.className += ' '+oSettings.aoColumns[iColumn].sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2333 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2334
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2335 /* Column visability */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2336 if ( !bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2337 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2338 oSettings.aoData[iRow]._anHidden[iColumn] = nCell;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2339 nCell.parentNode.removeChild( nCell );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2340 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2341 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2342 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2343 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2344 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2345
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2346
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2347
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2348 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2349 * Section - Drawing functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2350 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2351
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2352 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2353 * Function: _fnDrawHead
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2354 * Purpose: Create the HTML header for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2355 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2356 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2357 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2358 function _fnDrawHead( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2359 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2360 var i, nTh, iLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2361 var iThs = oSettings.nTable.getElementsByTagName('thead')[0].getElementsByTagName('th').length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2362 var iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2363
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2364 /* If there is a header in place - then use it - otherwise it's going to get nuked... */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2365 if ( iThs !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2366 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2367 /* We've got a thead from the DOM, so remove hidden columns and apply width to vis cols */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2368 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2369 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2370 //oSettings.aoColumns[i].nTh = nThs[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2371 nTh = oSettings.aoColumns[i].nTh;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2372
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2373 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2374 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2375 /* Set width */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2376 if ( oSettings.aoColumns[i].sWidth !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2377 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2378 nTh.style.width = oSettings.aoColumns[i].sWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2379 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2380
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2381 /* Set the title of the column if it is user defined (not what was auto detected) */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2382 if ( oSettings.aoColumns[i].sTitle != nTh.innerHTML )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2383 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2384 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2385 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2386 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2387 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2388 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2389 nTh.parentNode.removeChild( nTh );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2390 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2391 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2392 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2393 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2394 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2395 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2396 /* We don't have a header in the DOM - so we are going to have to create one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2397 var nTr = document.createElement( "tr" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2398
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2399 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2400 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2401 nTh = oSettings.aoColumns[i].nTh;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2402 nTh.innerHTML = oSettings.aoColumns[i].sTitle;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2403
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2404 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2405 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2406 if ( oSettings.aoColumns[i].sClass !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2407 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2408 nTh.className = oSettings.aoColumns[i].sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2409 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2410
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2411 if ( oSettings.aoColumns[i].sWidth !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2412 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2413 nTh.style.width = oSettings.aoColumns[i].sWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2414 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2415
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2416 nTr.appendChild( nTh );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2417 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2418 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2419 $('thead:eq(0)', oSettings.nTable).html( '' )[0].appendChild( nTr );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2420 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2421
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2422 /* Add the extra markup needed by jQuery UI's themes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2423 if ( oSettings.bJUI )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2424 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2425 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2426 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2427 oSettings.aoColumns[i].nTh.insertBefore( document.createElement('span'),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2428 oSettings.aoColumns[i].nTh.firstChild );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2429 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2430 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2431
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2432 /* Add sort listener */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2433 if ( oSettings.oFeatures.bSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2434 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2435 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2436 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2437 if ( oSettings.aoColumns[i].bSortable !== false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2438 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2439 _fnSortAttachListener( oSettings, oSettings.aoColumns[i].nTh, i );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2440 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2441 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2442 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2443 $(oSettings.aoColumns[i].nTh).addClass( oSettings.oClasses.sSortableNone );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2444 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2445 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2446
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2447 /* Take the brutal approach to cancelling text selection due to the shift key */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2448 $('thead:eq(0) th', oSettings.nTable).mousedown( function (e) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2449 if ( e.shiftKey )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2450 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2451 this.onselectstart = function() { return false; };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2452 return false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2453 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2454 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2455 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2456
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2457 /* Cache the footer elements */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2458 var nTfoot = oSettings.nTable.getElementsByTagName('tfoot');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2459 if ( nTfoot.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2460 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2461 iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2462 var nTfs = nTfoot[0].getElementsByTagName('th');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2463 for ( i=0, iLen=nTfs.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2464 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2465 oSettings.aoColumns[i].nTf = nTfs[i-iCorrector];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2466 if ( !oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2467 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2468 nTfs[i-iCorrector].parentNode.removeChild( nTfs[i-iCorrector] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2469 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2470 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2471 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2472 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2473 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2474
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2475 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2476 * Function: _fnDraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2477 * Purpose: Insert the required TR nodes into the table for display
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2478 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2479 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2480 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2481 function _fnDraw( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2482 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2483 var i, iLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2484 var anRows = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2485 var iRowCount = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2486 var bRowError = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2487 var iStrips = oSettings.asStripClasses.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2488 var iOpenRows = oSettings.aoOpenRows.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2489
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2490 /* If we are dealing with Ajax - do it here */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2491 if ( oSettings.oFeatures.bServerSide &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2492 !_fnAjaxUpdate( oSettings ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2493 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2494 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2495 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2496
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2497 /* Check and see if we have an initial draw position from state saving */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2498 if ( typeof oSettings.iInitDisplayStart != 'undefined' && oSettings.iInitDisplayStart != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2499 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2500 oSettings._iDisplayStart = (oSettings.iInitDisplayStart >= oSettings.fnRecordsDisplay()) ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2501 0 : oSettings.iInitDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2502 oSettings.iInitDisplayStart = -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2503 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2504 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2505
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2506 if ( oSettings.aiDisplay.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2507 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2508 var iStart = oSettings._iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2509 var iEnd = oSettings._iDisplayEnd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2510
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2511 if ( oSettings.oFeatures.bServerSide )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2512 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2513 iStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2514 iEnd = oSettings.aoData.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2515 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2516
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2517 for ( var j=iStart ; j<iEnd ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2518 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2519 var aoData = oSettings.aoData[ oSettings.aiDisplay[j] ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2520 var nRow = aoData.nTr;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2521
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2522 /* Remove the old stripping classes and then add the new one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2523 if ( iStrips !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2524 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2525 var sStrip = oSettings.asStripClasses[ iRowCount % iStrips ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2526 if ( aoData._sRowStripe != sStrip )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2527 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2528 $(nRow).removeClass( aoData._sRowStripe ).addClass( sStrip );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2529 aoData._sRowStripe = sStrip;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2530 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2531 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2532
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2533 /* Custom row callback function - might want to manipule the row */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2534 if ( typeof oSettings.fnRowCallback == "function" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2535 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2536 nRow = oSettings.fnRowCallback( nRow,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2537 oSettings.aoData[ oSettings.aiDisplay[j] ]._aData, iRowCount, j );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2538 if ( !nRow && !bRowError )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2539 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2540 alert( "DataTables warning: A node was not returned by fnRowCallback" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2541 bRowError = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2542 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2543 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2544
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2545 anRows.push( nRow );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2546 iRowCount++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2547
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2548 /* If there is an open row - and it is attached to this parent - attach it on redraw */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2549 if ( iOpenRows !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2550 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2551 for ( var k=0 ; k<iOpenRows ; k++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2552 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2553 if ( nRow == oSettings.aoOpenRows[k].nParent )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2554 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2555 anRows.push( oSettings.aoOpenRows[k].nTr );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2556 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2557 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2558 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2559 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2560 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2561 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2562 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2563 /* Table is empty - create a row with an empty message in it */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2564 anRows[ 0 ] = document.createElement( 'tr' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2565
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2566 if ( typeof oSettings.asStripClasses[0] != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2567 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2568 anRows[ 0 ].className = oSettings.asStripClasses[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2569 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2570
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2571 var nTd = document.createElement( 'td' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2572 nTd.setAttribute( 'valign', "top" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2573 nTd.colSpan = oSettings.aoColumns.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2574 nTd.className = oSettings.oClasses.sRowEmpty;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2575 nTd.innerHTML = oSettings.oLanguage.sZeroRecords;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2576
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2577 anRows[ iRowCount ].appendChild( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2578 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2579
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2580 /* Callback the header and footer custom funcation if there is one */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2581 if ( typeof oSettings.fnHeaderCallback == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2582 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2583 oSettings.fnHeaderCallback( $('thead:eq(0)>tr', oSettings.nTable)[0],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2584 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2585 oSettings.aiDisplay );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2586 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2587
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2588 if ( typeof oSettings.fnFooterCallback == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2589 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2590 oSettings.fnFooterCallback( $('tfoot:eq(0)>tr', oSettings.nTable)[0],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2591 _fnGetDataMaster( oSettings ), oSettings._iDisplayStart, oSettings.fnDisplayEnd(),
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2592 oSettings.aiDisplay );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2593 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2594
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2595 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2596 * Need to remove any old row from the display - note we can't just empty the tbody using
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2597 * $().html('') since this will unbind the jQuery event handlers (even although the node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2598 * still exists!) - equally we can't use innerHTML, since IE throws an exception.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2599 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2600 var nBody = oSettings.nTable.getElementsByTagName('tbody');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2601 if ( nBody[0] )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2602 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2603 var nTrs = nBody[0].childNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2604 for ( i=nTrs.length-1 ; i>=0 ; i-- )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2605 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2606 nTrs[i].parentNode.removeChild( nTrs[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2607 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2608
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2609 /* Put the draw table into the dom */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2610 for ( i=0, iLen=anRows.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2611 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2612 nBody[0].appendChild( anRows[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2613 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2614 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2615
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2616 /* Call all required callback functions for the end of a draw */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2617 for ( i=0, iLen=oSettings.aoDrawCallback.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2618 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2619 oSettings.aoDrawCallback[i].fn( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2620 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2621
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2622 /* Draw is complete, sorting and filtering must be as well */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2623 oSettings.bSorted = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2624 oSettings.bFiltered = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2625
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2626 /* Perform certain DOM operations after the table has been drawn for the first time */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2627 if ( typeof oSettings._bInitComplete == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2628 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2629 oSettings._bInitComplete = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2630
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2631 /* Set an absolute width for the table such that pagination doesn't
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2632 * cause the table to resize
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2633 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2634 if ( oSettings.oFeatures.bAutoWidth && oSettings.nTable.offsetWidth !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2635 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2636 oSettings.nTable.style.width = oSettings.nTable.offsetWidth+"px";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2637 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2638 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2639 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2640
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2641 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2642 * Function: _fnReDraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2643 * Purpose: Redraw the table - taking account of the various features which are enabled
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2644 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2645 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2646 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2647 function _fnReDraw( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2648 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2649 if ( oSettings.oFeatures.bSort )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2650 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2651 /* Sorting will refilter and draw for us */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2652 _fnSort( oSettings, oSettings.oPreviousSearch );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2653 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2654 else if ( oSettings.oFeatures.bFilter )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2655 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2656 /* Filtering will redraw for us */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2657 _fnFilterComplete( oSettings, oSettings.oPreviousSearch );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2658 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2659 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2660 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2661 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2662 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2663 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2664 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2665
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2666 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2667 * Function: _fnAjaxUpdate
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2668 * Purpose: Update the table using an Ajax call
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2669 * Returns: bool: block the table drawing or not
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2670 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2671 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2672 function _fnAjaxUpdate( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2673 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2674 if ( oSettings.bAjaxDataGet )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2675 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2676 _fnProcessingDisplay( oSettings, true );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2677 var iColumns = oSettings.aoColumns.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2678 var aoData = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2679 var i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2680
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2681 /* Paging and general */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2682 oSettings.iServerDraw++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2683 aoData.push( { "name": "sEcho", "value": oSettings.iServerDraw } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2684 aoData.push( { "name": "iColumns", "value": iColumns } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2685 aoData.push( { "name": "sColumns", "value": _fnColumnOrdering(oSettings) } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2686 aoData.push( { "name": "iDisplayStart", "value": oSettings._iDisplayStart } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2687 aoData.push( { "name": "iDisplayLength", "value": oSettings.oFeatures.bPaginate !== false ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2688 oSettings._iDisplayLength : -1 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2689
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2690 /* Filtering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2691 if ( oSettings.oFeatures.bFilter !== false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2692 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2693 aoData.push( { "name": "sSearch", "value": oSettings.oPreviousSearch.sSearch } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2694 aoData.push( { "name": "bEscapeRegex", "value": oSettings.oPreviousSearch.bEscapeRegex } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2695 for ( i=0 ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2696 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2697 aoData.push( { "name": "sSearch_"+i, "value": oSettings.aoPreSearchCols[i].sSearch } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2698 aoData.push( { "name": "bEscapeRegex_"+i, "value": oSettings.aoPreSearchCols[i].bEscapeRegex } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2699 aoData.push( { "name": "bSearchable_"+i, "value": oSettings.aoColumns[i].bSearchable } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2700 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2701 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2702
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2703 /* Sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2704 if ( oSettings.oFeatures.bSort !== false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2705 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2706 var iFixed = oSettings.aaSortingFixed !== null ? oSettings.aaSortingFixed.length : 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2707 var iUser = oSettings.aaSorting.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2708 aoData.push( { "name": "iSortingCols", "value": iFixed+iUser } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2709 for ( i=0 ; i<iFixed ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2710 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2711 aoData.push( { "name": "iSortCol_"+i, "value": oSettings.aaSortingFixed[i][0] } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2712 aoData.push( { "name": "sSortDir_"+i, "value": oSettings.aaSortingFixed[i][1] } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2713 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2714
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2715 for ( i=0 ; i<iUser ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2716 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2717 aoData.push( { "name": "iSortCol_"+(i+iFixed), "value": oSettings.aaSorting[i][0] } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2718 aoData.push( { "name": "sSortDir_"+(i+iFixed), "value": oSettings.aaSorting[i][1] } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2719 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2720
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2721 for ( i=0 ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2722 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2723 aoData.push( { "name": "bSortable_"+i, "value": oSettings.aoColumns[i].bSortable } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2724 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2725 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2726
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2727 oSettings.fnServerData( oSettings.sAjaxSource, aoData, function(json) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2728 _fnAjaxUpdateDraw( oSettings, json );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2729 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2730 return false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2731 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2732 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2733 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2734 return true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2735 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2736 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2737
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2738 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2739 * Function: _fnAjaxUpdateDraw
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2740 * Purpose: Data the data from the server (nuking the old) and redraw the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2741 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2742 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2743 * object:json - json data return from the server.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2744 * The following must be defined:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2745 * iTotalRecords, iTotalDisplayRecords, aaData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2746 * The following may be defined:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2747 * sColumns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2748 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2749 function _fnAjaxUpdateDraw ( oSettings, json )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2750 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2751 if ( typeof json.sEcho != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2752 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2753 /* Protect against old returns over-writing a new one. Possible when you get
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2754 * very fast interaction, and later queires are completed much faster
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2755 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2756 if ( json.sEcho*1 < oSettings.iServerDraw )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2757 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2758 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2759 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2760 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2761 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2762 oSettings.iServerDraw = json.sEcho * 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2763 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2764 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2765
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2766 _fnClearTable( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2767 oSettings._iRecordsTotal = json.iTotalRecords;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2768 oSettings._iRecordsDisplay = json.iTotalDisplayRecords;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2769
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2770 /* Determine if reordering is required */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2771 var sOrdering = _fnColumnOrdering(oSettings);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2772 var bReOrder = (typeof json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2773 if ( bReOrder )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2774 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2775 var aiIndex = _fnReOrderIndex( oSettings, json.sColumns );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2776 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2777
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2778 for ( var i=0, iLen=json.aaData.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2779 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2780 if ( bReOrder )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2781 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2782 /* If we need to re-order, then create a new array with the correct order and add it */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2783 var aData = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2784 for ( var j=0, jLen=oSettings.aoColumns.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2785 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2786 aData.push( json.aaData[i][ aiIndex[j] ] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2787 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2788 _fnAddData( oSettings, aData );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2789 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2790 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2791 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2792 /* No re-order required, sever got it "right" - just straight add */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2793 _fnAddData( oSettings, json.aaData[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2794 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2795 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2796 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2797
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2798 oSettings.bAjaxDataGet = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2799 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2800 oSettings.bAjaxDataGet = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2801 _fnProcessingDisplay( oSettings, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2802 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2803
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2804
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2805 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2806 * Section - Options (features) HTML
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2807 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2808
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2809 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2810 * Function: _fnAddOptionsHtml
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2811 * Purpose: Add the options to the page HTML for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2812 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2813 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2814 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2815 function _fnAddOptionsHtml ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2816 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2817 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2818 * Create a temporary, empty, div which we can later on replace with what we have generated
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2819 * we do it this way to rendering the 'options' html offline - speed :-)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2820 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2821 var nHolding = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2822 oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2823
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2824 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2825 * All DataTables are wrapped in a div - this is not currently optional - backwards
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2826 * compatability. It can be removed if you don't want it.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2827 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2828 var nWrapper = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2829 nWrapper.className = oSettings.oClasses.sWrapper;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2830 if ( oSettings.sTableId !== '' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2831 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2832 nWrapper.setAttribute( 'id', oSettings.sTableId+'_wrapper' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2833 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2834
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2835 /* Track where we want to insert the option */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2836 var nInsertNode = nWrapper;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2837
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2838 /* Substitute any constants in the dom string */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2839 var sDom = oSettings.sDom.replace( "H", "fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2840 sDom = sDom.replace( "F", "fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2841
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2842 /* Loop over the user set positioning and place the elements as needed */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2843 var aDom = sDom.split('');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2844 var nTmp, iPushFeature, cOption, nNewNode, cNext, sClass, j;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2845 for ( var i=0 ; i<aDom.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2846 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2847 iPushFeature = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2848 cOption = aDom[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2849
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2850 if ( cOption == '<' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2851 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2852 /* New container div */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2853 nNewNode = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2854
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2855 /* Check to see if we should append a class name to the container */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2856 cNext = aDom[i+1];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2857 if ( cNext == "'" || cNext == '"' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2858 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2859 sClass = "";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2860 j = 2;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2861 while ( aDom[i+j] != cNext )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2862 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2863 sClass += aDom[i+j];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2864 j++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2865 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2866 nNewNode.className = sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2867 i += j; /* Move along the position array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2868 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2869
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2870 nInsertNode.appendChild( nNewNode );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2871 nInsertNode = nNewNode;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2872 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2873 else if ( cOption == '>' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2874 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2875 /* End container div */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2876 nInsertNode = nInsertNode.parentNode;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2877 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2878 else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2879 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2880 /* Length */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2881 nTmp = _fnFeatureHtmlLength( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2882 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2883 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2884 else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2885 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2886 /* Filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2887 nTmp = _fnFeatureHtmlFilter( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2888 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2889 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2890 else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2891 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2892 /* pRocessing */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2893 nTmp = _fnFeatureHtmlProcessing( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2894 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2895 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2896 else if ( cOption == 't' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2897 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2898 /* Table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2899 nTmp = oSettings.nTable;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2900 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2901 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2902 else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2903 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2904 /* Info */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2905 nTmp = _fnFeatureHtmlInfo( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2906 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2907 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2908 else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2909 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2910 /* Pagination */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2911 nTmp = _fnFeatureHtmlPaginate( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2912 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2913 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2914 else if ( _oExt.aoFeatures.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2915 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2916 /* Plug-in features */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2917 var aoFeatures = _oExt.aoFeatures;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2918 for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2919 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2920 if ( cOption == aoFeatures[k].cFeature )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2921 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2922 nTmp = aoFeatures[k].fnInit( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2923 if ( nTmp )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2924 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2925 iPushFeature = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2926 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2927 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2928 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2929 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2930 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2931
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2932 /* Add to the 2D features array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2933 if ( iPushFeature == 1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2934 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2935 if ( typeof oSettings.aanFeatures[cOption] != 'object' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2936 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2937 oSettings.aanFeatures[cOption] = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2938 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2939 oSettings.aanFeatures[cOption].push( nTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2940 nInsertNode.appendChild( nTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2941 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2942 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2943
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2944 /* Built our DOM structure - replace the holding div with what we want */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2945 nHolding.parentNode.replaceChild( nWrapper, nHolding );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2946 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2947
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2948
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2949 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2950 * Section - Feature: Filtering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2951 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2952
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2953 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2954 * Function: _fnFeatureHtmlFilter
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2955 * Purpose: Generate the node required for filtering text
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2956 * Returns: node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2957 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2958 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2959 function _fnFeatureHtmlFilter ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2960 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2961 var nFilter = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2962 if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.f == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2963 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2964 nFilter.setAttribute( 'id', oSettings.sTableId+'_filter' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2965 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2966 nFilter.className = oSettings.oClasses.sFilter;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2967 var sSpace = oSettings.oLanguage.sSearch==="" ? "" : " ";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2968 nFilter.innerHTML = oSettings.oLanguage.sSearch+sSpace+'<input type="text" />';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2969
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2970 var jqFilter = $("input", nFilter);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2971 jqFilter.val( oSettings.oPreviousSearch.sSearch.replace('"','&quot;') );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2972 jqFilter.keyup( function(e) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2973 /* Update all other filter input elements for the new display */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2974 var n = oSettings.aanFeatures.f;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2975 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2976 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2977 if ( n[i] != this.parentNode )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2978 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2979 $('input', n[i]).val( this.value );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2980 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2981 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2982
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2983 /* Now do the filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2984 _fnFilterComplete( oSettings, {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2985 "sSearch": this.value,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2986 "bEscapeRegex": oSettings.oPreviousSearch.bEscapeRegex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2987 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2988 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2989
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2990 jqFilter.keypress( function(e) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2991 /* Prevent default */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2992 if ( e.keyCode == 13 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2993 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2994 return false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2995 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2996 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2997
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2998 return nFilter;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
2999 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3000
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3001 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3002 * Function: _fnFilterComplete
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3003 * Purpose: Filter the table using both the global filter and column based filtering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3004 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3005 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3006 * object:oSearch: search information
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3007 * int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3008 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3009 function _fnFilterComplete ( oSettings, oInput, iForce )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3010 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3011 /* Filter on everything */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3012 _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bEscapeRegex );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3013
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3014 /* Now do the individual column filter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3015 for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3016 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3017 _fnFilterColumn( oSettings, oSettings.aoPreSearchCols[i].sSearch, i,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3018 oSettings.aoPreSearchCols[i].bEscapeRegex );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3019 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3020
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3021 /* Custom filtering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3022 if ( _oExt.afnFiltering.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3023 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3024 _fnFilterCustom( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3025 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3026
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3027 /* Tell the draw function we have been filtering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3028 oSettings.bFiltered = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3029
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3030 /* Redraw the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3031 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3032 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3033 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3034
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3035 /* Rebuild search array 'offline' */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3036 _fnBuildSearchArray( oSettings, 0 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3037 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3038
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3039 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3040 * Function: _fnFilterCustom
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3041 * Purpose: Apply custom filtering functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3042 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3043 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3044 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3045 function _fnFilterCustom( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3046 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3047 var afnFilters = _oExt.afnFiltering;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3048 for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3049 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3050 var iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3051 for ( var j=0, jLen=oSettings.aiDisplay.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3052 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3053 var iDisIndex = oSettings.aiDisplay[j-iCorrector];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3054
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3055 /* Check if we should use this row based on the filtering function */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3056 if ( !afnFilters[i]( oSettings, oSettings.aoData[iDisIndex]._aData, iDisIndex ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3057 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3058 oSettings.aiDisplay.splice( j-iCorrector, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3059 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3060 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3061 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3062 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3063 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3064
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3065 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3066 * Function: _fnFilterColumn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3067 * Purpose: Filter the table on a per-column basis
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3068 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3069 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3070 * string:sInput - string to filter on
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3071 * int:iColumn - column to filter
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3072 * bool:bEscapeRegex - escape regex or not
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3073 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3074 function _fnFilterColumn ( oSettings, sInput, iColumn, bEscapeRegex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3075 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3076 if ( sInput === "" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3077 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3078 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3079 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3080
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3081 var iIndexCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3082 var sRegexMatch = bEscapeRegex ? _fnEscapeRegex( sInput ) : sInput;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3083 var rpSearch = new RegExp( sRegexMatch, "i" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3084
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3085 for ( var i=oSettings.aiDisplay.length-1 ; i>=0 ; i-- )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3086 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3087 var sData = _fnDataToSearch( oSettings.aoData[ oSettings.aiDisplay[i] ]._aData[iColumn],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3088 oSettings.aoColumns[iColumn].sType );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3089 if ( ! rpSearch.test( sData ) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3090 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3091 oSettings.aiDisplay.splice( i, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3092 iIndexCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3093 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3094 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3095 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3096
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3097 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3098 * Function: _fnFilter
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3099 * Purpose: Filter the data table based on user input and draw the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3100 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3101 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3102 * string:sInput - string to filter on
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3103 * int:iForce - optional - force a research of the master array (1) or not (undefined or 0)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3104 * bool:bEscapeRegex - escape regex or not
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3105 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3106 function _fnFilter( oSettings, sInput, iForce, bEscapeRegex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3107 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3108 var i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3109
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3110 /* Check if we are forcing or not - optional parameter */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3111 if ( typeof iForce == 'undefined' || iForce === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3112 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3113 iForce = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3114 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3115
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3116 /* Need to take account of custom filtering functions always */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3117 if ( _oExt.afnFiltering.length !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3118 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3119 iForce = 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3120 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3121
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3122 /* Generate the regular expression to use. Something along the lines of:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3123 * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3124 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3125 var asSearch = bEscapeRegex ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3126 _fnEscapeRegex( sInput ).split( ' ' ) :
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3127 sInput.split( ' ' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3128 var sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3129 var rpSearch = new RegExp( sRegExpString, "i" ); /* case insensitive */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3130
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3131 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3132 * If the input is blank - we want the full data set
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3133 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3134 if ( sInput.length <= 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3135 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3136 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3137 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3138 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3139 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3140 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3141 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3142 * We are starting a new search or the new search string is smaller
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3143 * then the old one (i.e. delete). Search from the master array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3144 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3145 if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length ||
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3146 oSettings.oPreviousSearch.sSearch.length > sInput.length || iForce == 1 ||
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3147 sInput.indexOf(oSettings.oPreviousSearch.sSearch) !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3148 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3149 /* Nuke the old display array - we are going to rebuild it */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3150 oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3151
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3152 /* Force a rebuild of the search array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3153 _fnBuildSearchArray( oSettings, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3154
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3155 /* Search through all records to populate the search array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3156 * The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3157 * mapping
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3158 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3159 for ( i=0 ; i<oSettings.aiDisplayMaster.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3160 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3161 if ( rpSearch.test(oSettings.asDataSearch[i]) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3162 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3163 oSettings.aiDisplay.push( oSettings.aiDisplayMaster[i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3164 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3165 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3166 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3167 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3168 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3169 /* Using old search array - refine it - do it this way for speed
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3170 * Don't have to search the whole master array again
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3171 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3172 var iIndexCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3173
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3174 /* Search the current results */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3175 for ( i=0 ; i<oSettings.asDataSearch.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3176 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3177 if ( ! rpSearch.test(oSettings.asDataSearch[i]) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3178 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3179 oSettings.aiDisplay.splice( i-iIndexCorrector, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3180 iIndexCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3181 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3182 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3183 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3184 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3185 oSettings.oPreviousSearch.sSearch = sInput;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3186 oSettings.oPreviousSearch.bEscapeRegex = bEscapeRegex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3187 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3188
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3189 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3190 * Function: _fnBuildSearchArray
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3191 * Purpose: Create an array which can be quickly search through
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3192 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3193 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3194 * int:iMaster - use the master data array - optional
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3195 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3196 function _fnBuildSearchArray ( oSettings, iMaster )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3197 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3198 /* Clear out the old data */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3199 oSettings.asDataSearch.splice( 0, oSettings.asDataSearch.length );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3200
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3201 var aArray = (typeof iMaster != 'undefined' && iMaster == 1) ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3202 oSettings.aiDisplayMaster : oSettings.aiDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3203
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3204 for ( var i=0, iLen=aArray.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3205 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3206 oSettings.asDataSearch[i] = '';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3207 for ( var j=0, jLen=oSettings.aoColumns.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3208 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3209 if ( oSettings.aoColumns[j].bSearchable )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3210 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3211 var sData = oSettings.aoData[ aArray[i] ]._aData[j];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3212 oSettings.asDataSearch[i] += _fnDataToSearch( sData, oSettings.aoColumns[j].sType )+' ';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3213 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3214 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3215 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3216 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3217
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3218 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3219 * Function: _fnDataToSearch
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3220 * Purpose: Convert raw data into something that the user can search on
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3221 * Returns: string: - search string
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3222 * Inputs: string:sData - data to be modified
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3223 * string:sType - data type
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3224 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3225 function _fnDataToSearch ( sData, sType )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3226 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3227
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3228 if ( typeof _oExt.ofnSearch[sType] == "function" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3229 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3230 return _oExt.ofnSearch[sType]( sData );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3231 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3232 else if ( sType == "html" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3233 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3234 return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3235 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3236 else if ( typeof sData == "string" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3237 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3238 return sData.replace(/\n/g," ");
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3239 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3240 return sData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3241 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3242
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3243
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3244 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3245 * Section - Feature: Sorting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3246 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3247
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3248 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3249 * Function: _fnSort
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3250 * Purpose: Change the order of the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3251 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3252 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3253 * bool:bApplyClasses - optional - should we apply classes or not
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3254 * Notes: We always sort the master array and then apply a filter again
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3255 * if it is needed. This probably isn't optimal - but atm I can't think
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3256 * of any other way which is (each has disadvantages). we want to sort aiDisplayMaster -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3257 * but according to aoData[]._aData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3258 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3259 function _fnSort ( oSettings, bApplyClasses )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3260 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3261 var aaSort = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3262 var oSort = _oExt.oSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3263 var aoData = oSettings.aoData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3264 var iDataSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3265 var iDataType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3266 var i, j, jLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3267
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3268 /* No sorting required if server-side or no sorting array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3269 if ( !oSettings.oFeatures.bServerSide &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3270 (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3271 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3272 if ( oSettings.aaSortingFixed !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3273 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3274 aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3275 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3276 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3277 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3278 aaSort = oSettings.aaSorting.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3279 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3280
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3281 /* If there is a sorting data type, and a fuction belonging to it, then we need to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3282 * get the data from the developer's function and apply it for this column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3283 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3284 for ( i=0 ; i<aaSort.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3285 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3286 var iColumn = aaSort[i][0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3287 var sDataType = oSettings.aoColumns[ iColumn ].sSortDataType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3288 if ( typeof _oExt.afnSortData[sDataType] != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3289 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3290 var iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3291 var aData = _oExt.afnSortData[sDataType]( oSettings, iColumn );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3292 for ( j=0, jLen=aoData.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3293 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3294 if ( aoData[j] !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3295 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3296 aoData[j]._aData[iColumn] = aData[iCorrector];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3297 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3298 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3299 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3300 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3301 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3302
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3303 /* DataTables offers two different methods for doing the 2D array sorting over multiple
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3304 * columns. The first is to construct a function dynamically, and then evaluate and run
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3305 * the function, while the second has no need for evalulation, but is a little bit slower.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3306 * This is used for environments which do not allow eval() for code execuation such as AIR
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3307 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3308 if ( !window.runtime )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3309 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3310 /* Dynamically created sorting function. Based on the information that we have, we can
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3311 * create a sorting function as if it were specifically written for this sort. Here we
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3312 * want to build a function something like (for two column sorting):
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3313 * fnLocalSorting = function(a,b){
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3314 * var iTest;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3315 * iTest = oSort['string-asc']('data11', 'data12');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3316 * if (iTest === 0)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3317 * iTest = oSort['numeric-desc']('data21', 'data22');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3318 * if (iTest === 0)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3319 * return oSort['numeric-desc'](1,2);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3320 * return iTest;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3321 * }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3322 * So basically we have a test for each column, and if that column matches, test the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3323 * next one. If all columns match, then we use a numeric sort on the position the two
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3324 * row have in the original data array in order to provide a stable sort.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3325 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3326 var fnLocalSorting;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3327 var sDynamicSort = "fnLocalSorting = function(a,b){"+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3328 "var iTest;";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3329
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3330 for ( i=0 ; i<aaSort.length-1 ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3331 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3332 iDataSort = oSettings.aoColumns[ aaSort[i][0] ].iDataSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3333 iDataType = oSettings.aoColumns[ iDataSort ].sType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3334 sDynamicSort += "iTest = oSort['"+iDataType+"-"+aaSort[i][1]+"']"+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3335 "( aoData[a]._aData["+iDataSort+"], aoData[b]._aData["+iDataSort+"] ); if ( iTest === 0 )";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3336 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3337
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3338 iDataSort = oSettings.aoColumns[ aaSort[aaSort.length-1][0] ].iDataSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3339 iDataType = oSettings.aoColumns[ iDataSort ].sType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3340 sDynamicSort += "iTest = oSort['"+iDataType+"-"+aaSort[aaSort.length-1][1]+"']"+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3341 "( aoData[a]._aData["+iDataSort+"], aoData[b]._aData["+iDataSort+"] );"+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3342 "if (iTest===0) return oSort['numeric-"+aaSort[aaSort.length-1][1]+"'](a, b); "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3343 "return iTest;}";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3344
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3345 /* The eval has to be done to a variable for IE */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3346 eval( sDynamicSort );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3347 oSettings.aiDisplayMaster.sort( fnLocalSorting );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3348 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3349 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3350 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3351 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3352 * Non-eval() sorting (AIR and other environments which doesn't allow code in eval()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3353 * Note that for reasonable sized data sets this method is around 1.5 times slower than
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3354 * the eval above (hence why it is not used all the time). Oddly enough, it is ever so
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3355 * slightly faster for very small sets (presumably the eval has overhead).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3356 * Single column (1083 records) - eval: 32mS AIR: 38mS
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3357 * Two columns (1083 records) - eval: 55mS AIR: 66mS
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3358 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3359
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3360 /* Build a cached array so the sort doesn't have to process this stuff on every call */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3361 var aAirSort = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3362 var iLen = aaSort.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3363 for ( i=0 ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3364 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3365 iDataSort = oSettings.aoColumns[ aaSort[i][0] ].iDataSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3366 aAirSort.push( [
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3367 iDataSort,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3368 oSettings.aoColumns[ iDataSort ].sType+'-'+aaSort[i][1]
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3369 ] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3370 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3371
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3372 oSettings.aiDisplayMaster.sort( function (a,b) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3373 var iTest;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3374 for ( var i=0 ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3375 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3376 iTest = oSort[ aAirSort[i][1] ]( aoData[a]._aData[aAirSort[i][0]], aoData[b]._aData[aAirSort[i][0]] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3377 if ( iTest !== 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3378 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3379 return iTest;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3380 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3381 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3382 return 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3383 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3384 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3385 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3386
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3387 /* Alter the sorting classes to take account of the changes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3388 if ( typeof bApplyClasses == 'undefined' || bApplyClasses )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3389 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3390 _fnSortingClasses( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3391 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3392
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3393 /* Tell the draw function that we have sorted the data */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3394 oSettings.bSorted = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3395
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3396 /* Copy the master data into the draw array and re-draw */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3397 if ( oSettings.oFeatures.bFilter )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3398 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3399 /* _fnFilter() will redraw the table for us */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3400 _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3401 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3402 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3403 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3404 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3405 oSettings._iDisplayStart = 0; /* reset display back to page 0 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3406 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3407 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3408 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3409 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3410
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3411 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3412 * Function: _fnSortAttachListener
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3413 * Purpose: Attach a sort handler (click) to a node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3414 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3415 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3416 * node:nNode - node to attach the handler to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3417 * int:iDataIndex - column sorting index
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3418 * function:fnCallback - callback function - optional
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3419 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3420 function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3421 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3422 $(nNode).click( function (e) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3423 /* If the column is not sortable - don't to anything */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3424 if ( oSettings.aoColumns[iDataIndex].bSortable === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3425 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3426 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3427 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3428
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3429 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3430 * This is a little bit odd I admit... I declare a temporary function inside the scope of
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3431 * _fnDrawHead and the click handler in order that the code presented here can be used
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3432 * twice - once for when bProcessing is enabled, and another time for when it is
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3433 * disabled, as we need to perform slightly different actions.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3434 * Basically the issue here is that the Javascript engine in modern browsers don't
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3435 * appear to allow the rendering engine to update the display while it is still excuting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3436 * it's thread (well - it does but only after long intervals). This means that the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3437 * 'processing' display doesn't appear for a table sort. To break the js thread up a bit
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3438 * I force an execution break by using setTimeout - but this breaks the expected
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3439 * thread continuation for the end-developer's point of view (their code would execute
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3440 * too early), so we on;y do it when we absolutely have to.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3441 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3442 var fnInnerSorting = function () {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3443 var iColumn, iNextSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3444
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3445 /* If the shift key is pressed then we are multipe column sorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3446 if ( e.shiftKey )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3447 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3448 /* Are we already doing some kind of sort on this column? */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3449 var bFound = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3450 for ( var i=0 ; i<oSettings.aaSorting.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3451 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3452 if ( oSettings.aaSorting[i][0] == iDataIndex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3453 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3454 bFound = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3455 iColumn = oSettings.aaSorting[i][0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3456 iNextSort = oSettings.aaSorting[i][2]+1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3457
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3458 if ( typeof oSettings.aoColumns[iColumn].asSorting[iNextSort] == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3459 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3460 /* Reached the end of the sorting options, remove from multi-col sort */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3461 oSettings.aaSorting.splice( i, 1 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3462 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3463 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3464 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3465 /* Move onto next sorting direction */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3466 oSettings.aaSorting[i][1] = oSettings.aoColumns[iColumn].asSorting[iNextSort];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3467 oSettings.aaSorting[i][2] = iNextSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3468 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3469 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3470 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3471 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3472
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3473 /* No sort yet - add it in */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3474 if ( bFound === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3475 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3476 oSettings.aaSorting.push( [ iDataIndex,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3477 oSettings.aoColumns[iDataIndex].asSorting[0], 0 ] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3478 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3479 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3480 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3481 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3482 /* If no shift key then single column sort */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3483 if ( oSettings.aaSorting.length == 1 && oSettings.aaSorting[0][0] == iDataIndex )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3484 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3485 iColumn = oSettings.aaSorting[0][0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3486 iNextSort = oSettings.aaSorting[0][2]+1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3487 if ( typeof oSettings.aoColumns[iColumn].asSorting[iNextSort] == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3488 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3489 iNextSort = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3490 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3491 oSettings.aaSorting[0][1] = oSettings.aoColumns[iColumn].asSorting[iNextSort];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3492 oSettings.aaSorting[0][2] = iNextSort;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3493 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3494 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3495 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3496 oSettings.aaSorting.splice( 0, oSettings.aaSorting.length );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3497 oSettings.aaSorting.push( [ iDataIndex,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3498 oSettings.aoColumns[iDataIndex].asSorting[0], 0 ] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3499 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3500 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3501
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3502 /* Run the sort */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3503 _fnSort( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3504 }; /* /fnInnerSorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3505
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3506 if ( !oSettings.oFeatures.bProcessing )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3507 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3508 fnInnerSorting();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3509 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3510 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3511 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3512 _fnProcessingDisplay( oSettings, true );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3513 setTimeout( function() {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3514 fnInnerSorting();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3515 if ( !oSettings.oFeatures.bServerSide )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3516 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3517 _fnProcessingDisplay( oSettings, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3518 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3519 }, 0 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3520 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3521
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3522 /* Call the user specified callback function - used for async user interaction */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3523 if ( typeof fnCallback == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3524 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3525 fnCallback( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3526 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3527 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3528 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3529
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3530 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3531 * Function: _fnSortingClasses
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3532 * Purpose: Set the sortting classes on the header
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3533 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3534 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3535 * Notes: It is safe to call this function when bSort is false
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3536 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3537 function _fnSortingClasses( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3538 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3539 var i, iLen, j, jLen, iFound;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3540 var aaSort, sClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3541 var iColumns = oSettings.aoColumns.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3542 var oClasses = oSettings.oClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3543
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3544 for ( i=0 ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3545 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3546 if ( oSettings.aoColumns[i].bSortable )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3547 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3548 $(oSettings.aoColumns[i].nTh).removeClass( oClasses.sSortAsc +" "+ oClasses.sSortDesc +
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3549 " "+ oSettings.aoColumns[i].sSortingClass );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3550 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3551 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3552
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3553 if ( oSettings.aaSortingFixed !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3554 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3555 aaSort = oSettings.aaSortingFixed.concat( oSettings.aaSorting );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3556 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3557 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3558 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3559 aaSort = oSettings.aaSorting.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3560 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3561
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3562 /* Apply the required classes to the header */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3563 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3564 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3565 if ( oSettings.aoColumns[i].bSortable )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3566 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3567 sClass = oSettings.aoColumns[i].sSortingClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3568 iFound = -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3569 for ( j=0 ; j<aaSort.length ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3570 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3571 if ( aaSort[j][0] == i )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3572 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3573 sClass = ( aaSort[j][1] == "asc" ) ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3574 oClasses.sSortAsc : oClasses.sSortDesc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3575 iFound = j;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3576 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3577 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3578 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3579 $(oSettings.aoColumns[i].nTh).addClass( sClass );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3580
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3581 if ( oSettings.bJUI )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3582 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3583 /* jQuery UI uses extra markup */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3584 var jqSpan = $("span", oSettings.aoColumns[i].nTh);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3585 jqSpan.removeClass(oClasses.sSortJUIAsc +" "+ oClasses.sSortJUIDesc +" "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3586 oClasses.sSortJUI +" "+ oClasses.sSortJUIAscAllowed +" "+ oClasses.sSortJUIDescAllowed );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3587
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3588 var sSpanClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3589 if ( iFound == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3590 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3591 sSpanClass = oSettings.aoColumns[i].sSortingClassJUI;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3592 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3593 else if ( aaSort[iFound][1] == "asc" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3594 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3595 sSpanClass = oClasses.sSortJUIAsc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3596 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3597 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3598 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3599 sSpanClass = oClasses.sSortJUIDesc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3600 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3601
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3602 jqSpan.addClass( sSpanClass );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3603 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3604 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3605 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3606 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3607 /* No sorting on this column, so add the base class. This will have been assigned by
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3608 * _fnAddColumn
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3609 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3610 $(oSettings.aoColumns[i].nTh).addClass( oSettings.aoColumns[i].sSortingClass );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3611 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3612 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3613
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3614 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3615 * Apply the required classes to the table body
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3616 * Note that this is given as a feature switch since it can significantly slow down a sort
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3617 * on large data sets (adding and removing of classes is always slow at the best of times..)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3618 * Further to this, note that this code is admitadly fairly ugly. It could be made a lot
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3619 * simpiler using jQuery selectors and add/removeClass, but that is significantly slower
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3620 * (on the order of 5 times slower) - hence the direct DOM manipulation here.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3621 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3622 sClass = oClasses.sSortColumn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3623
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3624 if ( oSettings.oFeatures.bSort && oSettings.oFeatures.bSortClasses )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3625 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3626 var nTds = _fnGetTdNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3627
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3628 /* Remove the old classes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3629 if ( nTds.length >= iColumns )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3630 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3631 for ( i=0 ; i<iColumns ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3632 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3633 if ( nTds[i].className.indexOf(sClass+"1") != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3634 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3635 for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3636 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3637 nTds[(iColumns*j)+i].className =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3638 nTds[(iColumns*j)+i].className.replace( " "+sClass+"1", "" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3639 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3640 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3641 else if ( nTds[i].className.indexOf(sClass+"2") != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3642 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3643 for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3644 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3645 nTds[(iColumns*j)+i].className =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3646 nTds[(iColumns*j)+i].className.replace( " "+sClass+"2", "" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3647 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3648 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3649 else if ( nTds[i].className.indexOf(sClass+"3") != -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3650 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3651 for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3652 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3653 nTds[(iColumns*j)+i].className =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3654 nTds[(iColumns*j)+i].className.replace( " "+sClass+"3", "" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3655 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3656 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3657 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3658 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3659
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3660 /* Add the new classes to the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3661 var iClass = 1, iTargetCol;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3662 for ( i=0 ; i<aaSort.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3663 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3664 iTargetCol = parseInt( aaSort[i][0], 10 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3665 for ( j=0, jLen=(nTds.length/iColumns) ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3666 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3667 nTds[(iColumns*j)+iTargetCol].className += " "+sClass+iClass;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3668 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3669
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3670 if ( iClass < 3 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3671 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3672 iClass++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3673 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3674 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3675 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3676 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3677
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3678
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3679 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3680 * Section - Feature: Pagination. Note that most of the paging logic is done in
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3681 * _oExt.oPagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3682 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3683
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3684 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3685 * Function: _fnFeatureHtmlPaginate
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3686 * Purpose: Generate the node required for default pagination
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3687 * Returns: node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3688 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3689 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3690 function _fnFeatureHtmlPaginate ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3691 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3692 var nPaginate = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3693 nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3694
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3695 _oExt.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3696 function( oSettings ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3697 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3698 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3699 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3700 );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3701
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3702 /* Add a draw callback for the pagination on first instance, to update the paging display */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3703 if ( typeof oSettings.aanFeatures.p == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3704 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3705 oSettings.aoDrawCallback.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3706 "fn": function( oSettings ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3707 _oExt.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3708 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3709 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3710 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3711 },
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3712 "sName": "pagination"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3713 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3714 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3715 return nPaginate;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3716 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3717
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3718 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3719 * Function: _fnPageChange
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3720 * Purpose: Alter the display settings to change the page
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3721 * Returns: bool:true - page has changed, false - no change (no effect) eg 'first' on page 1
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3722 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3723 * string:sAction - paging action to take: "first", "previous", "next" or "last"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3724 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3725 function _fnPageChange ( oSettings, sAction )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3726 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3727 var iOldStart = oSettings._iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3728
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3729 if ( sAction == "first" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3730 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3731 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3732 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3733 else if ( sAction == "previous" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3734 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3735 oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3736 oSettings._iDisplayStart - oSettings._iDisplayLength :
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3737 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3738
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3739 /* Correct for underrun */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3740 if ( oSettings._iDisplayStart < 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3741 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3742 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3743 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3744 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3745 else if ( sAction == "next" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3746 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3747 if ( oSettings._iDisplayLength >= 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3748 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3749 /* Make sure we are not over running the display array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3750 if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3751 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3752 oSettings._iDisplayStart += oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3753 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3754 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3755 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3756 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3757 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3758 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3759 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3760 else if ( sAction == "last" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3761 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3762 if ( oSettings._iDisplayLength >= 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3763 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3764 var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3765 oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3766 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3767 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3768 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3769 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3770 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3771 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3772 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3773 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3774 alert( "DataTables warning: unknown paging action: "+sAction );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3775 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3776
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3777 return iOldStart != oSettings._iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3778 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3779
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3780
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3781 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3782 * Section - Feature: HTML info
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3783 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3784
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3785 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3786 * Function: _fnFeatureHtmlInfo
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3787 * Purpose: Generate the node required for the info display
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3788 * Returns: node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3789 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3790 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3791 function _fnFeatureHtmlInfo ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3792 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3793 var nInfo = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3794 nInfo.className = oSettings.oClasses.sInfo;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3795
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3796 /* Actions that are to be taken once only for this feature */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3797 if ( typeof oSettings.aanFeatures.i == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3798 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3799 /* Add draw callback */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3800 oSettings.aoDrawCallback.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3801 "fn": _fnUpdateInfo,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3802 "sName": "information"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3803 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3804
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3805 /* Add id */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3806 if ( oSettings.sTableId !== '' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3807 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3808 nInfo.setAttribute( 'id', oSettings.sTableId+'_info' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3809 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3810 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3811
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3812 return nInfo;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3813 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3814
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3815 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3816 * Function: _fnUpdateInfo
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3817 * Purpose: Update the information elements in the display
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3818 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3819 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3820 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3821 function _fnUpdateInfo ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3822 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3823 /* Show information about the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3824 if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3825 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3826 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3827 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3828
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3829 var nFirst = oSettings.aanFeatures.i[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3830
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3831 if ( oSettings.fnRecordsDisplay() === 0 &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3832 oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3833 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3834 /* Empty record set */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3835 nFirst.innerHTML = oSettings.oLanguage.sInfoEmpty+ oSettings.oLanguage.sInfoPostFix;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3836 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3837 else if ( oSettings.fnRecordsDisplay() === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3838 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3839 /* Rmpty record set after filtering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3840 nFirst.innerHTML = oSettings.oLanguage.sInfoEmpty +' '+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3841 oSettings.oLanguage.sInfoFiltered.replace('_MAX_',
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3842 oSettings.fnRecordsTotal())+ oSettings.oLanguage.sInfoPostFix;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3843 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3844 else if ( oSettings.fnRecordsDisplay() == oSettings.fnRecordsTotal() )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3845 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3846 /* Normal record set */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3847 nFirst.innerHTML = oSettings.oLanguage.sInfo.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3848 replace('_START_',oSettings._iDisplayStart+1).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3849 replace('_END_',oSettings.fnDisplayEnd()).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3850 replace('_TOTAL_',oSettings.fnRecordsDisplay())+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3851 oSettings.oLanguage.sInfoPostFix;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3852 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3853 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3854 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3855 /* Record set after filtering */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3856 nFirst.innerHTML =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3857 oSettings.oLanguage.sInfo.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3858 replace('_START_',oSettings._iDisplayStart+1).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3859 replace('_END_',oSettings.fnDisplayEnd()).
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3860 replace('_TOTAL_',oSettings.fnRecordsDisplay()) +' '+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3861 oSettings.oLanguage.sInfoFiltered.replace('_MAX_', oSettings.fnRecordsTotal())+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3862 oSettings.oLanguage.sInfoPostFix;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3863 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3864
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3865 /* No point in recalculating for the other info elements, just copy the first one in */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3866 var n = oSettings.aanFeatures.i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3867 if ( n.length > 1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3868 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3869 var sInfo = nFirst.innerHTML;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3870 for ( var i=1, iLen=n.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3871 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3872 n[i].innerHTML = sInfo;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3873 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3874 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3875 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3876
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3877
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3878 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3879 * Section - Feature: Length change
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3880 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3881
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3882 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3883 * Function: _fnFeatureHtmlLength
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3884 * Purpose: Generate the node required for user display length changing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3885 * Returns: node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3886 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3887 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3888 function _fnFeatureHtmlLength ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3889 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3890 /* This can be overruled by not using the _MENU_ var/macro in the language variable */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3891 var sName = (oSettings.sTableId === "") ? "" : 'name="'+oSettings.sTableId+'_length"';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3892 var sStdMenu =
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3893 '<select size="1" '+sName+'>'+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3894 '<option value="10">10</option>'+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3895 '<option value="25">25</option>'+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3896 '<option value="50">50</option>'+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3897 '<option value="100">100</option>'+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3898 '</select>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3899
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3900 var nLength = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3901 if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.l == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3902 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3903 nLength.setAttribute( 'id', oSettings.sTableId+'_length' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3904 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3905 nLength.className = oSettings.oClasses.sLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3906 nLength.innerHTML = oSettings.oLanguage.sLengthMenu.replace( '_MENU_', sStdMenu );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3907
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3908 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3909 * Set the length to the current display length - thanks to Andrea Pavlovic for this fix,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3910 * and Stefan Skopnik for fixing the fix!
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3911 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3912 $('select option[value="'+oSettings._iDisplayLength+'"]',nLength).attr("selected",true);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3913
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3914 $('select', nLength).change( function(e) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3915 var iVal = $(this).val();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3916
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3917 /* Update all other length options for the new display */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3918 var n = oSettings.aanFeatures.l;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3919 for ( var i=0, iLen=n.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3920 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3921 if ( n[i] != this.parentNode )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3922 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3923 $('select', n[i]).val( iVal );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3924 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3925 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3926
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3927 /* Redraw the table */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3928 oSettings._iDisplayLength = parseInt(iVal, 10);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3929 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3930
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3931 /* If we have space to show extra rows (backing up from the end point - then do so */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3932 if ( oSettings._iDisplayEnd == oSettings.aiDisplay.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3933 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3934 oSettings._iDisplayStart = oSettings._iDisplayEnd - oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3935 if ( oSettings._iDisplayStart < 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3936 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3937 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3938 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3939 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3940
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3941 if ( oSettings._iDisplayLength == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3942 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3943 oSettings._iDisplayStart = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3944 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3945
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3946 _fnDraw( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3947 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3948
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3949 return nLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3950 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3951
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3952
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3953 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3954 * Section - Feature: Processing incidator
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3955 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3956
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3957 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3958 * Function: _fnFeatureHtmlProcessing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3959 * Purpose: Generate the node required for the processing node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3960 * Returns: node
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3961 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3962 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3963 function _fnFeatureHtmlProcessing ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3964 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3965 var nProcessing = document.createElement( 'div' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3966
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3967 if ( oSettings.sTableId !== '' && typeof oSettings.aanFeatures.r == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3968 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3969 nProcessing.setAttribute( 'id', oSettings.sTableId+'_processing' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3970 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3971 nProcessing.innerHTML = oSettings.oLanguage.sProcessing;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3972 nProcessing.className = oSettings.oClasses.sProcessing;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3973 oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3974
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3975 return nProcessing;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3976 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3977
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3978 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3979 * Function: _fnProcessingDisplay
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3980 * Purpose: Display or hide the processing indicator
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3981 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3982 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3983 * bool:
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3984 * true - show the processing indicator
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3985 * false - don't show
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3986 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3987 function _fnProcessingDisplay ( oSettings, bShow )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3988 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3989 if ( oSettings.oFeatures.bProcessing )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3990 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3991 var an = oSettings.aanFeatures.r;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3992 for ( var i=0, iLen=an.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3993 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3994 an[i].style.visibility = bShow ? "visible" : "hidden";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3995 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3996 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3997 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3998
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
3999
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4000 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4001 * Section - Support functions
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4002 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4003
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4004 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4005 * Function: _fnVisibleToColumnIndex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4006 * Purpose: Covert the index of a visible column to the index in the data array (take account
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4007 * of hidden columns)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4008 * Returns: int:i - the data index
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4009 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4010 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4011 function _fnVisibleToColumnIndex( oSettings, iMatch )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4012 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4013 var iColumn = -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4014
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4015 for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4016 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4017 if ( oSettings.aoColumns[i].bVisible === true )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4018 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4019 iColumn++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4020 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4021
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4022 if ( iColumn == iMatch )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4023 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4024 return i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4025 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4026 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4027
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4028 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4029 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4030
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4031 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4032 * Function: _fnColumnIndexToVisible
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4033 * Purpose: Covert the index of an index in the data array and convert it to the visible
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4034 * column index (take account of hidden columns)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4035 * Returns: int:i - the data index
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4036 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4037 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4038 function _fnColumnIndexToVisible( oSettings, iMatch )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4039 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4040 var iVisible = -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4041 for ( var i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4042 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4043 if ( oSettings.aoColumns[i].bVisible === true )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4044 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4045 iVisible++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4046 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4047
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4048 if ( i == iMatch )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4049 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4050 return oSettings.aoColumns[i].bVisible === true ? iVisible : null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4051 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4052 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4053
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4054 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4055 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4056
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4057
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4058 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4059 * Function: _fnNodeToDataIndex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4060 * Purpose: Take a TR element and convert it to an index in aoData
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4061 * Returns: int:i - index if found, null if not
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4062 * Inputs: object:s - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4063 * node:n - the TR element to find
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4064 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4065 function _fnNodeToDataIndex( s, n )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4066 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4067 for ( var i=0, iLen=s.aoData.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4068 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4069 if ( s.aoData[i] !== null && s.aoData[i].nTr == n )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4070 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4071 return i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4072 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4073 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4074 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4075 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4076
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4077 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4078 * Function: _fnVisbleColumns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4079 * Purpose: Get the number of visible columns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4080 * Returns: int:i - the number of visible columns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4081 * Inputs: object:oS - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4082 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4083 function _fnVisbleColumns( oS )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4084 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4085 var iVis = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4086 for ( var i=0 ; i<oS.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4087 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4088 if ( oS.aoColumns[i].bVisible === true )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4089 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4090 iVis++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4091 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4092 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4093 return iVis;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4094 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4095
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4096 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4097 * Function: _fnCalculateEnd
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4098 * Purpose: Rcalculate the end point based on the start point
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4099 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4100 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4101 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4102 function _fnCalculateEnd( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4103 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4104 if ( oSettings.oFeatures.bPaginate === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4105 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4106 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4107 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4108 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4109 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4110 /* Set the end point of the display - based on how many elements there are
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4111 * still to display
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4112 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4113 if ( oSettings._iDisplayStart + oSettings._iDisplayLength > oSettings.aiDisplay.length ||
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4114 oSettings._iDisplayLength == -1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4115 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4116 oSettings._iDisplayEnd = oSettings.aiDisplay.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4117 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4118 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4119 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4120 oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4121 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4122 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4123 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4124
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4125 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4126 * Function: _fnConvertToWidth
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4127 * Purpose: Convert a CSS unit width to pixels (e.g. 2em)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4128 * Returns: int:iWidth - width in pixels
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4129 * Inputs: string:sWidth - width to be converted
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4130 * node:nParent - parent to get the with for (required for
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4131 * relative widths) - optional
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4132 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4133 function _fnConvertToWidth ( sWidth, nParent )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4134 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4135 if ( !sWidth || sWidth === null || sWidth === '' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4136 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4137 return 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4138 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4139
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4140 if ( typeof nParent == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4141 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4142 nParent = document.getElementsByTagName('body')[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4143 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4144
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4145 var iWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4146 var nTmp = document.createElement( "div" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4147 nTmp.style.width = sWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4148
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4149 nParent.appendChild( nTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4150 iWidth = nTmp.offsetWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4151 nParent.removeChild( nTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4152
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4153 return ( iWidth );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4154 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4155
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4156 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4157 * Function: _fnCalculateColumnWidths
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4158 * Purpose: Calculate the width of columns for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4159 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4160 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4161 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4162 function _fnCalculateColumnWidths ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4163 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4164 var iTableWidth = oSettings.nTable.offsetWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4165 var iTotalUserIpSize = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4166 var iTmpWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4167 var iVisibleColumns = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4168 var iColums = oSettings.aoColumns.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4169 var i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4170 var oHeaders = $('thead:eq(0)>th', oSettings.nTable);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4171
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4172 /* Convert any user input sizes into pixel sizes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4173 for ( i=0 ; i<iColums ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4174 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4175 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4176 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4177 iVisibleColumns++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4178
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4179 if ( oSettings.aoColumns[i].sWidth !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4180 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4181 iTmpWidth = _fnConvertToWidth( oSettings.aoColumns[i].sWidth,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4182 oSettings.nTable.parentNode );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4183
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4184 /* Total up the user defined widths for later calculations */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4185 iTotalUserIpSize += iTmpWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4186
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4187 oSettings.aoColumns[i].sWidth = iTmpWidth+"px";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4188 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4189 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4190 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4191
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4192 /* If the number of columns in the DOM equals the number that we
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4193 * have to process in dataTables, then we can use the offsets that are
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4194 * created by the web-browser. No custom sizes can be set in order for
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4195 * this to happen
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4196 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4197 if ( iColums == oHeaders.length && iTotalUserIpSize === 0 && iVisibleColumns == iColums )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4198 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4199 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4200 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4201 oSettings.aoColumns[i].sWidth = oHeaders[i].offsetWidth+"px";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4202 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4203 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4204 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4205 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4206 /* Otherwise we are going to have to do some calculations to get
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4207 * the width of each column. Construct a 1 row table with the maximum
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4208 * string sizes in the data, and any user defined widths
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4209 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4210 var nCalcTmp = oSettings.nTable.cloneNode( false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4211 nCalcTmp.setAttribute( "id", '' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4212
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4213 var sTableTmp = '<table class="'+nCalcTmp.className+'">';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4214 var sCalcHead = "<tr>";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4215 var sCalcHtml = "<tr>";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4216
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4217 /* Construct a tempory table which we will inject (invisibly) into
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4218 * the dom - to let the browser do all the hard word
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4219 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4220 for ( i=0 ; i<iColums ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4221 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4222 if ( oSettings.aoColumns[i].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4223 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4224 sCalcHead += '<th>'+oSettings.aoColumns[i].sTitle+'</th>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4225
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4226 if ( oSettings.aoColumns[i].sWidth !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4227 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4228 var sWidth = '';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4229 if ( oSettings.aoColumns[i].sWidth !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4230 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4231 sWidth = ' style="width:'+oSettings.aoColumns[i].sWidth+';"';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4232 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4233
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4234 sCalcHtml += '<td'+sWidth+' tag_index="'+i+'">'+fnGetMaxLenString( oSettings, i)+'</td>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4235 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4236 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4237 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4238 sCalcHtml += '<td tag_index="'+i+'">'+fnGetMaxLenString( oSettings, i)+'</td>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4239 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4240 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4241 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4242
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4243 sCalcHead += "</tr>";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4244 sCalcHtml += "</tr>";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4245
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4246 /* Create the tmp table node (thank you jQuery) */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4247 nCalcTmp = $( sTableTmp + sCalcHead + sCalcHtml +'</table>' )[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4248 nCalcTmp.style.width = iTableWidth + "px";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4249 nCalcTmp.style.visibility = "hidden";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4250 nCalcTmp.style.position = "absolute"; /* Try to aviod scroll bar */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4251
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4252 oSettings.nTable.parentNode.appendChild( nCalcTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4253
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4254 var oNodes = $("tr:eq(1)>td", nCalcTmp);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4255 var iIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4256
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4257 /* Gather in the browser calculated widths for the rows */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4258 for ( i=0 ; i<oNodes.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4259 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4260 iIndex = oNodes[i].getAttribute('tag_index');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4261
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4262 var iContentWidth = $("td", nCalcTmp).eq(i).width();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4263 var iSetWidth = oSettings.aoColumns[i].sWidth ?
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4264 oSettings.aoColumns[i].sWidth.slice(0, -2) : 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4265 oSettings.aoColumns[iIndex].sWidth = Math.max(iContentWidth, iSetWidth) + "px";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4266 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4267
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4268 oSettings.nTable.parentNode.removeChild( nCalcTmp );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4269 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4270 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4271
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4272 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4273 * Function: fnGetMaxLenString
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4274 * Purpose: Get the maximum strlen for each data column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4275 * Returns: string: - max strlens for each column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4276 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4277 * int:iCol - column of interest
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4278 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4279 function fnGetMaxLenString( oSettings, iCol )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4280 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4281 var iMax = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4282 var iMaxIndex = -1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4283
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4284 for ( var i=0 ; i<oSettings.aoData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4285 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4286 if ( oSettings.aoData[i]._aData[iCol].length > iMax )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4287 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4288 iMax = oSettings.aoData[i]._aData[iCol].length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4289 iMaxIndex = i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4290 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4291 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4292
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4293 if ( iMaxIndex >= 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4294 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4295 return oSettings.aoData[iMaxIndex]._aData[iCol];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4296 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4297 return '';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4298 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4299
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4300 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4301 * Function: _fnArrayCmp
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4302 * Purpose: Compare two arrays
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4303 * Returns: 0 if match, 1 if length is different, 2 if no match
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4304 * Inputs: array:aArray1 - first array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4305 * array:aArray2 - second array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4306 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4307 function _fnArrayCmp( aArray1, aArray2 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4308 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4309 if ( aArray1.length != aArray2.length )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4310 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4311 return 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4312 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4313
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4314 for ( var i=0 ; i<aArray1.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4315 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4316 if ( aArray1[i] != aArray2[i] )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4317 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4318 return 2;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4319 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4320 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4321
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4322 return 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4323 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4324
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4325 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4326 * Function: _fnDetectType
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4327 * Purpose: Get the sort type based on an input string
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4328 * Returns: string: - type (defaults to 'string' if no type can be detected)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4329 * Inputs: string:sData - data we wish to know the type of
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4330 * Notes: This function makes use of the DataTables plugin objct _oExt
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4331 * (.aTypes) such that new types can easily be added.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4332 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4333 function _fnDetectType( sData )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4334 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4335 var aTypes = _oExt.aTypes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4336 var iLen = aTypes.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4337
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4338 for ( var i=0 ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4339 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4340 var sType = aTypes[i]( sData );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4341 if ( sType !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4342 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4343 return sType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4344 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4345 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4346
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4347 return 'string';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4348 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4349
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4350 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4351 * Function: _fnSettingsFromNode
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4352 * Purpose: Return the settings object for a particular table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4353 * Returns: object: Settings object - or null if not found
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4354 * Inputs: node:nTable - table we are using as a dataTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4355 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4356 function _fnSettingsFromNode ( nTable )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4357 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4358 for ( var i=0 ; i<_aoSettings.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4359 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4360 if ( _aoSettings[i].nTable == nTable )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4361 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4362 return _aoSettings[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4363 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4364 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4365
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4366 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4367 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4368
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4369 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4370 * Function: _fnGetDataMaster
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4371 * Purpose: Return an array with the full table data
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4372 * Returns: array array:aData - Master data array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4373 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4374 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4375 function _fnGetDataMaster ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4376 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4377 var aData = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4378 var iLen = oSettings.aoData.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4379 for ( var i=0 ; i<iLen; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4380 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4381 if ( oSettings.aoData[i] === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4382 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4383 aData.push( null );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4384 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4385 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4386 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4387 aData.push( oSettings.aoData[i]._aData );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4388 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4389 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4390 return aData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4391 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4392
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4393 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4394 * Function: _fnGetTrNodes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4395 * Purpose: Return an array with the TR nodes for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4396 * Returns: array: - TR array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4397 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4398 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4399 function _fnGetTrNodes ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4400 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4401 var aNodes = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4402 var iLen = oSettings.aoData.length;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4403 for ( var i=0 ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4404 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4405 if ( oSettings.aoData[i] === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4406 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4407 aNodes.push( null );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4408 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4409 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4410 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4411 aNodes.push( oSettings.aoData[i].nTr );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4412 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4413 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4414 return aNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4415 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4416
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4417 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4418 * Function: _fnGetTdNodes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4419 * Purpose: Return an array with the TD nodes for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4420 * Returns: array: - TD array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4421 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4422 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4423 function _fnGetTdNodes ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4424 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4425 var nTrs = _fnGetTrNodes( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4426 var nTds = [], nTd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4427 var anReturn = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4428 var iCorrector;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4429 var iRow, iRows, iColumn, iColumns;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4430
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4431 for ( iRow=0, iRows=nTrs.length ; iRow<iRows ; iRow++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4432 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4433 nTds = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4434 for ( iColumn=0, iColumns=nTrs[iRow].childNodes.length ; iColumn<iColumns ; iColumn++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4435 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4436 nTd = nTrs[iRow].childNodes[iColumn];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4437 if ( nTd.nodeName == "TD" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4438 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4439 nTds.push( nTd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4440 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4441 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4442
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4443 iCorrector = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4444 for ( iColumn=0, iColumns=oSettings.aoColumns.length ; iColumn<iColumns ; iColumn++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4445 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4446 if ( oSettings.aoColumns[iColumn].bVisible )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4447 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4448 anReturn.push( nTds[iColumn-iCorrector] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4449 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4450 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4451 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4452 anReturn.push( oSettings.aoData[iRow]._anHidden[iColumn] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4453 iCorrector++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4454 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4455 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4456 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4457 return anReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4458 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4459
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4460 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4461 * Function: _fnEscapeRegex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4462 * Purpose: scape a string stuch that it can be used in a regular expression
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4463 * Returns: string: - escaped string
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4464 * Inputs: string:sVal - string to escape
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4465 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4466 function _fnEscapeRegex ( sVal )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4467 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4468 var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^' ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4469 var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4470 return sVal.replace(reReplace, '\\$1');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4471 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4472
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4473 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4474 * Function: _fnReOrderIndex
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4475 * Purpose: Figure out how to reorder a display list
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4476 * Returns: array int:aiReturn - index list for reordering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4477 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4478 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4479 function _fnReOrderIndex ( oSettings, sColumns )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4480 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4481 var aColumns = sColumns.split(',');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4482 var aiReturn = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4483
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4484 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4485 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4486 for ( var j=0 ; j<iLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4487 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4488 if ( oSettings.aoColumns[i].sName == aColumns[j] )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4489 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4490 aiReturn.push( j );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4491 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4492 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4493 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4494 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4495
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4496 return aiReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4497 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4498
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4499 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4500 * Function: _fnColumnOrdering
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4501 * Purpose: Get the column ordering that DataTables expects
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4502 * Returns: string: - comma separated list of names
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4503 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4504 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4505 function _fnColumnOrdering ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4506 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4507 var sNames = '';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4508 for ( var i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4509 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4510 sNames += oSettings.aoColumns[i].sName+',';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4511 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4512 if ( sNames.length == iLen )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4513 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4514 return "";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4515 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4516 return sNames.slice(0, -1);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4517 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4518
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4519 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4520 * Function: _fnClearTable
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4521 * Purpose: Nuke the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4522 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4523 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4524 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4525 function _fnClearTable( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4526 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4527 oSettings.aoData.length = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4528 oSettings.aiDisplayMaster.length = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4529 oSettings.aiDisplay.length = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4530 _fnCalculateEnd( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4531 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4532
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4533 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4534 * Function: _fnSaveState
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4535 * Purpose: Save the state of a table in a cookie such that the page can be reloaded
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4536 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4537 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4538 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4539 function _fnSaveState ( oSettings )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4540 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4541 if ( !oSettings.oFeatures.bStateSave )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4542 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4543 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4544 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4545
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4546 /* Store the interesting variables */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4547 var i;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4548 var sValue = "{";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4549 sValue += '"iStart": '+oSettings._iDisplayStart+',';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4550 sValue += '"iEnd": '+oSettings._iDisplayEnd+',';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4551 sValue += '"iLength": '+oSettings._iDisplayLength+',';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4552 sValue += '"sFilter": "'+oSettings.oPreviousSearch.sSearch.replace('"','\\"')+'",';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4553 sValue += '"sFilterEsc": '+oSettings.oPreviousSearch.bEscapeRegex+',';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4554
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4555 sValue += '"aaSorting": [ ';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4556 for ( i=0 ; i<oSettings.aaSorting.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4557 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4558 sValue += "["+oSettings.aaSorting[i][0]+",'"+oSettings.aaSorting[i][1]+"'],";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4559 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4560 sValue = sValue.substring(0, sValue.length-1);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4561 sValue += "],";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4562
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4563 sValue += '"aaSearchCols": [ ';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4564 for ( i=0 ; i<oSettings.aoPreSearchCols.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4565 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4566 sValue += "['"+oSettings.aoPreSearchCols[i].sSearch.replace("'","\'")+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4567 "',"+oSettings.aoPreSearchCols[i].bEscapeRegex+"],";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4568 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4569 sValue = sValue.substring(0, sValue.length-1);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4570 sValue += "],";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4571
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4572 sValue += '"abVisCols": [ ';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4573 for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4574 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4575 sValue += oSettings.aoColumns[i].bVisible+",";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4576 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4577 sValue = sValue.substring(0, sValue.length-1);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4578 sValue += "]";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4579
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4580 sValue += "}";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4581 _fnCreateCookie( "SpryMedia_DataTables_"+oSettings.sInstance, sValue,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4582 oSettings.iCookieDuration );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4583 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4584
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4585 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4586 * Function: _fnLoadState
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4587 * Purpose: Attempt to load a saved table state from a cookie
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4588 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4589 * Inputs: object:oSettings - dataTables settings object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4590 * object:oInit - DataTables init object so we can override settings
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4591 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4592 function _fnLoadState ( oSettings, oInit )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4593 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4594 if ( !oSettings.oFeatures.bStateSave )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4595 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4596 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4597 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4598
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4599 var oData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4600 var sData = _fnReadCookie( "SpryMedia_DataTables_"+oSettings.sInstance );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4601 if ( sData !== null && sData !== '' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4602 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4603 /* Try/catch the JSON eval - if it is bad then we ignore it */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4604 try
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4605 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4606 /* Use the JSON library for safety - if it is available */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4607 if ( typeof JSON == 'object' && typeof JSON.parse == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4608 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4609 /* DT 1.4.0 used single quotes for a string - JSON.parse doesn't allow this and throws
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4610 * an error. So for now we can do this. This can be removed in future it is just to
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4611 * allow the tranfrer to 1.4.1+ to occur
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4612 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4613 oData = JSON.parse( sData.replace(/'/g, '"') );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4614 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4615 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4616 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4617 oData = eval( '('+sData+')' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4618 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4619 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4620 catch( e )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4621 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4622 return;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4623 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4624
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4625 /* Restore key features */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4626 oSettings._iDisplayStart = oData.iStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4627 oSettings.iInitDisplayStart = oData.iStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4628 oSettings._iDisplayEnd = oData.iEnd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4629 oSettings._iDisplayLength = oData.iLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4630 oSettings.oPreviousSearch.sSearch = oData.sFilter;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4631 oSettings.aaSorting = oData.aaSorting.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4632 oSettings.saved_aaSorting = oData.aaSorting.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4633
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4634 /* Search filtering - global reference added in 1.4.1 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4635 if ( typeof oData.sFilterEsc != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4636 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4637 oSettings.oPreviousSearch.bEscapeRegex = oData.sFilterEsc;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4638 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4639
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4640 /* Column filtering - added in 1.5.0 beta 6 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4641 if ( typeof oData.aaSearchCols != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4642 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4643 for ( var i=0 ; i<oData.aaSearchCols.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4644 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4645 oSettings.aoPreSearchCols[i] = {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4646 "sSearch": oData.aaSearchCols[i][0],
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4647 "bEscapeRegex": oData.aaSearchCols[i][1]
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4648 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4649 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4650 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4651
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4652 /* Column visibility state - added in 1.5.0 beta 10 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4653 if ( typeof oData.abVisCols != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4654 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4655 /* Pass back visibiliy settings to the init handler, but to do not here override
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4656 * the init object that the user might have passed in
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4657 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4658 oInit.saved_aoColumns = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4659 for ( i=0 ; i<oData.abVisCols.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4660 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4661 oInit.saved_aoColumns[i] = {};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4662 oInit.saved_aoColumns[i].bVisible = oData.abVisCols[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4663 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4664 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4665 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4666 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4667
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4668 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4669 * Function: _fnCreateCookie
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4670 * Purpose: Create a new cookie with a value to store the state of a table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4671 * Returns: -
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4672 * Inputs: string:sName - name of the cookie to create
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4673 * string:sValue - the value the cookie should take
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4674 * int:iSecs - duration of the cookie
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4675 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4676 function _fnCreateCookie ( sName, sValue, iSecs )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4677 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4678 var date = new Date();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4679 date.setTime( date.getTime()+(iSecs*1000) );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4680
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4681 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4682 * Shocking but true - it would appear IE has major issues with having the path being
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4683 * set to anything but root. We need the cookie to be available based on the path, so we
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4684 * have to append the pathname to the cookie name. Appalling.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4685 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4686 sName += '_'+window.location.pathname.replace(/[\/:]/g,"").toLowerCase();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4687
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4688 document.cookie = sName+"="+encodeURIComponent(sValue)+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4689 "; expires="+date.toGMTString()+"; path=/";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4690 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4691
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4692 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4693 * Function: _fnReadCookie
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4694 * Purpose: Read an old cookie to get a cookie with an old table state
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4695 * Returns: string: - contents of the cookie - or null if no cookie with that name found
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4696 * Inputs: string:sName - name of the cookie to read
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4697 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4698 function _fnReadCookie ( sName )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4699 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4700 var sNameEQ = sName +'_'+ window.location.pathname.replace(/[\/:]/g,"").toLowerCase() + "=";
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4701 var sCookieContents = document.cookie.split(';');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4702
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4703 for( var i=0 ; i<sCookieContents.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4704 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4705 var c = sCookieContents[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4706
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4707 while (c.charAt(0)==' ')
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4708 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4709 c = c.substring(1,c.length);
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4710 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4711
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4712 if (c.indexOf(sNameEQ) === 0)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4713 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4714 return decodeURIComponent( c.substring(sNameEQ.length,c.length) );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4715 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4716 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4717 return null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4718 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4719
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4720 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4721 * Function: _fnGetUniqueThs
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4722 * Purpose: Get an array of unique th elements, one for each column
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4723 * Returns: array node:aReturn - list of unique ths
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4724 * Inputs: node:nThead - The thead element for the table
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4725 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4726 function _fnGetUniqueThs ( nThead )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4727 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4728 var nTrs = nThead.getElementsByTagName('tr');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4729
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4730 /* Nice simple case */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4731 if ( nTrs.length == 1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4732 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4733 return nTrs[0].getElementsByTagName('th');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4734 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4735
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4736 /* Otherwise we need to figure out the layout array to get the nodes */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4737 var aLayout = [], aReturn = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4738 var ROWSPAN = 2, COLSPAN = 3, TDELEM = 4;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4739 var i, j, k, iLen, jLen, iColumnShifted;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4740 var fnShiftCol = function ( a, i, j ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4741 while ( typeof a[i][j] != 'undefined' ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4742 j++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4743 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4744 return j;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4745 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4746 var fnAddRow = function ( i ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4747 if ( typeof aLayout[i] == 'undefined' ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4748 aLayout[i] = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4749 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4750 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4751
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4752 /* Calculate a layout array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4753 for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4754 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4755 fnAddRow( i );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4756 var iColumn = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4757 var nTds = [];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4758
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4759 for ( j=0, jLen=nTrs[i].childNodes.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4760 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4761 if ( nTrs[i].childNodes[j].nodeName == "TD" || nTrs[i].childNodes[j].nodeName == "TH" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4762 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4763 nTds.push( nTrs[i].childNodes[j] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4764 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4765 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4766
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4767 for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4768 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4769 var iColspan = nTds[j].getAttribute('colspan') * 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4770 var iRowspan = nTds[j].getAttribute('rowspan') * 1;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4771
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4772 if ( !iColspan || iColspan===0 || iColspan===1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4773 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4774 iColumnShifted = fnShiftCol( aLayout, i, iColumn );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4775 aLayout[i][iColumnShifted] = (nTds[j].nodeName=="TD") ? TDELEM : nTds[j];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4776 if ( iRowspan || iRowspan===0 || iRowspan===1 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4777 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4778 for ( k=1 ; k<iRowspan ; k++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4779 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4780 fnAddRow( i+k );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4781 aLayout[i+k][iColumnShifted] = ROWSPAN;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4782 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4783 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4784 iColumn++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4785 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4786 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4787 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4788 iColumnShifted = fnShiftCol( aLayout, i, iColumn );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4789 for ( k=0 ; k<iColspan ; k++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4790 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4791 aLayout[i][iColumnShifted+k] = COLSPAN;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4792 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4793 iColumn += iColspan;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4794 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4795 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4796 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4797
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4798 /* Convert the layout array into a node array
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4799 * Note the use of aLayout[0] in the outloop, we want the outer loop to occur the same
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4800 * number of times as there are columns. Unusual having nested loops this way around
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4801 * but is what we need here.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4802 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4803 for ( i=0, iLen=aLayout[0].length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4804 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4805 for ( j=0, jLen=aLayout.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4806 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4807 if ( typeof aLayout[j][i] == 'object' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4808 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4809 aReturn.push( aLayout[j][i] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4810 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4811 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4812 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4813
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4814 return aReturn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4815 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4816
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4817 /*
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4818 * Function: _fnMap
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4819 * Purpose: See if a property is defined on one object, if so assign it to the other object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4820 * Returns: - (done by reference)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4821 * Inputs: object:oRet - target object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4822 * object:oSrc - source object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4823 * string:sName - property
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4824 * string:sMappedName - name to map too - optional, sName used if not given
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4825 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4826 function _fnMap( oRet, oSrc, sName, sMappedName )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4827 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4828 if ( typeof sMappedName == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4829 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4830 sMappedName = sName;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4831 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4832 if ( typeof oSrc[sName] != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4833 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4834 oRet[sMappedName] = oSrc[sName];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4835 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4836 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4837
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4838 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4839 * Section - API
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4840 *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4841 * I'm not overly happy with this solution - I'd much rather that there was a way of getting
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4842 * a list of all the private functions and do what we need to dynamically - but that doesn't
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4843 * appear to be possible. Bonkers. A better solution would be to provide a 'bind' type object
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4844 * To do - bind type method in DTs 2.x.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4845 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4846 this.oApi._fnInitalise = _fnInitalise;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4847 this.oApi._fnLanguageProcess = _fnLanguageProcess;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4848 this.oApi._fnAddColumn = _fnAddColumn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4849 this.oApi._fnAddData = _fnAddData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4850 this.oApi._fnGatherData = _fnGatherData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4851 this.oApi._fnDrawHead = _fnDrawHead;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4852 this.oApi._fnDraw = _fnDraw;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4853 this.oApi._fnAjaxUpdate = _fnAjaxUpdate;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4854 this.oApi._fnAddOptionsHtml = _fnAddOptionsHtml;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4855 this.oApi._fnFeatureHtmlFilter = _fnFeatureHtmlFilter;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4856 this.oApi._fnFeatureHtmlInfo = _fnFeatureHtmlInfo;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4857 this.oApi._fnFeatureHtmlPaginate = _fnFeatureHtmlPaginate;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4858 this.oApi._fnPageChange = _fnPageChange;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4859 this.oApi._fnFeatureHtmlLength = _fnFeatureHtmlLength;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4860 this.oApi._fnFeatureHtmlProcessing = _fnFeatureHtmlProcessing;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4861 this.oApi._fnProcessingDisplay = _fnProcessingDisplay;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4862 this.oApi._fnFilterComplete = _fnFilterComplete;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4863 this.oApi._fnFilterColumn = _fnFilterColumn;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4864 this.oApi._fnFilter = _fnFilter;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4865 this.oApi._fnSortingClasses = _fnSortingClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4866 this.oApi._fnVisibleToColumnIndex = _fnVisibleToColumnIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4867 this.oApi._fnColumnIndexToVisible = _fnColumnIndexToVisible;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4868 this.oApi._fnNodeToDataIndex = _fnNodeToDataIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4869 this.oApi._fnVisbleColumns = _fnVisbleColumns;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4870 this.oApi._fnBuildSearchArray = _fnBuildSearchArray;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4871 this.oApi._fnDataToSearch = _fnDataToSearch;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4872 this.oApi._fnCalculateEnd = _fnCalculateEnd;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4873 this.oApi._fnConvertToWidth = _fnConvertToWidth;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4874 this.oApi._fnCalculateColumnWidths = _fnCalculateColumnWidths;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4875 this.oApi._fnArrayCmp = _fnArrayCmp;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4876 this.oApi._fnDetectType = _fnDetectType;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4877 this.oApi._fnGetDataMaster = _fnGetDataMaster;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4878 this.oApi._fnGetTrNodes = _fnGetTrNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4879 this.oApi._fnGetTdNodes = _fnGetTdNodes;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4880 this.oApi._fnEscapeRegex = _fnEscapeRegex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4881 this.oApi._fnReOrderIndex = _fnReOrderIndex;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4882 this.oApi._fnColumnOrdering = _fnColumnOrdering;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4883 this.oApi._fnClearTable = _fnClearTable;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4884 this.oApi._fnSaveState = _fnSaveState;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4885 this.oApi._fnLoadState = _fnLoadState;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4886 this.oApi._fnCreateCookie = _fnCreateCookie;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4887 this.oApi._fnReadCookie = _fnReadCookie;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4888 this.oApi._fnGetUniqueThs = _fnGetUniqueThs;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4889 this.oApi._fnReDraw = _fnReDraw;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4890
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4891 /* Want to be able to reference "this" inside the this.each function */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4892 var _that = this;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4893
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4894
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4895 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4896 * Section - Constructor
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4897 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4898 return this.each(function()
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4899 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4900 var i=0, iLen, j, jLen;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4901
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4902 /* Sanity check that we are not re-initialising a table - if we are, alert an error */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4903 for ( i=0, iLen=_aoSettings.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4904 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4905 if ( _aoSettings[i].nTable == this )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4906 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4907 alert( "DataTables warning: Unable to re-initialise DataTable. "+
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4908 "Please use the API to make any configuration changes required." );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4909 return _aoSettings[i];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4910 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4911 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4912
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4913 /* Make a complete and independent copy of the settings object */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4914 var oSettings = new classSettings();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4915 _aoSettings.push( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4916
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4917 var bInitHandedOff = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4918 var bUsePassedData = false;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4919
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4920 /* Set the id */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4921 var sId = this.getAttribute( 'id' );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4922 if ( sId !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4923 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4924 oSettings.sTableId = sId;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4925 oSettings.sInstance = sId;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4926 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4927 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4928 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4929 oSettings.sInstance = _oExt._oExternConfig.iNextUnique ++;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4930 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4931
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4932 /* Set the table node */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4933 oSettings.nTable = this;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4934
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4935 /* Bind the API functions to the settings, so we can perform actions whenever oSettings is
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4936 * available
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4937 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4938 oSettings.oApi = _that.oApi;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4939
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4940 /* Store the features that we have available */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4941 if ( typeof oInit != 'undefined' && oInit !== null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4942 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4943 _fnMap( oSettings.oFeatures, oInit, "bPaginate" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4944 _fnMap( oSettings.oFeatures, oInit, "bLengthChange" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4945 _fnMap( oSettings.oFeatures, oInit, "bFilter" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4946 _fnMap( oSettings.oFeatures, oInit, "bSort" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4947 _fnMap( oSettings.oFeatures, oInit, "bInfo" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4948 _fnMap( oSettings.oFeatures, oInit, "bProcessing" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4949 _fnMap( oSettings.oFeatures, oInit, "bAutoWidth" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4950 _fnMap( oSettings.oFeatures, oInit, "bSortClasses" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4951 _fnMap( oSettings.oFeatures, oInit, "bServerSide" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4952 _fnMap( oSettings, oInit, "asStripClasses" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4953 _fnMap( oSettings, oInit, "fnRowCallback" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4954 _fnMap( oSettings, oInit, "fnHeaderCallback" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4955 _fnMap( oSettings, oInit, "fnFooterCallback" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4956 _fnMap( oSettings, oInit, "fnInitComplete" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4957 _fnMap( oSettings, oInit, "fnServerData" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4958 _fnMap( oSettings, oInit, "aaSorting" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4959 _fnMap( oSettings, oInit, "aaSortingFixed" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4960 _fnMap( oSettings, oInit, "sPaginationType" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4961 _fnMap( oSettings, oInit, "sAjaxSource" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4962 _fnMap( oSettings, oInit, "iCookieDuration" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4963 _fnMap( oSettings, oInit, "sDom" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4964 _fnMap( oSettings, oInit, "oSearch", "oPreviousSearch" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4965 _fnMap( oSettings, oInit, "aoSearchCols", "aoPreSearchCols" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4966 _fnMap( oSettings, oInit, "iDisplayLength", "_iDisplayLength" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4967 _fnMap( oSettings, oInit, "bJQueryUI", "bJUI" );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4968
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4969 if ( typeof oInit.fnDrawCallback == 'function' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4970 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4971 /* Add user given callback function to array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4972 oSettings.aoDrawCallback.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4973 "fn": oInit.fnDrawCallback,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4974 "sName": "user"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4975 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4976 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4977
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4978 if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4979 oSettings.oFeatures.bSortClasses )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4980 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4981 /* Enable sort classes for server-side processing. Safe to do it here, since server-side
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4982 * processing must be enabled by the developer
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4983 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4984 oSettings.aoDrawCallback.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4985 "fn": _fnSortingClasses,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4986 "sName": "server_side_sort_classes"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4987 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4988 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4989
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4990 if ( typeof oInit.bJQueryUI != 'undefined' && oInit.bJQueryUI )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4991 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4992 /* Use the JUI classes object for display. You could clone the oStdClasses object if
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4993 * you want to have multiple tables with multiple independent classes
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4994 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4995 oSettings.oClasses = _oExt.oJUIClasses;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4996
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4997 if ( typeof oInit.sDom == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4998 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
4999 /* Set the DOM to use a layout suitable for jQuery UI's theming */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5000 oSettings.sDom = '<"H"lfr>t<"F"ip>';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5001 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5002 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5003
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5004 if ( typeof oInit.iDisplayStart != 'undefined' &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5005 typeof oSettings.iInitDisplayStart == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5006 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5007 /* Display start point, taking into account the save saving */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5008 oSettings.iInitDisplayStart = oInit.iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5009 oSettings._iDisplayStart = oInit.iDisplayStart;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5010 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5011
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5012 /* Must be done after everything which can be overridden by a cookie! */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5013 if ( typeof oInit.bStateSave != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5014 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5015 oSettings.oFeatures.bStateSave = oInit.bStateSave;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5016 _fnLoadState( oSettings, oInit );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5017 oSettings.aoDrawCallback.push( {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5018 "fn": _fnSaveState,
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5019 "sName": "state_save"
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5020 } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5021 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5022
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5023 if ( typeof oInit.aaData != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5024 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5025 bUsePassedData = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5026 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5027
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5028 /* Backwards compatability */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5029 /* aoColumns / aoData - remove at some point... */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5030 if ( typeof oInit != 'undefined' && typeof oInit.aoData != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5031 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5032 oInit.aoColumns = oInit.aoData;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5033 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5034
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5035 /* Language definitions */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5036 if ( typeof oInit.oLanguage != 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5037 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5038 if ( typeof oInit.oLanguage.sUrl != 'undefined' && oInit.oLanguage.sUrl !== "" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5039 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5040 /* Get the language definitions from a file */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5041 oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5042 $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5043 _fnLanguageProcess( oSettings, json, true ); } );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5044 bInitHandedOff = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5045 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5046 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5047 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5048 _fnLanguageProcess( oSettings, oInit.oLanguage, false );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5049 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5050 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5051 /* Warning: The _fnLanguageProcess function is async to the remainder of this function due
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5052 * to the XHR. We use _bInitialised in _fnLanguageProcess() to check this the processing
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5053 * below is complete. The reason for spliting it like this is optimisation - we can fire
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5054 * off the XHR (if needed) and then continue processing the data.
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5055 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5056 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5057 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5058 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5059 /* Create a dummy object for quick manipulation later on. */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5060 oInit = {};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5061 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5062
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5063 /* Add the strip classes now that we know which classes to apply - unless overruled */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5064 if ( typeof oInit.asStripClasses == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5065 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5066 oSettings.asStripClasses.push( oSettings.oClasses.sStripOdd );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5067 oSettings.asStripClasses.push( oSettings.oClasses.sStripEven );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5068 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5069
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5070 /* See if we should load columns automatically or use defined ones - a bit messy this... */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5071 var nThead = this.getElementsByTagName('thead');
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5072 var nThs = nThead.length===0 ? null : _fnGetUniqueThs( nThead[0] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5073 var bUseCols = typeof oInit.aoColumns != 'undefined';
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5074
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5075 for ( i=0, iLen=bUseCols ? oInit.aoColumns.length : nThs.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5076 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5077 var oCol = bUseCols ? oInit.aoColumns[i] : null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5078 var nTh = nThs ? nThs[i] : null;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5079
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5080 /* Check if we have column visibilty state to restore, and also that the length of the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5081 * state saved columns matches the currently know number of columns
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5082 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5083 if ( typeof oInit.saved_aoColumns != 'undefined' && oInit.saved_aoColumns.length == iLen )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5084 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5085 if ( oCol === null )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5086 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5087 oCol = {};
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5088 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5089 oCol.bVisible = oInit.saved_aoColumns[i].bVisible;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5090 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5091
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5092 _fnAddColumn( oSettings, oCol, nTh );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5093 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5094
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5095 /* Check the aaSorting array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5096 for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5097 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5098 var oColumn = oSettings.aoColumns[ oSettings.aaSorting[i][0] ];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5099
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5100 /* Add a default sorting index */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5101 if ( typeof oSettings.aaSorting[i][2] == 'undefined' )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5102 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5103 oSettings.aaSorting[i][2] = 0;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5104 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5105
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5106 /* If aaSorting is not defined, then we use the first indicator in asSorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5107 if ( typeof oInit.aaSorting == "undefined" &&
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5108 typeof oSettings.saved_aaSorting == "undefined" )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5109 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5110 oSettings.aaSorting[i][1] = oColumn.asSorting[0];
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5111 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5112
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5113 /* Set the current sorting index based on aoColumns.asSorting */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5114 for ( j=0, jLen=oColumn.asSorting.length ; j<jLen ; j++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5115 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5116 if ( oSettings.aaSorting[i][1] == oColumn.asSorting[j] )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5117 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5118 oSettings.aaSorting[i][2] = j;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5119 break;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5120 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5121 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5122 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5123
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5124 /* Sanity check that there is a thead and tfoot. If not let's just create them */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5125 if ( this.getElementsByTagName('thead').length === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5126 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5127 this.appendChild( document.createElement( 'thead' ) );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5128 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5129
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5130 if ( this.getElementsByTagName('tbody').length === 0 )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5131 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5132 this.appendChild( document.createElement( 'tbody' ) );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5133 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5134
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5135 /* Check if there is data passing into the constructor */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5136 if ( bUsePassedData )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5137 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5138 for ( i=0 ; i<oInit.aaData.length ; i++ )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5139 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5140 _fnAddData( oSettings, oInit.aaData[ i ] );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5141 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5142 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5143 else
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5144 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5145 /* Grab the data from the page */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5146 _fnGatherData( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5147 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5148
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5149 /* Copy the data index array */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5150 oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5151
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5152 /* Calculate sizes for columns */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5153 if ( oSettings.oFeatures.bAutoWidth )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5154 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5155 _fnCalculateColumnWidths( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5156 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5157
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5158 /* Initialisation complete - table can be drawn */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5159 oSettings.bInitialised = true;
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5160
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5161 /* Check if we need to initialise the table (it might not have been handed off to the
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5162 * language processor)
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5163 */
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5164 if ( bInitHandedOff === false )
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5165 {
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5166 _fnInitalise( oSettings );
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5167 }
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5168 });
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5169 };
7f008e782563 add gui files to product via FileSystemSite
casties
parents:
diff changeset
5170 })(jQuery);