esphinx-rails 1.1.3 → 1.1.4

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: 2a1eb931a5add6cb29b9f6b16e539d4e9f1705d7
4
- data.tar.gz: b077b92b26170d6ddad4a883c36dcca8d3274c44
3
+ metadata.gz: baf8bd52431fbc926f9fdd67ef5bdcc638554c5f
4
+ data.tar.gz: 37a5888cf93d7e7f2fea524ac093f171db8fddf0
5
5
  SHA512:
6
- metadata.gz: ff87486de461af49f7888fc7e51b87999c2c1c129e231c3122b7dec55be6bd46f5f6c8db9efa4c5ae126c35c6448b23b7f713ed7817a700390863ef77ffda787
7
- data.tar.gz: 27fa98bc00024b5910af2ce9213c73b5632670a596ae47a2b4c6b32f8bb3fe739b65eb6f6ea2d6af438054e061a11089ffdc04d5bd7af428205d404d2ddd0f35
6
+ metadata.gz: 6832eefaa1d84150710d77a5c025a97aedd71c2d505be2fea66a31671fe3ea20de217ea20af9dfa175275863275d225d5ab38a8a0cf810297f64361ebbaa7160
7
+ data.tar.gz: aa571d7f6fd414bb389c2f7d3f69b4cdd8190d35fff95d40eca71788e73d610caf87f9872039dd9fff0258aab8884ff875dcaa3d0ba5cfdcb8da33832c5ef9ec
@@ -164,6 +164,17 @@ var
164
164
 
165
165
  $.prototype.extend(true, {
166
166
 
167
+ events: function() {
168
+ var
169
+ mappedNode = mapped(this.asNode());
170
+
171
+ if (mappedNode) {
172
+ return Object.clone(mappedNode);
173
+ }
174
+
175
+ return {};
176
+ },
177
+
167
178
  on: function(eventName, capture, runOnListener) {
168
179
  on.call(this, eventName, capture, runOnListener);
169
180
 
@@ -215,14 +226,7 @@ var
215
226
  },
216
227
 
217
228
  attachedEvent: function(eventName) {
218
- var
219
- mappedNode = mapped(this.asNode());
220
-
221
- if (mappedNode && mappedNode[eventName]) {
222
- return true;
223
- }
224
-
225
- return false;
229
+ return Object.hasAttribute(this.events(), eventName);
226
230
  }
227
231
 
228
232
  });
@@ -19,7 +19,7 @@ var
19
19
 
