angular-smart-search 0.0.6 → 0.0.7

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: 04cb4a6f9b79c9b5ea2f7eb89b4596550f584c30
4
- data.tar.gz: 12e620cc49c2ccc19b7cff616eae6af86de53cdf
3
+ metadata.gz: 83ac3b3075bfa04501aee56f6ebc8c0314a77270
4
+ data.tar.gz: f5807fcebe7eabd1a60fcf3d11652f3483e8c0cd
5
5
  SHA512:
6
- metadata.gz: 7cc5b239350f9d22de67291d61a3641d82614210ddcefd1aab076a8416c7c7a4062695ac66d6cccb2d5dcec2aee34db1574235b0a2225c33cf0287ce51239d75
7
- data.tar.gz: 41194c15087798de012a842e53ba4033d0452658f7cf8ff6c9a42c722d929ae51204d1ddbffb9620ca1925709274f096557c45815007976777ea3cdff9bae247
6
+ metadata.gz: ec4697a8a6da61f9067a1050765cee639a216046038ad81b7eaa46ed0ee37c4d526660b672e58abd0f49982ff56f06269d19e279d02b88fb3caac9a4bb2870dc
7
+ data.tar.gz: 80c37f6cab48fbbfdee87b23836fc4add0359fe7d7b6310962218448641006272cb7165920f12613629b70e8e07d22a5d59df83aecc2b2451f7617a236489bc5
@@ -1,5 +1,5 @@
1
1
  // author: Samuel Mueller
2
- // version: 0.0.6
2
+ // version: 0.0.7
3
3
  // license: MIT
4
4
  // homepage: http://github.com/ssmm/angular-smart-search
