esphinx-rails 1.1.2

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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +21 -0
  4. data/config/environments/production.rb +1 -0
  5. data/config/environments/staging.rb +1 -0
  6. data/config/initializers/assets.rb +7 -0
  7. data/esphinx.gemspec +19 -0
  8. data/lib/assets/javascripts/esphinx/element.js +256 -0
  9. data/lib/assets/javascripts/esphinx/event.js +227 -0
  10. data/lib/assets/javascripts/esphinx/index.js +3 -0
  11. data/lib/assets/javascripts/esphinx/lib/collection.js +51 -0
  12. data/lib/assets/javascripts/esphinx/lib/comparable.js +54 -0
  13. data/lib/assets/javascripts/esphinx/lib/extensions/array.js +541 -0
  14. data/lib/assets/javascripts/esphinx/lib/extensions/function.js +46 -0
  15. data/lib/assets/javascripts/esphinx/lib/extensions/index.js +1 -0
  16. data/lib/assets/javascripts/esphinx/lib/extensions/location.js +111 -0
  17. data/lib/assets/javascripts/esphinx/lib/extensions/map.js +29 -0
  18. data/lib/assets/javascripts/esphinx/lib/extensions/number.js +42 -0
  19. data/lib/assets/javascripts/esphinx/lib/extensions/object.js +502 -0
  20. data/lib/assets/javascripts/esphinx/lib/extensions/string.js +130 -0
  21. data/lib/assets/javascripts/esphinx/lib/extensions/x_path_result.js +31 -0
  22. data/lib/assets/javascripts/esphinx/lib/patterns/gof/flyweight/factory.js +115 -0
  23. data/lib/assets/javascripts/esphinx/lib/patterns/gof/flyweight/flyweight.js +12 -0
  24. data/lib/assets/javascripts/esphinx/lib/patterns/gof/iterator.js +332 -0
  25. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/context.js +42 -0
  26. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs/element.js +78 -0
  27. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs/object.js +83 -0
  28. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs.js +19 -0
  29. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/search.js +24 -0
  30. data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/search_proxy.js +52 -0
  31. data/lib/assets/javascripts/esphinx/lib/patterns/index.js +1 -0
  32. data/lib/assets/javascripts/esphinx/main.js +361 -0
  33. data/lib/assets/javascripts/esphinx/node.js +276 -0
  34. data/lib/assets/javascripts/esphinx/properties/forms.js +161 -0
  35. data/lib/assets/javascripts/esphinx/properties/inputs/text.js +29 -0
  36. data/lib/assets/javascripts/esphinx/property.js +308 -0
  37. data/lib/assets/javascripts/esphinx/query.js +347 -0
  38. data/lib/assets/javascripts/esphinx/samples/sort.js +30 -0
  39. data/lib/assets/javascripts/esphinx/style.js +342 -0
  40. data/lib/assets/javascripts/esphinx/util/ajax.js +152 -0
  41. data/lib/assets/javascripts/esphinx/util/autocomplete.js +356 -0
  42. data/lib/assets/javascripts/esphinx/util/browser.js +66 -0
  43. data/lib/assets/javascripts/esphinx/util/cookie.js +167 -0
  44. data/lib/assets/javascripts/esphinx/util/keyboard.js +110 -0
  45. data/lib/assets/javascripts/esphinx/util/loader.js +84 -0
  46. data/lib/assets/javascripts/esphinx/util/observer.js +58 -0
  47. data/lib/assets/javascripts/esphinx/util/promise.js +127 -0
  48. data/lib/assets/javascripts/esphinx/util/protector.js +142 -0
  49. data/lib/assets/javascripts/esphinx/util/range.js +6 -0
  50. data/lib/assets/javascripts/esphinx/util/scrollbar.js +22 -0
  51. data/lib/esphinx/rails/engine.rb +7 -0
  52. data/lib/esphinx/rails/version.rb +5 -0
  53. data/lib/esphinx-rails.rb +1 -0
  54. data/vendor/assets/javascripts/jquery-2.2.2.min.js +1 -0
  55. metadata +99 -0
