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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +21 -0
- data/config/environments/production.rb +1 -0
- data/config/environments/staging.rb +1 -0
- data/config/initializers/assets.rb +7 -0
- data/esphinx.gemspec +19 -0
- data/lib/assets/javascripts/esphinx/element.js +256 -0
- data/lib/assets/javascripts/esphinx/event.js +227 -0
- data/lib/assets/javascripts/esphinx/index.js +3 -0
- data/lib/assets/javascripts/esphinx/lib/collection.js +51 -0
- data/lib/assets/javascripts/esphinx/lib/comparable.js +54 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/array.js +541 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/function.js +46 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/index.js +1 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/location.js +111 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/map.js +29 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/number.js +42 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/object.js +502 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/string.js +130 -0
- data/lib/assets/javascripts/esphinx/lib/extensions/x_path_result.js +31 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/flyweight/factory.js +115 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/flyweight/flyweight.js +12 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/iterator.js +332 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/context.js +42 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs/element.js +78 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs/object.js +83 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/graphs/bfs.js +19 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/search.js +24 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/gof/strategies/search/search_proxy.js +52 -0
- data/lib/assets/javascripts/esphinx/lib/patterns/index.js +1 -0
- data/lib/assets/javascripts/esphinx/main.js +361 -0
- data/lib/assets/javascripts/esphinx/node.js +276 -0
- data/lib/assets/javascripts/esphinx/properties/forms.js +161 -0
- data/lib/assets/javascripts/esphinx/properties/inputs/text.js +29 -0
- data/lib/assets/javascripts/esphinx/property.js +308 -0
- data/lib/assets/javascripts/esphinx/query.js +347 -0
- data/lib/assets/javascripts/esphinx/samples/sort.js +30 -0
- data/lib/assets/javascripts/esphinx/style.js +342 -0
- data/lib/assets/javascripts/esphinx/util/ajax.js +152 -0
- data/lib/assets/javascripts/esphinx/util/autocomplete.js +356 -0
- data/lib/assets/javascripts/esphinx/util/browser.js +66 -0
- data/lib/assets/javascripts/esphinx/util/cookie.js +167 -0
- data/lib/assets/javascripts/esphinx/util/keyboard.js +110 -0
- data/lib/assets/javascripts/esphinx/util/loader.js +84 -0
- data/lib/assets/javascripts/esphinx/util/observer.js +58 -0
- data/lib/assets/javascripts/esphinx/util/promise.js +127 -0
- data/lib/assets/javascripts/esphinx/util/protector.js +142 -0
- data/lib/assets/javascripts/esphinx/util/range.js +6 -0
- data/lib/assets/javascripts/esphinx/util/scrollbar.js +22 -0
- data/lib/esphinx/rails/engine.rb +7 -0
- data/lib/esphinx/rails/version.rb +5 -0
- data/lib/esphinx-rails.rb +1 -0
- data/vendor/assets/javascripts/jquery-2.2.2.min.js +1 -0
- metadata +99 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
// var
|
2
|
+
// self = this.copy(),
|
3
|
+
// i = 0,
|
4
|
+
// count = 0,
|
5
|
+
// aux;
|
6
|
+
|
7
|
+
// while (true) {
|
8
|
+
// if (count === self.length - 1) { break; }
|
9
|
+
// while (true) {
|
10
|
+
// i = count;
|
11
|
+
// if (self[i] > self[i + 1]) { //0, 1
|
12
|
+
// aux = self[i];
|
13
|
+
// self[i] = self[i + 1];
|
14
|
+
// self[i + 1] = aux;
|
15
|
+
// while (true) {
|
16
|
+
// if (i === 0 || self[i] > self[i - 1]) { break; }
|
17
|
+
// aux = self[i];
|
18
|
+
// self[i] = self[i - 1];
|
19
|
+
// self[i - 1] = aux;
|
20
|
+
// i -= 1;
|
21
|
+
// }
|
22
|
+
// }
|
23
|
+
// if (i === 0 || self[i] < self[i + 1]) {
|
24
|
+
// break;
|
25
|
+
// }
|
26
|
+
// }
|
27
|
+
// count += 1;
|
28
|
+
// }
|
29
|
+
|
30
|
+
// return self;
|
@@ -0,0 +1,342 @@
|
|
1
|
+
var
|
2
|
+
esPhinx,
|
3
|
+
Iterable;
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
var
|
9
|
+
displayObjects = [];
|
10
|
+
|
11
|
+
$.prototype.extend({
|
12
|
+
|
13
|
+
// css: function(property, value, delay = 0) {
|
14
|
+
css: function(property, value, delay) {
|
15
|
+
if (typeof delay != "number") {delay = 0;}
|
16
|
+
var
|
17
|
+
properties,
|
18
|
+
number,
|
19
|
+
computedStyle,
|
20
|
+
propertyPriority,
|
21
|
+
callback,
|
22
|
+
propertiesIteratorBlock,
|
23
|
+
self = this,
|
24
|
+
node = this.asNode(),
|
25
|
+
offsetPattern = /\b(width|height|top|left)\b/,
|
26
|
+
originalProperties = {},
|
27
|
+
|
28
|
+
visibilityPropertiesCollection = {
|
29
|
+
position: "absolute",
|
30
|
+
visibility: "hidden",
|
31
|
+
display: "block"
|
32
|
+
},
|
33
|
+
|
34
|
+
visibilityPropertiesList = [
|
35
|
+
"position",
|
36
|
+
"visibility",
|
37
|
+
"display"
|
38
|
+
],
|
39
|
+
|
40
|
+
nonexistentProperties = [],
|
41
|
+
|
42
|
+
recordOriginalPropertiesIteratorBlock = function(p) {
|
43
|
+
if(!node.style[p]) {
|
44
|
+
nonexistentProperties.push(p);
|
45
|
+
}
|
46
|
+
originalProperties[p] = node.style[p] ||
|
47
|
+
computedStyle[p];
|
48
|
+
node.style.setProperty(p, visibilityPropertiesCollection[p],
|
49
|
+
"important");
|
50
|
+
},
|
51
|
+
|
52
|
+
toRevertPropertiesIteratorBlock = function(p) {
|
53
|
+
node.style.setProperty(p, originalProperties[p], node.style
|
54
|
+
.getPropertyPriority(p));
|
55
|
+
},
|
56
|
+
|
57
|
+
nonexistentPropertiesIteratorBlock = function(p) {
|
58
|
+
node.style.removeProperty(p);
|
59
|
+
};
|
60
|
+
|
61
|
+
if (value === 0) {
|
62
|
+
value = value.toString();
|
63
|
+
}
|
64
|
+
|
65
|
+
// (key, value)
|
66
|
+
if (!value && !Object.belongToClass(property, Object)) {
|
67
|
+
property = property.strikeCase();
|
68
|
+
computedStyle = window.getComputedStyle(node);
|
69
|
+
value = computedStyle.getPropertyValue(property);
|
70
|
+
|
71
|
+
if (node.style[property]) {
|
72
|
+
value = node.style[property];
|
73
|
+
} else if (computedStyle.display == "none" &&
|
74
|
+
offsetPattern.test(property)) {
|
75
|
+
visibilityPropertiesList
|
76
|
+
.forEach(recordOriginalPropertiesIteratorBlock);
|
77
|
+
|
78
|
+
value = computedStyle.getPropertyValue(property);
|
79
|
+
|
80
|
+
// remove
|
81
|
+
nonexistentProperties
|
82
|
+
.forEach(nonexistentPropertiesIteratorBlock);
|
83
|
+
|
84
|
+
// revert
|
85
|
+
visibilityPropertiesList.difference(nonexistentProperties)
|
86
|
+
.forEach(toRevertPropertiesIteratorBlock);
|
87
|
+
}
|
88
|
+
|
89
|
+
number = parseFloat(value);
|
90
|
+
|
91
|
+
if (Number.isNaN(number)) {
|
92
|
+
return value;
|
93
|
+
} else {
|
94
|
+
return number;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
if (Object.belongToClass(property, Object)) {
|
100
|
+
|
101
|
+
if (typeof value == "number") { delay = value; }
|
102
|
+
|
103
|
+
properties = property;
|
104
|
+
|
105
|
+
callback = function(node) {
|
106
|
+
computedStyle = window.getComputedStyle(node);
|
107
|
+
|
108
|
+
propertiesIteratorBlock = function(value, property) {
|
109
|
+
property = property.strikeCase();
|
110
|
+
propertyPriority = computedStyle
|
111
|
+
.getPropertyPriority(property);
|
112
|
+
node.style.setProperty(property, value,
|
113
|
+
propertyPriority);
|
114
|
+
};
|
115
|
+
|
116
|
+
$.each(properties, propertiesIteratorBlock);
|
117
|
+
};
|
118
|
+
|
119
|
+
} else {
|
120
|
+
callback = function(node) {
|
121
|
+
computedStyle = window.getComputedStyle(node);
|
122
|
+
property = property.strikeCase();
|
123
|
+
propertyPriority = computedStyle
|
124
|
+
.getPropertyPriority(property);
|
125
|
+
node.style.setProperty(property, value, propertyPriority);
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
129
|
+
if (delay) {
|
130
|
+
window.setTimeout(function() {
|
131
|
+
self.each(callback);
|
132
|
+
}, delay);
|
133
|
+
} else {
|
134
|
+
self.each(callback);
|
135
|
+
}
|
136
|
+
|
137
|
+
return this;
|
138
|
+
},
|
139
|
+
|
140
|
+
centralizeAt: function(reference) {
|
141
|
+
var
|
142
|
+
self = this,
|
143
|
+
parent,
|
144
|
+
|
145
|
+
centralize = function(reference) {
|
146
|
+
this.css("position", "absolute");
|
147
|
+
|
148
|
+
this.css({
|
149
|
+
top: (reference.height() / 2) -
|
150
|
+
(this.height() / 2) + "px",
|
151
|
+
left: (reference.width() / 2) -
|
152
|
+
(this.width() / 2) + "px"
|
153
|
+
});
|
154
|
+
};
|
155
|
+
|
156
|
+
if (!Object.hasSameClass(reference, this)) {
|
157
|
+
reference = $(reference);
|
158
|
+
}
|
159
|
+
|
160
|
+
centralize.call(this, reference);
|
161
|
+
|
162
|
+
if (reference.isA(window.Element)) {
|
163
|
+
parent = reference;
|
164
|
+
} else {
|
165
|
+
parent = $().push(window);
|
166
|
+
}
|
167
|
+
|
168
|
+
parent.on("resize", function() {
|
169
|
+
centralize.call(self, reference);
|
170
|
+
});
|
171
|
+
|
172
|
+
return this;
|
173
|
+
},
|
174
|
+
|
175
|
+
// hide: function(delay = 0) {
|
176
|
+
hide: function(delay) {
|
177
|
+
if (typeof delay != "number") {delay = 0;}
|
178
|
+
|
179
|
+
var
|
180
|
+
exists,
|
181
|
+
iterator,
|
182
|
+
node = this.asNode(),
|
183
|
+
|
184
|
+
callback = function(hash) {
|
185
|
+
if (hash.element == node) {
|
186
|
+
exists = true;
|
187
|
+
this.finalize();
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
if (node instanceof window.Element) {
|
192
|
+
if ($(node).css("display") != "none") {
|
193
|
+
iterator = Iterable.Proxy.new(displayObjects);
|
194
|
+
iterator.each(callback);
|
195
|
+
|
196
|
+
if (!exists && this.css("display")) {
|
197
|
+
displayObjects.push({
|
198
|
+
element: node,
|
199
|
+
display: this.css("display")
|
200
|
+
});
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
}
|
205
|
+
|
206
|
+
this.css("display", "none", delay);
|
207
|
+
|
208
|
+
return this;
|
209
|
+
},
|
210
|
+
|
211
|
+
show: function() {
|
212
|
+
var
|
213
|
+
style,
|
214
|
+
inlineDisplay,
|
215
|
+
display,
|
216
|
+
iterator,
|
217
|
+
node = this.asNode(),
|
218
|
+
|
219
|
+
callback = function(hash) {
|
220
|
+
if (hash.element == node) {
|
221
|
+
display = hash.display;
|
222
|
+
this.finalize();
|
223
|
+
}
|
224
|
+
};
|
225
|
+
|
226
|
+
if (node instanceof window.Element) {
|
227
|
+
style = node.style;
|
228
|
+
inlineDisplay = style.display;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (this.css("display") == "none") {
|
232
|
+
iterator = Iterable.Proxy.new(displayObjects);
|
233
|
+
iterator.each(callback);
|
234
|
+
|
235
|
+
if (display) {
|
236
|
+
this.css("display", display);
|
237
|
+
} else if (inlineDisplay) {
|
238
|
+
style.display = null;
|
239
|
+
if (this.css("display") == "none") {
|
240
|
+
this.css("display", "block");
|
241
|
+
}
|
242
|
+
} else {
|
243
|
+
this.css("display", "block");
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
return this;
|
248
|
+
},
|
249
|
+
|
250
|
+
// horizontalToggle: function(initialMargin = 0) {
|
251
|
+
horizontalToggle: function(initialMargin, callback) {
|
252
|
+
initialMargin = initialMargin || 0;
|
253
|
+
if (typeof initialMargin == "function") {
|
254
|
+
callback = initialMargin;
|
255
|
+
initialMargin = 0;
|
256
|
+
}
|
257
|
+
|
258
|
+
var
|
259
|
+
width,
|
260
|
+
margin,
|
261
|
+
marginRight,
|
262
|
+
marginLeft,
|
263
|
+
duration,
|
264
|
+
|
265
|
+
iteratorBlock = function(node) {
|
266
|
+
node = $(node);
|
267
|
+
|
268
|
+
width = Math.round(node.width());
|
269
|
+
marginLeft = Math.abs(node.css("margin-left"));
|
270
|
+
marginRight = Math.abs(node.css("margin-right"));
|
271
|
+
duration = node.transitionDuration();
|
272
|
+
|
273
|
+
if (typeof duration != "number") {
|
274
|
+
duration = 0;
|
275
|
+
}
|
276
|
+
|
277
|
+
// discovering more criteria to know if align on right (||)
|
278
|
+
if (node.css("float") == "right") {
|
279
|
+
margin = Math.abs(Math.round(node.css("margin-right")));
|
280
|
+
if (margin != (width + marginLeft)) {
|
281
|
+
node.css("margin-right", - (width + marginLeft) +
|
282
|
+
"px");
|
283
|
+
} else {
|
284
|
+
node.css("margin-right", initialMargin + "px");
|
285
|
+
}
|
286
|
+
} else {
|
287
|
+
margin = Math.abs(Math.round(node.css("margin-left")));
|
288
|
+
if (margin != (width + marginRight)) {
|
289
|
+
node.css("margin-left", - (width + marginRight) +
|
290
|
+
"px");
|
291
|
+
} else {
|
292
|
+
node.css("margin-left", initialMargin + "px");
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
window.setTimeout(function() {
|
297
|
+
callback.call(node);
|
298
|
+
}, duration);
|
299
|
+
|
300
|
+
};
|
301
|
+
|
302
|
+
this.each(iteratorBlock);
|
303
|
+
|
304
|
+
return this;
|
305
|
+
},
|
306
|
+
|
307
|
+
toggleClass: function(classList, changeTo) {
|
308
|
+
var
|
309
|
+
callback = function(node) {
|
310
|
+
if ($(node).hasClass(classList)) {
|
311
|
+
$(node).removeClass(classList);
|
312
|
+
if (changeTo) {
|
313
|
+
$(node).addClass(changeTo);
|
314
|
+
}
|
315
|
+
} else if (changeTo) {
|
316
|
+
if ($(node).hasClass(changeTo)) {
|
317
|
+
$(node).removeClass(changeTo);
|
318
|
+
$(node).addClass(classList);
|
319
|
+
} else {
|
320
|
+
$(node).addClass(classList);
|
321
|
+
}
|
322
|
+
} else {
|
323
|
+
$(node).addClass(classList);
|
324
|
+
}
|
325
|
+
};
|
326
|
+
|
327
|
+
this.each(callback);
|
328
|
+
|
329
|
+
return this;
|
330
|
+
},
|
331
|
+
|
332
|
+
toggle: function() {
|
333
|
+
if (this.css("display") == "none") {
|
334
|
+
this.show();
|
335
|
+
} else {
|
336
|
+
this.hide();
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
});
|
341
|
+
|
342
|
+
}(esPhinx));
|
@@ -0,0 +1,152 @@
|
|
1
|
+
var
|
2
|
+
esPhinx;
|
3
|
+
|
4
|
+
|
5
|
+
(function($) {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
$.extend({
|
9
|
+
Ajax: {}
|
10
|
+
});
|
11
|
+
|
12
|
+
$.Extender.extend($.Ajax, true, {
|
13
|
+
new: function(URL) {
|
14
|
+
var
|
15
|
+
promise,
|
16
|
+
progressEvent,
|
17
|
+
ifRaiseException,
|
18
|
+
ConstructorReference = $.Ajax.new,
|
19
|
+
_options = {},
|
20
|
+
callback = function() {},
|
21
|
+
xhr = new window.XMLHttpRequest(),
|
22
|
+
|
23
|
+
setRequestHeaders = function(xhr, headers) {
|
24
|
+
if (headers) {
|
25
|
+
$.each(headers, function(value, header) {
|
26
|
+
if (value) {
|
27
|
+
xhr.setRequestHeader(header, value);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
},
|
32
|
+
|
33
|
+
resolveOptions = function(options) {
|
34
|
+
// abstract events
|
35
|
+
// _error = options.error || callback,
|
36
|
+
_options.abort = options.abort || callback;
|
37
|
+
|
38
|
+
// loadstart
|
39
|
+
_options.start = options.start || callback;
|
40
|
+
|
41
|
+
// progress
|
42
|
+
_options.progress = options.progress || callback;
|
43
|
+
|
44
|
+
// loadend
|
45
|
+
_options.complete = options.complete || callback;
|
46
|
+
|
47
|
+
_options.success = options.success || callback;
|
48
|
+
},
|
49
|
+
|
50
|
+
start = function(xhr, type, URL, options) {
|
51
|
+
// async false raise warning of deprecated
|
52
|
+
xhr.open(type, URL, true, options.user, options.password);
|
53
|
+
|
54
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
55
|
+
|
56
|
+
setRequestHeaders(xhr, options.headers);
|
57
|
+
},
|
58
|
+
|
59
|
+
get = function(xhr, URL, options) {
|
60
|
+
var
|
61
|
+
composed = "";
|
62
|
+
|
63
|
+
if (options.URLParemeters) {
|
64
|
+
$.each(options.URLParemeters, function(value, key) {
|
65
|
+
if (Object.belongToClass(value, Object)) {
|
66
|
+
value = JSON.stringify(value);
|
67
|
+
}
|
68
|
+
|
69
|
+
composed += key + "=" + value + "&";
|
70
|
+
});
|
71
|
+
|
72
|
+
composed = composed.slice(0, composed.length - 1);
|
73
|
+
URL += "?" + encodeURI(composed);
|
74
|
+
}
|
75
|
+
|
76
|
+
start(xhr, "GET", URL, options);
|
77
|
+
|
78
|
+
// request
|
79
|
+
xhr.send(null);
|
80
|
+
};
|
81
|
+
|
82
|
+
|
83
|
+
if (!(this instanceof ConstructorReference)) {
|
84
|
+
return new ConstructorReference(URL);
|
85
|
+
}
|
86
|
+
|
87
|
+
xhr.addEventListener("abort", function() {
|
88
|
+
_options.abort();
|
89
|
+
});
|
90
|
+
|
91
|
+
// readyState == 1 or xhr.OPENED
|
92
|
+
xhr.addEventListener("loadstart", function() {
|
93
|
+
_options.start(xhr);
|
94
|
+
});
|
95
|
+
|
96
|
+
// readyState == 3 or xhr.LOADING
|
97
|
+
xhr.addEventListener("progress", function(e) {
|
98
|
+
_options.progress(e);
|
99
|
+
progressEvent = e;
|
100
|
+
});
|
101
|
+
promise = $.Promise.new({
|
102
|
+
onAccomplish: function(response) {
|
103
|
+
// binary or text file, different of executable script
|
104
|
+
if (/^application/
|
105
|
+
.test(xhr.getResponseHeader("Content-Type")) ||
|
106
|
+
(/^text/.test(xhr.getResponseHeader("Content-Type")) &&
|
107
|
+
!/\/(javascript|ecmascript)/.test(xhr
|
108
|
+
.getResponseHeader("Content-Type")))) {
|
109
|
+
_options.success(response);
|
110
|
+
} else {
|
111
|
+
// script
|
112
|
+
if (/\/(javascript|ecmascript)/.test(xhr
|
113
|
+
.getResponseHeader("Content-Type"))) {
|
114
|
+
eval.call(window, response);
|
115
|
+
// URL to video, audio or picture
|
116
|
+
} else {
|
117
|
+
_options.success(URL);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}, function(accomplish) {
|
122
|
+
if (progressEvent && (!progressEvent.lengthComputable ||
|
123
|
+
progressEvent.loaded == progressEvent.total)) {
|
124
|
+
accomplish(xhr.response);
|
125
|
+
}
|
126
|
+
});
|
127
|
+
|
128
|
+
// readyState == 4 or xhr.DONE
|
129
|
+
xhr.addEventListener("loadend", function() {
|
130
|
+
_options.complete(xhr);
|
131
|
+
});
|
132
|
+
|
133
|
+
this.abort = function(callback) {
|
134
|
+
xhr.abort();
|
135
|
+
promise.reject(callback);
|
136
|
+
};
|
137
|
+
|
138
|
+
this.catch = function(callback) {
|
139
|
+
ifRaiseException = callback;
|
140
|
+
promise.catch(callback);
|
141
|
+
};
|
142
|
+
|
143
|
+
this.get = function(options) {
|
144
|
+
resolveOptions(options);
|
145
|
+
get(xhr, URL, options);
|
146
|
+
};
|
147
|
+
|
148
|
+
return this;
|
149
|
+
}
|
150
|
+
});
|
151
|
+
|
152
|
+
}(esPhinx));
|