5
5
  (function() {
@@ -11,8 +11,7 @@
11
11
 
12
12
  angular.module("angular-smart-search").directive("smartSearch", [
13
13
  "$http", "searchQueryFactory", "templateFactory", function($http, searchQueryFactory, templateFactory) {
14
- var QueryState;
15
-
14
+ var QueryState, successCallbacks;
16
15
  QueryState = function() {
17
16
  this.state = 'initial';
18
17
  this.query = void 0;
@@ -23,12 +22,14 @@
23
22
  return this.state = state;
24
23
  };
25
24
  };
25
+ successCallbacks = [];
26
26
  return {
27
27
  restrict: "A",
28
- scope: true,
28
+ scope: {
29
+ stub: "="
30
+ },
29
31
  compile: function(element, attributes, transclude) {
30
32
  var detailOverlay, id_field, template;
31
-
32
33
  if (attributes.detailOverlay) {
33
34
  detailOverlay = jQuery("#" + attributes.detailOverlay);
34
35
  if (!detailOverlay[0]) {
@@ -46,8 +47,7 @@
46
47
  element.append(id_field);
47
48
  return {
48
49
  post: function($scope, $element, $attributes) {
49
- var allowedFormats, detailOverlayTrigger, hideOverlay, outerQueryTimeout, queryState, quickQueryInput, searchInput, searchOverlay, service, showOverlay;
50
-
50
+ var allowedFormats, detailOverlayTrigger, hideOverlay, outerQueryTimeout, queryState, quickQueryInput, searchInput, searchOverlay, service, setResult, showOverlay;
51
51
  queryState = new QueryState();
52
52
  $scope.queryState = queryState;
53
53
  $scope.resultList = [];
@@ -94,15 +94,14 @@
94
94
  }).error(function() {});
95
95
  };
96
96
  $scope.pick = function(item) {
97
- queryState.setTo("successful");
98
- $scope.result = item;
97
+ setResult(item);
99
98
  return $scope.hideSearchOverlay();
100
99
  };
101
100
  $scope.hover = function(item) {
102
101
  return $scope.currentItem = item;
103
102
  };
104
103
  outerQueryTimeout = null;
105
- return $scope.outerQueryChanged = function(query) {
104
+ $scope.outerQueryChanged = function(query) {
106
105
  window.clearTimeout(outerQueryTimeout);
107
106
  if (!query) {
108
107
  if ($scope.result) {
@@ -117,8 +116,7 @@
117
116
  queryState.setTo("pending");
118
117
  $http.get("" + service + ".json?" + query.format.name + "=" + query.query).success(function(data) {
119
118
  if (data[0] && data[0].id) {
120
- queryState.setTo("successful");
121
- return $scope.result = data[0];
119
+ return setResult(data[0]);
122
120
  } else {
123
121
  return queryState.setTo("unsuccessful");
124
122
  }
@@ -132,6 +130,34 @@
132
130
  }
133
131
  }
134
132
  };
133
+ setResult = function(result) {
134
+ var callback, _i, _len, _results;
135
+ queryState.setTo("successful");
136
+ $scope.result = result;
137
+ if (successCallbacks.length > 0) {
138
+ _results = [];
139
+ for (_i = 0, _len = successCallbacks.length; _i < _len; _i++) {
140
+ callback = successCallbacks[_i];
141
+ _results.push(callback.call(void 0, result));
142
+ }
143
+ return _results;
144
+ }
145
+ };
146
+ if ($attributes.stub) {
147
+ return $scope.stub = {
148
+ registerSuccessCallback: function(callback) {
149
+ return successCallbacks.push(callback);
150
+ },
151
+ reset: function() {
152
+ $scope.result = void 0;
153
+ $scope.quickQuery = "";
154
+ return queryState.setTo("");
155
+ },
156
+ set: function(value) {
157
+ return setResult(value);
158
+ }
159
+ };
160
+ }
135
161
  }
136
162
  };
137
163
  }
@@ -142,7 +168,6 @@
142
168
  angular.module("angular-smart-search").provider("markupStore", [
143
169
  function() {
144
170
  var infoIconClass, overlayClass, searchIconClass, successIconClass;
145
-
146
171
  successIconClass = "icon-info-sign icon-large";
147
172
  infoIconClass = "icon-info-sign";
148
173
  searchIconClass = "icon-search";
@@ -181,7 +206,6 @@
181
206
  angular.module("angular-smart-search").provider("searchQueryFactory", [
182
207
  function() {
183
208
  var Query, detectFormat, formats;
184
-
185
209
  Query = function(query, format) {
186
210
  this.format = format;
187
211
  this.query = query;
@@ -189,7 +213,6 @@
189
213
  formats = {};
190
214
  detectFormat = function(query, allowedFormats) {
191
215
  var name, _i, _len;
192
-
193
216
  for (_i = 0, _len = allowedFormats.length; _i < _len; _i++) {
194
217
  name = allowedFormats[_i];
195
218
  if (formats[name] && formats[name].pattern.exec(query)) {
@@ -199,7 +222,6 @@
199
222
  };
200
223
  this.registerFormats = function(formats) {
201
224
  var format, _i, _len, _results;
202
-
203
225
  _results = [];
204
226
  for (_i = 0, _len = formats.length; _i < _len; _i++) {
205
227
  format = formats[_i];
@@ -213,7 +235,6 @@
213
235
  return this.$get = function() {
214
236
  return function(query, allowedFormats) {
215
237
  var format;
216
-
217
238
  format = detectFormat(query, allowedFormats);
218
239
  if (format) {
219
240
  return new Query(query, format);
@@ -226,7 +247,6 @@
226
247
  angular.module("angular-smart-search").service("templateFactory", [
227
248
  "markupStore", function(markupStore) {
228
249
  var detailOverlay, detailOverlayTrigger, inputSection, overlayStyle, resultIcon, searchOverlay, showDetailOverlayAction, successIcon;
229
-
230
250
  overlayStyle = "style=' display: none; position: absolute; background-color: white; padding: 30px; border: solid; border-width: 1px; border-color: rgb(221, 221, 221); border-radius: 10px; '";
231
251
  detailOverlayTrigger = "<i detail-overlay-trigger class='" + (markupStore.infoIconClass()) + "' ng-click='showDetailOverlay()'></i>";
232
252
  successIcon = "<i class='" + (markupStore.successIconClass()) + "'></i>";
File without changes
@@ -1,3 +1,3 @@
1
1
  module AngularSmartSearch
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-smart-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler