comparison DataTables-1.9.4/media/src/model/model.settings.js @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ac5f9272033b
1
2
3 /**
4 * DataTables settings object - this holds all the information needed for a
5 * given table, including configuration, data and current application of the
6 * table options. DataTables does not have a single instance for each DataTable
7 * with the settings attached to that instance, but rather instances of the
8 * DataTable "class" are created on-the-fly as needed (typically by a
9 * $().dataTable() call) and the settings object is then applied to that
10 * instance.
11 *
12 * Note that this object is related to {@link DataTable.defaults} but this
13 * one is the internal data store for DataTables's cache of columns. It should
14 * NOT be manipulated outside of DataTables. Any configuration should be done
15 * through the initialisation options.
16 * @namespace
17 * @todo Really should attach the settings object to individual instances so we
18 * don't need to create new instances on each $().dataTable() call (if the
19 * table already exists). It would also save passing oSettings around and
20 * into every single function. However, this is a very significant
21 * architecture change for DataTables and will almost certainly break
22 * backwards compatibility with older installations. This is something that
23 * will be done in 2.0.
24 */
25 DataTable.models.oSettings = {
26 /**
27 * Primary features of DataTables and their enablement state.
28 * @namespace
29 */
30 "oFeatures": {
31
32 /**
33 * Flag to say if DataTables should automatically try to calculate the
34 * optimum table and columns widths (true) or not (false).
35 * Note that this parameter will be set by the initialisation routine. To
36 * set a default use {@link DataTable.defaults}.
37 * @type boolean
38 */
39 "bAutoWidth": null,
40
41 /**
42 * Delay the creation of TR and TD elements until they are actually
43 * needed by a driven page draw. This can give a significant speed
44 * increase for Ajax source and Javascript source data, but makes no
45 * difference at all fro DOM and server-side processing tables.
46 * Note that this parameter will be set by the initialisation routine. To
47 * set a default use {@link DataTable.defaults}.
48 * @type boolean
49 */
50 "bDeferRender": null,
51
52 /**
53 * Enable filtering on the table or not. Note that if this is disabled
54 * then there is no filtering at all on the table, including fnFilter.
55 * To just remove the filtering input use sDom and remove the 'f' option.
56 * Note that this parameter will be set by the initialisation routine. To
57 * set a default use {@link DataTable.defaults}.
58 * @type boolean
59 */
60 "bFilter": null,
61
62 /**
63 * Table information element (the 'Showing x of y records' div) enable
64 * flag.
65 * Note that this parameter will be set by the initialisation routine. To
66 * set a default use {@link DataTable.defaults}.
67 * @type boolean
68 */
69 "bInfo": null,
70
71 /**
72 * Present a user control allowing the end user to change the page size
73 * when pagination is enabled.
74 * Note that this parameter will be set by the initialisation routine. To
75 * set a default use {@link DataTable.defaults}.
76 * @type boolean
77 */
78 "bLengthChange": null,
79
80 /**
81 * Pagination enabled or not. Note that if this is disabled then length
82 * changing must also be disabled.
83 * Note that this parameter will be set by the initialisation routine. To
84 * set a default use {@link DataTable.defaults}.
85 * @type boolean
86 */
87 "bPaginate": null,
88
89 /**
90 * Processing indicator enable flag whenever DataTables is enacting a
91 * user request - typically an Ajax request for server-side processing.
92 * Note that this parameter will be set by the initialisation routine. To
93 * set a default use {@link DataTable.defaults}.
94 * @type boolean
95 */
96 "bProcessing": null,
97
98 /**
99 * Server-side processing enabled flag - when enabled DataTables will
100 * get all data from the server for every draw - there is no filtering,
101 * sorting or paging done on the client-side.
102 * Note that this parameter will be set by the initialisation routine. To
103 * set a default use {@link DataTable.defaults}.
104 * @type boolean
105 */
106 "bServerSide": null,
107
108 /**
109 * Sorting enablement flag.
110 * Note that this parameter will be set by the initialisation routine. To
111 * set a default use {@link DataTable.defaults}.
112 * @type boolean
113 */
114 "bSort": null,
115
116 /**
117 * Apply a class to the columns which are being sorted to provide a
118 * visual highlight or not. This can slow things down when enabled since
119 * there is a lot of DOM interaction.
120 * Note that this parameter will be set by the initialisation routine. To
121 * set a default use {@link DataTable.defaults}.
122 * @type boolean
123 */
124 "bSortClasses": null,
125
126 /**
127 * State saving enablement flag.
128 * Note that this parameter will be set by the initialisation routine. To
129 * set a default use {@link DataTable.defaults}.
130 * @type boolean
131 */
132 "bStateSave": null
133 },
134
135
136 /**
137 * Scrolling settings for a table.
138 * @namespace
139 */
140 "oScroll": {
141 /**
142 * Indicate if DataTables should be allowed to set the padding / margin
143 * etc for the scrolling header elements or not. Typically you will want
144 * this.
145 * Note that this parameter will be set by the initialisation routine. To
146 * set a default use {@link DataTable.defaults}.
147 * @type boolean
148 */
149 "bAutoCss": null,
150
151 /**
152 * When the table is shorter in height than sScrollY, collapse the
153 * table container down to the height of the table (when true).
154 * Note that this parameter will be set by the initialisation routine. To
155 * set a default use {@link DataTable.defaults}.
156 * @type boolean
157 */
158 "bCollapse": null,
159
160 /**
161 * Infinite scrolling enablement flag. Now deprecated in favour of
162 * using the Scroller plug-in.
163 * Note that this parameter will be set by the initialisation routine. To
164 * set a default use {@link DataTable.defaults}.
165 * @type boolean
166 */
167 "bInfinite": null,
168
169 /**
170 * Width of the scrollbar for the web-browser's platform. Calculated
171 * during table initialisation.
172 * @type int
173 * @default 0
174 */
175 "iBarWidth": 0,
176
177 /**
178 * Space (in pixels) between the bottom of the scrolling container and
179 * the bottom of the scrolling viewport before the next page is loaded
180 * when using infinite scrolling.
181 * Note that this parameter will be set by the initialisation routine. To
182 * set a default use {@link DataTable.defaults}.
183 * @type int
184 */
185 "iLoadGap": null,
186
187 /**
188 * Viewport width for horizontal scrolling. Horizontal scrolling is
189 * disabled if an empty string.
190 * Note that this parameter will be set by the initialisation routine. To
191 * set a default use {@link DataTable.defaults}.
192 * @type string
193 */
194 "sX": null,
195
196 /**
197 * Width to expand the table to when using x-scrolling. Typically you
198 * should not need to use this.
199 * Note that this parameter will be set by the initialisation routine. To
200 * set a default use {@link DataTable.defaults}.
201 * @type string
202 * @deprecated
203 */
204 "sXInner": null,
205
206 /**
207 * Viewport height for vertical scrolling. Vertical scrolling is disabled
208 * if an empty string.
209 * Note that this parameter will be set by the initialisation routine. To
210 * set a default use {@link DataTable.defaults}.
211 * @type string
212 */
213 "sY": null
214 },
215
216 /**
217 * Language information for the table.
218 * @namespace
219 * @extends DataTable.defaults.oLanguage
220 */
221 "oLanguage": {
222 /**
223 * Information callback function. See
224 * {@link DataTable.defaults.fnInfoCallback}
225 * @type function
226 * @default null
227 */
228 "fnInfoCallback": null
229 },
230
231 /**
232 * Browser support parameters
233 * @namespace
234 */
235 "oBrowser": {
236 /**
237 * Indicate if the browser incorrectly calculates width:100% inside a
238 * scrolling element (IE6/7)
239 * @type boolean
240 * @default false
241 */
242 "bScrollOversize": false
243 },
244
245 /**
246 * Array referencing the nodes which are used for the features. The
247 * parameters of this object match what is allowed by sDom - i.e.
248 * <ul>
249 * <li>'l' - Length changing</li>
250 * <li>'f' - Filtering input</li>
251 * <li>'t' - The table!</li>
252 * <li>'i' - Information</li>
253 * <li>'p' - Pagination</li>
254 * <li>'r' - pRocessing</li>
255 * </ul>
256 * @type array
257 * @default []
258 */
259 "aanFeatures": [],
260
261 /**
262 * Store data information - see {@link DataTable.models.oRow} for detailed
263 * information.
264 * @type array
265 * @default []
266 */
267 "aoData": [],
268
269 /**
270 * Array of indexes which are in the current display (after filtering etc)
271 * @type array
272 * @default []
273 */
274 "aiDisplay": [],
275
276 /**
277 * Array of indexes for display - no filtering
278 * @type array
279 * @default []
280 */
281 "aiDisplayMaster": [],
282
283 /**
284 * Store information about each column that is in use
285 * @type array
286 * @default []
287 */
288 "aoColumns": [],
289
290 /**
291 * Store information about the table's header
292 * @type array
293 * @default []
294 */
295 "aoHeader": [],
296
297 /**
298 * Store information about the table's footer
299 * @type array
300 * @default []
301 */
302 "aoFooter": [],
303
304 /**
305 * Search data array for regular expression searching
306 * @type array
307 * @default []
308 */
309 "asDataSearch": [],
310
311 /**
312 * Store the applied global search information in case we want to force a
313 * research or compare the old search to a new one.
314 * Note that this parameter will be set by the initialisation routine. To
315 * set a default use {@link DataTable.defaults}.
316 * @namespace
317 * @extends DataTable.models.oSearch
318 */
319 "oPreviousSearch": {},
320
321 /**
322 * Store the applied search for each column - see
323 * {@link DataTable.models.oSearch} for the format that is used for the
324 * filtering information for each column.
325 * @type array
326 * @default []
327 */
328 "aoPreSearchCols": [],
329
330 /**
331 * Sorting that is applied to the table. Note that the inner arrays are
332 * used in the following manner:
333 * <ul>
334 * <li>Index 0 - column number</li>
335 * <li>Index 1 - current sorting direction</li>
336 * <li>Index 2 - index of asSorting for this column</li>
337 * </ul>
338 * Note that this parameter will be set by the initialisation routine. To
339 * set a default use {@link DataTable.defaults}.
340 * @type array
341 * @todo These inner arrays should really be objects
342 */
343 "aaSorting": null,
344
345 /**
346 * Sorting that is always applied to the table (i.e. prefixed in front of
347 * aaSorting).
348 * Note that this parameter will be set by the initialisation routine. To
349 * set a default use {@link DataTable.defaults}.
350 * @type array|null
351 * @default null
352 */
353 "aaSortingFixed": null,
354
355 /**
356 * Classes to use for the striping of a table.
357 * Note that this parameter will be set by the initialisation routine. To
358 * set a default use {@link DataTable.defaults}.
359 * @type array
360 * @default []
361 */
362 "asStripeClasses": null,
363
364 /**
365 * If restoring a table - we should restore its striping classes as well
366 * @type array
367 * @default []
368 */
369 "asDestroyStripes": [],
370
371 /**
372 * If restoring a table - we should restore its width
373 * @type int
374 * @default 0
375 */
376 "sDestroyWidth": 0,
377
378 /**
379 * Callback functions array for every time a row is inserted (i.e. on a draw).
380 * @type array
381 * @default []
382 */
383 "aoRowCallback": [],
384
385 /**
386 * Callback functions for the header on each draw.
387 * @type array
388 * @default []
389 */
390 "aoHeaderCallback": [],
391
392 /**
393 * Callback function for the footer on each draw.
394 * @type array
395 * @default []
396 */
397 "aoFooterCallback": [],
398
399 /**
400 * Array of callback functions for draw callback functions
401 * @type array
402 * @default []
403 */
404 "aoDrawCallback": [],
405
406 /**
407 * Array of callback functions for row created function
408 * @type array
409 * @default []
410 */
411 "aoRowCreatedCallback": [],
412
413 /**
414 * Callback functions for just before the table is redrawn. A return of
415 * false will be used to cancel the draw.
416 * @type array
417 * @default []
418 */
419 "aoPreDrawCallback": [],
420
421 /**
422 * Callback functions for when the table has been initialised.
423 * @type array
424 * @default []
425 */
426 "aoInitComplete": [],
427
428
429 /**
430 * Callbacks for modifying the settings to be stored for state saving, prior to
431 * saving state.
432 * @type array
433 * @default []
434 */
435 "aoStateSaveParams": [],
436
437 /**
438 * Callbacks for modifying the settings that have been stored for state saving
439 * prior to using the stored values to restore the state.
440 * @type array
441 * @default []
442 */
443 "aoStateLoadParams": [],
444
445 /**
446 * Callbacks for operating on the settings object once the saved state has been
447 * loaded
448 * @type array
449 * @default []
450 */
451 "aoStateLoaded": [],
452
453 /**
454 * Cache the table ID for quick access
455 * @type string
456 * @default <i>Empty string</i>
457 */
458 "sTableId": "",
459
460 /**
461 * The TABLE node for the main table
462 * @type node
463 * @default null
464 */
465 "nTable": null,
466
467 /**
468 * Permanent ref to the thead element
469 * @type node
470 * @default null
471 */
472 "nTHead": null,
473
474 /**
475 * Permanent ref to the tfoot element - if it exists
476 * @type node
477 * @default null
478 */
479 "nTFoot": null,
480
481 /**
482 * Permanent ref to the tbody element
483 * @type node
484 * @default null
485 */
486 "nTBody": null,
487
488 /**
489 * Cache the wrapper node (contains all DataTables controlled elements)
490 * @type node
491 * @default null
492 */
493 "nTableWrapper": null,
494
495 /**
496 * Indicate if when using server-side processing the loading of data
497 * should be deferred until the second draw.
498 * Note that this parameter will be set by the initialisation routine. To
499 * set a default use {@link DataTable.defaults}.
500 * @type boolean
501 * @default false
502 */
503 "bDeferLoading": false,
504
505 /**
506 * Indicate if all required information has been read in
507 * @type boolean
508 * @default false
509 */
510 "bInitialised": false,
511
512 /**
513 * Information about open rows. Each object in the array has the parameters
514 * 'nTr' and 'nParent'
515 * @type array
516 * @default []
517 */
518 "aoOpenRows": [],
519
520 /**
521 * Dictate the positioning of DataTables' control elements - see
522 * {@link DataTable.model.oInit.sDom}.
523 * Note that this parameter will be set by the initialisation routine. To
524 * set a default use {@link DataTable.defaults}.
525 * @type string
526 * @default null
527 */
528 "sDom": null,
529
530 /**
531 * Which type of pagination should be used.
532 * Note that this parameter will be set by the initialisation routine. To
533 * set a default use {@link DataTable.defaults}.
534 * @type string
535 * @default two_button
536 */
537 "sPaginationType": "two_button",
538
539 /**
540 * The cookie duration (for bStateSave) in seconds.
541 * Note that this parameter will be set by the initialisation routine. To
542 * set a default use {@link DataTable.defaults}.
543 * @type int
544 * @default 0
545 */
546 "iCookieDuration": 0,
547
548 /**
549 * The cookie name prefix.
550 * Note that this parameter will be set by the initialisation routine. To
551 * set a default use {@link DataTable.defaults}.
552 * @type string
553 * @default <i>Empty string</i>
554 */
555 "sCookiePrefix": "",
556
557 /**
558 * Callback function for cookie creation.
559 * Note that this parameter will be set by the initialisation routine. To
560 * set a default use {@link DataTable.defaults}.
561 * @type function
562 * @default null
563 */
564 "fnCookieCallback": null,
565
566 /**
567 * Array of callback functions for state saving. Each array element is an
568 * object with the following parameters:
569 * <ul>
570 * <li>function:fn - function to call. Takes two parameters, oSettings
571 * and the JSON string to save that has been thus far created. Returns
572 * a JSON string to be inserted into a json object
573 * (i.e. '"param": [ 0, 1, 2]')</li>
574 * <li>string:sName - name of callback</li>
575 * </ul>
576 * @type array
577 * @default []
578 */
579 "aoStateSave": [],
580
581 /**
582 * Array of callback functions for state loading. Each array element is an
583 * object with the following parameters:
584 * <ul>
585 * <li>function:fn - function to call. Takes two parameters, oSettings
586 * and the object stored. May return false to cancel state loading</li>
587 * <li>string:sName - name of callback</li>
588 * </ul>
589 * @type array
590 * @default []
591 */
592 "aoStateLoad": [],
593
594 /**
595 * State that was loaded from the cookie. Useful for back reference
596 * @type object
597 * @default null
598 */
599 "oLoadedState": null,
600
601 /**
602 * Source url for AJAX data for the table.
603 * Note that this parameter will be set by the initialisation routine. To
604 * set a default use {@link DataTable.defaults}.
605 * @type string
606 * @default null
607 */
608 "sAjaxSource": null,
609
610 /**
611 * Property from a given object from which to read the table data from. This
612 * can be an empty string (when not server-side processing), in which case
613 * it is assumed an an array is given directly.
614 * Note that this parameter will be set by the initialisation routine. To
615 * set a default use {@link DataTable.defaults}.
616 * @type string
617 */
618 "sAjaxDataProp": null,
619
620 /**
621 * Note if draw should be blocked while getting data
622 * @type boolean
623 * @default true
624 */
625 "bAjaxDataGet": true,
626
627 /**
628 * The last jQuery XHR object that was used for server-side data gathering.
629 * This can be used for working with the XHR information in one of the
630 * callbacks
631 * @type object
632 * @default null
633 */
634 "jqXHR": null,
635
636 /**
637 * Function to get the server-side data.
638 * Note that this parameter will be set by the initialisation routine. To
639 * set a default use {@link DataTable.defaults}.
640 * @type function
641 */
642 "fnServerData": null,
643
644 /**
645 * Functions which are called prior to sending an Ajax request so extra
646 * parameters can easily be sent to the server
647 * @type array
648 * @default []
649 */
650 "aoServerParams": [],
651
652 /**
653 * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
654 * required).
655 * Note that this parameter will be set by the initialisation routine. To
656 * set a default use {@link DataTable.defaults}.
657 * @type string
658 */
659 "sServerMethod": null,
660
661 /**
662 * Format numbers for display.
663 * Note that this parameter will be set by the initialisation routine. To
664 * set a default use {@link DataTable.defaults}.
665 * @type function
666 */
667 "fnFormatNumber": null,
668
669 /**
670 * List of options that can be used for the user selectable length menu.
671 * Note that this parameter will be set by the initialisation routine. To
672 * set a default use {@link DataTable.defaults}.
673 * @type array
674 * @default []
675 */
676 "aLengthMenu": null,
677
678 /**
679 * Counter for the draws that the table does. Also used as a tracker for
680 * server-side processing
681 * @type int
682 * @default 0
683 */
684 "iDraw": 0,
685
686 /**
687 * Indicate if a redraw is being done - useful for Ajax
688 * @type boolean
689 * @default false
690 */
691 "bDrawing": false,
692
693 /**
694 * Draw index (iDraw) of the last error when parsing the returned data
695 * @type int
696 * @default -1
697 */
698 "iDrawError": -1,
699
700 /**
701 * Paging display length
702 * @type int
703 * @default 10
704 */
705 "_iDisplayLength": 10,
706
707 /**
708 * Paging start point - aiDisplay index
709 * @type int
710 * @default 0
711 */
712 "_iDisplayStart": 0,
713
714 /**
715 * Paging end point - aiDisplay index. Use fnDisplayEnd rather than
716 * this property to get the end point
717 * @type int
718 * @default 10
719 * @private
720 */
721 "_iDisplayEnd": 10,
722
723 /**
724 * Server-side processing - number of records in the result set
725 * (i.e. before filtering), Use fnRecordsTotal rather than
726 * this property to get the value of the number of records, regardless of
727 * the server-side processing setting.
728 * @type int
729 * @default 0
730 * @private
731 */
732 "_iRecordsTotal": 0,
733
734 /**
735 * Server-side processing - number of records in the current display set
736 * (i.e. after filtering). Use fnRecordsDisplay rather than
737 * this property to get the value of the number of records, regardless of
738 * the server-side processing setting.
739 * @type boolean
740 * @default 0
741 * @private
742 */
743 "_iRecordsDisplay": 0,
744
745 /**
746 * Flag to indicate if jQuery UI marking and classes should be used.
747 * Note that this parameter will be set by the initialisation routine. To
748 * set a default use {@link DataTable.defaults}.
749 * @type boolean
750 */
751 "bJUI": null,
752
753 /**
754 * The classes to use for the table
755 * @type object
756 * @default {}
757 */
758 "oClasses": {},
759
760 /**
761 * Flag attached to the settings object so you can check in the draw
762 * callback if filtering has been done in the draw. Deprecated in favour of
763 * events.
764 * @type boolean
765 * @default false
766 * @deprecated
767 */
768 "bFiltered": false,
769
770 /**
771 * Flag attached to the settings object so you can check in the draw
772 * callback if sorting has been done in the draw. Deprecated in favour of
773 * events.
774 * @type boolean
775 * @default false
776 * @deprecated
777 */
778 "bSorted": false,
779
780 /**
781 * Indicate that if multiple rows are in the header and there is more than
782 * one unique cell per column, if the top one (true) or bottom one (false)
783 * should be used for sorting / title by DataTables.
784 * Note that this parameter will be set by the initialisation routine. To
785 * set a default use {@link DataTable.defaults}.
786 * @type boolean
787 */
788 "bSortCellsTop": null,
789
790 /**
791 * Initialisation object that is used for the table
792 * @type object
793 * @default null
794 */
795 "oInit": null,
796
797 /**
798 * Destroy callback functions - for plug-ins to attach themselves to the
799 * destroy so they can clean up markup and events.
800 * @type array
801 * @default []
802 */
803 "aoDestroyCallback": [],
804
805
806 /**
807 * Get the number of records in the current record set, before filtering
808 * @type function
809 */
810 "fnRecordsTotal": function ()
811 {
812 if ( this.oFeatures.bServerSide ) {
813 return parseInt(this._iRecordsTotal, 10);
814 } else {
815 return this.aiDisplayMaster.length;
816 }
817 },
818
819 /**
820 * Get the number of records in the current record set, after filtering
821 * @type function
822 */
823 "fnRecordsDisplay": function ()
824 {
825 if ( this.oFeatures.bServerSide ) {
826 return parseInt(this._iRecordsDisplay, 10);
827 } else {
828 return this.aiDisplay.length;
829 }
830 },
831
832 /**
833 * Set the display end point - aiDisplay index
834 * @type function
835 * @todo Should do away with _iDisplayEnd and calculate it on-the-fly here
836 */
837 "fnDisplayEnd": function ()
838 {
839 if ( this.oFeatures.bServerSide ) {
840 if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
841 return this._iDisplayStart+this.aiDisplay.length;
842 } else {
843 return Math.min( this._iDisplayStart+this._iDisplayLength,
844 this._iRecordsDisplay );
845 }
846 } else {
847 return this._iDisplayEnd;
848 }
849 },
850
851 /**
852 * The DataTables object for this table
853 * @type object
854 * @default null
855 */
856 "oInstance": null,
857
858 /**
859 * Unique identifier for each instance of the DataTables object. If there
860 * is an ID on the table node, then it takes that value, otherwise an
861 * incrementing internal counter is used.
862 * @type string
863 * @default null
864 */
865 "sInstance": null,
866
867 /**
868 * tabindex attribute value that is added to DataTables control elements, allowing
869 * keyboard navigation of the table and its controls.
870 */
871 "iTabIndex": 0,
872
873 /**
874 * DIV container for the footer scrolling table if scrolling
875 */
876 "nScrollHead": null,
877
878 /**
879 * DIV container for the footer scrolling table if scrolling
880 */
881 "nScrollFoot": null
882 };