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,42 @@
|
|
1
|
+
var
|
2
|
+
StrategyContext;
|
3
|
+
|
4
|
+
// generic strategy factory
|
5
|
+
(function($module) {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
Object.defineProperties($module, {
|
9
|
+
StrategyContext: {
|
10
|
+
value: {}
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
Object.defineProperties(StrategyContext, {
|
15
|
+
|
16
|
+
new: {
|
17
|
+
// value: function(strategy, ...args) {
|
18
|
+
value: function(strategy) {
|
19
|
+
|
20
|
+
var
|
21
|
+
_strategy = strategy,
|
22
|
+
ConstructorReference = StrategyContext.new;
|
23
|
+
|
24
|
+
if (!(this instanceof ConstructorReference)) {
|
25
|
+
return new ConstructorReference(strategy);
|
26
|
+
}
|
27
|
+
|
28
|
+
this.strategy = function(strategy) {
|
29
|
+
if (strategy) {
|
30
|
+
_strategy = strategy;
|
31
|
+
}
|
32
|
+
|
33
|
+
return _strategy;
|
34
|
+
};
|
35
|
+
|
36
|
+
return this;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
});
|
41
|
+
|
42
|
+
})(window);
|
@@ -0,0 +1,78 @@
|
|
1
|
+
//= require ../bfs
|
2
|
+
|
3
|
+
var
|
4
|
+
Search,
|
5
|
+
Iterable;
|
6
|
+
|
7
|
+
// concrete strategy
|
8
|
+
(function($module) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
Object.defineProperties($module, {
|
12
|
+
Element: {
|
13
|
+
value: {}
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
Object.defineProperties($module.Element, {
|
18
|
+
new: {
|
19
|
+
value: function(collection) {
|
20
|
+
|
21
|
+
var
|
22
|
+
ConstructorReference = $module.Element.new;
|
23
|
+
|
24
|
+
if (!(this instanceof ConstructorReference)) {
|
25
|
+
return new ConstructorReference(collection);
|
26
|
+
}
|
27
|
+
|
28
|
+
this.research = function(callback) {
|
29
|
+
var
|
30
|
+
queueIterator,
|
31
|
+
iterator,
|
32
|
+
queue = [{trace: [], collection: collection}],
|
33
|
+
self = this,
|
34
|
+
|
35
|
+
cleanQueue = function() {
|
36
|
+
queue = [];
|
37
|
+
},
|
38
|
+
|
39
|
+
iteratorBlock = function(node) {
|
40
|
+
callback.call(self, node);
|
41
|
+
|
42
|
+
if (node.childElementCount) {
|
43
|
+
queue.push({
|
44
|
+
collection: node.children
|
45
|
+
});
|
46
|
+
}
|
47
|
+
},
|
48
|
+
|
49
|
+
queueBlock = function(map) {
|
50
|
+
cleanQueue();
|
51
|
+
|
52
|
+
iterator = Iterable.Proxy.new(map.collection);
|
53
|
+
|
54
|
+
iterator.each(iteratorBlock);
|
55
|
+
};
|
56
|
+
|
57
|
+
|
58
|
+
if (collection instanceof window.Node) {
|
59
|
+
queue = [{trace: [], collection: collection.children}];
|
60
|
+
}
|
61
|
+
|
62
|
+
while (true) {
|
63
|
+
if (queue.length) {
|
64
|
+
queueIterator = Iterable.Proxy.new(queue);
|
65
|
+
queueIterator.each(queueBlock);
|
66
|
+
} else {
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
};
|
72
|
+
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
});
|
77
|
+
|
78
|
+
})(Search.Graphs.BFS);
|
@@ -0,0 +1,83 @@
|
|
1
|
+
//= require ../bfs
|
2
|
+
|
3
|
+
var
|
4
|
+
Search,
|
5
|
+
Iterable;
|
6
|
+
|
7
|
+
// concrete strategy
|
8
|
+
(function($module) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
Object.defineProperties($module, {
|
12
|
+
Object: {
|
13
|
+
value: {}
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
Object.defineProperties($module.Object, {
|
18
|
+
new: {
|
19
|
+
value: function(collection) {
|
20
|
+
|
21
|
+
var
|
22
|
+
ConstructorReference = $module.Object.new;
|
23
|
+
|
24
|
+
if (!(this instanceof ConstructorReference)) {
|
25
|
+
return new ConstructorReference(collection);
|
26
|
+
}
|
27
|
+
|
28
|
+
this.research = function(callback) {
|
29
|
+
var
|
30
|
+
queueIterator,
|
31
|
+
iterator,
|
32
|
+
key,
|
33
|
+
map,
|
34
|
+
// As novas versões do JS trazem a classe Map, a qual permite associar objetos como chave, isto é, um objeto poderá ser a chave de outro. Em um objeto literal as chaves podem ser apenas do tipo string ou number
|
35
|
+
queue = [{trace: [], collection: collection}],
|
36
|
+
self = this,
|
37
|
+
|
38
|
+
cleanQueue = function() {
|
39
|
+
queue = [];
|
40
|
+
},
|
41
|
+
|
42
|
+
queueBlock = function(map) {
|
43
|
+
var
|
44
|
+
iteratorBlock = function(object) {
|
45
|
+
key = iterator.key();
|
46
|
+
|
47
|
+
// to break use "return ...;"
|
48
|
+
callback.call(self, object, key, map.trace);
|
49
|
+
|
50
|
+
if (typeof object == "object" &&
|
51
|
+
(Iterable.isIterable(object) ||
|
52
|
+
(Object.belongToClass(object,
|
53
|
+
Object)))) {
|
54
|
+
// put on queue
|
55
|
+
queue.push({
|
56
|
+
trace: map.trace.concat(key),
|
57
|
+
collection: object
|
58
|
+
});
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
cleanQueue();
|
63
|
+
iterator = Iterable.Proxy.new(map.collection);
|
64
|
+
iterator.each(iteratorBlock);
|
65
|
+
};
|
66
|
+
|
67
|
+
while (true) {
|
68
|
+
if (queue.length) {
|
69
|
+
queueIterator = Iterable.Proxy.new(queue);
|
70
|
+
queueIterator.each(queueBlock);
|
71
|
+
} else {
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
};
|
77
|
+
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
})(Search.Graphs.BFS);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
//= require ../search
|
2
|
+
|
3
|
+
var
|
4
|
+
Search;
|
5
|
+
|
6
|
+
// concrete strategy
|
7
|
+
(function($module) {
|
8
|
+
"use strict";
|
9
|
+
|
10
|
+
try {
|
11
|
+
// Breadth-First Search
|
12
|
+
Object.defineProperties($module, {
|
13
|
+
BFS: {
|
14
|
+
value: {}
|
15
|
+
}
|
16
|
+
});
|
17
|
+
} catch(e) {}
|
18
|
+
|
19
|
+
})(Search.Graphs);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
var
|
2
|
+
Search;
|
3
|
+
|
4
|
+
// namespace
|
5
|
+
(function($module) {
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
try {
|
9
|
+
Object.defineProperties($module, {
|
10
|
+
Search: {
|
11
|
+
value: {}
|
12
|
+
}
|
13
|
+
});
|
14
|
+
} catch(e) {}
|
15
|
+
|
16
|
+
try {
|
17
|
+
Object.defineProperties(Search, {
|
18
|
+
Graphs: {
|
19
|
+
value: {}
|
20
|
+
}
|
21
|
+
});
|
22
|
+
} catch(e) {}
|
23
|
+
|
24
|
+
})(window);
|
@@ -0,0 +1,52 @@
|
|
1
|
+
//= require ./search
|
2
|
+
|
3
|
+
var
|
4
|
+
StrategyContext,
|
5
|
+
SearchContext;
|
6
|
+
|
7
|
+
// strategy context proxy
|
8
|
+
(function($module) {
|
9
|
+
"use strict";
|
10
|
+
|
11
|
+
Object.defineProperties($module, {
|
12
|
+
SearchContext: {
|
13
|
+
value: {}
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
|
18
|
+
Object.defineProperties(SearchContext, {
|
19
|
+
Proxy: {
|
20
|
+
value: {}
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
24
|
+
Object.defineProperties(SearchContext.Proxy, {
|
25
|
+
|
26
|
+
new: {
|
27
|
+
// value: function(strategy, ...args) {
|
28
|
+
value: function(strategy) {
|
29
|
+
var
|
30
|
+
_strategy,
|
31
|
+
superContext,
|
32
|
+
ConstructorReference = SearchContext.Proxy.new;
|
33
|
+
|
34
|
+
if (!(this instanceof ConstructorReference)) {
|
35
|
+
return new ConstructorReference(strategy);
|
36
|
+
}
|
37
|
+
|
38
|
+
superContext = StrategyContext.new.call(this);
|
39
|
+
_strategy = superContext.strategy(strategy);
|
40
|
+
|
41
|
+
// "override"
|
42
|
+
this.research = function(callback) {
|
43
|
+
return _strategy.research(callback);
|
44
|
+
};
|
45
|
+
|
46
|
+
return this;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
});
|
51
|
+
|
52
|
+
})(window);
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
@@ -0,0 +1,361 @@
|
|
1
|
+
//= require ./lib/patterns
|
2
|
+
//= require ./lib/extensions
|
3
|
+
|
4
|
+
// See how that must be resolved without compromising the builder pattern
|
5
|
+
|
6
|
+
var
|
7
|
+
esPhinx,
|
8
|
+
Iterable,
|
9
|
+
SearchContext,
|
10
|
+
Search;
|
11
|
+
|
12
|
+
// IIFE
|
13
|
+
(function($module) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
// closure (private static attribute)
|
17
|
+
var
|
18
|
+
NAME = "esPhinx",
|
19
|
+
|
20
|
+
selectInBreadth = function(iterable, callback) {
|
21
|
+
var
|
22
|
+
strategy;
|
23
|
+
|
24
|
+
if (iterable instanceof window.Node) {
|
25
|
+
strategy = SearchContext.Proxy.new(Search.Graphs.BFS.Element
|
26
|
+
.new(iterable));
|
27
|
+
} else {
|
28
|
+
strategy = SearchContext.Proxy.new(Search.Graphs.BFS.Object
|
29
|
+
.new(iterable));
|
30
|
+
}
|
31
|
+
|
32
|
+
return strategy.research(callback);
|
33
|
+
},
|
34
|
+
|
35
|
+
resolveContext = function(context) {
|
36
|
+
if (typeof context == "object") {
|
37
|
+
if (context instanceof window.esPhinx ||
|
38
|
+
context instanceof Element) {
|
39
|
+
return context;
|
40
|
+
}
|
41
|
+
} else if (typeof context == "string") {
|
42
|
+
// recursivity
|
43
|
+
return window.esPhinx(context);
|
44
|
+
}
|
45
|
+
|
46
|
+
return window.document;
|
47
|
+
},
|
48
|
+
|
49
|
+
Extender = {
|
50
|
+
extend: function(object, final, structure) {
|
51
|
+
var
|
52
|
+
context,
|
53
|
+
strategy,
|
54
|
+
verbose = false,
|
55
|
+
propertyDescriptors = {
|
56
|
+
enumerable: true,
|
57
|
+
configurable: false
|
58
|
+
},
|
59
|
+
|
60
|
+
// create or mount the context. If there is trace and object type is an Object, but it doesn't exists, it will be created, else it will be mounted.
|
61
|
+
mountContext = function(methodName, trace, originalObject) {
|
62
|
+
var
|
63
|
+
context = originalObject,
|
64
|
+
|
65
|
+
callback = function(v) {
|
66
|
+
if (!context[v]) {
|
67
|
+
context[v] = {};
|
68
|
+
}
|
69
|
+
|
70
|
+
context = context[v];
|
71
|
+
},
|
72
|
+
|
73
|
+
isAnAccessor = function(methodName, trace) {
|
74
|
+
return (methodName == "get" ||
|
75
|
+
methodName == "set") && trace.length;
|
76
|
+
};
|
77
|
+
|
78
|
+
if ((trace.length &&
|
79
|
+
!isAnAccessor(methodName, trace)) ||
|
80
|
+
methodName != "get" && methodName != "set") {
|
81
|
+
|
82
|
+
trace.forEach(callback);
|
83
|
+
}
|
84
|
+
|
85
|
+
return context;
|
86
|
+
},
|
87
|
+
|
88
|
+
informeIf = function(verbose) {
|
89
|
+
if (verbose) {
|
90
|
+
console.warn("Property \"" + name +
|
91
|
+
"\" of class \"" +
|
92
|
+
Object.className(context) +
|
93
|
+
"\" can't be redefined because " +
|
94
|
+
"it's configured as read-only.");
|
95
|
+
}
|
96
|
+
},
|
97
|
+
|
98
|
+
hasAnyAccessor = function(body) {
|
99
|
+
return Object.implementsMethods(body, "get") ||
|
100
|
+
Object.implementsMethods(body, "set");
|
101
|
+
},
|
102
|
+
|
103
|
+
callback = function(body, name, trace) {
|
104
|
+
|
105
|
+
if (!Object.belongToClass(body, Object) ||
|
106
|
+
// otherwise it will arrive there still
|
107
|
+
Object.empty(body) || hasAnyAccessor(body)) {
|
108
|
+
|
109
|
+
context = mountContext(name, trace, object);
|
110
|
+
|
111
|
+
// propertyDescriptors = JSON
|
112
|
+
// .parse(JSON.parse(JSON.stringify("{\"" + name +
|
113
|
+
// "\":" + JSON.stringify(propertyDescriptors) + "}")));
|
114
|
+
|
115
|
+
if (Object.belongToClass(body, Object)){
|
116
|
+
if (hasAnyAccessor(body)) {
|
117
|
+
delete propertyDescriptors.writable;
|
118
|
+
delete propertyDescriptors.configurable;
|
119
|
+
propertyDescriptors.get = body.get ||
|
120
|
+
function() {};
|
121
|
+
propertyDescriptors.set = body.set ||
|
122
|
+
function() {};
|
123
|
+
} else if (Object.empty(body)) {
|
124
|
+
propertyDescriptors.value = {};
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
if (typeof body == "function") {
|
128
|
+
delete propertyDescriptors.enumerable;
|
129
|
+
}
|
130
|
+
|
131
|
+
propertyDescriptors.value = body;
|
132
|
+
}
|
133
|
+
|
134
|
+
try {
|
135
|
+
Object.defineProperty(context, name,
|
136
|
+
propertyDescriptors);
|
137
|
+
} catch (e) {
|
138
|
+
informeIf(verbose);
|
139
|
+
}
|
140
|
+
|
141
|
+
// restart propertyDescriptors
|
142
|
+
propertyDescriptors = {
|
143
|
+
enumerable: true,
|
144
|
+
configurable: false,
|
145
|
+
writable: !final
|
146
|
+
};
|
147
|
+
}
|
148
|
+
|
149
|
+
};
|
150
|
+
|
151
|
+
if (!structure && (typeof final == "object" ||
|
152
|
+
typeof final == "function")) {
|
153
|
+
structure = final;
|
154
|
+
}
|
155
|
+
|
156
|
+
if (typeof final != "boolean") {
|
157
|
+
final = false;
|
158
|
+
}
|
159
|
+
propertyDescriptors.writable = !final;
|
160
|
+
propertyDescriptors.configurable = false;
|
161
|
+
|
162
|
+
strategy = SearchContext.Proxy.new(Search.Graphs.BFS.Object
|
163
|
+
.new(structure));
|
164
|
+
strategy.research(callback);
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
168
|
+
|
169
|
+
if (!$module.esPhinx) {
|
170
|
+
|
171
|
+
Extender.extend($module, {
|
172
|
+
esPhinx: function(selector, context) {
|
173
|
+
var
|
174
|
+
parsed,
|
175
|
+
self = window.esPhinx,
|
176
|
+
mainReference = this,
|
177
|
+
collection = [],
|
178
|
+
|
179
|
+
callback = function(node) {
|
180
|
+
collection = collection.concat(Array
|
181
|
+
.from(node
|
182
|
+
.querySelectorAll(selector)))
|
183
|
+
.flatten();
|
184
|
+
},
|
185
|
+
|
186
|
+
hasElement = function(iterable) {
|
187
|
+
var
|
188
|
+
iterator,
|
189
|
+
response = false,
|
190
|
+
|
191
|
+
callback = function(object) {
|
192
|
+
if (object instanceof window.Element) {
|
193
|
+
this.finalize();
|
194
|
+
response = true;
|
195
|
+
}
|
196
|
+
};
|
197
|
+
|
198
|
+
iterator = Iterable.Proxy.new(iterable);
|
199
|
+
iterator.each(callback);
|
200
|
+
return response;
|
201
|
+
};
|
202
|
+
|
203
|
+
if (!(mainReference instanceof self)) {
|
204
|
+
return new self(selector, context);
|
205
|
+
}
|
206
|
+
|
207
|
+
context = resolveContext(context);
|
208
|
+
|
209
|
+
if (selector) {
|
210
|
+
if (selector instanceof self) {
|
211
|
+
return selector;
|
212
|
+
} else if (typeof selector == "function") {
|
213
|
+
// don't never pass a autoexecutable function as parameter
|
214
|
+
return window.document
|
215
|
+
.addEventListener("DOMContentLoaded",
|
216
|
+
function(e) {
|
217
|
+
selector.call(self, self, e);
|
218
|
+
});
|
219
|
+
// get children "".match(/(>)(<.(?=(<\/)))/)[0]
|
220
|
+
// add support to XPath
|
221
|
+
} else if (typeof selector == "string") {
|
222
|
+
parsed = (new window.DOMParser())
|
223
|
+
.parseFromString(selector, "text/html");
|
224
|
+
|
225
|
+
if (parsed.head.childElementCount) {
|
226
|
+
collection = Array.from(parsed.head
|
227
|
+
.childNodes);
|
228
|
+
} else {
|
229
|
+
collection = Array.from(parsed.body
|
230
|
+
.childNodes);
|
231
|
+
}
|
232
|
+
|
233
|
+
if (!hasElement(collection)) {
|
234
|
+
collection = [];
|
235
|
+
if (Iterable.isIterable(context)) {
|
236
|
+
Array.from(context)
|
237
|
+
.forEach(callback);
|
238
|
+
} else {
|
239
|
+
try {
|
240
|
+
collection = Array.from(context
|
241
|
+
.querySelectorAll(selector));
|
242
|
+
} catch (e) {}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
} else if (selector instanceof window.Node) {
|
246
|
+
collection = [selector];
|
247
|
+
} else if (selector instanceof Object) {
|
248
|
+
collection = Array.from(selector);
|
249
|
+
|
250
|
+
if (!Object.belongToClass(selector,
|
251
|
+
window.HTMLCollection) &&
|
252
|
+
collection.length) {
|
253
|
+
mainReference[0] = selector;
|
254
|
+
|
255
|
+
if (selector == window) {
|
256
|
+
collection = [];
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
Object.assign(mainReference, collection);
|
262
|
+
}
|
263
|
+
|
264
|
+
Extender.extend(mainReference, {
|
265
|
+
splice: Array.prototype.splice,
|
266
|
+
|
267
|
+
toString: function() {
|
268
|
+
return "[object " + NAME + "]";
|
269
|
+
}
|
270
|
+
});
|
271
|
+
|
272
|
+
Iterable.toIterable(mainReference);
|
273
|
+
|
274
|
+
return mainReference;
|
275
|
+
},
|
276
|
+
|
277
|
+
});
|
278
|
+
|
279
|
+
Extender.extend(esPhinx, {
|
280
|
+
Extender: {}
|
281
|
+
});
|
282
|
+
|
283
|
+
Extender.extend(esPhinx.Extender, {
|
284
|
+
extend: function(object, final, structure) {
|
285
|
+
Extender.extend(object, final, structure);
|
286
|
+
}
|
287
|
+
});
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
esPhinx.Extender.extend(esPhinx, true, {
|
292
|
+
extend: function() {
|
293
|
+
this.Extender.extend(this, arguments[0], arguments[1]);
|
294
|
+
}
|
295
|
+
});
|
296
|
+
|
297
|
+
esPhinx.Extender.extend(esPhinx.prototype, true, {
|
298
|
+
extend: function() {
|
299
|
+
esPhinx.Extender.extend(this, arguments[0], arguments[1]);
|
300
|
+
}
|
301
|
+
});
|
302
|
+
|
303
|
+
esPhinx.extend(true, {
|
304
|
+
|
305
|
+
selectByText: function(text, context) {
|
306
|
+
var
|
307
|
+
collection = [],
|
308
|
+
|
309
|
+
callback = function(element) {
|
310
|
+
collection = collection.concat(document.evaluate(
|
311
|
+
"descendant-or-self::*[normalize-space(text())='" +
|
312
|
+
text.trim() + "']", element).elements()).flatten();
|
313
|
+
};
|
314
|
+
|
315
|
+
this.select(this(resolveContext(context)), callback);
|
316
|
+
|
317
|
+
return esPhinx(collection);
|
318
|
+
},
|
319
|
+
|
320
|
+
isIterable: function(object) {
|
321
|
+
return Iterable.isIterable(object);
|
322
|
+
},
|
323
|
+
|
324
|
+
selectInBreadth: function(collection, callback) {
|
325
|
+
return selectInBreadth(collection, callback);
|
326
|
+
},
|
327
|
+
|
328
|
+
each: function(collection, startingIndex, finalIndex, callback) {
|
329
|
+
var
|
330
|
+
iterator = Iterable.Proxy.new(collection);
|
331
|
+
|
332
|
+
iterator.each(startingIndex, finalIndex, callback);
|
333
|
+
},
|
334
|
+
|
335
|
+
reverseEach: function(collection, startingIndex, callback) {
|
336
|
+
var
|
337
|
+
iterator = Iterable.Proxy.new(collection);
|
338
|
+
|
339
|
+
if (typeof startingIndex == "function") {
|
340
|
+
callback = startingIndex;
|
341
|
+
}
|
342
|
+
|
343
|
+
iterator.reverseEach(startingIndex, callback);
|
344
|
+
},
|
345
|
+
|
346
|
+
select: function(collection, callback) {
|
347
|
+
var
|
348
|
+
iterator = Iterable.Proxy.new(collection);
|
349
|
+
|
350
|
+
return iterator.select(callback);
|
351
|
+
}
|
352
|
+
|
353
|
+
});
|
354
|
+
|
355
|
+
})(window);
|
356
|
+
|
357
|
+
// recognize a element
|
358
|
+
// (^( *<)[a-z]+ *)( *((\/)|(>.*<\/[a-z]+))(> *)$)
|
359
|
+
|
360
|
+
// recognize attributes and values
|
361
|
+
// It's not possible capture attributes and their values, because their values can be given any character, which forces them to use ".+".
|