grid_table 1.5.0 → 1.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b27c4be55d74d0ccf12bd427010198b701bdca0
4
- data.tar.gz: 8e36d295b387aabfde419f540831d6ffc9bcac17
3
+ metadata.gz: 77af68b6e6fae8251c5a11ed4ef26f59932f006c
4
+ data.tar.gz: 6c63b21f7e353036aa53e6e71b26d9e8fb8b305e
5
5
  SHA512:
6
- metadata.gz: 4aeac716e13fd0351d22ef03e0513b38c93441ab804456f3d899ae0e2452fa564ad7202835d0b5bdb05cca0af2c1cf7dd534eb3cac747c286dbc346d969f2d0e
7
- data.tar.gz: fbf43395823247b8ac48b06d44619ff8d952f284c19a8be0c3e570d14ebf8c1644f4547cf47a310ce2e4fcc5c2b7d986c7e42c301e668d36e812663ed6c3f27c
6
+ metadata.gz: c086aa624c594eb0d62a8fad8f0d848ad9f811871dde54b32b20ea3250a662936bd2ab2b792a1580ac3f02f7f4910b53dc9da0ed5f8457384917c1006ed669a7
7
+ data.tar.gz: 6c49ab52d943b133b3735be60d378c691dcf732c7f716cc3b997e77cf40226ce2b5a1d14c649a0bb049f0acb73d6d2a817f88b02479274d1df2d480103db890f
@@ -1,3 +1,3 @@
1
1
  module GridTable
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '1.5.1'.freeze
3
3
  end
@@ -22,7 +22,7 @@ $(function() {
22
22
  }
23
23
  return gridtable.setUrl(url);
24
24
  } else {
25
- return gridtable.setUrl(updateQueryString(n, _this.value, url));
25
+ return gridtable.setUrl(gridtable.updateQueryString(n, _this.value, url));
26
26
  }
27
27
  };
28
28
  })(this));
@@ -62,6 +62,7 @@ window.GridTableFactory = (function() {
62
62
  gridTable = GridTableFactory.get($table);
63
63
  return gridTable.refresh();
64
64
  });
65
+
65
66
  this.gridTableList[$table.data('grid-table-id') || this.defaultGridTableId] = gridTable;
66
67
  return gridTable;
67
68
  };
@@ -365,12 +366,12 @@ GridTable = (function() {
365
366
  return display.text("" + (this.gridTableParams.page + 1) + " of " + (last_page + 1) + " (" + total_rows + ")");
366
367
  };
367
368
 
368
- GridTable.prototype.updateSortDisplay = function() {
369
+ GridTable.prototype.updateSortDisplay = function () {
369
370
  var field, sortOrder;
370
371
  field = this.gridTableParams.sortCol;
371
372
  sortOrder = this.gridTableParams.sortOrder;
372
- return this.gridTableDOM.find('thead th[data-sort="true"], .thead [data-sort="true"]').each((function(_this) {
373
- return function(i, c) {
373
+ return this.gridTableDOM.find('thead th[data-sort="true"], .thead [data-sort="true"]').each((function (_this) {
374
+ return function (i, c) {
374
375
  var value;
375
376
  value = $(c).data('field');
376
377
  if (value === field) {
@@ -393,6 +394,35 @@ GridTable = (function() {
393
394
  })(this));
394
395
  };
395
396
 
397
+ GridTable.prototype.updateQueryString = function (key, value, url) {
398
+ var hash, re, separator;
399
+ if (!url) {
400
+ url = window.location.href;
401
+ }
402
+ re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi");
403
+ if (re.test(url)) {
404
+ if (typeof value !== "undefined" && value !== null) {
405
+ url = url.replace(re, "$1" + key + "=" + value + "$2$3");
406
+ } else {
407
+ hash = url.split("#");
408
+ url = hash[0].replace(re, "$1$3").replace(/(&|\?)$/, "");
409
+ if (typeof hash[1] !== "undefined" && hash[1] !== null) {
410
+ url += "#" + hash[1];
411
+ }
412
+ }
413
+ } else {
414
+ if (typeof value !== "undefined" && value !== null) {
415
+ separator = (url.indexOf("?") !== -1 ? "&" : "?");
416
+ hash = url.split("#");
417
+ url = hash[0] + separator + key + "=" + value;
418
+ if (typeof hash[1] !== "undefined" && hash[1] !== null) {
419
+ url += "#" + hash[1];
420
+ }
421
+ }
422
+ }
423
+ return url;
424
+ };
425
+
396
426
  GridTableParams = (function() {
397
427
  GridTableParams.prototype.id = null;
398
428
  GridTableParams.prototype.url = null;
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.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Principe
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-31 00:00:00.000000000 Z
12
+ date: 2017-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.6.11
84
+ rubygems_version: 2.5.2
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Utility for powerful HTML Tables