vhx-quartz 0.8.13 → 0.8.14

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: 5f3b1f370da12dd7b2b70a20b48da83fc87a20d7
4
- data.tar.gz: 51a9f012c06ccb7bc2ae1054914b2e9fbfbd362d
3
+ metadata.gz: ed9c6b706a79dcb829f3486c4698e6a50b4749c7
4
+ data.tar.gz: 0c24e0ce1ca75435f3bbfb9d29f5631ca9ba8e0d
5
5
  SHA512:
6
- metadata.gz: 93bba1f22606cc457a25389fc87a9ab0f5a7de2870ea185b0672810acac3db2ba4b57efc7da40828f7353dd695876c386ad7147f122fd8e36c1ad7e509ade967
7
- data.tar.gz: f535f1af403f70791b40daa603337c9934626cfd485585fbdaa03065d8d1c0d811e969197493b407b1c90d15171b8f9b7a3fb42e75664c442ab58c456b2c7cba
6
+ metadata.gz: d31a167eb369d139d46a71ce975ef6df4e7629c77effbe7e69c38db6e50eec1bf34c406579025022e6c4db297f7307629dfeeba3ce2300da5ad8cf153bb6da95
7
+ data.tar.gz: 4ed6c6afb12e6e8ec10bcb353c32c509e93387ed233c37e1c5d941bbc0c349c52fe52be1181831392039eb76882ab56b9e7d40179e840ca1f01de9b18ac55d50
@@ -1,5 +1,5 @@
1
1
  module Vhx
2
2
  module Quartz
3
- VERSION = "0.8.13"
3
+ VERSION = "0.8.14"
4
4
  end
5
5
  end
@@ -4,6 +4,8 @@ vhxm.components.shared.search_input.controller = function (opts) {
4
4
  var self = this;
5
5
 
6
6
  self.timeout = null;
7
+ self.state = new vhxm.components.shared.search_input.state();
8
+ self.state.value(opts.value ? opts.value : null);
7
9
 
8
10
  self.debounceSearch = function (event) {
9
11
  if (self.timeout) {
@@ -25,6 +27,25 @@ vhxm.components.shared.search_input.controller = function (opts) {
25
27
  opts.callback(data);
26
28
  });
27
29
  };
30
+
31
+ self.updateQueryParam = function (query) {
32
+ var loc = window.location;
33
+ var search = void 0;
34
+ var href = loc.pathname;
35
+
36
+ if (query.length && window.history && window.history.replaceState) {
37
+ search = loc.search.length && loc.search.match(/\?/) ? loc.search : '?';
38
+ href += search.match(/q\=/) ? search.replace(/q\=(\w|\-)*/, 'q=' + query) : search + 'q=' + query;
39
+ history.replaceState({}, '', href);
40
+ } else {
41
+ search = loc.search.replace(/q\=(\w|\-)*/, '');
42
+ href += search.length === 1 ? '' : loc.search;
43
+ history.replaceState({}, '', href);
44
+ }
45
+ };
46
+ };
47
+ vhxm.components.shared.search_input.state = function () {
48
+ this.value = m.prop(null);
28
49
  };
29
50
 
30
51
  vhxm.components.shared.search_input.ui.container = {
@@ -35,8 +56,19 @@ vhxm.components.shared.search_input.ui.container = {
35
56
  return m('input.c-select--search.padding-right-large.icon-search-navy.icon--xsmall', {
36
57
  config: opts.config ? opts.config : '',
37
58
  type: 'text',
59
+ value: ctrl.state.value(),
38
60
  placeholder: opts.placeholder ? opts.placeholder : 'Search',
61
+ onkeydown: function oninput(event) {
62
+ if (parseInt(event.which, 10) === 13 || parseInt(event.keyCode, 10) === 13) {
63
+ ctrl.fetchResults(event.target.value);
64
+ ctrl.timeout = null;
65
+ }
66
+ },
39
67
  oninput: function oninput(event) {
68
+ ctrl.state.value(event.target.value);
69
+ if (opts.queryParam) {
70
+ ctrl.updateQueryParam(event.target.value);
71
+ }
40
72
  if (opts.oninput) {
41
73
  opts.oninput(event);
42
74
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vhx-quartz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.13
4
+ version: 0.8.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Robertson, Courtney Burton, Steven Bone, David Gonzalez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-01 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties