kea-rails 2.0.0.pre.alpha7 → 2.0.0.pre.alpha8

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: b25bf5539b381f32b9ac9e973d3e9b56fb2454ec
4
- data.tar.gz: a859b774a0064aab1da30f353597bc9ac8372597
3
+ metadata.gz: bdf73285a8e4d06d187dd8734d0e30bb70de18c6
4
+ data.tar.gz: cc190abd5736d51c5ca5d78f535b3d4c9dc067e8
5
5
  SHA512:
6
- metadata.gz: 1313b35eacc20fed9a39fa41d4f2f37a51892f8c1d961b775d15a8209f9389bf6798b187455e9e7c69e998df34c5b5409b918ac32974cd3147a6bd615c89d635
7
- data.tar.gz: f21c516b38d87bee6a9c5648ab1223e89f0c2eda00a90b32b91a571e822f3b790b74830524771fce54a3417fbd237476f1ec71a0c391b7becf4e726715ad9735
6
+ metadata.gz: b33d8e41ce1305be6d623f8d0ec1db886a9f9ac4848b19e8feb87ba12c3dbd54d16e8bc79062c732389f33ddcff4a15736cf5b5dfe3f15bc8889d6e5fff0c920
7
+ data.tar.gz: e5d26cf01a06e13a554e9416c4b301d5f952179ae6a39251289b5c03250edf59223a889ceed5eaa76d7fc1a20d934c5e51f50c8c97bdef58f3a2caeeeb6bc36f
@@ -4,9 +4,9 @@
4
4
  ko.bindingHandlers.komplete = {
5
5
  init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
6
6
  var $container = $(element),
7
- $searchInput = $container.find('> .komplete-search-term'),
8
- listener = new window.keypress.Listener( $searchInput.get(0) ),
9
7
  options = ko.unwrap(valueAccessor()),
8
+ $searchInput,
9
+ listener,
10
10
  AutocompleteVm,
11
11
  AutocompleteResult,
12
12
  vm,
@@ -26,13 +26,14 @@
26
26
  this.responseMap = {label: 'label', value: 'value'};
27
27
  this.searchTerm = ko.observable('').extend({ rateLimit: { timeout: 500, method: "notifyWhenChangesStop" } });
28
28
  this.requestInProgress = ko.observable(false);
29
+ this.hasFocus = ko.observable(false);
29
30
 
30
31
  this.showDropdown = ko.computed(function() {
31
- return this.searchResults().length > 0;
32
+ return this.searchResults().length > 0 && this.hasFocus();
32
33
  }, this, {deferEvaluation: true});
33
34
 
34
35
  this.searchTerm.subscribe(function() {
35
- if (this.searchTerm().length > 0) {
36
+ if (this.searchTerm() && this.searchTerm().length > 0) {
36
37
  this.fetch();
37
38
  }
38
39
  }, this);
@@ -48,7 +49,12 @@
48
49
  var currentFocus = this.focusedResult(),
49
50
  focusedIdx = currentFocus ? this.searchResults().indexOf(currentFocus) : -1,
50
51
  futureFocus = focusedIdx !== -1 ? this.searchResults()[focusedIdx + idxOffset] : null;
51
-
52
+
53
+ if (!currentFocus && this.searchResults()[0]) {
54
+ this.searchResults()[0].hasFocus(true);
55
+ return;
56
+ }
57
+
52
58
  if (!futureFocus) { return; }
53
59
 
54
60
  currentFocus.hasFocus(false);
@@ -109,6 +115,13 @@
109
115
 
110
116
  vm = options.vm || new AutocompleteVm(options.url, options.autoSelect, options.onSelect);
111
117
 
118
+ if (options.observable) {
119
+ ko.computed(function() {
120
+ vm.searchTerm( options.observable() );
121
+
122
+ }, this, { disposeWhenNodeIsRemoved: element });
123
+ }
124
+
112
125
  if (options.fetch) {
113
126
  vm.fetch = options.fetch;
114
127
  }
@@ -121,45 +134,60 @@
121
134
  vm.parseResults = options.parseResults;
122
135
  }
123
136
 
124
- listener.register_combo({
125
- keys: "down",
126
- on_keydown: function() { vm.focusNext(); }
127
- });
128
-
129
- listener.register_combo({
130
- keys: "up",
131
- on_keydown: function() { vm.focusPrevious(); }
132
- });
133
-
134
- listener.register_combo({
135
- keys: "enter",
136
- on_keydown: function() {
137
- if (!options.autoSelect && !vm.focusedResult()) {
138
- if (options.blurOnSelect) {
139
- $searchInput.get(0).blur();
140
- }
141
-
142
- vm.select( $searchInput.val() );
143
-
144
- } else if (options.autoSelect && !vm.focusedResult()) {
145
- return;
146
-
147
- } else {
148
- if (options.blurOnSelect) {
149
- $searchInput.get(0).blur();
137
+ $container.on('componentReady', function() {
138
+ $searchInput = $container.find('> .komplete-search-term');
139
+ listener = new window.keypress.Listener( $searchInput.get(0) );
140
+
141
+ $searchInput.on('focus', function() {
142
+ vm.hasFocus(true);
143
+ });
144
+
145
+ $searchInput.on('blur', function() {
146
+ vm.hasFocus(false);
147
+ });
148
+
149
+ listener.register_combo({
150
+ keys: "down",
151
+ on_keydown: function() { vm.focusNext(); }
152
+ });
153
+
154
+ listener.register_combo({
155
+ keys: "up",
156
+ on_keydown: function() { vm.focusPrevious(); }
157
+ });
158
+
159
+ listener.register_combo({
160
+ keys: "enter",
161
+ on_keydown: function() {
162
+ if (!options.autoSelect && !vm.focusedResult()) {
163
+ if (options.blurOnSelect) {
164
+ $searchInput.get(0).blur();
165
+ }
166
+
167
+ vm.select( $searchInput.val() );
168
+
169
+ } else if (options.autoSelect && !vm.focusedResult()) {
170
+ return;
171
+
172
+ } else {
173
+ if (options.blurOnSelect) {
174
+ $searchInput.get(0).blur();
175
+ }
176
+
177
+ vm.select( vm.focusedResult() );
150
178
  }
151
-
152
- vm.select( vm.focusedResult() );
153
179
  }
154
- }
155
- });
156
-
157
- $container.on('click', function() {
158
- $searchInput.focus();
180
+ });
181
+
182
+ $container.on('click', function() {
183
+ $searchInput.focus();
184
+ });
159
185
  });
160
186
 
161
187
  ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
162
- listener.destroy();
188
+ if (listener) {
189
+ listener.destroy();
190
+ }
163
191
  });
164
192
 
165
193
  return ko.bindingHandlers.with.init(element, function() { return vm; }, allBindingsAccessor, viewModel, bindingContext);
@@ -0,0 +1,20 @@
1
+ (function(ko, $) {
2
+ "use strict";
3
+
4
+ ko.components.register('komplete-search', {
5
+ viewModel: function(params) {
6
+ this.mandatory = typeof params.mandatory === 'undefined' ? false : params.mandatory;
7
+ this.options = params.options || {};
8
+ },
9
+ template:
10
+ '<div data-bind="komplete: options" class="komplete">' +
11
+ '<!-- ko template: { nodes: $componentTemplateNodes, afterRender: function(children) { $(children).parent().trigger("componentReady"); } } --><!-- /ko -->' +
12
+ '<div data-bind="visible: showDropdown" class="komplete-dropdown">' +
13
+ '<ul data-bind="foreach: searchResults">' +
14
+ '<li data-bind="text: label, click: $parent.select.bind($parent, $data), css: { \'has-focus\': hasFocus }, clickBubble: false"></li>' +
15
+ '</ul>' +
16
+ '</div>' +
17
+ '</div>'
18
+ });
19
+
20
+ })(ko, $);
@@ -73,7 +73,16 @@
73
73
  };
74
74
 
75
75
  this.hide = function hide() {
76
+ // that.runCallbacks('beforeClose');
77
+ // that.veil.hide();
78
+ that.hideAndRemove();
79
+ };
80
+
81
+ this.hideAndRemove = function hideAndRemove() {
76
82
  that.runCallbacks('beforeClose');
83
+ that.veil.addCallback('afterHide', function() {
84
+ that.veil.destroy();
85
+ });
77
86
  that.veil.hide();
78
87
  };
79
88
 
@@ -125,6 +125,10 @@
125
125
  return fragment;
126
126
  };
127
127
 
128
+ Base.prototype.resetLiveSearch = function resetLiveSearch() {
129
+ this.liveSearchFragments.removeAll();
130
+ };
131
+
128
132
  Base.prototype.defaultFragment = function defaultFragment() {
129
133
  return new this.Fragment(this, this.displayName, 1);
130
134
  };
@@ -205,10 +205,11 @@
205
205
 
206
206
  if (fragments) {
207
207
  fragments.forEach(function(fragment) { that.fragmentsForSearchTerm.push(fragment); });
208
- fragments[0].hasFocus(true);
209
208
  }
210
209
  });
211
210
 
211
+ // fragments[0].hasFocus(true);
212
+
212
213
  } else {
213
214
  if (that.providerSearchActive()) {
214
215
  that.setDefaultFragments();
@@ -224,6 +225,11 @@
224
225
 
225
226
  if (that.fragmentsForSearchTerm().length === 0) {
226
227
  that.setDefaultFragments();
228
+ that.showLiveSearchWidgets(false);
229
+
230
+ that.liveSearchProviders().forEach(function(provider) {
231
+ provider.resetLiveSearch();
232
+ });
227
233
  }
228
234
  });
229
235
 
@@ -1,3 +1,3 @@
1
1
  module Kea
2
- VERSION = "2.0.0-alpha7"
2
+ VERSION = "2.0.0-alpha8"
3
3
  end
@@ -26,6 +26,8 @@
26
26
  * @param {Number} [options.offsetX=10] - the horizontal distance between anchor and popover in px
27
27
  * @param {Number} [options.offsetY=10] - the vertical distance between anchor and popover in px
28
28
  * @param {String} [options.popoverClass] - additional CSS class(es) to apply to the popover markup
29
+ * @param {String,Function} [options.appendTo] - where to insert the popover markup - either 'body', 'afterElement', or a callback that
30
+ * takes the markup as a parameter and inserts it
29
31
  * @param {Boolean} [options.debug=false] - provide debug information and error handling in the console
