grid_table 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grid_table/version.rb +1 -1
- data/vendor/assets/javascripts/gridtable.js +29 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3202a35b5d6d85fbbdf04d12963a0bd82651d455
|
4
|
+
data.tar.gz: 7915cef04379b90835c032f59ae56a278e999845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f0f1eef1170ad6f22ce3d434221b814aee50b374cd47eba60cf2cc3541f77725eded31ce6ae496985edaa8a679876b4f9078a63df4ed0b2657ec5f95bb5e9df
|
7
|
+
data.tar.gz: b7c2fbe34dbb5d4aba65298dcea29461dfd38088e69cac06e230f1aaf8add3683dae33906c12f83d843d94eb26c6369c98102c68a34ed97db1522afba0eff9e3
|
data/lib/grid_table/version.rb
CHANGED
@@ -5,7 +5,7 @@ $(function() {
|
|
5
5
|
var gridtables = GridTableFactory.getAll($(this));
|
6
6
|
for (var i = 0; i < gridtables.length; i++) {
|
7
7
|
var gridtable = gridtables[i];
|
8
|
-
gridtable.refresh((function
|
8
|
+
gridtable.refresh((function(_this) {
|
9
9
|
var $checked, n, url;
|
10
10
|
n = _this.name;
|
11
11
|
url = gridtable.getUrl();
|
@@ -15,7 +15,7 @@ $(function() {
|
|
15
15
|
if (_this.type === 'checkbox') {
|
16
16
|
$checked = $(':checkbox[name="' + n + '"]:checked');
|
17
17
|
if ($checked.length > 0) {
|
18
|
-
url += '?' + ($checked.map(function
|
18
|
+
url += '?' + ($checked.map(function() {
|
19
19
|
return "" + n + "=" + this.value;
|
20
20
|
}).toArray().join('&'));
|
21
21
|
}
|
@@ -30,9 +30,9 @@ $(function() {
|
|
30
30
|
|
31
31
|
return;
|
32
32
|
});
|
33
|
+
|
33
34
|
return $('.grid-table').each(function() {
|
34
|
-
var $table;
|
35
|
-
$table = $(this);
|
35
|
+
var $table = $(this);
|
36
36
|
return GridTableFactory.createGridTable($table).loadGridTable($table);
|
37
37
|
});
|
38
38
|
});
|
@@ -41,16 +41,15 @@ window.GridTableFactory = (function() {
|
|
41
41
|
function GridTableFactory() {}
|
42
42
|
|
43
43
|
GridTableFactory.gridTableList = {};
|
44
|
-
|
45
44
|
GridTableFactory.defaultGridTableId = 'default-grid-table';
|
46
45
|
|
47
|
-
GridTableFactory.get = function
|
46
|
+
GridTableFactory.get = function(obj) {
|
48
47
|
var gridtables = this.getAll(obj);
|
49
48
|
|
50
49
|
return gridtables.length > 0 ? gridtables[0] : null;
|
51
50
|
};
|
52
51
|
|
53
|
-
GridTableFactory.getAll = function
|
52
|
+
GridTableFactory.getAll = function(obj) {
|
54
53
|
var ids;
|
55
54
|
if (typeof obj === 'object') {
|
56
55
|
ids = ($(obj).data('grid-table-id') || this.defaultGridTableId).split(',');
|
@@ -90,14 +89,6 @@ window.GridTableFactory = (function() {
|
|
90
89
|
})();
|
91
90
|
|
92
91
|
GridTable = (function() {
|
93
|
-
var GridTableParams, sortIcons;
|
94
|
-
|
95
|
-
sortIcons = {
|
96
|
-
"default": 'fa fa-sort',
|
97
|
-
asc: 'fa fa-sort-desc',
|
98
|
-
desc: 'fa fa-sort-asc'
|
99
|
-
};
|
100
|
-
|
101
92
|
GridTable.prototype.gridTableParams = null;
|
102
93
|
GridTable.prototype.gridTableDOM = null;
|
103
94
|
GridTable.prototype.loadDataCompleteCallback = null;
|
@@ -122,7 +113,7 @@ GridTable = (function() {
|
|
122
113
|
return function(index, column) {
|
123
114
|
var $column;
|
124
115
|
$column = $(column);
|
125
|
-
$column.append("<i class='" + sortIcons['default'] + "'></i>");
|
116
|
+
$column.append("<i class='" + _this.gridTableParams.sortIcons['default'] + "'></i>");
|
126
117
|
if ($column.data('default-sort')) {
|
127
118
|
_this.setSort($column.data('field'), $column.data('default-sort'), true);
|
128
119
|
}
|
@@ -355,7 +346,7 @@ GridTable = (function() {
|
|
355
346
|
$(previous).on('click', (function(_this) {
|
356
347
|
return function(event) {
|
357
348
|
event.preventDefault();
|
358
|
-
return _this.setPage(Math.max
|
349
|
+
return _this.setPage(Math.max((_this.gridTableParams.page - 1), 0));
|
359
350
|
};
|
360
351
|
})(this));
|
361
352
|
} else {
|
@@ -384,35 +375,35 @@ GridTable = (function() {
|
|
384
375
|
return display.text("" + (this.gridTableParams.page + 1) + " of " + (last_page + 1) + " (" + total_rows + ")");
|
385
376
|
};
|
386
377
|
|
387
|
-
GridTable.prototype.updateSortDisplay = function
|
378
|
+
GridTable.prototype.updateSortDisplay = function() {
|
388
379
|
var field, sortOrder;
|
389
380
|
field = this.gridTableParams.sortCol;
|
390
381
|
sortOrder = this.gridTableParams.sortOrder;
|
391
|
-
return this.gridTableDOM.find('thead th[data-sort="true"], .thead [data-sort="true"]').each((function
|
392
|
-
return function
|
382
|
+
return this.gridTableDOM.find('thead th[data-sort="true"], .thead [data-sort="true"]').each((function(_this) {
|
383
|
+
return function(i, c) {
|
393
384
|
var value;
|
394
385
|
value = $(c).data('field');
|
395
386
|
if (value === field) {
|
396
387
|
switch (sortOrder) {
|
397
388
|
case 'asc':
|
398
389
|
$(c).addClass('sorting');
|
399
|
-
return $(c).find('i').attr('class', sortIcons['asc']);
|
390
|
+
return $(c).find('i').attr('class', _this.gridTableParams.sortIcons['asc']);
|
400
391
|
case 'desc':
|
401
392
|
$(c).addClass('sorting');
|
402
|
-
return $(c).find('i').attr('class', sortIcons['desc']);
|
393
|
+
return $(c).find('i').attr('class', _this.gridTableParams.sortIcons['desc']);
|
403
394
|
default:
|
404
395
|
$(c).removeClass('sorting');
|
405
|
-
return $(c).find('i').attr('class', sortIcons['default']);
|
396
|
+
return $(c).find('i').attr('class', _this.gridTableParams.sortIcons['default']);
|
406
397
|
}
|
407
398
|
} else {
|
408
399
|
$(c).removeClass('sorting');
|
409
|
-
return $(c).find('i').attr('class', sortIcons['default']);
|
400
|
+
return $(c).find('i').attr('class', _this.gridTableParams.sortIcons['default']);
|
410
401
|
}
|
411
402
|
};
|
412
403
|
})(this));
|
413
404
|
};
|
414
405
|
|
415
|
-
GridTable.prototype.updateQueryString = function
|
406
|
+
GridTable.prototype.updateQueryString = function(key, value, url) {
|
416
407
|
var hash, re, separator;
|
417
408
|
if (!url) {
|
418
409
|
url = window.location.href;
|
@@ -450,9 +441,14 @@ GridTable = (function() {
|
|
450
441
|
GridTableParams.prototype.page = 0;
|
451
442
|
GridTableParams.prototype.pageSize = 10;
|
452
443
|
GridTableParams.prototype.pageSizeOptions = [5, 10, 25, 50, 100, 200];
|
444
|
+
GridTableParams.prototype.sortIcons = {
|
445
|
+
"default": 'fa fa-sort',
|
446
|
+
"asc": 'fa fa-sort-desc',
|
447
|
+
"desc": 'fa fa-sort-asc'
|
448
|
+
};
|
453
449
|
|
454
450
|
function GridTableParams(params) {
|
455
|
-
if (
|
451
|
+
if (params != null) {
|
456
452
|
if ('sortCol' in params) {
|
457
453
|
this.sortCol = params['sortCol'];
|
458
454
|
}
|
@@ -474,6 +470,9 @@ GridTable = (function() {
|
|
474
470
|
if ('url' in params) {
|
475
471
|
this.url = params['url'];
|
476
472
|
}
|
473
|
+
if ('sortIcons' in params) {
|
474
|
+
this.sortIcons = params['sortIcons'];
|
475
|
+
}
|
477
476
|
}
|
478
477
|
}
|
479
478
|
|
@@ -489,6 +488,10 @@ GridTable = (function() {
|
|
489
488
|
return this.pageSize = pageSize;
|
490
489
|
};
|
491
490
|
|
491
|
+
GridTableParams.prototype.setSortIcons = function(sortIcons) {
|
492
|
+
return this.sortIcons = sortIcons;
|
493
|
+
};
|
494
|
+
|
492
495
|
GridTableParams.prototype.setSort = function(column, direction) {
|
493
496
|
var order;
|
494
497
|
this.page = 0;
|