annotate test-data/res_files/js/bootstrap-table.js @ 72:b140b740f828 draft

"planemo upload for repository https://github.com/GReD-Clermont/sRNAPipe/ commit e90f8c18f63f21f99b1a0fc9c381290f3fd31e16"
author brasset_jensen
date Tue, 30 Jun 2020 06:38:36 -0400
parents 9185ca0a7b43
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1 /**
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2 * @author zhixin wen <wenzhixin2010@gmail.com>
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3 * version: 1.11.1
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
4 * https://github.com/wenzhixin/bootstrap-table/
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
5 */
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
6
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
7 (function ($) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
8 'use strict';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
9
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
10 // TOOLS DEFINITION
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
11 // ======================
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
12
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
13 var cachedWidth = null;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
14
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
15 // it only does '%s', and return '' when arguments are undefined
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
16 var sprintf = function (str) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
17 var args = arguments,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
18 flag = true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
19 i = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
20
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
21 str = str.replace(/%s/g, function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
22 var arg = args[i++];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
23
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
24 if (typeof arg === 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
25 flag = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
26 return '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
27 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
28 return arg;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
29 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
30 return flag ? str : '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
31 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
32
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
33 var getPropertyFromOther = function (list, from, to, value) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
34 var result = '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
35 $.each(list, function (i, item) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
36 if (item[from] === value) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
37 result = item[to];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
38 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
39 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
40 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
41 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
42 return result;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
43 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
44
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
45 var getFieldIndex = function (columns, field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
46 var index = -1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
47
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
48 $.each(columns, function (i, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
49 if (column.field === field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
50 index = i;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
51 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
52 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
53 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
54 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
55 return index;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
56 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
57
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
58 // http://jsfiddle.net/wenyi/47nz7ez9/3/
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
59 var setFieldIndex = function (columns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
60 var i, j, k,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
61 totalCol = 0,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
62 flag = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
63
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
64 for (i = 0; i < columns[0].length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
65 totalCol += columns[0][i].colspan || 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
66 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
67
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
68 for (i = 0; i < columns.length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
69 flag[i] = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
70 for (j = 0; j < totalCol; j++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
71 flag[i][j] = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
72 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
73 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
74
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
75 for (i = 0; i < columns.length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
76 for (j = 0; j < columns[i].length; j++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
77 var r = columns[i][j],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
78 rowspan = r.rowspan || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
79 colspan = r.colspan || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
80 index = $.inArray(false, flag[i]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
81
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
82 if (colspan === 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
83 r.fieldIndex = index;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
84 // when field is undefined, use index instead
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
85 if (typeof r.field === 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
86 r.field = index;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
87 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
88 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
89
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
90 for (k = 0; k < rowspan; k++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
91 flag[i + k][index] = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
92 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
93 for (k = 0; k < colspan; k++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
94 flag[i][index + k] = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
95 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
96 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
97 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
98 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
99
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
100 var getScrollBarWidth = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
101 if (cachedWidth === null) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
102 var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
103 outer = $('<div/>').addClass('fixed-table-scroll-outer'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
104 w1, w2;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
105
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
106 outer.append(inner);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
107 $('body').append(outer);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
108
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
109 w1 = inner[0].offsetWidth;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
110 outer.css('overflow', 'scroll');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
111 w2 = inner[0].offsetWidth;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
112
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
113 if (w1 === w2) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
114 w2 = outer[0].clientWidth;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
115 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
116
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
117 outer.remove();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
118 cachedWidth = w1 - w2;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
119 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
120 return cachedWidth;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
121 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
122
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
123 var calculateObjectValue = function (self, name, args, defaultValue) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
124 var func = name;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
125
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
126 if (typeof name === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
127 // support obj.func1.func2
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
128 var names = name.split('.');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
129
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
130 if (names.length > 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
131 func = window;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
132 $.each(names, function (i, f) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
133 func = func[f];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
134 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
135 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
136 func = window[name];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
137 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
138 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
139 if (typeof func === 'object') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
140 return func;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
141 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
142 if (typeof func === 'function') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
143 return func.apply(self, args || []);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
144 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
145 if (!func && typeof name === 'string' && sprintf.apply(this, [name].concat(args))) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
146 return sprintf.apply(this, [name].concat(args));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
147 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
148 return defaultValue;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
149 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
150
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
151 var compareObjects = function (objectA, objectB, compareLength) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
152 // Create arrays of property names
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
153 var objectAProperties = Object.getOwnPropertyNames(objectA),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
154 objectBProperties = Object.getOwnPropertyNames(objectB),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
155 propName = '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
156
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
157 if (compareLength) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
158 // If number of properties is different, objects are not equivalent
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
159 if (objectAProperties.length !== objectBProperties.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
160 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
161 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
162 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
163
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
164 for (var i = 0; i < objectAProperties.length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
165 propName = objectAProperties[i];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
166
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
167 // If the property is not in the object B properties, continue with the next property
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
168 if ($.inArray(propName, objectBProperties) > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
169 // If values of same property are not equal, objects are not equivalent
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
170 if (objectA[propName] !== objectB[propName]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
171 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
172 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
173 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
174 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
175
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
176 // If we made it this far, objects are considered equivalent
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
177 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
178 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
179
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
180 var escapeHTML = function (text) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
181 if (typeof text === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
182 return text
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
183 .replace(/&/g, '&amp;')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
184 .replace(/</g, '&lt;')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
185 .replace(/>/g, '&gt;')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
186 .replace(/"/g, '&quot;')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
187 .replace(/'/g, '&#039;')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
188 .replace(/`/g, '&#x60;');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
189 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
190 return text;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
191 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
192
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
193 var getRealDataAttr = function (dataAttr) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
194 for (var attr in dataAttr) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
195 var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
196 if (auxAttr !== attr) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
197 dataAttr[auxAttr] = dataAttr[attr];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
198 delete dataAttr[attr];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
199 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
200 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
201
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
202 return dataAttr;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
203 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
204
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
205 var getItemField = function (item, field, escape) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
206 var value = item;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
207
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
208 if (typeof field !== 'string' || item.hasOwnProperty(field)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
209 return escape ? escapeHTML(item[field]) : item[field];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
210 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
211 var props = field.split('.');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
212 for (var p in props) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
213 if (props.hasOwnProperty(p)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
214 value = value && value[props[p]];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
215 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
216 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
217 return escape ? escapeHTML(value) : value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
218 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
219
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
220 var isIEBrowser = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
221 return !!(navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
222 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
223
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
224 var objectKeys = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
225 // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
226 if (!Object.keys) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
227 Object.keys = (function() {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
228 var hasOwnProperty = Object.prototype.hasOwnProperty,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
229 hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
230 dontEnums = [
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
231 'toString',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
232 'toLocaleString',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
233 'valueOf',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
234 'hasOwnProperty',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
235 'isPrototypeOf',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
236 'propertyIsEnumerable',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
237 'constructor'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
238 ],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
239 dontEnumsLength = dontEnums.length;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
240
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
241 return function(obj) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
242 if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
243 throw new TypeError('Object.keys called on non-object');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
244 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
245
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
246 var result = [], prop, i;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
247
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
248 for (prop in obj) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
249 if (hasOwnProperty.call(obj, prop)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
250 result.push(prop);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
251 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
252 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
253
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
254 if (hasDontEnumBug) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
255 for (i = 0; i < dontEnumsLength; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
256 if (hasOwnProperty.call(obj, dontEnums[i])) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
257 result.push(dontEnums[i]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
258 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
259 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
260 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
261 return result;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
262 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
263 }());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
264 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
265 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
266
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
267 // BOOTSTRAP TABLE CLASS DEFINITION
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
268 // ======================
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
269
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
270 var BootstrapTable = function (el, options) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
271 this.options = options;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
272 this.$el = $(el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
273 this.$el_ = this.$el.clone();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
274 this.timeoutId_ = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
275 this.timeoutFooter_ = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
276
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
277 this.init();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
278 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
279
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
280 BootstrapTable.DEFAULTS = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
281 classes: 'table table-hover',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
282 sortClass: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
283 locale: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
284 height: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
285 undefinedText: '-',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
286 sortName: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
287 sortOrder: 'asc',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
288 sortStable: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
289 striped: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
290 columns: [[]],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
291 data: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
292 totalField: 'total',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
293 dataField: 'rows',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
294 method: 'get',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
295 url: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
296 ajax: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
297 cache: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
298 contentType: 'application/json',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
299 dataType: 'json',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
300 ajaxOptions: {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
301 queryParams: function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
302 return params;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
303 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
304 queryParamsType: 'limit', // undefined
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
305 responseHandler: function (res) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
306 return res;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
307 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
308 pagination: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
309 onlyInfoPagination: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
310 paginationLoop: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
311 sidePagination: 'client', // client or server
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
312 totalRows: 0, // server side need to set
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
313 pageNumber: 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
314 pageSize: 10,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
315 pageList: [10, 25, 50, 100],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
316 paginationHAlign: 'right', //right, left
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
317 paginationVAlign: 'bottom', //bottom, top, both
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
318 paginationDetailHAlign: 'left', //right, left
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
319 paginationPreText: '&lsaquo;',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
320 paginationNextText: '&rsaquo;',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
321 search: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
322 searchOnEnterKey: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
323 strictSearch: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
324 searchAlign: 'right',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
325 selectItemName: 'btSelectItem',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
326 showHeader: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
327 showFooter: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
328 showColumns: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
329 showPaginationSwitch: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
330 showRefresh: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
331 showToggle: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
332 buttonsAlign: 'right',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
333 smartDisplay: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
334 escape: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
335 minimumCountColumns: 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
336 idField: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
337 uniqueId: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
338 cardView: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
339 detailView: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
340 detailFormatter: function (index, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
341 return '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
342 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
343 trimOnSearch: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
344 clickToSelect: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
345 singleSelect: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
346 toolbar: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
347 toolbarAlign: 'left',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
348 checkboxHeader: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
349 sortable: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
350 silentSort: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
351 maintainSelected: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
352 searchTimeOut: 500,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
353 searchText: '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
354 iconSize: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
355 buttonsClass: 'default',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
356 iconsPrefix: 'glyphicon', // glyphicon of fa (font awesome)
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
357 icons: {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
358 paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
359 paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
360 refresh: 'glyphicon-refresh icon-refresh',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
361 toggle: 'glyphicon-list-alt icon-list-alt',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
362 columns: 'glyphicon-th icon-th',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
363 detailOpen: 'glyphicon-plus icon-plus',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
364 detailClose: 'glyphicon-minus icon-minus'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
365 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
366
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
367 customSearch: $.noop,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
368
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
369 customSort: $.noop,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
370
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
371 rowStyle: function (row, index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
372 return {};
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
373 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
374
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
375 rowAttributes: function (row, index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
376 return {};
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
377 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
378
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
379 footerStyle: function (row, index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
380 return {};
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
381 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
382
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
383 onAll: function (name, args) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
384 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
385 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
386 onClickCell: function (field, value, row, $element) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
387 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
388 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
389 onDblClickCell: function (field, value, row, $element) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
390 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
391 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
392 onClickRow: function (item, $element) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
393 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
394 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
395 onDblClickRow: function (item, $element) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
396 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
397 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
398 onSort: function (name, order) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
399 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
400 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
401 onCheck: function (row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
402 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
403 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
404 onUncheck: function (row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
405 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
406 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
407 onCheckAll: function (rows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
408 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
409 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
410 onUncheckAll: function (rows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
411 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
412 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
413 onCheckSome: function (rows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
414 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
415 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
416 onUncheckSome: function (rows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
417 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
418 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
419 onLoadSuccess: function (data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
420 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
421 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
422 onLoadError: function (status) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
423 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
424 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
425 onColumnSwitch: function (field, checked) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
426 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
427 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
428 onPageChange: function (number, size) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
429 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
430 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
431 onSearch: function (text) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
432 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
433 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
434 onToggle: function (cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
435 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
436 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
437 onPreBody: function (data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
438 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
439 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
440 onPostBody: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
441 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
442 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
443 onPostHeader: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
444 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
445 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
446 onExpandRow: function (index, row, $detail) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
447 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
448 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
449 onCollapseRow: function (index, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
450 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
451 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
452 onRefreshOptions: function (options) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
453 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
454 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
455 onRefresh: function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
456 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
457 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
458 onResetView: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
459 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
460 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
461 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
462
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
463 BootstrapTable.LOCALES = {};
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
464
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
465 BootstrapTable.LOCALES['en-US'] = BootstrapTable.LOCALES.en = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
466 formatLoadingMessage: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
467 return 'Loading, please wait...';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
468 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
469 formatRecordsPerPage: function (pageNumber) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
470 return sprintf('%s rows per page', pageNumber);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
471 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
472 formatShowingRows: function (pageFrom, pageTo, totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
473 return sprintf('Showing %s to %s of %s rows', pageFrom, pageTo, totalRows);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
474 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
475 formatDetailPagination: function (totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
476 return sprintf('Showing %s rows', totalRows);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
477 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
478 formatSearch: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
479 return 'Search';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
480 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
481 formatNoMatches: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
482 return 'No matching records found';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
483 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
484 formatPaginationSwitch: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
485 return 'Hide/Show pagination';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
486 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
487 formatRefresh: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
488 return 'Refresh';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
489 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
490 formatToggle: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
491 return 'Toggle';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
492 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
493 formatColumns: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
494 return 'Columns';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
495 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
496 formatAllRows: function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
497 return 'All';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
498 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
499 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
500
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
501 $.extend(BootstrapTable.DEFAULTS, BootstrapTable.LOCALES['en-US']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
502
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
503 BootstrapTable.COLUMN_DEFAULTS = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
504 radio: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
505 checkbox: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
506 checkboxEnabled: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
507 field: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
508 title: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
509 titleTooltip: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
510 'class': undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
511 align: undefined, // left, right, center
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
512 halign: undefined, // left, right, center
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
513 falign: undefined, // left, right, center
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
514 valign: undefined, // top, middle, bottom
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
515 width: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
516 sortable: false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
517 order: 'asc', // asc, desc
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
518 visible: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
519 switchable: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
520 clickToSelect: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
521 formatter: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
522 footerFormatter: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
523 events: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
524 sorter: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
525 sortName: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
526 cellStyle: undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
527 searchable: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
528 searchFormatter: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
529 cardVisible: true,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
530 escape : false
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
531 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
532
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
533 BootstrapTable.EVENTS = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
534 'all.bs.table': 'onAll',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
535 'click-cell.bs.table': 'onClickCell',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
536 'dbl-click-cell.bs.table': 'onDblClickCell',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
537 'click-row.bs.table': 'onClickRow',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
538 'dbl-click-row.bs.table': 'onDblClickRow',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
539 'sort.bs.table': 'onSort',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
540 'check.bs.table': 'onCheck',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
541 'uncheck.bs.table': 'onUncheck',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
542 'check-all.bs.table': 'onCheckAll',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
543 'uncheck-all.bs.table': 'onUncheckAll',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
544 'check-some.bs.table': 'onCheckSome',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
545 'uncheck-some.bs.table': 'onUncheckSome',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
546 'load-success.bs.table': 'onLoadSuccess',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
547 'load-error.bs.table': 'onLoadError',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
548 'column-switch.bs.table': 'onColumnSwitch',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
549 'page-change.bs.table': 'onPageChange',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
550 'search.bs.table': 'onSearch',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
551 'toggle.bs.table': 'onToggle',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
552 'pre-body.bs.table': 'onPreBody',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
553 'post-body.bs.table': 'onPostBody',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
554 'post-header.bs.table': 'onPostHeader',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
555 'expand-row.bs.table': 'onExpandRow',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
556 'collapse-row.bs.table': 'onCollapseRow',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
557 'refresh-options.bs.table': 'onRefreshOptions',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
558 'reset-view.bs.table': 'onResetView',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
559 'refresh.bs.table': 'onRefresh'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
560 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
561
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
562 BootstrapTable.prototype.init = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
563 this.initLocale();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
564 this.initContainer();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
565 this.initTable();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
566 this.initHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
567 this.initData();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
568 this.initHiddenRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
569 this.initFooter();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
570 this.initToolbar();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
571 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
572 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
573 this.initSearchText();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
574 this.initServer();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
575 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
576
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
577 BootstrapTable.prototype.initLocale = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
578 if (this.options.locale) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
579 var parts = this.options.locale.split(/-|_/);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
580 parts[0].toLowerCase();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
581 if (parts[1]) parts[1].toUpperCase();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
582 if ($.fn.bootstrapTable.locales[this.options.locale]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
583 // locale as requested
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
584 $.extend(this.options, $.fn.bootstrapTable.locales[this.options.locale]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
585 } else if ($.fn.bootstrapTable.locales[parts.join('-')]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
586 // locale with sep set to - (in case original was specified with _)
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
587 $.extend(this.options, $.fn.bootstrapTable.locales[parts.join('-')]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
588 } else if ($.fn.bootstrapTable.locales[parts[0]]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
589 // short locale language code (i.e. 'en')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
590 $.extend(this.options, $.fn.bootstrapTable.locales[parts[0]]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
591 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
592 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
593 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
594
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
595 BootstrapTable.prototype.initContainer = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
596 this.$container = $([
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
597 '<div class="bootstrap-table">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
598 '<div class="fixed-table-toolbar"></div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
599 this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
600 '<div class="fixed-table-pagination" style="clear: both;"></div>' :
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
601 '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
602 '<div class="fixed-table-container">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
603 '<div class="fixed-table-header"><table></table></div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
604 '<div class="fixed-table-body">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
605 '<div class="fixed-table-loading">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
606 this.options.formatLoadingMessage(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
607 '</div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
608 '</div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
609 '<div class="fixed-table-footer"><table><tr></tr></table></div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
610 this.options.paginationVAlign === 'bottom' || this.options.paginationVAlign === 'both' ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
611 '<div class="fixed-table-pagination"></div>' :
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
612 '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
613 '</div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
614 '</div>'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
615 ].join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
616
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
617 this.$container.insertAfter(this.$el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
618 this.$tableContainer = this.$container.find('.fixed-table-container');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
619 this.$tableHeader = this.$container.find('.fixed-table-header');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
620 this.$tableBody = this.$container.find('.fixed-table-body');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
621 this.$tableLoading = this.$container.find('.fixed-table-loading');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
622 this.$tableFooter = this.$container.find('.fixed-table-footer');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
623 this.$toolbar = this.$container.find('.fixed-table-toolbar');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
624 this.$pagination = this.$container.find('.fixed-table-pagination');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
625
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
626 this.$tableBody.append(this.$el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
627 this.$container.after('<div class="clearfix"></div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
628
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
629 this.$el.addClass(this.options.classes);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
630 if (this.options.striped) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
631 this.$el.addClass('table-striped');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
632 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
633 if ($.inArray('table-no-bordered', this.options.classes.split(' ')) !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
634 this.$tableContainer.addClass('table-no-bordered');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
635 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
636 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
637
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
638 BootstrapTable.prototype.initTable = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
639 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
640 columns = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
641 data = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
642
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
643 this.$header = this.$el.find('>thead');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
644 if (!this.$header.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
645 this.$header = $('<thead></thead>').appendTo(this.$el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
646 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
647 this.$header.find('tr').each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
648 var column = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
649
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
650 $(this).find('th').each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
651 // Fix #2014 - getFieldIndex and elsewhere assume this is string, causes issues if not
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
652 if (typeof $(this).data('field') !== 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
653 $(this).data('field', $(this).data('field') + '');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
654 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
655 column.push($.extend({}, {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
656 title: $(this).html(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
657 'class': $(this).attr('class'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
658 titleTooltip: $(this).attr('title'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
659 rowspan: $(this).attr('rowspan') ? +$(this).attr('rowspan') : undefined,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
660 colspan: $(this).attr('colspan') ? +$(this).attr('colspan') : undefined
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
661 }, $(this).data()));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
662 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
663 columns.push(column);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
664 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
665 if (!$.isArray(this.options.columns[0])) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
666 this.options.columns = [this.options.columns];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
667 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
668 this.options.columns = $.extend(true, [], columns, this.options.columns);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
669 this.columns = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
670
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
671 setFieldIndex(this.options.columns);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
672 $.each(this.options.columns, function (i, columns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
673 $.each(columns, function (j, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
674 column = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, column);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
675
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
676 if (typeof column.fieldIndex !== 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
677 that.columns[column.fieldIndex] = column;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
678 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
679
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
680 that.options.columns[i][j] = column;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
681 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
682 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
683
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
684 // if options.data is setting, do not process tbody data
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
685 if (this.options.data.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
686 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
687 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
688
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
689 var m = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
690 this.$el.find('>tbody>tr').each(function (y) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
691 var row = {};
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
692
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
693 // save tr's id, class and data-* attributes
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
694 row._id = $(this).attr('id');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
695 row._class = $(this).attr('class');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
696 row._data = getRealDataAttr($(this).data());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
697
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
698 $(this).find('>td').each(function (x) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
699 var $this = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
700 cspan = +$this.attr('colspan') || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
701 rspan = +$this.attr('rowspan') || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
702 tx, ty;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
703
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
704 for (; m[y] && m[y][x]; x++); //skip already occupied cells in current row
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
705
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
706 for (tx = x; tx < x + cspan; tx++) { //mark matrix elements occupied by current cell with true
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
707 for (ty = y; ty < y + rspan; ty++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
708 if (!m[ty]) { //fill missing rows
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
709 m[ty] = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
710 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
711 m[ty][tx] = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
712 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
713 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
714
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
715 var field = that.columns[x].field;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
716
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
717 row[field] = $(this).html();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
718 // save td's id, class and data-* attributes
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
719 row['_' + field + '_id'] = $(this).attr('id');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
720 row['_' + field + '_class'] = $(this).attr('class');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
721 row['_' + field + '_rowspan'] = $(this).attr('rowspan');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
722 row['_' + field + '_colspan'] = $(this).attr('colspan');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
723 row['_' + field + '_title'] = $(this).attr('title');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
724 row['_' + field + '_data'] = getRealDataAttr($(this).data());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
725 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
726 data.push(row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
727 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
728 this.options.data = data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
729 if (data.length) this.fromHtml = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
730 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
731
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
732 BootstrapTable.prototype.initHeader = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
733 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
734 visibleColumns = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
735 html = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
736
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
737 this.header = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
738 fields: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
739 styles: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
740 classes: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
741 formatters: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
742 events: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
743 sorters: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
744 sortNames: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
745 cellStyles: [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
746 searchables: []
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
747 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
748
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
749 $.each(this.options.columns, function (i, columns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
750 html.push('<tr>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
751
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
752 if (i === 0 && !that.options.cardView && that.options.detailView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
753 html.push(sprintf('<th class="detail" rowspan="%s"><div class="fht-cell"></div></th>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
754 that.options.columns.length));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
755 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
756
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
757 $.each(columns, function (j, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
758 var text = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
759 halign = '', // header align style
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
760 align = '', // body align style
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
761 style = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
762 class_ = sprintf(' class="%s"', column['class']),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
763 order = that.options.sortOrder || column.order,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
764 unitWidth = 'px',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
765 width = column.width;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
766
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
767 if (column.width !== undefined && (!that.options.cardView)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
768 if (typeof column.width === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
769 if (column.width.indexOf('%') !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
770 unitWidth = '%';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
771 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
772 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
773 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
774 if (column.width && typeof column.width === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
775 width = column.width.replace('%', '').replace('px', '');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
776 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
777
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
778 halign = sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
779 align = sprintf('text-align: %s; ', column.align);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
780 style = sprintf('vertical-align: %s; ', column.valign);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
781 style += sprintf('width: %s; ', (column.checkbox || column.radio) && !width ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
782 '36px' : (width ? width + unitWidth : undefined));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
783
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
784 if (typeof column.fieldIndex !== 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
785 that.header.fields[column.fieldIndex] = column.field;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
786 that.header.styles[column.fieldIndex] = align + style;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
787 that.header.classes[column.fieldIndex] = class_;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
788 that.header.formatters[column.fieldIndex] = column.formatter;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
789 that.header.events[column.fieldIndex] = column.events;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
790 that.header.sorters[column.fieldIndex] = column.sorter;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
791 that.header.sortNames[column.fieldIndex] = column.sortName;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
792 that.header.cellStyles[column.fieldIndex] = column.cellStyle;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
793 that.header.searchables[column.fieldIndex] = column.searchable;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
794
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
795 if (!column.visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
796 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
797 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
798
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
799 if (that.options.cardView && (!column.cardVisible)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
800 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
801 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
802
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
803 visibleColumns[column.field] = column;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
804 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
805
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
806 html.push('<th' + sprintf(' title="%s"', column.titleTooltip),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
807 column.checkbox || column.radio ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
808 sprintf(' class="bs-checkbox %s"', column['class'] || '') :
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
809 class_,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
810 sprintf(' style="%s"', halign + style),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
811 sprintf(' rowspan="%s"', column.rowspan),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
812 sprintf(' colspan="%s"', column.colspan),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
813 sprintf(' data-field="%s"', column.field),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
814 '>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
815
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
816 html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
817 'sortable both' : ''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
818
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
819 text = that.options.escape ? escapeHTML(column.title) : column.title;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
820
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
821 if (column.checkbox) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
822 if (!that.options.singleSelect && that.options.checkboxHeader) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
823 text = '<input name="btSelectAll" type="checkbox" />';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
824 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
825 that.header.stateField = column.field;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
826 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
827 if (column.radio) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
828 text = '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
829 that.header.stateField = column.field;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
830 that.options.singleSelect = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
831 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
832
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
833 html.push(text);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
834 html.push('</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
835 html.push('<div class="fht-cell"></div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
836 html.push('</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
837 html.push('</th>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
838 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
839 html.push('</tr>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
840 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
841
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
842 this.$header.html(html.join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
843 this.$header.find('th[data-field]').each(function (i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
844 $(this).data(visibleColumns[$(this).data('field')]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
845 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
846 this.$container.off('click', '.th-inner').on('click', '.th-inner', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
847 var target = $(this);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
848
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
849 if (that.options.detailView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
850 if (target.closest('.bootstrap-table')[0] !== that.$container[0])
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
851 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
852 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
853
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
854 if (that.options.sortable && target.parent().data().sortable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
855 that.onSort(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
856 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
857 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
858
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
859 this.$header.children().children().off('keypress').on('keypress', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
860 if (that.options.sortable && $(this).data().sortable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
861 var code = event.keyCode || event.which;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
862 if (code == 13) { //Enter keycode
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
863 that.onSort(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
864 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
865 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
866 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
867
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
868 $(window).off('resize.bootstrap-table');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
869 if (!this.options.showHeader || this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
870 this.$header.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
871 this.$tableHeader.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
872 this.$tableLoading.css('top', 0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
873 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
874 this.$header.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
875 this.$tableHeader.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
876 this.$tableLoading.css('top', this.$header.outerHeight() + 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
877 // Assign the correct sortable arrow
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
878 this.getCaret();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
879 $(window).on('resize.bootstrap-table', $.proxy(this.resetWidth, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
880 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
881
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
882 this.$selectAll = this.$header.find('[name="btSelectAll"]');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
883 this.$selectAll.off('click').on('click', function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
884 var checked = $(this).prop('checked');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
885 that[checked ? 'checkAll' : 'uncheckAll']();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
886 that.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
887 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
888 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
889
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
890 BootstrapTable.prototype.initFooter = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
891 if (!this.options.showFooter || this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
892 this.$tableFooter.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
893 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
894 this.$tableFooter.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
895 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
896 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
897
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
898 /**
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
899 * @param data
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
900 * @param type: append / prepend
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
901 */
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
902 BootstrapTable.prototype.initData = function (data, type) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
903 if (type === 'append') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
904 this.data = this.data.concat(data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
905 } else if (type === 'prepend') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
906 this.data = [].concat(data).concat(this.data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
907 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
908 this.data = data || this.options.data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
909 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
910
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
911 // Fix #839 Records deleted when adding new row on filtered table
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
912 if (type === 'append') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
913 this.options.data = this.options.data.concat(data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
914 } else if (type === 'prepend') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
915 this.options.data = [].concat(data).concat(this.options.data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
916 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
917 this.options.data = this.data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
918 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
919
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
920 if (this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
921 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
922 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
923 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
924 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
925
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
926 BootstrapTable.prototype.initSort = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
927 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
928 name = this.options.sortName,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
929 order = this.options.sortOrder === 'desc' ? -1 : 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
930 index = $.inArray(this.options.sortName, this.header.fields),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
931 timeoutId = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
932
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
933 if (this.options.customSort !== $.noop) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
934 this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
935 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
936 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
937
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
938 if (index !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
939 if (this.options.sortStable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
940 $.each(this.data, function (i, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
941 if (!row.hasOwnProperty('_position')) row._position = i;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
942 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
943 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
944
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
945 this.data.sort(function (a, b) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
946 if (that.header.sortNames[index]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
947 name = that.header.sortNames[index];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
948 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
949 var aa = getItemField(a, name, that.options.escape),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
950 bb = getItemField(b, name, that.options.escape),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
951 value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
952
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
953 if (value !== undefined) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
954 return order * value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
955 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
956
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
957 // Fix #161: undefined or null string sort bug.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
958 if (aa === undefined || aa === null) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
959 aa = '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
960 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
961 if (bb === undefined || bb === null) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
962 bb = '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
963 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
964
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
965 if (that.options.sortStable && aa === bb) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
966 aa = a._position;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
967 bb = b._position;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
968 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
969
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
970 // IF both values are numeric, do a numeric comparison
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
971 if ($.isNumeric(aa) && $.isNumeric(bb)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
972 // Convert numerical values form string to float.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
973 aa = parseFloat(aa);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
974 bb = parseFloat(bb);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
975 if (aa < bb) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
976 return order * -1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
977 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
978 return order;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
979 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
980
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
981 if (aa === bb) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
982 return 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
983 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
984
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
985 // If value is not a string, convert to string
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
986 if (typeof aa !== 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
987 aa = aa.toString();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
988 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
989
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
990 if (aa.localeCompare(bb) === -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
991 return order * -1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
992 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
993
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
994 return order;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
995 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
996
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
997 if (this.options.sortClass !== undefined) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
998 clearTimeout(timeoutId);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
999 timeoutId = setTimeout(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1000 that.$el.removeClass(that.options.sortClass);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1001 var index = that.$header.find(sprintf('[data-field="%s"]',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1002 that.options.sortName).index() + 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1003 that.$el.find(sprintf('tr td:nth-child(%s)', index))
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1004 .addClass(that.options.sortClass);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1005 }, 250);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1006 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1007 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1008 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1009
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1010 BootstrapTable.prototype.onSort = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1011 var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1012 $this_ = this.$header.find('th').eq($this.index());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1013
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1014 this.$header.add(this.$header_).find('span.order').remove();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1015
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1016 if (this.options.sortName === $this.data('field')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1017 this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1018 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1019 this.options.sortName = $this.data('field');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1020 this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1021 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1022 this.trigger('sort', this.options.sortName, this.options.sortOrder);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1023
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1024 $this.add($this_).data('order', this.options.sortOrder);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1025
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1026 // Assign the correct sortable arrow
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1027 this.getCaret();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1028
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1029 if (this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1030 this.initServer(this.options.silentSort);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1031 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1032 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1033
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1034 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1035 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1036 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1037
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1038 BootstrapTable.prototype.initToolbar = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1039 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1040 html = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1041 timeoutId = 0,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1042 $keepOpen,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1043 $search,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1044 switchableCount = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1045
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1046 if (this.$toolbar.find('.bs-bars').children().length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1047 $('body').append($(this.options.toolbar));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1048 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1049 this.$toolbar.html('');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1050
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1051 if (typeof this.options.toolbar === 'string' || typeof this.options.toolbar === 'object') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1052 $(sprintf('<div class="bs-bars pull-%s"></div>', this.options.toolbarAlign))
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1053 .appendTo(this.$toolbar)
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1054 .append($(this.options.toolbar));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1055 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1056
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1057 // showColumns, showToggle, showRefresh
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1058 html = [sprintf('<div class="columns columns-%s btn-group pull-%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1059 this.options.buttonsAlign, this.options.buttonsAlign)];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1060
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1061 if (typeof this.options.icons === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1062 this.options.icons = calculateObjectValue(null, this.options.icons);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1063 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1064
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1065 if (this.options.showPaginationSwitch) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1066 html.push(sprintf('<button class="btn' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1067 sprintf(' btn-%s', this.options.buttonsClass) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1068 sprintf(' btn-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1069 '" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1070 this.options.formatPaginationSwitch()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1071 sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1072 '</button>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1073 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1074
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1075 if (this.options.showRefresh) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1076 html.push(sprintf('<button class="btn' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1077 sprintf(' btn-%s', this.options.buttonsClass) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1078 sprintf(' btn-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1079 '" type="button" name="refresh" aria-label="refresh" title="%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1080 this.options.formatRefresh()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1081 sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1082 '</button>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1083 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1084
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1085 if (this.options.showToggle) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1086 html.push(sprintf('<button class="btn' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1087 sprintf(' btn-%s', this.options.buttonsClass) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1088 sprintf(' btn-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1089 '" type="button" name="toggle" aria-label="toggle" title="%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1090 this.options.formatToggle()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1091 sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggle),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1092 '</button>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1093 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1094
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1095 if (this.options.showColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1096 html.push(sprintf('<div class="keep-open btn-group" title="%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1097 this.options.formatColumns()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1098 '<button type="button" aria-label="columns" class="btn' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1099 sprintf(' btn-%s', this.options.buttonsClass) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1100 sprintf(' btn-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1101 ' dropdown-toggle" data-toggle="dropdown">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1102 sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1103 ' <span class="caret"></span>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1104 '</button>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1105 '<ul class="dropdown-menu" role="menu">');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1106
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1107 $.each(this.columns, function (i, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1108 if (column.radio || column.checkbox) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1109 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1110 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1111
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1112 if (that.options.cardView && !column.cardVisible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1113 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1114 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1115
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1116 var checked = column.visible ? ' checked="checked"' : '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1117
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1118 if (column.switchable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1119 html.push(sprintf('<li role="menuitem">' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1120 '<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1121 '</li>', column.field, i, checked, column.title));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1122 switchableCount++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1123 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1124 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1125 html.push('</ul>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1126 '</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1127 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1128
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1129 html.push('</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1130
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1131 // Fix #188: this.showToolbar is for extensions
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1132 if (this.showToolbar || html.length > 2) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1133 this.$toolbar.append(html.join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1134 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1135
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1136 if (this.options.showPaginationSwitch) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1137 this.$toolbar.find('button[name="paginationSwitch"]')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1138 .off('click').on('click', $.proxy(this.togglePagination, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1139 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1140
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1141 if (this.options.showRefresh) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1142 this.$toolbar.find('button[name="refresh"]')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1143 .off('click').on('click', $.proxy(this.refresh, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1144 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1145
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1146 if (this.options.showToggle) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1147 this.$toolbar.find('button[name="toggle"]')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1148 .off('click').on('click', function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1149 that.toggleView();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1150 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1151 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1152
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1153 if (this.options.showColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1154 $keepOpen = this.$toolbar.find('.keep-open');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1155
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1156 if (switchableCount <= this.options.minimumCountColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1157 $keepOpen.find('input').prop('disabled', true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1158 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1159
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1160 $keepOpen.find('li').off('click').on('click', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1161 event.stopImmediatePropagation();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1162 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1163 $keepOpen.find('input').off('click').on('click', function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1164 var $this = $(this);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1165
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1166 that.toggleColumn($(this).val(), $this.prop('checked'), false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1167 that.trigger('column-switch', $(this).data('field'), $this.prop('checked'));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1168 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1169 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1170
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1171 if (this.options.search) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1172 html = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1173 html.push(
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1174 '<div class="pull-' + this.options.searchAlign + ' search">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1175 sprintf('<input class="form-control' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1176 sprintf(' input-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1177 '" type="text" placeholder="%s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1178 this.options.formatSearch()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1179 '</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1180
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1181 this.$toolbar.append(html.join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1182 $search = this.$toolbar.find('.search input');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1183 $search.off('keyup drop blur').on('keyup drop blur', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1184 if (that.options.searchOnEnterKey && event.keyCode !== 13) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1185 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1186 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1187
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1188 if ($.inArray(event.keyCode, [37, 38, 39, 40]) > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1189 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1190 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1191
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1192 clearTimeout(timeoutId); // doesn't matter if it's 0
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1193 timeoutId = setTimeout(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1194 that.onSearch(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1195 }, that.options.searchTimeOut);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1196 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1197
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1198 if (isIEBrowser()) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1199 $search.off('mouseup').on('mouseup', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1200 clearTimeout(timeoutId); // doesn't matter if it's 0
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1201 timeoutId = setTimeout(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1202 that.onSearch(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1203 }, that.options.searchTimeOut);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1204 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1205 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1206 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1207 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1208
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1209 BootstrapTable.prototype.onSearch = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1210 var text = $.trim($(event.currentTarget).val());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1211
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1212 // trim search input
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1213 if (this.options.trimOnSearch && $(event.currentTarget).val() !== text) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1214 $(event.currentTarget).val(text);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1215 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1216
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1217 if (text === this.searchText) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1218 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1219 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1220 this.searchText = text;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1221 this.options.searchText = text;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1222
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1223 this.options.pageNumber = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1224 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1225 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1226 this.trigger('search', text);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1227 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1228
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1229 BootstrapTable.prototype.initSearch = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1230 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1231
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1232 if (this.options.sidePagination !== 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1233 if (this.options.customSearch !== $.noop) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1234 this.options.customSearch.apply(this, [this.searchText]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1235 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1236 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1237
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1238 var s = this.searchText && (this.options.escape ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1239 escapeHTML(this.searchText) : this.searchText).toLowerCase();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1240 var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1241
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1242 // Check filter
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1243 this.data = f ? $.grep(this.options.data, function (item, i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1244 for (var key in f) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1245 if ($.isArray(f[key]) && $.inArray(item[key], f[key]) === -1 ||
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1246 !$.isArray(f[key]) && item[key] !== f[key]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1247 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1248 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1249 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1250 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1251 }) : this.options.data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1252
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1253 this.data = s ? $.grep(this.data, function (item, i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1254 for (var j = 0; j < that.header.fields.length; j++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1255
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1256 if (!that.header.searchables[j]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1257 continue;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1258 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1259
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1260 var key = $.isNumeric(that.header.fields[j]) ? parseInt(that.header.fields[j], 10) : that.header.fields[j];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1261 var column = that.columns[getFieldIndex(that.columns, key)];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1262 var value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1263
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1264 if (typeof key === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1265 value = item;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1266 var props = key.split('.');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1267 for (var prop_index = 0; prop_index < props.length; prop_index++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1268 value = value[props[prop_index]];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1269 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1270
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1271 // Fix #142: respect searchForamtter boolean
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1272 if (column && column.searchFormatter) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1273 value = calculateObjectValue(column,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1274 that.header.formatters[j], [value, item, i], value);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1275 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1276 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1277 value = item[key];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1278 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1279
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1280 if (typeof value === 'string' || typeof value === 'number') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1281 if (that.options.strictSearch) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1282 if ((value + '').toLowerCase() === s) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1283 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1284 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1285 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1286 if ((value + '').toLowerCase().indexOf(s) !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1287 return true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1288 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1289 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1290 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1291 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1292 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1293 }) : this.data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1294 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1295 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1296
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1297 BootstrapTable.prototype.initPagination = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1298 if (!this.options.pagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1299 this.$pagination.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1300 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1301 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1302 this.$pagination.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1303 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1304
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1305 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1306 html = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1307 $allSelected = false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1308 i, from, to,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1309 $pageList,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1310 $first, $pre,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1311 $next, $last,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1312 $number,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1313 data = this.getData(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1314 pageList = this.options.pageList;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1315
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1316 if (this.options.sidePagination !== 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1317 this.options.totalRows = data.length;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1318 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1319
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1320 this.totalPages = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1321 if (this.options.totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1322 if (this.options.pageSize === this.options.formatAllRows()) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1323 this.options.pageSize = this.options.totalRows;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1324 $allSelected = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1325 } else if (this.options.pageSize === this.options.totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1326 // Fix #667 Table with pagination,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1327 // multiple pages and a search that matches to one page throws exception
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1328 var pageLst = typeof this.options.pageList === 'string' ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1329 this.options.pageList.replace('[', '').replace(']', '')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1330 .replace(/ /g, '').toLowerCase().split(',') : this.options.pageList;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1331 if ($.inArray(this.options.formatAllRows().toLowerCase(), pageLst) > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1332 $allSelected = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1333 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1334 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1335
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1336 this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1337
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1338 this.options.totalPages = this.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1339 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1340 if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1341 this.options.pageNumber = this.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1342 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1343
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1344 this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1345 this.pageTo = this.options.pageNumber * this.options.pageSize;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1346 if (this.pageTo > this.options.totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1347 this.pageTo = this.options.totalRows;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1348 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1349
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1350 html.push(
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1351 '<div class="pull-' + this.options.paginationDetailHAlign + ' pagination-detail">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1352 '<span class="pagination-info">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1353 this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) :
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1354 this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1355 '</span>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1356
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1357 if (!this.options.onlyInfoPagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1358 html.push('<span class="page-list">');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1359
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1360 var pageNumber = [
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1361 sprintf('<span class="btn-group %s">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1362 this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1363 'dropdown' : 'dropup'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1364 '<button type="button" class="btn' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1365 sprintf(' btn-%s', this.options.buttonsClass) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1366 sprintf(' btn-%s', this.options.iconSize) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1367 ' dropdown-toggle" data-toggle="dropdown">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1368 '<span class="page-size">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1369 $allSelected ? this.options.formatAllRows() : this.options.pageSize,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1370 '</span>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1371 ' <span class="caret"></span>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1372 '</button>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1373 '<ul class="dropdown-menu" role="menu">'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1374 ];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1375
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1376 if (typeof this.options.pageList === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1377 var list = this.options.pageList.replace('[', '').replace(']', '')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1378 .replace(/ /g, '').split(',');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1379
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1380 pageList = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1381 $.each(list, function (i, value) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1382 pageList.push(value.toUpperCase() === that.options.formatAllRows().toUpperCase() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1383 that.options.formatAllRows() : +value);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1384 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1385 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1386
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1387 $.each(pageList, function (i, page) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1388 if (!that.options.smartDisplay || i === 0 || pageList[i - 1] < that.options.totalRows) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1389 var active;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1390 if ($allSelected) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1391 active = page === that.options.formatAllRows() ? ' class="active"' : '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1392 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1393 active = page === that.options.pageSize ? ' class="active"' : '';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1394 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1395 pageNumber.push(sprintf('<li role="menuitem"%s><a href="#">%s</a></li>', active, page));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1396 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1397 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1398 pageNumber.push('</ul></span>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1399
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1400 html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1401 html.push('</span>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1402
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1403 html.push('</div>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1404 '<div class="pull-' + this.options.paginationHAlign + ' pagination">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1405 '<ul class="pagination' + sprintf(' pagination-%s', this.options.iconSize) + '">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1406 '<li class="page-pre"><a href="#">' + this.options.paginationPreText + '</a></li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1407
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1408 if (this.totalPages < 5) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1409 from = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1410 to = this.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1411 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1412 from = this.options.pageNumber - 2;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1413 to = from + 4;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1414 if (from < 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1415 from = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1416 to = 5;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1417 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1418 if (to > this.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1419 to = this.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1420 from = to - 4;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1421 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1422 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1423
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1424 if (this.totalPages >= 6) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1425 if (this.options.pageNumber >= 3) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1426 html.push('<li class="page-first' + (1 === this.options.pageNumber ? ' active' : '') + '">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1427 '<a href="#">', 1, '</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1428 '</li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1429
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1430 from++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1431 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1432
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1433 if (this.options.pageNumber >= 4) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1434 if (this.options.pageNumber == 4 || this.totalPages == 6 || this.totalPages == 7) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1435 from--;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1436 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1437 html.push('<li class="page-first-separator disabled">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1438 '<a href="#">...</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1439 '</li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1440 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1441
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1442 to--;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1443 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1444 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1445
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1446 if (this.totalPages >= 7) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1447 if (this.options.pageNumber >= (this.totalPages - 2)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1448 from--;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1449 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1450 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1451
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1452 if (this.totalPages == 6) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1453 if (this.options.pageNumber >= (this.totalPages - 2)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1454 to++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1455 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1456 } else if (this.totalPages >= 7) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1457 if (this.totalPages == 7 || this.options.pageNumber >= (this.totalPages - 3)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1458 to++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1459 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1460 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1461
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1462 for (i = from; i <= to; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1463 html.push('<li class="page-number' + (i === this.options.pageNumber ? ' active' : '') + '">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1464 '<a href="#">', i, '</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1465 '</li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1466 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1467
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1468 if (this.totalPages >= 8) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1469 if (this.options.pageNumber <= (this.totalPages - 4)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1470 html.push('<li class="page-last-separator disabled">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1471 '<a href="#">...</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1472 '</li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1473 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1474 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1475
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1476 if (this.totalPages >= 6) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1477 if (this.options.pageNumber <= (this.totalPages - 3)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1478 html.push('<li class="page-last' + (this.totalPages === this.options.pageNumber ? ' active' : '') + '">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1479 '<a href="#">', this.totalPages, '</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1480 '</li>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1481 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1482 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1483
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1484 html.push(
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1485 '<li class="page-next"><a href="#">' + this.options.paginationNextText + '</a></li>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1486 '</ul>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1487 '</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1488 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1489 this.$pagination.html(html.join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1490
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1491 if (!this.options.onlyInfoPagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1492 $pageList = this.$pagination.find('.page-list a');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1493 $first = this.$pagination.find('.page-first');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1494 $pre = this.$pagination.find('.page-pre');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1495 $next = this.$pagination.find('.page-next');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1496 $last = this.$pagination.find('.page-last');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1497 $number = this.$pagination.find('.page-number');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1498
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1499 if (this.options.smartDisplay) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1500 if (this.totalPages <= 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1501 this.$pagination.find('div.pagination').hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1502 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1503 if (pageList.length < 2 || this.options.totalRows <= pageList[0]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1504 this.$pagination.find('span.page-list').hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1505 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1506
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1507 // when data is empty, hide the pagination
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1508 this.$pagination[this.getData().length ? 'show' : 'hide']();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1509 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1510
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1511 if (!this.options.paginationLoop) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1512 if (this.options.pageNumber === 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1513 $pre.addClass('disabled');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1514 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1515 if (this.options.pageNumber === this.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1516 $next.addClass('disabled');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1517 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1518 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1519
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1520 if ($allSelected) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1521 this.options.pageSize = this.options.formatAllRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1522 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1523 $pageList.off('click').on('click', $.proxy(this.onPageListChange, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1524 $first.off('click').on('click', $.proxy(this.onPageFirst, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1525 $pre.off('click').on('click', $.proxy(this.onPagePre, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1526 $next.off('click').on('click', $.proxy(this.onPageNext, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1527 $last.off('click').on('click', $.proxy(this.onPageLast, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1528 $number.off('click').on('click', $.proxy(this.onPageNumber, this));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1529 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1530 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1531
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1532 BootstrapTable.prototype.updatePagination = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1533 // Fix #171: IE disabled button can be clicked bug.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1534 if (event && $(event.currentTarget).hasClass('disabled')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1535 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1536 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1537
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1538 if (!this.options.maintainSelected) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1539 this.resetRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1540 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1541
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1542 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1543 if (this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1544 this.initServer();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1545 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1546 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1547 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1548
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1549 this.trigger('page-change', this.options.pageNumber, this.options.pageSize);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1550 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1551
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1552 BootstrapTable.prototype.onPageListChange = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1553 var $this = $(event.currentTarget);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1554
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1555 $this.parent().addClass('active').siblings().removeClass('active');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1556 this.options.pageSize = $this.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1557 this.options.formatAllRows() : +$this.text();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1558 this.$toolbar.find('.page-size').text(this.options.pageSize);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1559
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1560 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1561 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1562 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1563
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1564 BootstrapTable.prototype.onPageFirst = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1565 this.options.pageNumber = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1566 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1567 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1568 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1569
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1570 BootstrapTable.prototype.onPagePre = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1571 if ((this.options.pageNumber - 1) === 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1572 this.options.pageNumber = this.options.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1573 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1574 this.options.pageNumber--;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1575 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1576 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1577 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1578 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1579
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1580 BootstrapTable.prototype.onPageNext = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1581 if ((this.options.pageNumber + 1) > this.options.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1582 this.options.pageNumber = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1583 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1584 this.options.pageNumber++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1585 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1586 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1587 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1588 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1589
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1590 BootstrapTable.prototype.onPageLast = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1591 this.options.pageNumber = this.totalPages;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1592 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1593 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1594 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1595
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1596 BootstrapTable.prototype.onPageNumber = function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1597 if (this.options.pageNumber === +$(event.currentTarget).text()) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1598 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1599 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1600 this.options.pageNumber = +$(event.currentTarget).text();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1601 this.updatePagination(event);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1602 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1603 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1604
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1605 BootstrapTable.prototype.initRow = function(item, i, data, parentDom) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1606 var that=this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1607 key,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1608 html = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1609 style = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1610 csses = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1611 data_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1612 attributes = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1613 htmlAttributes = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1614
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1615 if ($.inArray(item, this.hiddenRows) > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1616 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1617 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1618
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1619 style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1620
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1621 if (style && style.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1622 for (key in style.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1623 csses.push(key + ': ' + style.css[key]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1624 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1625 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1626
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1627 attributes = calculateObjectValue(this.options,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1628 this.options.rowAttributes, [item, i], attributes);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1629
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1630 if (attributes) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1631 for (key in attributes) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1632 htmlAttributes.push(sprintf('%s="%s"', key, escapeHTML(attributes[key])));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1633 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1634 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1635
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1636 if (item._data && !$.isEmptyObject(item._data)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1637 $.each(item._data, function(k, v) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1638 // ignore data-index
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1639 if (k === 'index') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1640 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1641 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1642 data_ += sprintf(' data-%s="%s"', k, v);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1643 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1644 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1645
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1646 html.push('<tr',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1647 sprintf(' %s', htmlAttributes.join(' ')),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1648 sprintf(' id="%s"', $.isArray(item) ? undefined : item._id),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1649 sprintf(' class="%s"', style.classes || ($.isArray(item) ? undefined : item._class)),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1650 sprintf(' data-index="%s"', i),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1651 sprintf(' data-uniqueid="%s"', item[this.options.uniqueId]),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1652 sprintf('%s', data_),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1653 '>'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1654 );
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1655
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1656 if (this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1657 html.push(sprintf('<td colspan="%s"><div class="card-views">', this.header.fields.length));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1658 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1659
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1660 if (!this.options.cardView && this.options.detailView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1661 html.push('<td>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1662 '<a class="detail-icon" href="#">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1663 sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.detailOpen),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1664 '</a>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1665 '</td>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1666 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1667
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1668 $.each(this.header.fields, function(j, field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1669 var text = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1670 value_ = getItemField(item, field, that.options.escape),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1671 value = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1672 type = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1673 cellStyle = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1674 id_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1675 class_ = that.header.classes[j],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1676 data_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1677 rowspan_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1678 colspan_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1679 title_ = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1680 column = that.columns[j];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1681
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1682 if (that.fromHtml && typeof value_ === 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1683 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1684 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1685
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1686 if (!column.visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1687 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1688 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1689
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1690 if (that.options.cardView && (!column.cardVisible)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1691 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1692 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1693
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1694 if (column.escape) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1695 value_ = escapeHTML(value_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1696 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1697
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1698 style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1699
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1700 // handle td's id and class
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1701 if (item['_' + field + '_id']) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1702 id_ = sprintf(' id="%s"', item['_' + field + '_id']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1703 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1704 if (item['_' + field + '_class']) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1705 class_ = sprintf(' class="%s"', item['_' + field + '_class']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1706 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1707 if (item['_' + field + '_rowspan']) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1708 rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1709 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1710 if (item['_' + field + '_colspan']) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1711 colspan_ = sprintf(' colspan="%s"', item['_' + field + '_colspan']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1712 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1713 if (item['_' + field + '_title']) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1714 title_ = sprintf(' title="%s"', item['_' + field + '_title']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1715 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1716 cellStyle = calculateObjectValue(that.header,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1717 that.header.cellStyles[j], [value_, item, i, field], cellStyle);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1718 if (cellStyle.classes) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1719 class_ = sprintf(' class="%s"', cellStyle.classes);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1720 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1721 if (cellStyle.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1722 var csses_ = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1723 for (var key in cellStyle.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1724 csses_.push(key + ': ' + cellStyle.css[key]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1725 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1726 style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; '));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1727 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1728
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1729 value = calculateObjectValue(column,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1730 that.header.formatters[j], [value_, item, i], value_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1731
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1732 if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1733 $.each(item['_' + field + '_data'], function(k, v) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1734 // ignore data-index
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1735 if (k === 'index') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1736 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1737 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1738 data_ += sprintf(' data-%s="%s"', k, v);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1739 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1740 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1741
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1742 if (column.checkbox || column.radio) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1743 type = column.checkbox ? 'checkbox' : type;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1744 type = column.radio ? 'radio' : type;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1745
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1746 text = [sprintf(that.options.cardView ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1747 '<div class="card-view %s">' : '<td class="bs-checkbox %s">', column['class'] || ''),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1748 '<input' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1749 sprintf(' data-index="%s"', i) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1750 sprintf(' name="%s"', that.options.selectItemName) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1751 sprintf(' type="%s"', type) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1752 sprintf(' value="%s"', item[that.options.idField]) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1753 sprintf(' checked="%s"', value === true ||
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1754 (value_ || value && value.checked) ? 'checked' : undefined) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1755 sprintf(' disabled="%s"', !column.checkboxEnabled ||
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1756 (value && value.disabled) ? 'disabled' : undefined) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1757 ' />',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1758 that.header.formatters[j] && typeof value === 'string' ? value : '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1759 that.options.cardView ? '</div>' : '</td>'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1760 ].join('');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1761
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1762 item[that.header.stateField] = value === true || (value && value.checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1763 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1764 value = typeof value === 'undefined' || value === null ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1765 that.options.undefinedText : value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1766
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1767 text = that.options.cardView ? ['<div class="card-view">',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1768 that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1769 getPropertyFromOther(that.columns, 'field', 'title', field)) : '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1770 sprintf('<span class="value">%s</span>', value),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1771 '</div>'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1772 ].join('') : [sprintf('<td%s %s %s %s %s %s %s>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1773 id_, class_, style, data_, rowspan_, colspan_, title_),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1774 value,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1775 '</td>'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1776 ].join('');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1777
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1778 // Hide empty data on Card view when smartDisplay is set to true.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1779 if (that.options.cardView && that.options.smartDisplay && value === '') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1780 // Should set a placeholder for event binding correct fieldIndex
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1781 text = '<div class="card-view"></div>';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1782 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1783 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1784
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1785 html.push(text);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1786 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1787
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1788 if (this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1789 html.push('</div></td>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1790 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1791 html.push('</tr>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1792
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1793 return html.join(' ');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1794 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1795
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1796 BootstrapTable.prototype.initBody = function (fixedScroll) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1797 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1798 html = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1799 data = this.getData();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1800
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1801 this.trigger('pre-body', data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1802
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1803 this.$body = this.$el.find('>tbody');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1804 if (!this.$body.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1805 this.$body = $('<tbody></tbody>').appendTo(this.$el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1806 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1807
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1808 //Fix #389 Bootstrap-table-flatJSON is not working
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1809
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1810 if (!this.options.pagination || this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1811 this.pageFrom = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1812 this.pageTo = data.length;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1813 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1814
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1815 var trFragments = $(document.createDocumentFragment());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1816 var hasTr;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1817
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1818 for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1819 var item = data[i];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1820 var tr = this.initRow(item, i, data, trFragments);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1821 hasTr = hasTr || !!tr;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1822 if (tr&&tr!==true) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1823 trFragments.append(tr);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1824 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1825 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1826
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1827 // show no records
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1828 if (!hasTr) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1829 trFragments.append('<tr class="no-records-found">' +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1830 sprintf('<td colspan="%s">%s</td>',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1831 this.$header.find('th').length,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1832 this.options.formatNoMatches()) +
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1833 '</tr>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1834 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1835
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1836 this.$body.html(trFragments);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1837
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1838 if (!fixedScroll) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1839 this.scrollTo(0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1840 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1841
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1842 // click to select by column
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1843 this.$body.find('> tr[data-index] > td').off('click dblclick').on('click dblclick', function (e) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1844 var $td = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1845 $tr = $td.parent(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1846 item = that.data[$tr.data('index')],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1847 index = $td[0].cellIndex,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1848 fields = that.getVisibleFields(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1849 field = fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1850 column = that.columns[getFieldIndex(that.columns, field)],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1851 value = getItemField(item, field, that.options.escape);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1852
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1853 if ($td.find('.detail-icon').length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1854 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1855 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1856
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1857 that.trigger(e.type === 'click' ? 'click-cell' : 'dbl-click-cell', field, value, item, $td);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1858 that.trigger(e.type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1859
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1860 // if click to select - then trigger the checkbox/radio click
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1861 if (e.type === 'click' && that.options.clickToSelect && column.clickToSelect) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1862 var $selectItem = $tr.find(sprintf('[name="%s"]', that.options.selectItemName));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1863 if ($selectItem.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1864 $selectItem[0].click(); // #144: .trigger('click') bug
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1865 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1866 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1867 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1868
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1869 this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1870 var $this = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1871 $tr = $this.parent().parent(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1872 index = $tr.data('index'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1873 row = data[index]; // Fix #980 Detail view, when searching, returns wrong row
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1874
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1875 // remove and update
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1876 if ($tr.next().is('tr.detail-view')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1877 $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailOpen));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1878 that.trigger('collapse-row', index, row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1879 $tr.next().remove();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1880 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1881 $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1882 $tr.after(sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.find('td').length));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1883 var $element = $tr.next().find('td');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1884 var content = calculateObjectValue(that.options, that.options.detailFormatter, [index, row, $element], '');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1885 if($element.length === 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1886 $element.append(content);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1887 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1888 that.trigger('expand-row', index, row, $element);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1889 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1890 that.resetView();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1891 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1892 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1893
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1894 this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1895 this.$selectItem.off('click').on('click', function (event) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1896 event.stopImmediatePropagation();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1897
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1898 var $this = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1899 checked = $this.prop('checked'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1900 row = that.data[$this.data('index')];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1901
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1902 if (that.options.maintainSelected && $(this).is(':radio')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1903 $.each(that.options.data, function (i, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1904 row[that.header.stateField] = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1905 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1906 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1907
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1908 row[that.header.stateField] = checked;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1909
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1910 if (that.options.singleSelect) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1911 that.$selectItem.not(this).each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1912 that.data[$(this).data('index')][that.header.stateField] = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1913 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1914 that.$selectItem.filter(':checked').not(this).prop('checked', false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1915 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1916
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1917 that.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1918 that.trigger(checked ? 'check' : 'uncheck', row, $this);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1919 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1920
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1921 $.each(this.header.events, function (i, events) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1922 if (!events) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1923 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1924 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1925 // fix bug, if events is defined with namespace
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1926 if (typeof events === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1927 events = calculateObjectValue(null, events);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1928 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1929
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1930 var field = that.header.fields[i],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1931 fieldIndex = $.inArray(field, that.getVisibleFields());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1932
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1933 if (that.options.detailView && !that.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1934 fieldIndex += 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1935 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1936
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1937 for (var key in events) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1938 that.$body.find('>tr:not(.no-records-found)').each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1939 var $tr = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1940 $td = $tr.find(that.options.cardView ? '.card-view' : 'td').eq(fieldIndex),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1941 index = key.indexOf(' '),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1942 name = key.substring(0, index),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1943 el = key.substring(index + 1),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1944 func = events[key];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1945
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1946 $td.find(el).off(name).on(name, function (e) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1947 var index = $tr.data('index'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1948 row = that.data[index],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1949 value = row[field];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1950
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1951 func.apply(this, [e, value, row, index]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1952 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1953 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1954 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1955 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1956
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1957 this.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1958 this.resetView();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1959
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1960 this.trigger('post-body', data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1961 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1962
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1963 BootstrapTable.prototype.initServer = function (silent, query, url) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1964 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1965 data = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1966 params = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1967 searchText: this.searchText,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1968 sortName: this.options.sortName,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1969 sortOrder: this.options.sortOrder
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1970 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1971 request;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1972
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1973 if (this.options.pagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1974 params.pageSize = this.options.pageSize === this.options.formatAllRows() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1975 this.options.totalRows : this.options.pageSize;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1976 params.pageNumber = this.options.pageNumber;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1977 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1978
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1979 if (!(url || this.options.url) && !this.options.ajax) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1980 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1981 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1982
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1983 if (this.options.queryParamsType === 'limit') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1984 params = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1985 search: params.searchText,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1986 sort: params.sortName,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1987 order: params.sortOrder
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1988 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1989
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1990 if (this.options.pagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1991 params.offset = this.options.pageSize === this.options.formatAllRows() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1992 0 : this.options.pageSize * (this.options.pageNumber - 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1993 params.limit = this.options.pageSize === this.options.formatAllRows() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1994 this.options.totalRows : this.options.pageSize;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1995 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1996 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1997
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1998 if (!($.isEmptyObject(this.filterColumnsPartial))) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
1999 params.filter = JSON.stringify(this.filterColumnsPartial, null);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2000 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2001
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2002 data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2003
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2004 $.extend(data, query || {});
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2005
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2006 // false to stop request
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2007 if (data === false) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2008 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2009 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2010
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2011 if (!silent) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2012 this.$tableLoading.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2013 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2014 request = $.extend({}, calculateObjectValue(null, this.options.ajaxOptions), {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2015 type: this.options.method,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2016 url: url || this.options.url,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2017 data: this.options.contentType === 'application/json' && this.options.method === 'post' ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2018 JSON.stringify(data) : data,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2019 cache: this.options.cache,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2020 contentType: this.options.contentType,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2021 dataType: this.options.dataType,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2022 success: function (res) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2023 res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2024
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2025 that.load(res);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2026 that.trigger('load-success', res);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2027 if (!silent) that.$tableLoading.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2028 },
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2029 error: function (res) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2030 that.trigger('load-error', res.status, res);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2031 if (!silent) that.$tableLoading.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2032 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2033 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2034
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2035 if (this.options.ajax) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2036 calculateObjectValue(this, this.options.ajax, [request], null);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2037 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2038 if (this._xhr && this._xhr.readyState !== 4) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2039 this._xhr.abort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2040 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2041 this._xhr = $.ajax(request);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2042 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2043 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2044
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2045 BootstrapTable.prototype.initSearchText = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2046 if (this.options.search) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2047 if (this.options.searchText !== '') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2048 var $search = this.$toolbar.find('.search input');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2049 $search.val(this.options.searchText);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2050 this.onSearch({currentTarget: $search});
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2051 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2052 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2053 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2054
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2055 BootstrapTable.prototype.getCaret = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2056 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2057
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2058 $.each(this.$header.find('th'), function (i, th) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2059 $(th).find('.sortable').removeClass('desc asc').addClass($(th).data('field') === that.options.sortName ? that.options.sortOrder : 'both');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2060 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2061 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2062
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2063 BootstrapTable.prototype.updateSelected = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2064 var checkAll = this.$selectItem.filter(':enabled').length &&
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2065 this.$selectItem.filter(':enabled').length ===
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2066 this.$selectItem.filter(':enabled').filter(':checked').length;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2067
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2068 this.$selectAll.add(this.$selectAll_).prop('checked', checkAll);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2069
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2070 this.$selectItem.each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2071 $(this).closest('tr')[$(this).prop('checked') ? 'addClass' : 'removeClass']('selected');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2072 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2073 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2074
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2075 BootstrapTable.prototype.updateRows = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2076 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2077
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2078 this.$selectItem.each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2079 that.data[$(this).data('index')][that.header.stateField] = $(this).prop('checked');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2080 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2081 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2082
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2083 BootstrapTable.prototype.resetRows = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2084 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2085
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2086 $.each(this.data, function (i, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2087 that.$selectAll.prop('checked', false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2088 that.$selectItem.prop('checked', false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2089 if (that.header.stateField) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2090 row[that.header.stateField] = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2091 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2092 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2093 this.initHiddenRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2094 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2095
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2096 BootstrapTable.prototype.trigger = function (name) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2097 var args = Array.prototype.slice.call(arguments, 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2098
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2099 name += '.bs.table';
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2100 this.options[BootstrapTable.EVENTS[name]].apply(this.options, args);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2101 this.$el.trigger($.Event(name), args);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2102
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2103 this.options.onAll(name, args);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2104 this.$el.trigger($.Event('all.bs.table'), [name, args]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2105 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2106
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2107 BootstrapTable.prototype.resetHeader = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2108 // fix #61: the hidden table reset header bug.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2109 // fix bug: get $el.css('width') error sometime (height = 500)
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2110 clearTimeout(this.timeoutId_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2111 this.timeoutId_ = setTimeout($.proxy(this.fitHeader, this), this.$el.is(':hidden') ? 100 : 0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2112 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2113
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2114 BootstrapTable.prototype.fitHeader = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2115 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2116 fixedBody,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2117 scrollWidth,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2118 focused,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2119 focusedTemp;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2120
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2121 if (that.$el.is(':hidden')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2122 that.timeoutId_ = setTimeout($.proxy(that.fitHeader, that), 100);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2123 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2124 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2125 fixedBody = this.$tableBody.get(0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2126
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2127 scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth &&
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2128 fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2129 getScrollBarWidth() : 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2130
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2131 this.$el.css('margin-top', -this.$header.outerHeight());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2132
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2133 focused = $(':focus');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2134 if (focused.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2135 var $th = focused.parents('th');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2136 if ($th.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2137 var dataField = $th.attr('data-field');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2138 if (dataField !== undefined) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2139 var $headerTh = this.$header.find("[data-field='" + dataField + "']");
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2140 if ($headerTh.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2141 $headerTh.find(":input").addClass("focus-temp");
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2142 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2143 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2144 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2145 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2146
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2147 this.$header_ = this.$header.clone(true, true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2148 this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2149 this.$tableHeader.css({
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2150 'margin-right': scrollWidth
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2151 }).find('table').css('width', this.$el.outerWidth())
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2152 .html('').attr('class', this.$el.attr('class'))
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2153 .append(this.$header_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2154
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2155
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2156 focusedTemp = $('.focus-temp:visible:eq(0)');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2157 if (focusedTemp.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2158 focusedTemp.focus();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2159 this.$header.find('.focus-temp').removeClass('focus-temp');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2160 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2161
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2162 // fix bug: $.data() is not working as expected after $.append()
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2163 this.$header.find('th[data-field]').each(function (i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2164 that.$header_.find(sprintf('th[data-field="%s"]', $(this).data('field'))).data($(this).data());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2165 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2166
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2167 var visibleFields = this.getVisibleFields(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2168 $ths = this.$header_.find('th');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2169
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2170 this.$body.find('>tr:first-child:not(.no-records-found) > *').each(function (i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2171 var $this = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2172 index = i;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2173
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2174 if (that.options.detailView && !that.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2175 if (i === 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2176 that.$header_.find('th.detail').find('.fht-cell').width($this.innerWidth());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2177 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2178 index = i - 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2179 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2180
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2181 var $th = that.$header_.find(sprintf('th[data-field="%s"]', visibleFields[index]));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2182 if ($th.length > 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2183 $th = $($ths[$this[0].cellIndex]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2184 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2185
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2186 $th.find('.fht-cell').width($this.innerWidth());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2187 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2188 // horizontal scroll event
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2189 // TODO: it's probably better improving the layout than binding to scroll event
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2190 this.$tableBody.off('scroll').on('scroll', function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2191 that.$tableHeader.scrollLeft($(this).scrollLeft());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2192
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2193 if (that.options.showFooter && !that.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2194 that.$tableFooter.scrollLeft($(this).scrollLeft());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2195 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2196 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2197 that.trigger('post-header');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2198 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2199
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2200 BootstrapTable.prototype.resetFooter = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2201 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2202 data = that.getData(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2203 html = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2204
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2205 if (!this.options.showFooter || this.options.cardView) { //do nothing
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2206 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2207 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2208
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2209 if (!this.options.cardView && this.options.detailView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2210 html.push('<td><div class="th-inner">&nbsp;</div><div class="fht-cell"></div></td>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2211 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2212
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2213 $.each(this.columns, function (i, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2214 var key,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2215 falign = '', // footer align style
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2216 valign = '',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2217 csses = [],
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2218 style = {},
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2219 class_ = sprintf(' class="%s"', column['class']);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2220
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2221 if (!column.visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2222 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2223 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2224
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2225 if (that.options.cardView && (!column.cardVisible)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2226 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2227 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2228
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2229 falign = sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2230 valign = sprintf('vertical-align: %s; ', column.valign);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2231
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2232 style = calculateObjectValue(null, that.options.footerStyle);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2233
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2234 if (style && style.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2235 for (key in style.css) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2236 csses.push(key + ': ' + style.css[key]);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2237 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2238 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2239
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2240 html.push('<td', class_, sprintf(' style="%s"', falign + valign + csses.concat().join('; ')), '>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2241 html.push('<div class="th-inner">');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2242
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2243 html.push(calculateObjectValue(column, column.footerFormatter, [data], '&nbsp;') || '&nbsp;');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2244
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2245 html.push('</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2246 html.push('<div class="fht-cell"></div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2247 html.push('</div>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2248 html.push('</td>');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2249 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2250
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2251 this.$tableFooter.find('tr').html(html.join(''));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2252 this.$tableFooter.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2253 clearTimeout(this.timeoutFooter_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2254 this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2255 this.$el.is(':hidden') ? 100 : 0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2256 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2257
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2258 BootstrapTable.prototype.fitFooter = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2259 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2260 $footerTd,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2261 elWidth,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2262 scrollWidth;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2263
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2264 clearTimeout(this.timeoutFooter_);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2265 if (this.$el.is(':hidden')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2266 this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2267 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2268 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2269
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2270 elWidth = this.$el.css('width');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2271 scrollWidth = elWidth > this.$tableBody.width() ? getScrollBarWidth() : 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2272
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2273 this.$tableFooter.css({
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2274 'margin-right': scrollWidth
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2275 }).find('table').css('width', elWidth)
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2276 .attr('class', this.$el.attr('class'));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2277
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2278 $footerTd = this.$tableFooter.find('td');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2279
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2280 this.$body.find('>tr:first-child:not(.no-records-found) > *').each(function (i) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2281 var $this = $(this);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2282
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2283 $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2284 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2285 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2286
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2287 BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2288 if (index === -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2289 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2290 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2291 this.columns[index].visible = checked;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2292 this.initHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2293 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2294 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2295 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2296
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2297 if (this.options.showColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2298 var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2299
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2300 if (needUpdate) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2301 $items.filter(sprintf('[value="%s"]', index)).prop('checked', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2302 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2303
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2304 if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2305 $items.filter(':checked').prop('disabled', true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2306 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2307 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2308 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2309
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2310 BootstrapTable.prototype.getVisibleFields = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2311 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2312 visibleFields = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2313
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2314 $.each(this.header.fields, function (j, field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2315 var column = that.columns[getFieldIndex(that.columns, field)];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2316
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2317 if (!column.visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2318 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2319 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2320 visibleFields.push(field);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2321 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2322 return visibleFields;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2323 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2324
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2325 // PUBLIC FUNCTION DEFINITION
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2326 // =======================
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2327
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2328 BootstrapTable.prototype.resetView = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2329 var padding = 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2330
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2331 if (params && params.height) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2332 this.options.height = params.height;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2333 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2334
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2335 this.$selectAll.prop('checked', this.$selectItem.length > 0 &&
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2336 this.$selectItem.length === this.$selectItem.filter(':checked').length);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2337
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2338 if (this.options.height) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2339 var toolbarHeight = this.$toolbar.outerHeight(true),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2340 paginationHeight = this.$pagination.outerHeight(true),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2341 height = this.options.height - toolbarHeight - paginationHeight;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2342
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2343 this.$tableContainer.css('height', height + 'px');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2344 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2345
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2346 if (this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2347 // remove the element css
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2348 this.$el.css('margin-top', '0');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2349 this.$tableContainer.css('padding-bottom', '0');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2350 this.$tableFooter.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2351 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2352 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2353
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2354 if (this.options.showHeader && this.options.height) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2355 this.$tableHeader.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2356 this.resetHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2357 padding += this.$header.outerHeight();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2358 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2359 this.$tableHeader.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2360 this.trigger('post-header');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2361 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2362
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2363 if (this.options.showFooter) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2364 this.resetFooter();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2365 if (this.options.height) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2366 padding += this.$tableFooter.outerHeight() + 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2367 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2368 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2369
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2370 // Assign the correct sortable arrow
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2371 this.getCaret();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2372 this.$tableContainer.css('padding-bottom', padding + 'px');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2373 this.trigger('reset-view');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2374 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2375
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2376 BootstrapTable.prototype.getData = function (useCurrentPage) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2377 return (this.searchText || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) ?
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2378 (useCurrentPage ? this.data.slice(this.pageFrom - 1, this.pageTo) : this.data) :
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2379 (useCurrentPage ? this.options.data.slice(this.pageFrom - 1, this.pageTo) : this.options.data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2380 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2381
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2382 BootstrapTable.prototype.load = function (data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2383 var fixedScroll = false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2384
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2385 // #431: support pagination
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2386 if (this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2387 this.options.totalRows = data[this.options.totalField];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2388 fixedScroll = data.fixedScroll;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2389 data = data[this.options.dataField];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2390 } else if (!$.isArray(data)) { // support fixedScroll
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2391 fixedScroll = data.fixedScroll;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2392 data = data.data;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2393 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2394
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2395 this.initData(data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2396 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2397 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2398 this.initBody(fixedScroll);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2399 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2400
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2401 BootstrapTable.prototype.append = function (data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2402 this.initData(data, 'append');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2403 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2404 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2405 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2406 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2407 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2408
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2409 BootstrapTable.prototype.prepend = function (data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2410 this.initData(data, 'prepend');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2411 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2412 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2413 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2414 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2415 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2416
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2417 BootstrapTable.prototype.remove = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2418 var len = this.options.data.length,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2419 i, row;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2420
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2421 if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2422 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2423 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2424
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2425 for (i = len - 1; i >= 0; i--) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2426 row = this.options.data[i];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2427
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2428 if (!row.hasOwnProperty(params.field)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2429 continue;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2430 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2431 if ($.inArray(row[params.field], params.values) !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2432 this.options.data.splice(i, 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2433 if (this.options.sidePagination === 'server') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2434 this.options.totalRows -= 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2435 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2436 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2437 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2438
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2439 if (len === this.options.data.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2440 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2441 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2442
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2443 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2444 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2445 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2446 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2447 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2448
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2449 BootstrapTable.prototype.removeAll = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2450 if (this.options.data.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2451 this.options.data.splice(0, this.options.data.length);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2452 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2453 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2454 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2455 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2456 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2457
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2458 BootstrapTable.prototype.getRowByUniqueId = function (id) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2459 var uniqueId = this.options.uniqueId,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2460 len = this.options.data.length,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2461 dataRow = null,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2462 i, row, rowUniqueId;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2463
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2464 for (i = len - 1; i >= 0; i--) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2465 row = this.options.data[i];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2466
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2467 if (row.hasOwnProperty(uniqueId)) { // uniqueId is a column
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2468 rowUniqueId = row[uniqueId];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2469 } else if(row._data.hasOwnProperty(uniqueId)) { // uniqueId is a row data property
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2470 rowUniqueId = row._data[uniqueId];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2471 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2472 continue;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2473 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2474
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2475 if (typeof rowUniqueId === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2476 id = id.toString();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2477 } else if (typeof rowUniqueId === 'number') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2478 if ((Number(rowUniqueId) === rowUniqueId) && (rowUniqueId % 1 === 0)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2479 id = parseInt(id);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2480 } else if ((rowUniqueId === Number(rowUniqueId)) && (rowUniqueId !== 0)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2481 id = parseFloat(id);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2482 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2483 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2484
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2485 if (rowUniqueId === id) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2486 dataRow = row;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2487 break;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2488 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2489 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2490
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2491 return dataRow;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2492 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2493
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2494 BootstrapTable.prototype.removeByUniqueId = function (id) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2495 var len = this.options.data.length,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2496 row = this.getRowByUniqueId(id);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2497
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2498 if (row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2499 this.options.data.splice(this.options.data.indexOf(row), 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2500 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2501
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2502 if (len === this.options.data.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2503 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2504 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2505
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2506 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2507 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2508 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2509 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2510
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2511 BootstrapTable.prototype.updateByUniqueId = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2512 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2513 var allParams = $.isArray(params) ? params : [ params ];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2514
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2515 $.each(allParams, function(i, params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2516 var rowId;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2517
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2518 if (!params.hasOwnProperty('id') || !params.hasOwnProperty('row')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2519 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2520 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2521
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2522 rowId = $.inArray(that.getRowByUniqueId(params.id), that.options.data);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2523
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2524 if (rowId === -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2525 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2526 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2527 $.extend(that.options.data[rowId], params.row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2528 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2529
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2530 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2531 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2532 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2533 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2534 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2535
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2536 BootstrapTable.prototype.insertRow = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2537 if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2538 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2539 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2540 this.data.splice(params.index, 0, params.row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2541 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2542 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2543 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2544 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2545 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2546
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2547 BootstrapTable.prototype.updateRow = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2548 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2549 var allParams = $.isArray(params) ? params : [ params ];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2550
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2551 $.each(allParams, function(i, params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2552 if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2553 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2554 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2555 $.extend(that.options.data[params.index], params.row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2556 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2557
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2558 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2559 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2560 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2561 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2562 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2563
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2564 BootstrapTable.prototype.initHiddenRows = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2565 this.hiddenRows = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2566 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2567
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2568 BootstrapTable.prototype.showRow = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2569 this.toggleRow(params, true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2570 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2571
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2572 BootstrapTable.prototype.hideRow = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2573 this.toggleRow(params, false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2574 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2575
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2576 BootstrapTable.prototype.toggleRow = function (params, visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2577 var row, index;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2578
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2579 if (params.hasOwnProperty('index')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2580 row = this.getData()[params.index];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2581 } else if (params.hasOwnProperty('uniqueId')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2582 row = this.getRowByUniqueId(params.uniqueId);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2583 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2584
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2585 if (!row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2586 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2587 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2588
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2589 index = $.inArray(row, this.hiddenRows);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2590
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2591 if (!visible && index === -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2592 this.hiddenRows.push(row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2593 } else if (visible && index > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2594 this.hiddenRows.splice(index, 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2595 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2596 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2597 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2598
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2599 BootstrapTable.prototype.getHiddenRows = function (show) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2600 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2601 data = this.getData(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2602 rows = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2603
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2604 $.each(data, function (i, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2605 if ($.inArray(row, that.hiddenRows) > -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2606 rows.push(row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2607 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2608 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2609 this.hiddenRows = rows;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2610 return rows;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2611 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2612
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2613 BootstrapTable.prototype.mergeCells = function (options) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2614 var row = options.index,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2615 col = $.inArray(options.field, this.getVisibleFields()),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2616 rowspan = options.rowspan || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2617 colspan = options.colspan || 1,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2618 i, j,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2619 $tr = this.$body.find('>tr'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2620 $td;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2621
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2622 if (this.options.detailView && !this.options.cardView) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2623 col += 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2624 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2625
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2626 $td = $tr.eq(row).find('>td').eq(col);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2627
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2628 if (row < 0 || col < 0 || row >= this.data.length) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2629 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2630 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2631
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2632 for (i = row; i < row + rowspan; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2633 for (j = col; j < col + colspan; j++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2634 $tr.eq(i).find('>td').eq(j).hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2635 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2636 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2637
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2638 $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2639 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2640
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2641 BootstrapTable.prototype.updateCell = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2642 if (!params.hasOwnProperty('index') ||
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2643 !params.hasOwnProperty('field') ||
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2644 !params.hasOwnProperty('value')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2645 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2646 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2647 this.data[params.index][params.field] = params.value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2648
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2649 if (params.reinit === false) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2650 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2651 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2652 this.initSort();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2653 this.initBody(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2654 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2655
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2656 BootstrapTable.prototype.getOptions = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2657 return this.options;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2658 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2659
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2660 BootstrapTable.prototype.getSelections = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2661 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2662
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2663 return $.grep(this.options.data, function (row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2664 // fix #2424: from html with checkbox
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2665 return row[that.header.stateField] === true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2666 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2667 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2668
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2669 BootstrapTable.prototype.getAllSelections = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2670 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2671
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2672 return $.grep(this.options.data, function (row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2673 return row[that.header.stateField];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2674 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2675 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2676
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2677 BootstrapTable.prototype.checkAll = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2678 this.checkAll_(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2679 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2680
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2681 BootstrapTable.prototype.uncheckAll = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2682 this.checkAll_(false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2683 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2684
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2685 BootstrapTable.prototype.checkInvert = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2686 var that = this;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2687 var rows = that.$selectItem.filter(':enabled');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2688 var checked = rows.filter(':checked');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2689 rows.each(function() {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2690 $(this).prop('checked', !$(this).prop('checked'));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2691 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2692 that.updateRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2693 that.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2694 that.trigger('uncheck-some', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2695 checked = that.getSelections();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2696 that.trigger('check-some', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2697 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2698
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2699 BootstrapTable.prototype.checkAll_ = function (checked) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2700 var rows;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2701 if (!checked) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2702 rows = this.getSelections();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2703 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2704 this.$selectAll.add(this.$selectAll_).prop('checked', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2705 this.$selectItem.filter(':enabled').prop('checked', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2706 this.updateRows();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2707 if (checked) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2708 rows = this.getSelections();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2709 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2710 this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2711 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2712
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2713 BootstrapTable.prototype.check = function (index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2714 this.check_(true, index);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2715 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2716
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2717 BootstrapTable.prototype.uncheck = function (index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2718 this.check_(false, index);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2719 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2720
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2721 BootstrapTable.prototype.check_ = function (checked, index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2722 var $el = this.$selectItem.filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2723 this.data[index][this.header.stateField] = checked;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2724 this.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2725 this.trigger(checked ? 'check' : 'uncheck', this.data[index], $el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2726 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2727
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2728 BootstrapTable.prototype.checkBy = function (obj) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2729 this.checkBy_(true, obj);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2730 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2731
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2732 BootstrapTable.prototype.uncheckBy = function (obj) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2733 this.checkBy_(false, obj);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2734 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2735
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2736 BootstrapTable.prototype.checkBy_ = function (checked, obj) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2737 if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2738 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2739 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2740
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2741 var that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2742 rows = [];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2743 $.each(this.options.data, function (index, row) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2744 if (!row.hasOwnProperty(obj.field)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2745 return false;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2746 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2747 if ($.inArray(row[obj.field], obj.values) !== -1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2748 var $el = that.$selectItem.filter(':enabled')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2749 .filter(sprintf('[data-index="%s"]', index)).prop('checked', checked);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2750 row[that.header.stateField] = checked;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2751 rows.push(row);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2752 that.trigger(checked ? 'check' : 'uncheck', row, $el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2753 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2754 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2755 this.updateSelected();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2756 this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2757 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2758
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2759 BootstrapTable.prototype.destroy = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2760 this.$el.insertBefore(this.$container);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2761 $(this.options.toolbar).insertBefore(this.$el);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2762 this.$container.next().remove();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2763 this.$container.remove();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2764 this.$el.html(this.$el_.html())
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2765 .css('margin-top', '0')
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2766 .attr('class', this.$el_.attr('class') || ''); // reset the class
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2767 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2768
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2769 BootstrapTable.prototype.showLoading = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2770 this.$tableLoading.show();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2771 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2772
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2773 BootstrapTable.prototype.hideLoading = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2774 this.$tableLoading.hide();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2775 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2776
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2777 BootstrapTable.prototype.togglePagination = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2778 this.options.pagination = !this.options.pagination;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2779 var button = this.$toolbar.find('button[name="paginationSwitch"] i');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2780 if (this.options.pagination) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2781 button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchDown);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2782 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2783 button.attr("class", this.options.iconsPrefix + " " + this.options.icons.paginationSwitchUp);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2784 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2785 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2786 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2787
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2788 BootstrapTable.prototype.refresh = function (params) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2789 if (params && params.url) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2790 this.options.url = params.url;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2791 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2792 if (params && params.pageNumber) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2793 this.options.pageNumber = params.pageNumber;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2794 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2795 if (params && params.pageSize) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2796 this.options.pageSize = params.pageSize;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2797 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2798 this.initServer(params && params.silent,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2799 params && params.query, params && params.url);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2800 this.trigger('refresh', params);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2801 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2802
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2803 BootstrapTable.prototype.resetWidth = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2804 if (this.options.showHeader && this.options.height) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2805 this.fitHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2806 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2807 if (this.options.showFooter) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2808 this.fitFooter();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2809 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2810 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2811
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2812 BootstrapTable.prototype.showColumn = function (field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2813 this.toggleColumn(getFieldIndex(this.columns, field), true, true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2814 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2815
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2816 BootstrapTable.prototype.hideColumn = function (field) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2817 this.toggleColumn(getFieldIndex(this.columns, field), false, true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2818 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2819
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2820 BootstrapTable.prototype.getHiddenColumns = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2821 return $.grep(this.columns, function (column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2822 return !column.visible;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2823 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2824 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2825
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2826 BootstrapTable.prototype.getVisibleColumns = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2827 return $.grep(this.columns, function (column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2828 return column.visible;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2829 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2830 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2831
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2832 BootstrapTable.prototype.toggleAllColumns = function (visible) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2833 $.each(this.columns, function (i, column) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2834 this.columns[i].visible = visible;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2835 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2836
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2837 this.initHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2838 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2839 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2840 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2841 if (this.options.showColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2842 var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2843
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2844 if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2845 $items.filter(':checked').prop('disabled', true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2846 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2847 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2848 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2849
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2850 BootstrapTable.prototype.showAllColumns = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2851 this.toggleAllColumns(true);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2852 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2853
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2854 BootstrapTable.prototype.hideAllColumns = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2855 this.toggleAllColumns(false);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2856 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2857
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2858 BootstrapTable.prototype.filterBy = function (columns) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2859 this.filterColumns = $.isEmptyObject(columns) ? {} : columns;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2860 this.options.pageNumber = 1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2861 this.initSearch();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2862 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2863 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2864
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2865 BootstrapTable.prototype.scrollTo = function (value) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2866 if (typeof value === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2867 value = value === 'bottom' ? this.$tableBody[0].scrollHeight : 0;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2868 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2869 if (typeof value === 'number') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2870 this.$tableBody.scrollTop(value);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2871 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2872 if (typeof value === 'undefined') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2873 return this.$tableBody.scrollTop();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2874 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2875 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2876
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2877 BootstrapTable.prototype.getScrollPosition = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2878 return this.scrollTo();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2879 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2880
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2881 BootstrapTable.prototype.selectPage = function (page) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2882 if (page > 0 && page <= this.options.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2883 this.options.pageNumber = page;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2884 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2885 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2886 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2887
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2888 BootstrapTable.prototype.prevPage = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2889 if (this.options.pageNumber > 1) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2890 this.options.pageNumber--;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2891 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2892 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2893 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2894
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2895 BootstrapTable.prototype.nextPage = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2896 if (this.options.pageNumber < this.options.totalPages) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2897 this.options.pageNumber++;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2898 this.updatePagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2899 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2900 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2901
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2902 BootstrapTable.prototype.toggleView = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2903 this.options.cardView = !this.options.cardView;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2904 this.initHeader();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2905 // Fixed remove toolbar when click cardView button.
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2906 //that.initToolbar();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2907 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2908 this.trigger('toggle', this.options.cardView);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2909 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2910
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2911 BootstrapTable.prototype.refreshOptions = function (options) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2912 //If the objects are equivalent then avoid the call of destroy / init methods
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2913 if (compareObjects(this.options, options, true)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2914 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2915 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2916 this.options = $.extend(this.options, options);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2917 this.trigger('refresh-options', this.options);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2918 this.destroy();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2919 this.init();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2920 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2921
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2922 BootstrapTable.prototype.resetSearch = function (text) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2923 var $search = this.$toolbar.find('.search input');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2924 $search.val(text || '');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2925 this.onSearch({currentTarget: $search});
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2926 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2927
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2928 BootstrapTable.prototype.expandRow_ = function (expand, index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2929 var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', index));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2930 if ($tr.next().is('tr.detail-view') === (expand ? false : true)) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2931 $tr.find('> td > .detail-icon').click();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2932 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2933 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2934
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2935 BootstrapTable.prototype.expandRow = function (index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2936 this.expandRow_(true, index);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2937 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2938
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2939 BootstrapTable.prototype.collapseRow = function (index) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2940 this.expandRow_(false, index);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2941 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2942
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2943 BootstrapTable.prototype.expandAllRows = function (isSubTable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2944 if (isSubTable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2945 var $tr = this.$body.find(sprintf('> tr[data-index="%s"]', 0)),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2946 that = this,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2947 detailIcon = null,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2948 executeInterval = false,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2949 idInterval = -1;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2950
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2951 if (!$tr.next().is('tr.detail-view')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2952 $tr.find('> td > .detail-icon').click();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2953 executeInterval = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2954 } else if (!$tr.next().next().is('tr.detail-view')) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2955 $tr.next().find(".detail-icon").click();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2956 executeInterval = true;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2957 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2958
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2959 if (executeInterval) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2960 try {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2961 idInterval = setInterval(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2962 detailIcon = that.$body.find("tr.detail-view").last().find(".detail-icon");
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2963 if (detailIcon.length > 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2964 detailIcon.click();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2965 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2966 clearInterval(idInterval);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2967 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2968 }, 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2969 } catch (ex) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2970 clearInterval(idInterval);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2971 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2972 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2973 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2974 var trs = this.$body.children();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2975 for (var i = 0; i < trs.length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2976 this.expandRow_(true, $(trs[i]).data("index"));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2977 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2978 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2979 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2980
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2981 BootstrapTable.prototype.collapseAllRows = function (isSubTable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2982 if (isSubTable) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2983 this.expandRow_(false, 0);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2984 } else {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2985 var trs = this.$body.children();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2986 for (var i = 0; i < trs.length; i++) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2987 this.expandRow_(false, $(trs[i]).data("index"));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2988 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2989 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2990 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2991
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2992 BootstrapTable.prototype.updateFormatText = function (name, text) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2993 if (this.options[sprintf('format%s', name)]) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2994 if (typeof text === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2995 this.options[sprintf('format%s', name)] = function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2996 return text;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2997 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2998 } else if (typeof text === 'function') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
2999 this.options[sprintf('format%s', name)] = text;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3000 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3001 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3002 this.initToolbar();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3003 this.initPagination();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3004 this.initBody();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3005 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3006
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3007 // BOOTSTRAP TABLE PLUGIN DEFINITION
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3008 // =======================
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3009
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3010 var allowedMethods = [
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3011 'getOptions',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3012 'getSelections', 'getAllSelections', 'getData',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3013 'load', 'append', 'prepend', 'remove', 'removeAll',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3014 'insertRow', 'updateRow', 'updateCell', 'updateByUniqueId', 'removeByUniqueId',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3015 'getRowByUniqueId', 'showRow', 'hideRow', 'getHiddenRows',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3016 'mergeCells',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3017 'checkAll', 'uncheckAll', 'checkInvert',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3018 'check', 'uncheck',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3019 'checkBy', 'uncheckBy',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3020 'refresh',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3021 'resetView',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3022 'resetWidth',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3023 'destroy',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3024 'showLoading', 'hideLoading',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3025 'showColumn', 'hideColumn', 'getHiddenColumns', 'getVisibleColumns',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3026 'showAllColumns', 'hideAllColumns',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3027 'filterBy',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3028 'scrollTo',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3029 'getScrollPosition',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3030 'selectPage', 'prevPage', 'nextPage',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3031 'togglePagination',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3032 'toggleView',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3033 'refreshOptions',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3034 'resetSearch',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3035 'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows',
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3036 'updateFormatText'
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3037 ];
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3038
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3039 $.fn.bootstrapTable = function (option) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3040 var value,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3041 args = Array.prototype.slice.call(arguments, 1);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3042
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3043 this.each(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3044 var $this = $(this),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3045 data = $this.data('bootstrap.table'),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3046 options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(),
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3047 typeof option === 'object' && option);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3048
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3049 if (typeof option === 'string') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3050 if ($.inArray(option, allowedMethods) < 0) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3051 throw new Error("Unknown method: " + option);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3052 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3053
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3054 if (!data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3055 return;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3056 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3057
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3058 value = data[option].apply(data, args);
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3059
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3060 if (option === 'destroy') {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3061 $this.removeData('bootstrap.table');
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3062 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3063 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3064
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3065 if (!data) {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3066 $this.data('bootstrap.table', (data = new BootstrapTable(this, options)));
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3067 }
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3068 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3069
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3070 return typeof value === 'undefined' ? this : value;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3071 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3072
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3073 $.fn.bootstrapTable.Constructor = BootstrapTable;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3074 $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3075 $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3076 $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3077 $.fn.bootstrapTable.methods = allowedMethods;
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3078 $.fn.bootstrapTable.utils = {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3079 sprintf: sprintf,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3080 getFieldIndex: getFieldIndex,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3081 compareObjects: compareObjects,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3082 calculateObjectValue: calculateObjectValue,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3083 getItemField: getItemField,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3084 objectKeys: objectKeys,
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3085 isIEBrowser: isIEBrowser
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3086 };
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3087
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3088 // BOOTSTRAP TABLE INIT
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3089 // =======================
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3090
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3091 $(function () {
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3092 $('[data-toggle="table"]').bootstrapTable();
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3093 });
9185ca0a7b43 Updated package according to recommendations.
pierre.pouchin
parents:
diff changeset
3094 })(jQuery);