30
32
  *
31
33
  * @param {Object} [callbacks] - callbacks to be triggered at various lifecycle moments
@@ -160,6 +162,7 @@
160
162
  offsetX: 10,
161
163
  offsetY: 10,
162
164
  popoverClass: "",
165
+ appendTo: 'body',
163
166
  cssTransitionSupport: true,
164
167
  allowParallelUse: true,
165
168
  disposable: false,
@@ -269,7 +272,16 @@
269
272
 
270
273
  this.$popover.html(this.content);
271
274
 
272
- $('body').append(this.$popover);
275
+ if (this.options.appendTo === 'body') {
276
+ $('body').append(this.$popover);
277
+
278
+ } else if (this.options.appendTo === 'afterElement') {
279
+ this.$anchorElement.after(this.$popover);
280
+
281
+ } else if (typeof this.options.appendTo === 'function') {
282
+ this.options.appendTo(this.$popover);
283
+ }
284
+
273
285
  _executeCallbacksFor.call(this, 'afterCreate', this.$anchorElement, this.$popover);
274
286
  };
275
287
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attachejs",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "homepage": "https://github.com/janfoeh/attachejs",
5
5
  "authors": [
6
6
  "Jan-Christian Foeh <jan@programmanstalt.de>"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veiljs",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "homepage": "https://github.com/janfoeh/veiljs",
5
5
  "authors": [
6
6
  "Jan-Christian Foeh <jan@programmanstalt.de>"
@@ -268,8 +268,9 @@
268
268
 
269
269
  if (this.options.listenToCustomEvents) {
270
270
  this.$overlay.off('hide.veil');
271
- _executeCallbacksFor.call(this, 'afterHide', this.$overlay);
272
271
  }
272
+
273
+ _executeCallbacksFor.call(this, 'afterHide', this.$overlay);
273
274
  };
274
275
 
275
276
  /**
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kea-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha7
4
+ version: 2.0.0.pre.alpha8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan-Christian Foeh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -45,6 +45,7 @@ files:
45
45
  - app/assets/javascripts/kea/bindings/validation_state.js
46
46
  - app/assets/javascripts/kea/bindings/wait_for_vm.js
47
47
  - app/assets/javascripts/kea/components/confirmation_button.js
48
+ - app/assets/javascripts/kea/components/komplete-search.js
48
49
  - app/assets/javascripts/kea/extenders/date.js
49
50
  - app/assets/javascripts/kea/extenders/equals.js
50
51
  - app/assets/javascripts/kea/extenders/external_validator.js