@@ -0,0 +1,130 @@
1
+ (function($) {
2
+ "use strict";
3
+
4
+
5
+ try {
6
+
7
+ Object.defineProperties($.prototype, {
8
+ reverse: {
9
+ value: function() {
10
+ var
11
+ reversed = "",
12
+ chars = this.split(""),
13
+
14
+ callback = function(c) {
15
+ reversed += c;
16
+ };
17
+
18
+ chars.reverse().forEach(callback);
19
+
20
+ return reversed;
21
+ }
22
+ },
23
+
24
+ span: {
25
+ value: function() {
26
+ return "<span>" + this + "</span>";
27
+ }
28
+ },
29
+
30
+ resolveDoubleQuotationMark: {
31
+ value: function() {
32
+ return this.replace(/"/g, function(captured, i, string) {
33
+ if (string[i - 1] != "\\" ) {
34
+ return "\\\"";
35
+ } else {
36
+ return "\"";
37
+ }
38
+ });
39
+ }
40
+ },
41
+
42
+ camelCase: {
43
+ value: function() {
44
+ var
45
+ pattern = /[_,\-][\S]/g,
46
+ string;
47
+
48
+ string = this.replace(pattern, function(capturedGroup) {
49
+ return capturedGroup[1].toUpperCase();
50
+ });
51
+
52
+ return string;
53
+ }
54
+ },
55
+
56
+ strikeCase: {
57
+ value: function() {
58
+ var
59
+ string = this.camelCase(),
60
+ pattern = /[A-Z_]/g;
61
+
62
+ string = string.replace(pattern, function(capturedGroup) {
63
+ return "-" + capturedGroup.toLowerCase();
64
+ });
65
+
66
+ return string;
67
+ }
68
+ },
69
+
70
+ capitalize: {
71
+ value: function() {
72
+ var
73
+ strArr = this.split(" "),
74
+ str = "",
75
+
76
+ callback = function(s, i) {
77
+ if (s.length > 3) {
78
+ str += s.charAt(0).toUpperCase() +
79
+ s.slice(1, s.length).toLowerCase();
80
+ } else {
81
+ str += s.toLowerCase();
82
+ }
83
+
84
+ if (i < strArr.length - 1) {
85
+ str += " ";
86
+ }
87
+ };
88
+
89
+ if (strArr.length == 1) {
90
+ return this.charAt(0).toUpperCase() +
91
+ this.slice(1, this.length).toLowerCase();
92
+ } else {
93
+ strArr.forEach(callback);
94
+ return str;
95
+ }
96
+ }
97
+ },
98
+
99
+ copyUntil: {
100
+ value: function(word, start) {
101
+ start = start || 0;
102
+
103
+ var
104
+ substr = this,
105
+ index;
106
+
107
+ index = substr.indexOf(word, start);
108
+ if (index > -1) {
109
+ return this.slice(start, index);
110
+ }
111
+ return this.slice(start, this.length);
112
+ }
113
+ },
114
+
115
+ empty: {
116
+ value: function() {
117
+ return this.length === 0;
118
+ }
119
+ },
120
+
121
+ filled: {
122
+ value: function() {
123
+ return !this.empty();
124
+ }
125
+ }
126
+ });
127
+
128
+ } catch(e) {}
129
+
130
+ })(String);
@@ -0,0 +1,31 @@
1
+ (function($) {
2
+ "use strict";
3
+
4
+
5
+ try {
6
+
7
+ Object.defineProperties($.prototype, {
8
+ elements: {
9
+ value: function() {
10
+ var
11
+ next,
12
+ collection = [];
13
+
14
+ do {
15
+ try {
16
+ next = this.iterateNext();
17
+ if (next) {
18
+ collection.push(next);
19
+ }
20
+ } catch (e) {}
21
+
22
+ } while (next)
23
+
24
+ return collection;
25
+ }
26
+ }
27
+ });
28
+
29
+ } catch(e) {}
30
+
31
+ })(XPathResult);
@@ -0,0 +1,115 @@
1
+ //= require ./flyweight
2
+
3
+ var
4
+ Flyweight,
5
+ Iterable;
6
+
7
+
8
+ (function($module) {
9
+ "use strict";
10
+
11
+
12
+ var
13
+ flyweights = [];
14
+
15
+ try {
16
+ Object.defineProperties($module, {
17
+ Factory: {
18
+ value: {}
19
+ }
20
+ });
21
+
22
+
23
+ Object.defineProperties($module.Factory, {
24
+ singletons: {
25
+ get: function() {
26
+ return flyweights;
27
+ }
28
+ },
29
+
30
+ exists: {
31
+ value: function(constructor, args) {
32
+ var
33
+ singleton,
34
+ iterator,
35
+
36
+ callback = function(map) {
37
+ if (map.singleton instanceof constructor) {
38
+ if (Object.areEquivalents(args, map.args)) {
39
+ singleton = map.singleton;
40
+ this.finalize();
41
+ }
42
+ }
43
+ };
44
+
45
+ if (typeof constructor == "function") {
46
+ iterator = Iterable.Proxy.new(flyweights);
47
+ iterator.each(callback);
48
+
49
+ return singleton;
50
+ }
51
+
52
+ return false;
53
+ }
54
+ },
55
+
56
+ new: {
57
+ value: function(constructor, args) {
58
+ var
59
+ BuiltConstructor,
60
+ singleton,
61
+ self = $module.Factory,
62
+ ConstructorReference = self.new;
63
+
64
+ if (!(this instanceof ConstructorReference)) {
65
+ if (this == self) {
66
+ return new ConstructorReference(constructor, args);
67
+ } else {
68
+ if (this.singleton) {
69
+ return this.singleton;
70
+ }
71
+
72
+ BuiltConstructor = this.buildConstructor(arguments);
73
+ }
74
+ } else {
75
+ singleton = $module.Factory.exists(constructor, args);
76
+
77
+ if (singleton) {
78
+ return singleton;
79
+ }
80
+
81
+ BuiltConstructor = constructor.buildConstructor(args);
82
+ flyweights.push(this);
83
+ }
84
+
85
+ this.singleton = new BuiltConstructor();
86
+ this.args = args;
87
+
88
+ this.singleton.deleteSingleton = function() {
89
+ var
90
+ index,
91
+ newInstances = [],
92
+
93
+ callback = function(object) {
94
+ newInstances.push(object.singleton);
95
+ };
96
+
97
+ flyweights.forEach(callback);
98
+
99
+ index = newInstances.indexOfEquivalence(this);
100
+ if (index > -1) {
101
+ flyweights.deleteAt(index);
102
+ return flyweights;
103
+ } else {
104
+ this.constructor.singleton = undefined;
105
+ }
106
+
107
+ };
108
+
109
+ return this.singleton;
110
+ }
111
+ }
112
+ });
113
+ } catch(e) {}
114
+
115
+ })(Flyweight);
@@ -0,0 +1,12 @@
1
+ (function($module) {
2
+ "use strict";
3
+
4
+ try {
5
+ Object.defineProperties($module, {
6
+ Flyweight: {
7
+ value: {}
8
+ }
9
+ });
10
+ } catch(e) {}
11
+
12
+ })(window);
@@ -0,0 +1,332 @@
1
+ var
2
+ Iterable;
3
+
4
+
5
+ (function($module) {
6
+ "use strict";
7
+
8
+ var
9
+ symbolExists = function() {
10
+ return window.hasOwnProperty("Symbol") &&
11
+ window.Symbol.hasOwnProperty("iterator");
12
+ },
13
+
14
+ isIterable = function(object) {
15
+ if (object) {
16
+ if (symbolExists() && object[window.Symbol.iterator] ==
17
+ Array.prototype[window.Symbol.iterator]) {
18
+ return true;
19
+ } else {
20
+ if (typeof object == "string" ||
21
+ typeof object == "object" &&
22
+ object.hasOwnProperty("length")) {
23
+ return true;
24
+ }
25
+ }
26
+ }
27
+
28
+ return false;
29
+ },
30
+
31
+ setAccessors = function(object) {
32
+ var
33
+ length = Object.keys(object).length,
34
+
35
+ accessors = function(length) {
36
+ return {
37
+ get: function() {
38
+ return length;
39
+ },
40
+ set: function() {
41
+ length = Object.keys(object).length;
42
+ }
43
+ };
44
+ };
45
+
46
+ Object.defineProperties(object, {
47
+ length: accessors(length)
48
+ });
49
+
50
+ // if (symbolExists()) {
51
+ // Object.defineProperties(object, {
52
+ // // js iterator protocol
53
+ // [window.Symbol.iterator]: {
54
+ // value: function() {
55
+ // var
56
+ // _iterator = _Iterable.Proxy.new(object);
57
+
58
+ // return {
59
+ // next: function() {
60
+ // return {
61
+ // value: _iterator.next(),
62
+ // done: !_iterator.hasNext()
63
+ // };
64
+ // }
65
+ // };
66
+ // }
67
+ // }
68
+ // });
69
+ // }
70
+ },
71
+
72
+ parse = function(collection) {
73
+ var
74
+ newObject = {};
75
+
76
+ Object.assign(newObject, collection);
77
+ setAccessors(newObject);
78
+
79
+ return newObject;
80
+ },
81
+
82
+ toIterable = function(collection) {
83
+ if (!isIterable(collection)) {
84
+ setAccessors(collection);
85
+ }
86
+ },
87
+
88
+ asIterable = function(collection) {
89
+ var
90
+ clone = {};
91
+
92
+ Object.assign(clone, collection);
93
+ toIterable(clone);
94
+
95
+ return clone;
96
+ },
97
+
98
+ Iterator_ = {
99
+ new: function(collection) {
100
+ var
101
+ keys,
102
+ amount,
103
+ i,
104
+ lastIndex,
105
+ ConstructorReference = Iterator_.new;
106
+
107
+ if (!(this instanceof ConstructorReference)) {
108
+ return new ConstructorReference(collection);
109
+ }
110
+
111
+ collection = asIterable(collection);
112
+ keys = Object.keys(collection);
113
+ amount = keys.length;
114
+ i = -1;
115
+ lastIndex = amount - 1;
116
+
117
+ this.index = function() {
118
+ return i;
119
+ };
120
+
121
+ // iteration protocols
122
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
123
+ this.next = function() {
124
+ // sum before to use
125
+ return collection[keys[++i]];
126
+ };
127
+
128
+ this.hasNext = function() {
129
+ return i < lastIndex;
130
+ };
131
+ ////////////
132
+
133
+ this.key = function() {
134
+ return keys[i];
135
+ };
136
+
137
+ this.previous = function() {
138
+ return collection[keys[--i]];
139
+ };
140
+
141
+ this.nextIndex = function(index) {
142
+ i = index - 1;
143
+ };
144
+
145
+ this.previousIndex = function(index) {
146
+ i = index + 1;
147
+ };
148
+
149
+ this.reset = function() {
150
+ i = -1;
151
+ };
152
+
153
+ this.finalize = function() {
154
+ i = amount;
155
+ };
156
+
157
+ this.finalizeOnReverse = function() {
158
+ this.reset();
159
+ };
160
+
161
+ this.hasPrev = function() {
162
+ return i > 0;
163
+ };
164
+
165
+ this.each = function(startingIndex, finalIndex, callback) {
166
+ if (typeof startingIndex == "function" ^
167
+ typeof finalIndex == "function") {
168
+ if (typeof finalIndex == "function") {
169
+ callback = finalIndex;
170
+ this.nextIndex(startingIndex);
171
+ } else {
172
+ callback = startingIndex;
173
+ }
174
+ } else {
175
+ if (typeof startingIndex == "number") {
176
+ this.nextIndex(startingIndex);
177
+ }
178
+
179
+ if (typeof finalIndex == "number") {
180
+ lastIndex = finalIndex;
181
+ }
182
+ }
183
+
184
+ while (this.hasNext()) {
185
+ callback.call(this, this.next(), this.key());
186
+ }
187
+ };
188
+
189
+ this.reverseEach = function(startingIndex, callback) {
190
+ this.finalize();
191
+
192
+ if (typeof callback != "function" &&
193
+ typeof startingIndex == "function") {
194
+ callback = startingIndex;
195
+ } else if (typeof startingIndex != "function") {
196
+ this.previousIndex(startingIndex);
197
+ }
198
+
199
+ while (this.hasPrev()) {
200
+ callback.call(this, this.previous(), this.key());
201
+ }
202
+ };
203
+
204
+ this.select = function(callback) {
205
+ var
206
+ selected = [],
207
+
208
+ iteratorBlock = function(item) {
209
+ if (callback.call(this, item, this.key())) {
210
+ selected.push(item);
211
+ }
212
+ };
213
+
214
+ this.each(iteratorBlock);
215
+
216
+ if (selected.length) {
217
+ return selected;
218
+ }
219
+
220
+ };
221
+ }
222
+ };
223
+
224
+ Object.defineProperties($module, {
225
+ Iterable: {
226
+ value: {}
227
+ }
228
+ });
229
+
230
+ Object.defineProperties(Iterable, {
231
+ Proxy: {
232
+ value: {}
233
+ }
234
+ });
235
+
236
+ Object.defineProperties(Iterable, {
237
+ symbolExists: {
238
+ value: function() {
239
+ return symbolExists();
240
+ }
241
+ },
242
+
243
+ isIterable: {
244
+ value: function(object) {
245
+ return isIterable(object);
246
+ }
247
+ },
248
+
249
+ parse: {
250
+ value: function(collection) {
251
+ return parse(collection);
252
+ }
253
+ },
254
+
255
+ toIterable: {
256
+ value: function(collection) {
257
+ toIterable(collection);
258
+ }
259
+ }
260
+ });
261
+
262
+ Object.defineProperties(Iterable.Proxy, {
263
+
264
+ new: {
265
+ value: function(collection) {
266
+ var
267
+ _iterator,
268
+ ConstructorReference = Iterable.Proxy.new;
269
+
270
+ if (!(this instanceof ConstructorReference)) {
271
+ return new ConstructorReference(collection);
272
+ }
273
+
274
+ _iterator = Iterator_.new(collection);
275
+
276
+ // instance methods
277
+ this.index = function() {
278
+ return _iterator.index;
279
+ };
280
+
281
+ this.key = function() {
282
+ return _iterator.key();
283
+ };
284
+
285
+ this.next = function() {
286
+ return _iterator.next();
287
+ };
288
+
289
+ this.previous = function() {
290
+ return _iterator.previous();
291
+ };
292
+
293
+ this.reset = function() {
294
+ _iterator.reset();
295
+ };
296
+
297
+ this.finalize = function() {
298
+ _iterator.finalize();
299
+ };
300
+
301
+ this.finalizeOnReverse = function() {
302
+ _iterator.finalizeOnReverse();
303
+ };
304
+
305
+ this.hasPrev = function() {
306
+ return _iterator.hasPrev();
307
+ };
308
+
309
+ this.hasNext = function() {
310
+ return _iterator.hasNext();
311
+ };
312
+
313
+ this.each = function(startingIndex, finalIndex, callback) {
314
+ return _iterator.each(startingIndex, finalIndex, callback);
315
+ };
316
+
317
+ this.reverseEach = function(startingIndex, callback) {
318
+ return _iterator.reverseEach(startingIndex, callback);
319
+ };
320
+
321
+ this.select = function(callback) {
322
+ return _iterator.select(callback);
323
+ };
324
+
325
+ return this;
326
+
327
+ }
328
+ }
329
+
330
+ });
331
+
332
+ })(window);