20
20
  callback = function(object1, object2) {
21
21
  // debugger
22
- // if (Object.classForName(Object.className(object1))
22
+ // if (Reflect.constructorForName(Object.className(object1))
23
23
  if (object1.constructor
24
24
  .implementsMethod("compareTo")) {
25
25
  return object1.compareTo(object2);
@@ -0,0 +1,36 @@
1
+ (function($module) {
2
+ "use strict";
3
+
4
+ try {
5
+
6
+ Object.defineProperties($module, {
7
+ UndefinedConstructorException: {
8
+ value: {}
9
+ }
10
+ });
11
+
12
+ Object.defineProperties($module.UndefinedConstructorException, {
13
+ new: {
14
+ value: function(message) {
15
+ var
16
+ ConstructorReference = window
17
+ .UndefinedConstructorException.new,
18
+
19
+ error = new Error(message);
20
+
21
+ if (!(this instanceof ConstructorReference)) {
22
+ return new ConstructorReference(message);
23
+ }
24
+ }
25
+ }
26
+
27
+ });
28
+
29
+ // window.UndefinedConstructorException.new.prototype = Object.create(window
30
+ // .UndefinedConstructorException.new.prototype);
31
+ // window.UndefinedConstructorException.new.prototype.constructor = window
32
+ // .UndefinedConstructorException.new;
33
+
34
+ } catch (e) {}
35
+
36
+ })(window);
@@ -1,4 +1,4 @@
1
- //= require ./array
1
+ //= require ./reflect
2
2
 
3
3
 
4
4
  var
@@ -143,8 +143,8 @@ var
143
143
  amount = 0,
144
144
 
145
145
  callback = function(object) {
146
- if ($.classForName($.className(object)) ==
147
- classFunction) {
146
+ if (Reflect.constructorForName($
147
+ .className(object)) == classFunction) {
148
148
  amount++;
149
149
  }
150
150
  };
@@ -159,42 +159,15 @@ var
159
159
  }
160
160
  },
161
161
 
162
- hasAttributes: {
163
- value: function(object, attributes) {
164
- var
165
- amount = 0,
166
- argumentsAsArray = Array.from(arguments),
167
- researchedAttributes = argumentsAsArray
168
- .slice(1, argumentsAsArray.length);
169
-
170
- attributes = $.attributes(object, true);
171
-
172
- researchedAttributes.forEach(function(attribute) {
173
- if (attributes.includes(attribute)) {
174
- amount++;
175
- }
176
- });
177
-
178
- return amount == researchedAttributes.length;
162
+ hasAttribute: {
163
+ value: function(object, attributeName) {
164
+ return $.attributes(object, true).includes(attributeName);
179
165
  }
180
166
  },
181
167
 
182
168
  implementsMethod: {
183
- value: function(object, methods) {
184
- var
185
- amount = 0,
186
- argumentsAsArray = Array.from(arguments),
187
- researchedMethods = argumentsAsArray
188
- .slice(1, argumentsAsArray.length);
189
-
190
- methods = $.methods(object);
191
- researchedMethods.forEach(function(method) {
192
- if (methods.includes(method)) {
193
- amount++;
194
- }
195
- });
196
-
197
- return amount == researchedMethods.length;
169
+ value: function(object, methodName) {
170
+ return $.methods(object).includes(methodName);
198
171
  }
199
172
  },
200
173
 
@@ -231,6 +204,7 @@ var
231
204
  string = $.prototype.toString.call(object);
232
205
 
233
206
  if (typeof object == "object" &&
207
+ // executar/verificar name ao invés de toString
234
208
  $.implementsMethod(object, "toString")) {
235
209
  // if implements, then calls it
236
210
  string = object.toString();
@@ -240,12 +214,6 @@ var
240
214
  }
241
215
  },
242
216
 
243
- classForName: {
244
- value: function(name) {
245
- return window[name];
246
- }
247
- },
248
-
249
217
  firstKey: {
250
218
  value: function(object) {
251
219
  var
@@ -0,0 +1,15 @@
1
+ (function($) {
2
+ "use strict";
3
+
4
+ try {
5
+ Object.defineProperties($, {
6
+ constructorForName: {
7
+ value: function(name, context) {
8
+ context = context || window;
9
+ return context[name];
10
+ }
11
+ },
12
+ });
13
+ } catch(e) {}
14
+
15
+ })(Reflect);
@@ -23,7 +23,8 @@ var
23
23
  Object.defineProperties($module.Factory, {
24
24
  singletons: {
25
25
  get: function() {
26
- return flyweights;
26
+ // inspect (read-only)
27
+ return flyweights.clone();
27
28
  }
28
29
  },
29
30
 
@@ -10,7 +10,6 @@ var
10
10
 
11
11
  autocomplete: function(elementsList, options, callback) {
12
12
  var
13
- completeOften,
14
13
  searchTextBox = this,
15
14
  nonCharacterKeysPattern = new RegExp($
16
15
  .nonCharacterKeysPattern()),
@@ -18,15 +17,6 @@ var
18
17
  elements2Recovery = [],
19
18
  afterAmountCharacters = options.afterAmountCharacters,
20
19
 
21
- complete2Recovery = function(object, times) {
22
- var
23
- i = 0;
24
-
25
- while (i++ < times) {
26
- elements2Recovery.push(object);
27
- }
28
- },
29
-
30
20
  resolveArguments = function(options) {
31
21
  if (!Object.belongToClass(options, Object)) {
32
22
  options = {};
@@ -43,96 +33,53 @@ var
43
33
  if (typeof afterAmountCharacters != "number") {
44
34
  afterAmountCharacters = 1;
45
35
  }
46
-
47
36
  },
48
37
 
49
38
  inlineSearch = function(element, options) {
50
39
  var
51
40
  eventListenerMethod,
52
- previousSearchText = searchTextBox.value();
41
+ previousElement,
42
+ previousSearchText = "";
53
43
 
54
44
  if (typeof eventListenerMethod == "function") {
55
45
  searchTextBox.off("input", eventListenerMethod);
56
46
  }
57
47
 
58
48
  eventListenerMethod = function(e) {
49
+ previousElement = previousElement || element
50
+ .clone(true);
51
+
59
52
  var
60
53
  resolvedList,
61
54
  foundElements,
62
- startingIndex,
63
- finalIndex,
64
- foundElement,
65
- previousElement = element,
66
- parent = element.clone(),
67
- searchTextLength = searchTextBox.value().length,
68
- searchTextDifference = previousSearchText.length -
69
- searchTextLength,
70
- searchTextAmount = (searchTextLength -
71
- afterAmountCharacters) + 1,
72
-
73
- replaceLast = function(object) {
74
- elements2Recovery.pop();
75
- complete2Recovery(object);
76
- };
55
+ resolvedElementsParent,
56
+ searchTextLength = searchTextBox.value().length;
77
57
 
78
58
  if (searchTextBox.value()) {
79
- startingIndex = searchTextBox.cursorPosition() - 2;
80
-
81
- if (startingIndex < 0) {
82
- startingIndex = 0;
83
- }
84
- finalIndex = startingIndex + searchTextDifference -
85
- 1;
86
-
87
- // when delete
88
- if (searchTextLength < previousSearchText.length &&
89
- searchTextLength >= afterAmountCharacters) {
90
-
91
- if (startingIndex === 0) {
92
- elements2Recovery.deleteAt(startingIndex,
93
- finalIndex);
94
- } else {
95
- elements2Recovery.deleteAt(startingIndex,
96
- elements2Recovery.lastIndex());
97
- }
98
59
 
99
- previousElement = elements2Recovery[
100
- elements2Recovery.lastIndex()];
60
+ if (searchTextLength < previousSearchText.length) {
61
+ previousElement = element.clone(true);
101
62
  }
102
63
 
64
+ previousSearchText = searchTextBox.value();
103
65
  resolvedList = resolveList(previousElement,
104
66
  options.order);
105
67
  foundElements = resolvedList.elements;
106
68
 
107
- if (foundElements.some() ||
108
- elements2Recovery.length < searchTextAmount) {
109
- if (searchTextDifference < 0) {
110
- completeOften = Math
111
- .abs(searchTextDifference);
112
- } else {
113
- completeOften = searchTextAmount -
114
- elements2Recovery.length;
115
- }
116
-
117
- if (foundElements.some()) {
118
- foundElement = parent.append(foundElements);
119
- previousElement = foundElement;
120
- }
121
-
122
- complete2Recovery(previousElement,
123
- completeOften);
124
- } else {
125
- replaceLast(previousElement);
69
+ if (foundElements.some()) {
70
+ resolvedElementsParent = previousElement
71
+ .clone();
72
+ previousElement = resolvedElementsParent
73
+ .append(resolvedList.elements);
126
74
  }
127
75
 
128
- previousSearchText = searchTextBox.value();
129
76
  callback.call($(this), foundElements, resolvedList
130
77
  .maps, e);
131
78
  } else {
132
79
  // reset
133
80
  elements2Recovery = [];
134
81
  previousSearchText = "";
135
- previousElement = element;
82
+ previousElement = element.clone(true);
136
83
  callback.call($(this), $(), e);
137
84
  }
138
85
 
@@ -173,12 +120,14 @@ var
173
120
  element = $(r);
174
121
 
175
122
  if (element.some()) {
176
- completeOften = (searchTextBox
177
- .value().length -
178
- afterAmountCharacters) + 1;
123
+ elements2Recovery.push(element);
124
+
125
+ // completeOften = (searchTextBox
126
+ // .value().length -
127
+ // afterAmountCharacters) + 1;
179
128
 
180
- complete2Recovery(element,
181
- completeOften);
129
+ // complete2Recovery(element,
130
+ // completeOften);
182
131
  }
183
132
 
184
133
  resolvedList = resolveList(element,
@@ -1,5 +1,5 @@
1
1
  module ESphinx
2
2
  module Rails
3
- VERSION = "1.1.3"
3
+ VERSION = "1.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esphinx-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - rplaurindo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-12-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Abstraction helpers for Javascript.
14
14
  email:
@@ -28,6 +28,7 @@ files:
28
28
  - lib/assets/javascripts/esphinx/index.js
29
29
  - lib/assets/javascripts/esphinx/lib/collection.js
30
30
  - lib/assets/javascripts/esphinx/lib/comparable.js
31
+ - lib/assets/javascripts/esphinx/lib/exceptions.js
31
32
  - lib/assets/javascripts/esphinx/lib/extensions/array.js
32
33
  - lib/assets/javascripts/esphinx/lib/extensions/function.js
33
34
  - lib/assets/javascripts/esphinx/lib/extensions/index.js
@@ -35,6 +36,7 @@ files:
35
36
  - lib/assets/javascripts/esphinx/lib/extensions/map.js
36
37
  - lib/assets/javascripts/esphinx/lib/extensions/number.js
37
38
  - lib/assets/javascripts/esphinx/lib/extensions/object.js
39
+ - lib/assets/javascripts/esphinx/lib/extensions/reflect.js
38
40
  - lib/assets/javascripts/esphinx/lib/extensions/string.js
39
41
  - lib/assets/javascripts/esphinx/lib/extensions/x_path_result.js
40
42
  - lib/assets/javascripts/esphinx/lib/patterns/gof/flyweight/factory.js