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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ee782089d85def4a645b9290d968fc5589798f4
4
- data.tar.gz: f5f457711afec9fdeb03ea79561e6987f4e259fb
3
+ metadata.gz: 3202a35b5d6d85fbbdf04d12963a0bd82651d455
4
+ data.tar.gz: 7915cef04379b90835c032f59ae56a278e999845
5
5
  SHA512:
6
- metadata.gz: cd12fdad809d552c2923c1e474d4661bebfeed4ec7de1451184cd252f20c338519dd2a6a2bcd1011e68de5d1821479786ed6bad6b649e8254caf122f601a36fc
7
- data.tar.gz: 501049d7d42f6940e569e0bc23f60fc5931444a1ed47669ec81c99536a8b30081298ca042e6f731f82dac00204a3972a849edacf9294c01382470ec2d306da90
6
+ metadata.gz: 8f0f1eef1170ad6f22ce3d434221b814aee50b374cd47eba60cf2cc3541f77725eded31ce6ae496985edaa8a679876b4f9078a63df4ed0b2657ec5f95bb5e9df
7
+ data.tar.gz: b7c2fbe34dbb5d4aba65298dcea29461dfd38088e69cac06e230f1aaf8add3683dae33906c12f83d843d94eb26c6369c98102c68a34ed97db1522afba0eff9e3
@@ -1,3 +1,3 @@
1
1
  module GridTable
2
- VERSION = '1.5.2'.freeze
2
+ VERSION = '1.5.3'.freeze
3
3
  end
@@ -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 (_this) {
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 (obj) {
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 (obj) {
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 ((_this.gridTableParams.page - 1), 0));
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 (_this) {
392
- return function (i, c) {
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 (key, value, url) {
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 ((params != null)) {
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;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grid_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Principe