|
1 | 1 | /*
|
2 |
| - * |
| 2 | + * |
3 | 3 | * TableSorter 2.0 - Client-side table sorting with ease!
|
4 | 4 | * Version 2.0.5b
|
5 | 5 | * @requires jQuery v1.2.3
|
6 |
| - * |
| 6 | + * |
7 | 7 | * Copyright (c) 2007 Christian Bach
|
8 | 8 | * Examples and docs at: http://tablesorter.com
|
9 | 9 | * Dual licensed under the MIT and GPL licenses:
|
10 | 10 | * http://www.opensource.org/licenses/mit-license.php
|
11 | 11 | * http://www.gnu.org/licenses/gpl.html
|
12 |
| - * |
| 12 | + * |
13 | 13 | */
|
14 | 14 | /**
|
15 |
| - * |
| 15 | + * |
16 | 16 | * @description Create a sortable table with multi-column sorting capabilitys
|
17 |
| - * |
| 17 | + * |
18 | 18 | * @example $('table').tablesorter();
|
19 | 19 | * @desc Create a simple tablesorter interface.
|
20 |
| - * |
| 20 | + * |
21 | 21 | * @example $('table').tablesorter({ sortList:[[0,0],[1,0]] });
|
22 | 22 | * @desc Create a tablesorter interface and sort on the first and secound column column headers.
|
23 |
| - * |
| 23 | + * |
24 | 24 | * @example $('table').tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } });
|
25 |
| - * |
| 25 | + * |
26 | 26 | * @desc Create a tablesorter interface and disableing the first and second column headers.
|
27 |
| - * |
28 |
| - * |
| 27 | + * |
| 28 | + * |
29 | 29 | * @example $('table').tablesorter({ headers: { 0: {sorter:"integer"}, 1: {sorter:"currency"} } });
|
30 |
| - * |
| 30 | + * |
31 | 31 | * @desc Create a tablesorter interface and set a column parser for the first
|
32 | 32 | * and second column.
|
33 |
| - * |
34 |
| - * |
| 33 | + * |
| 34 | + * |
35 | 35 | * @param Object
|
36 | 36 | * settings An object literal containing key/value pairs to provide
|
37 | 37 | * optional settings.
|
38 |
| - * |
39 |
| - * |
| 38 | + * |
| 39 | + * |
40 | 40 | * @option String cssHeader (optional) A string of the class name to be appended
|
41 | 41 | * to sortable tr elements in the thead of the table. Default value:
|
42 | 42 | * "header"
|
43 |
| - * |
| 43 | + * |
44 | 44 | * @option String cssAsc (optional) A string of the class name to be appended to
|
45 | 45 | * sortable tr elements in the thead on a ascending sort. Default value:
|
46 | 46 | * "headerSortUp"
|
47 |
| - * |
| 47 | + * |
48 | 48 | * @option String cssDesc (optional) A string of the class name to be appended
|
49 | 49 | * to sortable tr elements in the thead on a descending sort. Default
|
50 | 50 | * value: "headerSortDown"
|
51 |
| - * |
| 51 | + * |
52 | 52 | * @option String sortInitialOrder (optional) A string of the inital sorting
|
53 | 53 | * order can be asc or desc. Default value: "asc"
|
54 |
| - * |
| 54 | + * |
55 | 55 | * @option String sortMultisortKey (optional) A string of the multi-column sort
|
56 | 56 | * key. Default value: "shiftKey"
|
57 |
| - * |
| 57 | + * |
58 | 58 | * @option String textExtraction (optional) A string of the text-extraction
|
59 | 59 | * method to use. For complex html structures inside td cell set this
|
60 | 60 | * option to "complex", on large tables the complex option can be slow.
|
61 | 61 | * Default value: "simple"
|
62 |
| - * |
| 62 | + * |
63 | 63 | * @option Object headers (optional) An object of instructions for per-column
|
64 |
| - * controls in the format: headers: { 0: { option: setting }, ... }. For |
| 64 | + * controls in the format: headers: { 0: { option: setting }, ... }. For |
65 | 65 | * example, to disable sorting on the first two columns of a table:
|
66 | 66 | * headers: { 0: { sorter: false}, 1: {sorter: false} }.
|
67 | 67 | * Default value: null.
|
68 |
| - * |
69 |
| - * @option Array sortList (optional) An array of instructions for per-column sorting |
70 |
| - * and direction in the format: [[columnIndex, sortDirection], ... ] where |
71 |
| - * columnIndex is a zero-based index for your columns left-to-right and |
72 |
| - * sortDirection is 0 for Ascending and 1 for Descending. A valid argument |
73 |
| - * that sorts ascending first by column 1 and then column 2 looks like: |
| 68 | + * |
| 69 | + * @option Array sortList (optional) An array of instructions for per-column sorting |
| 70 | + * and direction in the format: [[columnIndex, sortDirection], ... ] where |
| 71 | + * columnIndex is a zero-based index for your columns left-to-right and |
| 72 | + * sortDirection is 0 for Ascending and 1 for Descending. A valid argument |
| 73 | + * that sorts ascending first by column 1 and then column 2 looks like: |
74 | 74 | * [[0,0],[1,0]]. Default value: null.
|
75 |
| - * |
| 75 | + * |
76 | 76 | * @option Array sortForce (optional) An array containing forced sorting rules.
|
77 | 77 | * Use to add an additional forced sort that will be appended to the dynamic
|
78 | 78 | * selections by the user. For example, can be used to sort people alphabetically
|
79 |
| - * after some other user-selected sort that results in rows with the same value |
80 |
| - * like dates or money due. It can help prevent data from appearing as though it |
| 79 | + * after some other user-selected sort that results in rows with the same value |
| 80 | + * like dates or money due. It can help prevent data from appearing as though it |
81 | 81 | * has a random secondary sort. Default value: null.
|
82 |
| - * |
| 82 | + * |
83 | 83 | * @option Boolean sortLocaleCompare (optional) Boolean flag indicating whatever
|
84 | 84 | * to use String.localeCampare method or not. Default set to true.
|
85 |
| - * |
86 |
| - * |
| 85 | + * |
| 86 | + * |
87 | 87 | * @option Array sortAppend (optional) An array containing forced sorting rules.
|
88 | 88 | * This option let's you specify a default sorting rule, which is
|
89 | 89 | * appended to user-selected rules. Default value: null
|
90 |
| - * |
| 90 | + * |
91 | 91 | * @option Boolean widthFixed (optional) Boolean flag indicating if tablesorter
|
92 | 92 | * should apply fixed widths to the table columns. This is usefull when
|
93 | 93 | * using the pager companion plugin. This options requires the dimension
|
94 | 94 | * jquery plugin. Default value: false
|
95 |
| - * |
| 95 | + * |
96 | 96 | * @option Boolean cancelSelection (optional) Boolean flag indicating if
|
97 | 97 | * tablesorter should cancel selection of the table headers text.
|
98 | 98 | * Default value: true
|
99 |
| - * |
| 99 | + * |
100 | 100 | * @option Boolean debug (optional) Boolean flag indicating if tablesorter
|
101 | 101 | * should display debuging information usefull for development.
|
102 |
| - * |
| 102 | + * |
103 | 103 | * @type jQuery
|
104 |
| - * |
| 104 | + * |
105 | 105 | * @name tablesorter
|
106 |
| - * |
| 106 | + * |
107 | 107 | * @cat Plugins/Tablesorter
|
108 |
| - * |
| 108 | + * |
109 | 109 | * @author Christian Bach/christian.bach@polyester.se
|
110 | 110 | */
|
111 | 111 |
|
|
300 | 300 | };
|
301 | 301 |
|
302 | 302 | function getElementText(config, node) {
|
303 |
| - |
| 303 | + |
304 | 304 | if (!node) return "";
|
305 |
| - |
| 305 | + |
306 | 306 | var $node = $(node),
|
307 | 307 | data = $node.attr('data-sort-value');
|
308 | 308 | if (data !== undefined) return data;
|
|
359 | 359 | tableBody[0].appendChild(r[pos][j]);
|
360 | 360 | }
|
361 | 361 |
|
362 |
| - // |
| 362 | + // |
363 | 363 | }
|
364 | 364 | }
|
365 | 365 |
|
|
393 | 393 | }
|
394 | 394 |
|
395 | 395 | var meta = ($.metadata) ? true : false;
|
396 |
| - |
| 396 | + |
397 | 397 | var header_index = computeTableHeaderCellIndexes(table);
|
398 | 398 |
|
399 | 399 | var $tableHeaders = $(table.config.selectorHeaders, table).each(function (index) {
|
400 | 400 |
|
401 | 401 | this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex];
|
402 | 402 | // this.column = index;
|
403 | 403 | this.order = formatSortingOrder(table.config.sortInitialOrder);
|
404 |
| - |
405 |
| - |
| 404 | + |
| 405 | + |
406 | 406 | this.count = this.order;
|
407 | 407 |
|
408 | 408 | if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) this.sortDisabled = true;
|
|
505 | 505 | };
|
506 | 506 | return false;
|
507 | 507 | }
|
508 |
| - |
| 508 | + |
509 | 509 | function checkHeaderOptionsSortingLocked(table, i) {
|
510 | 510 | if ((table.config.headers[i]) && (table.config.headers[i].lockedOrder)) return table.config.headers[i].lockedOrder;
|
511 | 511 | return false;
|
512 | 512 | }
|
513 |
| - |
| 513 | + |
514 | 514 | function applyWidget(table) {
|
515 | 515 | var c = table.config.widgets;
|
516 | 516 | var l = c.length;
|
|
588 | 588 | }
|
589 | 589 |
|
590 | 590 | /* sorting methods */
|
591 |
| - |
| 591 | + |
592 | 592 | var sortWrapper;
|
593 | 593 |
|
594 | 594 | function multisort(table, sortList, cache) {
|
|
741 | 741 | this.order = this.count++ % 2;
|
742 | 742 | // always sort on the locked order.
|
743 | 743 | if(this.lockedOrder) this.order = this.lockedOrder;
|
744 |
| - |
| 744 | + |
745 | 745 | // user only whants to sort on one
|
746 | 746 | // column
|
747 | 747 | if (!e[config.sortMultiSortKey]) {
|
|
988 | 988 | if (c.dateFormat == "us") {
|
989 | 989 | // reformat the string in ISO format
|
990 | 990 | s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2");
|
991 |
| - } |
| 991 | + } |
992 | 992 | if (c.dateFormat == "pt") {
|
993 |
| - s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); |
| 993 | + s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); |
994 | 994 | } else if (c.dateFormat == "uk") {
|
995 | 995 | // reformat the string in ISO format
|
996 | 996 | s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1");
|
|
0 commit comments