tidy-table-rails 2.1.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tidy/table/rails/version.rb +1 -1
- data/vendor/assets/javascripts/tidy-table.js +455 -429
- data/vendor/assets/stylesheets/tidy-table.css +100 -98
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12e68be6086553aac38ac04b81400fd45dd50b0f
|
4
|
+
data.tar.gz: 624b9c768589b6e4435fbb2446ceafb164e27ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f68d5c0091a2054bcaef4cc6f8ccdc829f2080016b1478ff3dab8fafa1eef8085df9d2f70d25aef7cba1b333e168c393f753a8014625a55f492a77924bad30c
|
7
|
+
data.tar.gz: 0f48caa076085027534bc31cf5fbbf711598e269f7ae2b40034db0fb01ca96ade6863e8efddf676e4ee8ae34d023ababb04a119b9fc7704d3188a4a175fba090
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/**
|
2
2
|
* Tidy Table
|
3
|
-
*
|
3
|
+
* Create a HTML table from JSON that can be sorted, selected
|
4
|
+
* and post-processed using a simple callback.
|
4
5
|
*
|
5
|
-
* Copyright 2012-2015, Marc S. Brooks (
|
6
|
+
* Copyright 2012-2015, Marc S. Brooks (https://mbrooks.info)
|
6
7
|
* Licensed under the MIT license:
|
7
8
|
* http://www.opensource.org/licenses/mit-license.php
|
8
9
|
*
|
@@ -11,434 +12,459 @@
|
|
11
12
|
*/
|
12
13
|
|
13
14
|
if (!window.jQuery || (window.jQuery && parseInt(window.jQuery.fn.jquery.replace('.', '')) < parseInt('1.8.3'.replace('.', '')))) {
|
14
|
-
|
15
|
+
throw new Error('Tidy-Table requires jQuery 1.8.3 or greater.');
|
15
16
|
}
|
16
17
|
|
17
18
|
(function($) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
19
|
+
var table = null;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @namespace TidyTable
|
23
|
+
*/
|
24
|
+
var methods = {
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Create new instance of Tidy-Table
|
28
|
+
*
|
29
|
+
* @memberof TidyTable
|
30
|
+
* @method init
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* $('#container').TidyTable(settings, config);
|
34
|
+
*
|
35
|
+
* @param {Object} settings
|
36
|
+
* @param {Object} config
|
37
|
+
*
|
38
|
+
* @returns {Object} jQuery object
|
39
|
+
*/
|
40
|
+
"init": function(settings, config) {
|
41
|
+
var $this = $(this),
|
42
|
+
data = $this.data();
|
43
|
+
|
44
|
+
// Default settings
|
45
|
+
var defaults = {
|
46
|
+
enableCheckbox: false,
|
47
|
+
enableMenu: false,
|
48
|
+
reverseSortDir: false,
|
49
|
+
responsive: false
|
50
|
+
};
|
51
|
+
|
52
|
+
if (arguments.length > 1) {
|
53
|
+
$.extend(defaults, settings);
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
config = settings;
|
57
|
+
}
|
58
|
+
|
59
|
+
// Config defaults
|
60
|
+
config = $.extend({
|
61
|
+
sortByPattern: function(col_num, val) {
|
62
|
+
if ( $.trim(col_num) ) {
|
63
|
+
return String(val).replace(/$|%|#/g, '');
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}, config);
|
67
|
+
|
68
|
+
if ( $.isEmptyObject(data) ) {
|
69
|
+
$this.data({
|
70
|
+
settings: defaults,
|
71
|
+
config: config
|
72
|
+
});
|
73
|
+
}
|
74
|
+
|
75
|
+
// Responsive layout?
|
76
|
+
if (defaults.responsive) {
|
77
|
+
$this.addClass('tidy_table media');
|
78
|
+
}
|
79
|
+
|
80
|
+
return $this.TidyTable('_createTable');
|
81
|
+
},
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Perform cleanup
|
85
|
+
*
|
86
|
+
* @memberof TidyTable
|
87
|
+
* @method destroy
|
88
|
+
*
|
89
|
+
* @example
|
90
|
+
* $('#container').TidyTable('destroy');
|
91
|
+
*/
|
92
|
+
"destroy": function() {
|
93
|
+
$(this).removeData();
|
94
|
+
},
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Create HTML table elements.
|
98
|
+
*
|
99
|
+
* @memberof TidyTable
|
100
|
+
* @method _createTable
|
101
|
+
* @private
|
102
|
+
*
|
103
|
+
* @param {String|undefined} num
|
104
|
+
* @param {String|undefined} order
|
105
|
+
*
|
106
|
+
* @returns {Object} jQuery object
|
107
|
+
*/
|
108
|
+
"_createTable": function(num, order) {
|
109
|
+
var $this = $(this),
|
110
|
+
data = $this.data();
|
111
|
+
|
112
|
+
// Create reusable elements.
|
113
|
+
table = $('<table></table>')
|
114
|
+
.addClass('tidy_table');
|
115
|
+
|
116
|
+
// Disable IE7/8 text selection.
|
117
|
+
table.mousedown(function() { return false; });
|
118
|
+
table.mouseover(function() { return false; });
|
119
|
+
|
120
|
+
var thead = $('<thead></thead>'),
|
121
|
+
tbody = $('<tbody></tbody>'),
|
122
|
+
titles = null;
|
123
|
+
|
124
|
+
// .. <THEAD>
|
125
|
+
(function() {
|
126
|
+
titles = data.config.columnTitles;
|
127
|
+
|
128
|
+
var row = $('<tr></tr>');
|
129
|
+
|
130
|
+
for (var i = 0; i < titles.length; i++) {
|
131
|
+
var title = titles[i];
|
132
|
+
|
133
|
+
var col = $('<th></th>')
|
134
|
+
.append(title)
|
135
|
+
.attr('title', title);
|
136
|
+
row.append(col);
|
137
|
+
|
138
|
+
var col_class;
|
139
|
+
|
140
|
+
// Determine column result order.
|
141
|
+
if (!data.settings.reverseSortDir) {
|
142
|
+
if (order == 'asc' || !order) {
|
143
|
+
col_class = 'sort_asc';
|
144
|
+
col.order = 'desc';
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
col_class = 'sort_desc';
|
148
|
+
col.order = 'asc';
|
149
|
+
}
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
if (order == 'desc' || !order) {
|
153
|
+
col_class = 'sort_asc';
|
154
|
+
col.order = 'asc';
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
col_class = 'sort_desc';
|
158
|
+
col.order = 'desc';
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
// Highlight selected column.
|
163
|
+
if (num == i) {
|
164
|
+
col.addClass(col_class);
|
165
|
+
}
|
166
|
+
|
167
|
+
// Attach sorting event to each column.
|
168
|
+
col.on('click', {
|
169
|
+
col_number: i,
|
170
|
+
sort_order: (num == i) ? col.order : 'asc'
|
171
|
+
},
|
172
|
+
function(event) {
|
173
|
+
$this.TidyTable('_sortByColumn', event.data.col_number, event.data.sort_order);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
|
177
|
+
thead.append(row);
|
178
|
+
})();
|
179
|
+
|
180
|
+
// .. <TBODY>
|
181
|
+
(function() {
|
182
|
+
var vals = data.config.columnValues;
|
183
|
+
|
184
|
+
for (var j = 0; j < vals.length; j++) {
|
185
|
+
var row = $('<tr></tr>');
|
186
|
+
|
187
|
+
for (var k = 0; k < vals[j].length; k++) {
|
188
|
+
var val = vals[j][k];
|
189
|
+
|
190
|
+
var col = $('<td></td>')
|
191
|
+
.append(val)
|
192
|
+
.attr('title', val);
|
193
|
+
row.append(col);
|
194
|
+
|
195
|
+
// Post-process table column HTML object.
|
196
|
+
if (data.config.postProcess && $.isFunction(data.config.postProcess.column)) {
|
197
|
+
data.config.postProcess.column(col);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
tbody.append(row);
|
202
|
+
}
|
203
|
+
|
204
|
+
table.append(thead);
|
205
|
+
table.append(tbody);
|
206
|
+
|
207
|
+
// Append check boxes to beginning each row.
|
208
|
+
if (data.settings && data.settings.enableCheckbox) {
|
209
|
+
var rows = table.find('tr');
|
210
|
+
|
211
|
+
rows.each(function(index) {
|
212
|
+
var input = $('<input></input>')
|
213
|
+
.attr('type', 'checkbox');
|
214
|
+
|
215
|
+
var col;
|
216
|
+
|
217
|
+
// First row is always the header.
|
218
|
+
if (index === 0) {
|
219
|
+
col = $('<th></th>');
|
220
|
+
|
221
|
+
// Attach event to check all boxes.
|
222
|
+
input.on('click', function() {
|
223
|
+
$this.TidyTable('_toggleSelRows', rows);
|
224
|
+
});
|
225
|
+
}
|
226
|
+
else {
|
227
|
+
col = $('<td></td>');
|
228
|
+
|
229
|
+
// Attach event to each checkbox.
|
230
|
+
input.on('click', {
|
231
|
+
box_number: index
|
232
|
+
},
|
233
|
+
function(event) {
|
234
|
+
$this.TidyTable('_toggleSelRows', rows, event.data.box_number);
|
235
|
+
});
|
236
|
+
}
|
237
|
+
|
238
|
+
col.append(input);
|
239
|
+
|
240
|
+
// Insert before first cell.
|
241
|
+
$(this).prepend(col);
|
242
|
+
});
|
243
|
+
}
|
244
|
+
})();
|
245
|
+
|
246
|
+
// Post-process table results HTML object.
|
247
|
+
if (data.config.postProcess && $.isFunction(data.config.postProcess.table)) {
|
248
|
+
data.config.postProcess.table(table);
|
249
|
+
}
|
250
|
+
|
251
|
+
var block = $this.children('table.tidy_table');
|
252
|
+
|
253
|
+
// If table exists, perform an in-place update of the element.
|
254
|
+
if (block[0]) {
|
255
|
+
block.replaceWith(table);
|
256
|
+
}
|
257
|
+
|
258
|
+
// Generate table/menu elements.
|
259
|
+
else {
|
260
|
+
if (data.settings && data.settings.enableMenu) {
|
261
|
+
$this.append(
|
262
|
+
$this.TidyTable('_createMenu', 'options')
|
263
|
+
);
|
264
|
+
}
|
265
|
+
|
266
|
+
$this.append(table);
|
267
|
+
}
|
268
|
+
|
269
|
+
return table;
|
270
|
+
},
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Create HTML select menu element
|
274
|
+
*
|
275
|
+
* @memberof TidyTable
|
276
|
+
* @method _createMenu
|
277
|
+
* @private
|
278
|
+
*
|
279
|
+
* @param {String} name
|
280
|
+
*
|
281
|
+
* @returns {Object} jQuery object
|
282
|
+
*/
|
283
|
+
"_createMenu": function(name) {
|
284
|
+
var $this = $(this),
|
285
|
+
data = $this.data();
|
286
|
+
|
287
|
+
// Create reusable elements.
|
288
|
+
var select = $('<select></select>')
|
289
|
+
.addClass('tidy_table ' + name)
|
290
|
+
.change(function() {
|
291
|
+
var elm = $(this);
|
292
|
+
|
293
|
+
var callback = data.config.menuOptions[ elm.val() ][1]['callback'];
|
294
|
+
|
295
|
+
// Callback event
|
296
|
+
if ( $.isFunction(callback) ) {
|
297
|
+
callback( $this.TidyTable('_getCheckedAsObj') );
|
298
|
+
}
|
299
|
+
|
300
|
+
elm.val(0);
|
301
|
+
});
|
302
|
+
|
303
|
+
// .. Options
|
304
|
+
$.each(data.config.menuOptions, function(index) {
|
305
|
+
var option = $('<option>' + data.config.menuOptions[index][0] + '</option>')
|
306
|
+
.attr('value', index);
|
307
|
+
|
308
|
+
select.append(option);
|
309
|
+
});
|
310
|
+
|
311
|
+
// Post-process select menu HTML object.
|
312
|
+
if (data.config.postProcess && $.isFunction(data.config.postProcess.menu)) {
|
313
|
+
data.config.postProcess.menu(select);
|
314
|
+
}
|
315
|
+
|
316
|
+
return select;
|
317
|
+
},
|
318
|
+
|
319
|
+
/**
|
320
|
+
* Return selected row values as an array.
|
321
|
+
*
|
322
|
+
* @memberof TidyTable
|
323
|
+
* @method _getCheckedAsObj
|
324
|
+
* @private
|
325
|
+
*
|
326
|
+
* @returns {Array}
|
327
|
+
*/
|
328
|
+
"_getCheckedAsObj": function() {
|
329
|
+
var $this = $(this),
|
330
|
+
rows = $this.find('tbody > tr'),
|
331
|
+
objs = [];
|
332
|
+
|
333
|
+
for (var i = 0; i < rows.length; i++) {
|
334
|
+
var cols = rows[i].childNodes;
|
335
|
+
|
336
|
+
// If the row checkbox is selected.
|
337
|
+
if (cols[0].firstChild.checked) {
|
338
|
+
var row = [];
|
339
|
+
|
340
|
+
// Simulate an associative array.
|
341
|
+
for (var j = 1; j < cols.length; j++) {
|
342
|
+
row[j - 1] = cols[j].textContent;
|
343
|
+
}
|
344
|
+
|
345
|
+
objs.push(row);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
return objs;
|
350
|
+
},
|
351
|
+
|
352
|
+
/**
|
353
|
+
* Select/Deselect (input checkbox and row highlight).
|
354
|
+
*
|
355
|
+
* @memberof TidyTable
|
356
|
+
* @method _toggleSelRows
|
357
|
+
* @private
|
358
|
+
*
|
359
|
+
* @param {Object} rows jQuery object
|
360
|
+
* @param {Number} num
|
361
|
+
*/
|
362
|
+
"_toggleSelRows": function(rows, num) {
|
363
|
+
var checked = null;
|
364
|
+
|
365
|
+
rows.each(function(index) {
|
366
|
+
var row = $(this),
|
367
|
+
input = row.find(':checkbox').first();
|
368
|
+
|
369
|
+
// Update all rows.
|
370
|
+
if (!num) {
|
371
|
+
if (index === 0) {
|
372
|
+
checked = (input.is(':checked')) ? true : false;
|
373
|
+
return;
|
374
|
+
}
|
375
|
+
|
376
|
+
if (checked) {
|
377
|
+
row.removeClass('check_off').addClass('check_on');
|
378
|
+
input.prop('checked', true);
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
row.removeClass('check_on').addClass('check_off');
|
382
|
+
input.prop('checked', false);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
|
386
|
+
// Update selected row.
|
387
|
+
else {
|
388
|
+
if (index === 0) {
|
389
|
+
return;
|
390
|
+
}
|
391
|
+
|
392
|
+
if (input.is(':checked')) {
|
393
|
+
row.removeClass('check_off').addClass('check_on');
|
394
|
+
input.prop('checked', true);
|
395
|
+
}
|
396
|
+
else {
|
397
|
+
row.removeClass('check_on').addClass('check_off');
|
398
|
+
input.prop('checked', false);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
});
|
402
|
+
},
|
403
|
+
|
404
|
+
/**
|
405
|
+
* Display results ordered by selected column.
|
406
|
+
*
|
407
|
+
* @memberof TidyTable
|
408
|
+
* @method _sortByColumn
|
409
|
+
* @private
|
410
|
+
*
|
411
|
+
* @param {Number} num
|
412
|
+
* @param {Number} order
|
413
|
+
*/
|
414
|
+
"_sortByColumn": function(num, order) {
|
415
|
+
var $this = $(this),
|
416
|
+
data = $this.data();
|
417
|
+
|
418
|
+
if ( $.isFunction(data.config.sortByPattern) ) {
|
419
|
+
var reverse = (order == 'desc') ? -1 : 1;
|
420
|
+
|
421
|
+
// Sort JSON object by bucket number.
|
422
|
+
data.config.columnValues.sort(function(a, b) {
|
423
|
+
var str1 = data.config.sortByPattern(num, a[num]),
|
424
|
+
str2 = data.config.sortByPattern(num, b[num]);
|
425
|
+
|
426
|
+
if (isNaN(str1)) {
|
427
|
+
return [reverse * cmpAny(str1, str2)] >
|
428
|
+
[reverse * cmpAny(str2, str1)] ? -1 : 1;
|
429
|
+
}
|
430
|
+
else {
|
431
|
+
return [reverse * cmpInt(str1, str2)];
|
432
|
+
}
|
433
|
+
});
|
434
|
+
}
|
435
|
+
|
436
|
+
$this.TidyTable('_createTable', num, order);
|
437
|
+
}
|
438
|
+
};
|
439
|
+
|
440
|
+
$.fn.TidyTable = function(method) {
|
441
|
+
if (methods[method]) {
|
442
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
443
|
+
}
|
444
|
+
else
|
445
|
+
if (typeof method === 'object' || !method) {
|
446
|
+
return methods.init.apply(this, arguments);
|
447
|
+
}
|
448
|
+
else {
|
449
|
+
$.error('Method ' + method + ' does not exist in jQuery.TidyTable');
|
450
|
+
}
|
451
|
+
};
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Generic string comparison functions.
|
455
|
+
*
|
456
|
+
* @protected
|
457
|
+
*
|
458
|
+
* @param {String} a
|
459
|
+
* @param {String} b
|
460
|
+
*
|
461
|
+
* @returns {Number}
|
462
|
+
*/
|
463
|
+
function cmpAny(a, b) {
|
464
|
+
return (a > b) ? 1 : (a < b) ? -1 : 0;
|
465
|
+
}
|
466
|
+
|
467
|
+
function cmpInt(a, b) {
|
468
|
+
return b - a;
|
469
|
+
}
|
444
470
|
})(jQuery);
|
@@ -1,8 +1,9 @@
|
|
1
1
|
/**
|
2
2
|
* Tidy Table
|
3
|
-
*
|
3
|
+
* Create a HTML table from JSON that can be sorted, selected
|
4
|
+
* and post-processed using a simple callback.
|
4
5
|
*
|
5
|
-
* Copyright 2012-2015, Marc S. Brooks (
|
6
|
+
* Copyright 2012-2015, Marc S. Brooks (https://mbrooks.info)
|
6
7
|
* Licensed under the MIT license:
|
7
8
|
* http://www.opensource.org/licenses/mit-license.php
|
8
9
|
*
|
@@ -11,129 +12,130 @@
|
|
11
12
|
*/
|
12
13
|
|
13
14
|
table.tidy_table {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
background-color: #FFFFFF;
|
16
|
+
border-collapse: collapse;
|
17
|
+
border: 1px solid #CCCCCC;
|
18
|
+
cursor: pointer;
|
19
|
+
white-space: nowrap;
|
19
20
|
}
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
.tidy_table thead {
|
23
|
+
border: none;
|
23
24
|
}
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
.tidy_table .check_on {
|
27
|
+
background-color: #F5F5F5;
|
27
28
|
}
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
.tidy_table .check_off {
|
31
|
+
background-color: #FFFFFF;
|
31
32
|
}
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
.tidy_table th {
|
35
|
+
background-color: #DDDDDD;
|
35
36
|
}
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
.tidy_table .sort_asc {
|
39
|
+
background: #EEEEEE url( images/arrow_asc.gif ) no-repeat right center;
|
39
40
|
}
|
40
41
|
|
41
|
-
|
42
|
-
|
42
|
+
.tidy_table .sort_desc {
|
43
|
+
background: #EEEEEE url( images/arrow_desc.gif ) no-repeat right center;
|
43
44
|
}
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
.tidy_table th,
|
47
|
+
.tidy_table td {
|
48
|
+
padding: 6px 20px;
|
48
49
|
}
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
.tidy_table td {
|
52
|
+
border-right: 1px solid #EEEEEE;
|
53
|
+
border-top: 1px solid #CCCCCC;
|
54
|
+
padding: 7px 20px;
|
54
55
|
}
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
.tidy_table th:nth-child(1),
|
58
|
+
.tidy_table td:nth-child(1) {
|
59
|
+
width: 10px;
|
59
60
|
}
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
.tidy_table td:nth-child(1) {
|
63
|
+
border-right: 1px solid #EEEEEE;
|
63
64
|
}
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
.tidy_table input[type=checkbox],
|
67
|
+
.tidy_table input[type=checkbox] {
|
68
|
+
display: block;
|
69
|
+
margin: 0px auto;
|
69
70
|
}
|
70
71
|
|
71
|
-
|
72
|
-
|
72
|
+
.tidy_table td:nth-last-child(1) {
|
73
|
+
border-right: none;
|
73
74
|
}
|
74
75
|
|
75
|
-
|
76
|
-
|
76
|
+
.tidy_table td .label {
|
77
|
+
display: none;
|
77
78
|
}
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
/**
|
81
|
+
* Responsive (mobile devices)
|
82
|
+
*/
|
81
83
|
@media only screen and (min-device-width: 0px) and (max-device-width: 768px) {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
84
|
+
.tidy_media {
|
85
|
+
margin: 0px !important;
|
86
|
+
width: auto !important;
|
87
|
+
overflow: none;
|
88
|
+
}
|
89
|
+
|
90
|
+
.tidy_media select {
|
91
|
+
position: relative;
|
92
|
+
right: 30px;
|
93
|
+
}
|
94
|
+
|
95
|
+
.tidy_media table {
|
96
|
+
border: 0px;
|
97
|
+
border-top: 1px solid #DDDDDD;
|
98
|
+
width: 100%;
|
99
|
+
}
|
100
|
+
|
101
|
+
.tidy_media table tr {
|
102
|
+
border-bottom: 1px solid #CCCCCC;
|
103
|
+
position: relative;
|
104
|
+
}
|
105
|
+
|
106
|
+
.tidy_media table tbody tr:last-child {
|
107
|
+
border: none;
|
108
|
+
}
|
109
|
+
|
110
|
+
.tidy_media table th,
|
111
|
+
.tidy_media table td {
|
112
|
+
box-sizing: border-box;
|
113
|
+
border: 0px;
|
114
|
+
clear: both;
|
115
|
+
float: left;
|
116
|
+
padding-left: 10px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.tidy_media table th:first-child,
|
120
|
+
.tidy_media table td:first-child {
|
121
|
+
background-color: transparent;
|
122
|
+
padding: 10px;
|
123
|
+
position: absolute;
|
124
|
+
right: 0px;
|
125
|
+
top: 2px;
|
126
|
+
width: auto;
|
127
|
+
}
|
128
|
+
|
129
|
+
.tidy_media table th {
|
130
|
+
text-align: left;
|
131
|
+
width: 100%;
|
132
|
+
}
|
133
|
+
|
134
|
+
.tidy_media table th:first-child {
|
135
|
+
top: -40px;
|
136
|
+
}
|
137
|
+
|
138
|
+
.tidy_media table td {
|
139
|
+
background-color: transparent;
|
140
|
+
}
|
139
141
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tidy-table-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dbackowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-rails
|