wpa_cli_web 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.bowerrc +3 -0
- data/lib/wpa_cli_web.rb +19 -31
- data/lib/wpa_cli_web/public/bower_components/house-style/.bower.json +14 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/.bowerrc +3 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/.gitignore +2 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/Gemfile +6 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/Gruntfile.js +99 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/Guardfile +19 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/bower.json +7 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/bower_components/normalize-css/LICENSE.md +19 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/bower_components/normalize-css/README.md +49 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/bower_components/normalize-css/bower.json +23 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/bower_components/normalize-css/normalize.css +396 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/house-style.css +860 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/house-style.min.css +1 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/base/base.css +37 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/button/button.css +26 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/grid/grid.css +151 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/grid/grid.png +0 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/grid/images.html +208 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/grid/index.html +141 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/loading/index.html +22 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/loading/loading.css +41 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/loading/spinner.svg +11 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/masthead/bbc-blocks-white.png +0 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/masthead/index.html +20 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/masthead/masthead.css +23 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/panel/panel.css +71 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/project-header/index.html +22 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/project-header/project-header.css +37 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/table/index.html +26 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/table/table.css +6 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/modules/transitions/transitions.css +11 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/package.json +21 -0
- data/lib/wpa_cli_web/public/bower_components/house-style/vendor/prefixfree.min.js +5 -0
- data/lib/wpa_cli_web/public/bower_components/normalize-css/.bower.json +21 -0
- data/lib/wpa_cli_web/public/bower_components/normalize-css/LICENSE.md +19 -0
- data/lib/wpa_cli_web/public/bower_components/normalize-css/README.md +49 -0
- data/lib/wpa_cli_web/public/bower_components/normalize-css/bower.json +12 -0
- data/lib/wpa_cli_web/public/bower_components/normalize-css/normalize.css +396 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/.bower.json +14 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/.gitignore +3 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/.travis.yml +10 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/LICENSE +7 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/Makefile +6 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/README.md +167 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/config/smoosh.json +35 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/integration/ender.js +1033 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/integration/integration.html +26 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/mobile/ender.js +62 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/mobile/package.json +14 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/mobile/qwery-mobile.js +79 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/mobile/qwery-mobile.min.js +7 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/mobile/src/mobile.js +72 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/package.json +25 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/pseudos/package.json +17 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/pseudos/qwery-pseudos.js +106 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/pseudos/qwery-pseudos.min.js +7 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/pseudos/src/pseudos.js +99 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/qwery.js +369 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/qwery.min.js +7 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/src/copyright.js +6 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/src/ender.js +62 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/src/qwery.js +362 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/W3C-Selector-tests.html +1372 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/benchmarks.html +220 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/index.html +132 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/mobile.html +58 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js +43 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/test-env.js +25 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/tests/tests.js +533 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/vendor/nw.js +1680 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/vendor/sink.css +79 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/vendor/sink.js +181 -0
- data/lib/wpa_cli_web/public/bower_components/qwery/vendor/sizzle.js +1400 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/.bower.json +14 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/.gitignore +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/.jshintrc +61 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/Makefile +8 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/README.md +308 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/build.json +74 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/make/tests.js +89 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/package.json +27 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/reqwest.js +565 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/reqwest.min.js +7 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/src/copyright.js +6 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/src/ender.js +26 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/src/reqwest.js +559 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/ender.js +117 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/badfixtures.xml +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures.html +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures.js +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures.json +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures.xml +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp2.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp3.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp_multi.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp_multi_b.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_jsonp_multi_c.jsonp +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/fixtures_with_prefix.json +1 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/fixtures/invalidJSON.json +5 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/tests.html +105 -0
- data/lib/wpa_cli_web/public/bower_components/reqwest/tests/tests.js +1723 -0
- data/lib/wpa_cli_web/views/access_points.erb +5 -0
- data/lib/wpa_cli_web/views/access_points_list.erb +19 -0
- data/lib/wpa_cli_web/views/layout.erb +141 -0
- data/lib/wpa_cli_web/views/networks_edit.erb +15 -0
- data/lib/wpa_cli_web/views/restart.erb +7 -0
- data/lib/wpa_cli_web/views/restarting.erb +14 -0
- data/wpa_cli_web.gemspec +1 -1
- metadata +111 -2
@@ -0,0 +1,369 @@
|
|
1
|
+
/*!
|
2
|
+
* @preserve Qwery - A Blazing Fast query selector engine
|
3
|
+
* https://github.com/ded/qwery
|
4
|
+
* copyright Dustin Diaz 2012
|
5
|
+
* MIT License
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function (name, context, definition) {
|
9
|
+
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
10
|
+
else if (typeof define == 'function' && define.amd) define(definition)
|
11
|
+
else context[name] = definition()
|
12
|
+
})('qwery', this, function () {
|
13
|
+
var doc = document
|
14
|
+
, html = doc.documentElement
|
15
|
+
, byClass = 'getElementsByClassName'
|
16
|
+
, byTag = 'getElementsByTagName'
|
17
|
+
, qSA = 'querySelectorAll'
|
18
|
+
, useNativeQSA = 'useNativeQSA'
|
19
|
+
, tagName = 'tagName'
|
20
|
+
, nodeType = 'nodeType'
|
21
|
+
, select // main select() method, assign later
|
22
|
+
|
23
|
+
, id = /#([\w\-]+)/
|
24
|
+
, clas = /\.[\w\-]+/g
|
25
|
+
, idOnly = /^#([\w\-]+)$/
|
26
|
+
, classOnly = /^\.([\w\-]+)$/
|
27
|
+
, tagOnly = /^([\w\-]+)$/
|
28
|
+
, tagAndOrClass = /^([\w]+)?\.([\w\-]+)$/
|
29
|
+
, splittable = /(^|,)\s*[>~+]/
|
30
|
+
, normalizr = /^\s+|\s*([,\s\+\~>]|$)\s*/g
|
31
|
+
, splitters = /[\s\>\+\~]/
|
32
|
+
, splittersMore = /(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/
|
33
|
+
, specialChars = /([.*+?\^=!:${}()|\[\]\/\\])/g
|
34
|
+
, simple = /^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/
|
35
|
+
, attr = /\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/
|
36
|
+
, pseudo = /:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/
|
37
|
+
, easy = new RegExp(idOnly.source + '|' + tagOnly.source + '|' + classOnly.source)
|
38
|
+
, dividers = new RegExp('(' + splitters.source + ')' + splittersMore.source, 'g')
|
39
|
+
, tokenizr = new RegExp(splitters.source + splittersMore.source)
|
40
|
+
, chunker = new RegExp(simple.source + '(' + attr.source + ')?' + '(' + pseudo.source + ')?')
|
41
|
+
|
42
|
+
var walker = {
|
43
|
+
' ': function (node) {
|
44
|
+
return node && node !== html && node.parentNode
|
45
|
+
}
|
46
|
+
, '>': function (node, contestant) {
|
47
|
+
return node && node.parentNode == contestant.parentNode && node.parentNode
|
48
|
+
}
|
49
|
+
, '~': function (node) {
|
50
|
+
return node && node.previousSibling
|
51
|
+
}
|
52
|
+
, '+': function (node, contestant, p1, p2) {
|
53
|
+
if (!node) return false
|
54
|
+
return (p1 = previous(node)) && (p2 = previous(contestant)) && p1 == p2 && p1
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
function cache() {
|
59
|
+
this.c = {}
|
60
|
+
}
|
61
|
+
cache.prototype = {
|
62
|
+
g: function (k) {
|
63
|
+
return this.c[k] || undefined
|
64
|
+
}
|
65
|
+
, s: function (k, v, r) {
|
66
|
+
v = r ? new RegExp(v) : v
|
67
|
+
return (this.c[k] = v)
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
var classCache = new cache()
|
72
|
+
, cleanCache = new cache()
|
73
|
+
, attrCache = new cache()
|
74
|
+
, tokenCache = new cache()
|
75
|
+
|
76
|
+
function classRegex(c) {
|
77
|
+
return classCache.g(c) || classCache.s(c, '(^|\\s+)' + c + '(\\s+|$)', 1)
|
78
|
+
}
|
79
|
+
|
80
|
+
// not quite as fast as inline loops in older browsers so don't use liberally
|
81
|
+
function each(a, fn) {
|
82
|
+
var i = 0, l = a.length
|
83
|
+
for (; i < l; i++) fn(a[i])
|
84
|
+
}
|
85
|
+
|
86
|
+
function flatten(ar) {
|
87
|
+
for (var r = [], i = 0, l = ar.length; i < l; ++i) arrayLike(ar[i]) ? (r = r.concat(ar[i])) : (r[r.length] = ar[i])
|
88
|
+
return r
|
89
|
+
}
|
90
|
+
|
91
|
+
function arrayify(ar) {
|
92
|
+
var i = 0, l = ar.length, r = []
|
93
|
+
for (; i < l; i++) r[i] = ar[i]
|
94
|
+
return r
|
95
|
+
}
|
96
|
+
|
97
|
+
function previous(n) {
|
98
|
+
while (n = n.previousSibling) if (n[nodeType] == 1) break;
|
99
|
+
return n
|
100
|
+
}
|
101
|
+
|
102
|
+
function q(query) {
|
103
|
+
return query.match(chunker)
|
104
|
+
}
|
105
|
+
|
106
|
+
// called using `this` as element and arguments from regex group results.
|
107
|
+
// given => div.hello[title="world"]:foo('bar')
|
108
|
+
// div.hello[title="world"]:foo('bar'), div, .hello, [title="world"], title, =, world, :foo('bar'), foo, ('bar'), bar]
|
109
|
+
function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value, wholePseudo, pseudo, wholePseudoVal, pseudoVal) {
|
110
|
+
var i, m, k, o, classes
|
111
|
+
if (this[nodeType] !== 1) return false
|
112
|
+
if (tag && tag !== '*' && this[tagName] && this[tagName].toLowerCase() !== tag) return false
|
113
|
+
if (idsAndClasses && (m = idsAndClasses.match(id)) && m[1] !== this.id) return false
|
114
|
+
if (idsAndClasses && (classes = idsAndClasses.match(clas))) {
|
115
|
+
for (i = classes.length; i--;) if (!classRegex(classes[i].slice(1)).test(this.className)) return false
|
116
|
+
}
|
117
|
+
if (pseudo && qwery.pseudos[pseudo] && !qwery.pseudos[pseudo](this, pseudoVal)) return false
|
118
|
+
if (wholeAttribute && !value) { // select is just for existance of attrib
|
119
|
+
o = this.attributes
|
120
|
+
for (k in o) {
|
121
|
+
if (Object.prototype.hasOwnProperty.call(o, k) && (o[k].name || k) == attribute) {
|
122
|
+
return this
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
if (wholeAttribute && !checkAttr(qualifier, getAttr(this, attribute) || '', value)) {
|
127
|
+
// select is for attrib equality
|
128
|
+
return false
|
129
|
+
}
|
130
|
+
return this
|
131
|
+
}
|
132
|
+
|
133
|
+
function clean(s) {
|
134
|
+
return cleanCache.g(s) || cleanCache.s(s, s.replace(specialChars, '\\$1'))
|
135
|
+
}
|
136
|
+
|
137
|
+
function checkAttr(qualify, actual, val) {
|
138
|
+
switch (qualify) {
|
139
|
+
case '=':
|
140
|
+
return actual == val
|
141
|
+
case '^=':
|
142
|
+
return actual.match(attrCache.g('^=' + val) || attrCache.s('^=' + val, '^' + clean(val), 1))
|
143
|
+
case '$=':
|
144
|
+
return actual.match(attrCache.g('$=' + val) || attrCache.s('$=' + val, clean(val) + '$', 1))
|
145
|
+
case '*=':
|
146
|
+
return actual.match(attrCache.g(val) || attrCache.s(val, clean(val), 1))
|
147
|
+
case '~=':
|
148
|
+
return actual.match(attrCache.g('~=' + val) || attrCache.s('~=' + val, '(?:^|\\s+)' + clean(val) + '(?:\\s+|$)', 1))
|
149
|
+
case '|=':
|
150
|
+
return actual.match(attrCache.g('|=' + val) || attrCache.s('|=' + val, '^' + clean(val) + '(-|$)', 1))
|
151
|
+
}
|
152
|
+
return 0
|
153
|
+
}
|
154
|
+
|
155
|
+
// given a selector, first check for simple cases then collect all base candidate matches and filter
|
156
|
+
function _qwery(selector, _root) {
|
157
|
+
var r = [], ret = [], i, l, m, token, tag, els, intr, item, root = _root
|
158
|
+
, tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
|
159
|
+
, dividedTokens = selector.match(dividers)
|
160
|
+
|
161
|
+
if (!tokens.length) return r
|
162
|
+
|
163
|
+
token = (tokens = tokens.slice(0)).pop() // copy cached tokens, take the last one
|
164
|
+
if (tokens.length && (m = tokens[tokens.length - 1].match(idOnly))) root = byId(_root, m[1])
|
165
|
+
if (!root) return r
|
166
|
+
|
167
|
+
intr = q(token)
|
168
|
+
// collect base candidates to filter
|
169
|
+
els = root !== _root && root[nodeType] !== 9 && dividedTokens && /^[+~]$/.test(dividedTokens[dividedTokens.length - 1]) ?
|
170
|
+
function (r) {
|
171
|
+
while (root = root.nextSibling) {
|
172
|
+
root[nodeType] == 1 && (intr[1] ? intr[1] == root[tagName].toLowerCase() : 1) && (r[r.length] = root)
|
173
|
+
}
|
174
|
+
return r
|
175
|
+
}([]) :
|
176
|
+
root[byTag](intr[1] || '*')
|
177
|
+
// filter elements according to the right-most part of the selector
|
178
|
+
for (i = 0, l = els.length; i < l; i++) {
|
179
|
+
if (item = interpret.apply(els[i], intr)) r[r.length] = item
|
180
|
+
}
|
181
|
+
if (!tokens.length) return r
|
182
|
+
|
183
|
+
// filter further according to the rest of the selector (the left side)
|
184
|
+
each(r, function (e) { if (ancestorMatch(e, tokens, dividedTokens)) ret[ret.length] = e })
|
185
|
+
return ret
|
186
|
+
}
|
187
|
+
|
188
|
+
// compare element to a selector
|
189
|
+
function is(el, selector, root) {
|
190
|
+
if (isNode(selector)) return el == selector
|
191
|
+
if (arrayLike(selector)) return !!~flatten(selector).indexOf(el) // if selector is an array, is el a member?
|
192
|
+
|
193
|
+
var selectors = selector.split(','), tokens, dividedTokens
|
194
|
+
while (selector = selectors.pop()) {
|
195
|
+
tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
|
196
|
+
dividedTokens = selector.match(dividers)
|
197
|
+
tokens = tokens.slice(0) // copy array
|
198
|
+
if (interpret.apply(el, q(tokens.pop())) && (!tokens.length || ancestorMatch(el, tokens, dividedTokens, root))) {
|
199
|
+
return true
|
200
|
+
}
|
201
|
+
}
|
202
|
+
return false
|
203
|
+
}
|
204
|
+
|
205
|
+
// given elements matching the right-most part of a selector, filter out any that don't match the rest
|
206
|
+
function ancestorMatch(el, tokens, dividedTokens, root) {
|
207
|
+
var cand
|
208
|
+
// recursively work backwards through the tokens and up the dom, covering all options
|
209
|
+
function crawl(e, i, p) {
|
210
|
+
while (p = walker[dividedTokens[i]](p, e)) {
|
211
|
+
if (isNode(p) && (interpret.apply(p, q(tokens[i])))) {
|
212
|
+
if (i) {
|
213
|
+
if (cand = crawl(p, i - 1, p)) return cand
|
214
|
+
} else return p
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root))
|
219
|
+
}
|
220
|
+
|
221
|
+
function isNode(el, t) {
|
222
|
+
return el && typeof el === 'object' && (t = el[nodeType]) && (t == 1 || t == 9)
|
223
|
+
}
|
224
|
+
|
225
|
+
function uniq(ar) {
|
226
|
+
var a = [], i, j;
|
227
|
+
o:
|
228
|
+
for (i = 0; i < ar.length; ++i) {
|
229
|
+
for (j = 0; j < a.length; ++j) if (a[j] == ar[i]) continue o
|
230
|
+
a[a.length] = ar[i]
|
231
|
+
}
|
232
|
+
return a
|
233
|
+
}
|
234
|
+
|
235
|
+
function arrayLike(o) {
|
236
|
+
return (typeof o === 'object' && isFinite(o.length))
|
237
|
+
}
|
238
|
+
|
239
|
+
function normalizeRoot(root) {
|
240
|
+
if (!root) return doc
|
241
|
+
if (typeof root == 'string') return qwery(root)[0]
|
242
|
+
if (!root[nodeType] && arrayLike(root)) return root[0]
|
243
|
+
return root
|
244
|
+
}
|
245
|
+
|
246
|
+
function byId(root, id, el) {
|
247
|
+
// if doc, query on it, else query the parent doc or if a detached fragment rewrite the query and run on the fragment
|
248
|
+
return root[nodeType] === 9 ? root.getElementById(id) :
|
249
|
+
root.ownerDocument &&
|
250
|
+
(((el = root.ownerDocument.getElementById(id)) && isAncestor(el, root) && el) ||
|
251
|
+
(!isAncestor(root, root.ownerDocument) && select('[id="' + id + '"]', root)[0]))
|
252
|
+
}
|
253
|
+
|
254
|
+
function qwery(selector, _root) {
|
255
|
+
var m, el, root = normalizeRoot(_root)
|
256
|
+
|
257
|
+
// easy, fast cases that we can dispatch with simple DOM calls
|
258
|
+
if (!root || !selector) return []
|
259
|
+
if (selector === window || isNode(selector)) {
|
260
|
+
return !_root || (selector !== window && isNode(root) && isAncestor(selector, root)) ? [selector] : []
|
261
|
+
}
|
262
|
+
if (selector && arrayLike(selector)) return flatten(selector)
|
263
|
+
if (m = selector.match(easy)) {
|
264
|
+
if (m[1]) return (el = byId(root, m[1])) ? [el] : []
|
265
|
+
if (m[2]) return arrayify(root[byTag](m[2]))
|
266
|
+
if (hasByClass && m[3]) return arrayify(root[byClass](m[3]))
|
267
|
+
}
|
268
|
+
|
269
|
+
return select(selector, root)
|
270
|
+
}
|
271
|
+
|
272
|
+
// where the root is not document and a relationship selector is first we have to
|
273
|
+
// do some awkward adjustments to get it to work, even with qSA
|
274
|
+
function collectSelector(root, collector) {
|
275
|
+
return function (s) {
|
276
|
+
var oid, nid
|
277
|
+
if (splittable.test(s)) {
|
278
|
+
if (root[nodeType] !== 9) {
|
279
|
+
// make sure the el has an id, rewrite the query, set root to doc and run it
|
280
|
+
if (!(nid = oid = root.getAttribute('id'))) root.setAttribute('id', nid = '__qwerymeupscotty')
|
281
|
+
s = '[id="' + nid + '"]' + s // avoid byId and allow us to match context element
|
282
|
+
collector(root.parentNode || root, s, true)
|
283
|
+
oid || root.removeAttribute('id')
|
284
|
+
}
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
s.length && collector(root, s, false)
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
var isAncestor = 'compareDocumentPosition' in html ?
|
292
|
+
function (element, container) {
|
293
|
+
return (container.compareDocumentPosition(element) & 16) == 16
|
294
|
+
} : 'contains' in html ?
|
295
|
+
function (element, container) {
|
296
|
+
container = container[nodeType] === 9 || container == window ? html : container
|
297
|
+
return container !== element && container.contains(element)
|
298
|
+
} :
|
299
|
+
function (element, container) {
|
300
|
+
while (element = element.parentNode) if (element === container) return 1
|
301
|
+
return 0
|
302
|
+
}
|
303
|
+
, getAttr = function () {
|
304
|
+
// detect buggy IE src/href getAttribute() call
|
305
|
+
var e = doc.createElement('p')
|
306
|
+
return ((e.innerHTML = '<a href="#x">x</a>') && e.firstChild.getAttribute('href') != '#x') ?
|
307
|
+
function (e, a) {
|
308
|
+
return a === 'class' ? e.className : (a === 'href' || a === 'src') ?
|
309
|
+
e.getAttribute(a, 2) : e.getAttribute(a)
|
310
|
+
} :
|
311
|
+
function (e, a) { return e.getAttribute(a) }
|
312
|
+
}()
|
313
|
+
, hasByClass = !!doc[byClass]
|
314
|
+
// has native qSA support
|
315
|
+
, hasQSA = doc.querySelector && doc[qSA]
|
316
|
+
// use native qSA
|
317
|
+
, selectQSA = function (selector, root) {
|
318
|
+
var result = [], ss, e
|
319
|
+
try {
|
320
|
+
if (root[nodeType] === 9 || !splittable.test(selector)) {
|
321
|
+
// most work is done right here, defer to qSA
|
322
|
+
return arrayify(root[qSA](selector))
|
323
|
+
}
|
324
|
+
// special case where we need the services of `collectSelector()`
|
325
|
+
each(ss = selector.split(','), collectSelector(root, function (ctx, s) {
|
326
|
+
e = ctx[qSA](s)
|
327
|
+
if (e.length == 1) result[result.length] = e.item(0)
|
328
|
+
else if (e.length) result = result.concat(arrayify(e))
|
329
|
+
}))
|
330
|
+
return ss.length > 1 && result.length > 1 ? uniq(result) : result
|
331
|
+
} catch (ex) { }
|
332
|
+
return selectNonNative(selector, root)
|
333
|
+
}
|
334
|
+
// no native selector support
|
335
|
+
, selectNonNative = function (selector, root) {
|
336
|
+
var result = [], items, m, i, l, r, ss
|
337
|
+
selector = selector.replace(normalizr, '$1')
|
338
|
+
if (m = selector.match(tagAndOrClass)) {
|
339
|
+
r = classRegex(m[2])
|
340
|
+
items = root[byTag](m[1] || '*')
|
341
|
+
for (i = 0, l = items.length; i < l; i++) {
|
342
|
+
if (r.test(items[i].className)) result[result.length] = items[i]
|
343
|
+
}
|
344
|
+
return result
|
345
|
+
}
|
346
|
+
// more complex selector, get `_qwery()` to do the work for us
|
347
|
+
each(ss = selector.split(','), collectSelector(root, function (ctx, s, rewrite) {
|
348
|
+
r = _qwery(s, ctx)
|
349
|
+
for (i = 0, l = r.length; i < l; i++) {
|
350
|
+
if (ctx[nodeType] === 9 || rewrite || isAncestor(r[i], root)) result[result.length] = r[i]
|
351
|
+
}
|
352
|
+
}))
|
353
|
+
return ss.length > 1 && result.length > 1 ? uniq(result) : result
|
354
|
+
}
|
355
|
+
, configure = function (options) {
|
356
|
+
// configNativeQSA: use fully-internal selector or native qSA where present
|
357
|
+
if (typeof options[useNativeQSA] !== 'undefined')
|
358
|
+
select = !options[useNativeQSA] ? selectNonNative : hasQSA ? selectQSA : selectNonNative
|
359
|
+
}
|
360
|
+
|
361
|
+
configure({ useNativeQSA: true })
|
362
|
+
|
363
|
+
qwery.configure = configure
|
364
|
+
qwery.uniq = uniq
|
365
|
+
qwery.is = is
|
366
|
+
qwery.pseudos = {}
|
367
|
+
|
368
|
+
return qwery
|
369
|
+
});
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* @preserve Qwery - A Blazing Fast query selector engine
|
3
|
+
* https://github.com/ded/qwery
|
4
|
+
* copyright Dustin Diaz 2012
|
5
|
+
* MIT License
|
6
|
+
*/
|
7
|
+
(function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("qwery",this,function(){function L(){this.c={}}function D(e){return A.g(e)||A.s(e,"(^|\\s+)"+e+"(\\s+|$)",1)}function P(e,t){var n=0,r=e.length;for(;n<r;n++)t(e[n])}function H(e){for(var t=[],n=0,r=e.length;n<r;++n)$(e[n])?t=t.concat(e[n]):t[t.length]=e[n];return t}function B(e){var t=0,n=e.length,r=[];for(;t<n;t++)r[t]=e[t];return r}function j(e){while(e=e.previousSibling)if(e[u]==1)break;return e}function F(e){return e.match(C)}function I(e,t,n,r,i,s,a,c,h,p,d){var v,m,g,y,b;if(this[u]!==1)return!1;if(t&&t!=="*"&&this[o]&&this[o].toLowerCase()!==t)return!1;if(n&&(m=n.match(f))&&m[1]!==this.id)return!1;if(n&&(b=n.match(l)))for(v=b.length;v--;)if(!D(b[v].slice(1)).test(this.className))return!1;if(h&&Q.pseudos[h]&&!Q.pseudos[h](this,d))return!1;if(r&&!a){y=this.attributes;for(g in y)if(Object.prototype.hasOwnProperty.call(y,g)&&(y[g].name||g)==i)return this}return r&&!R(s,Z(this,i)||"",a)?!1:this}function q(e){return O.g(e)||O.s(e,e.replace(b,"\\$1"))}function R(e,t,n){switch(e){case"=":return t==n;case"^=":return t.match(M.g("^="+n)||M.s("^="+n,"^"+q(n),1));case"$=":return t.match(M.g("$="+n)||M.s("$="+n,q(n)+"$",1));case"*=":return t.match(M.g(n)||M.s(n,q(n),1));case"~=":return t.match(M.g("~="+n)||M.s("~="+n,"(?:^|\\s+)"+q(n)+"(?:\\s+|$)",1));case"|=":return t.match(M.g("|="+n)||M.s("|="+n,"^"+q(n)+"(-|$)",1))}return 0}function U(e,t){var n=[],i=[],s,a,f,l,h,p,d,v,m=t,g=_.g(e)||_.s(e,e.split(N)),y=e.match(T);if(!g.length)return n;l=(g=g.slice(0)).pop(),g.length&&(f=g[g.length-1].match(c))&&(m=K(t,f[1]));if(!m)return n;d=F(l),p=m!==t&&m[u]!==9&&y&&/^[+~]$/.test(y[y.length-1])?function(e){while(m=m.nextSibling)m[u]==1&&(d[1]?d[1]==m[o].toLowerCase():1)&&(e[e.length]=m);return e}([]):m[r](d[1]||"*");for(s=0,a=p.length;s<a;s++)if(v=I.apply(p[s],d))n[n.length]=v;return g.length?(P(n,function(e){W(e,g,y)&&(i[i.length]=e)}),i):n}function z(e,t,n){if(X(t))return e==t;if($(t))return!!~H(t).indexOf(e);var r=t.split(","),i,s;while(t=r.pop()){i=_.g(t)||_.s(t,t.split(N)),s=t.match(T),i=i.slice(0);if(I.apply(e,F(i.pop()))&&(!i.length||W(e,i,s,n)))return!0}return!1}function W(e,t,n,r){function s(e,r,o){while(o=k[n[r]](o,e))if(X(o)&&I.apply(o,F(t[r]))){if(!r)return o;if(i=s(o,r-1,o))return i}}var i;return(i=s(e,t.length-1,e))&&(!r||Y(i,r))}function X(e,t){return e&&typeof e=="object"&&(t=e[u])&&(t==1||t==9)}function V(e){var t=[],n,r;e:for(n=0;n<e.length;++n){for(r=0;r<t.length;++r)if(t[r]==e[n])continue e;t[t.length]=e[n]}return t}function $(e){return typeof e=="object"&&isFinite(e.length)}function J(t){return t?typeof t=="string"?Q(t)[0]:!t[u]&&$(t)?t[0]:t:e}function K(e,t,n){return e[u]===9?e.getElementById(t):e.ownerDocument&&((n=e.ownerDocument.getElementById(t))&&Y(n,e)&&n||!Y(e,e.ownerDocument)&&a('[id="'+t+'"]',e)[0])}function Q(e,t){var i,s,o=J(t);if(!o||!e)return[];if(e===window||X(e))return!t||e!==window&&X(o)&&Y(e,o)?[e]:[];if(e&&$(e))return H(e);if(i=e.match(x)){if(i[1])return(s=K(o,i[1]))?[s]:[];if(i[2])return B(o[r](i[2]));if(et&&i[3])return B(o[n](i[3]))}return a(e,o)}function G(e,t){return function(n){var r,i;if(v.test(n)){e[u]!==9&&((i=r=e.getAttribute("id"))||e.setAttribute("id",i="__qwerymeupscotty"),n='[id="'+i+'"]'+n,t(e.parentNode||e,n,!0),r||e.removeAttribute("id"));return}n.length&&t(e,n,!1)}}var e=document,t=e.documentElement,n="getElementsByClassName",r="getElementsByTagName",i="querySelectorAll",s="useNativeQSA",o="tagName",u="nodeType",a,f=/#([\w\-]+)/,l=/\.[\w\-]+/g,c=/^#([\w\-]+)$/,h=/^\.([\w\-]+)$/,p=/^([\w\-]+)$/,d=/^([\w]+)?\.([\w\-]+)$/,v=/(^|,)\s*[>~+]/,m=/^\s+|\s*([,\s\+\~>]|$)\s*/g,g=/[\s\>\+\~]/,y=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,b=/([.*+?\^=!:${}()|\[\]\/\\])/g,w=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,E=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,S=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,x=new RegExp(c.source+"|"+p.source+"|"+h.source),T=new RegExp("("+g.source+")"+y.source,"g"),N=new RegExp(g.source+y.source),C=new RegExp(w.source+"("+E.source+")?"+"("+S.source+")?"),k={" ":function(e){return e&&e!==t&&e.parentNode},">":function(e,t){return e&&e.parentNode==t.parentNode&&e.parentNode},"~":function(e){return e&&e.previousSibling},"+":function(e,t,n,r){return e?(n=j(e))&&(r=j(t))&&n==r&&n:!1}};L.prototype={g:function(e){return this.c[e]||undefined},s:function(e,t,n){return t=n?new RegExp(t):t,this.c[e]=t}};var A=new L,O=new L,M=new L,_=new L,Y="compareDocumentPosition"in t?function(e,t){return(t.compareDocumentPosition(e)&16)==16}:"contains"in t?function(e,n){return n=n[u]===9||n==window?t:n,n!==e&&n.contains(e)}:function(e,t){while(e=e.parentNode)if(e===t)return 1;return 0},Z=function(){var t=e.createElement("p");return(t.innerHTML='<a href="#x">x</a>')&&t.firstChild.getAttribute("href")!="#x"?function(e,t){return t==="class"?e.className:t==="href"||t==="src"?e.getAttribute(t,2):e.getAttribute(t)}:function(e,t){return e.getAttribute(t)}}(),et=!!e[n],tt=e.querySelector&&e[i],nt=function(e,t){var n=[],r,s;try{return t[u]===9||!v.test(e)?B(t[i](e)):(P(r=e.split(","),G(t,function(e,t){s=e[i](t),s.length==1?n[n.length]=s.item(0):s.length&&(n=n.concat(B(s)))})),r.length>1&&n.length>1?V(n):n)}catch(o){}return rt(e,t)},rt=function(e,t){var n=[],i,s,o,a,f,l;e=e.replace(m,"$1");if(s=e.match(d)){f=D(s[2]),i=t[r](s[1]||"*");for(o=0,a=i.length;o<a;o++)f.test(i[o].className)&&(n[n.length]=i[o]);return n}return P(l=e.split(","),G(t,function(e,r,i){f=U(r,e);for(o=0,a=f.length;o<a;o++)if(e[u]===9||i||Y(f[o],t))n[n.length]=f[o]})),l.length>1&&n.length>1?V(n):n},it=function(e){typeof e[s]!="undefined"&&(a=e[s]?tt?nt:rt:rt)};return it({useNativeQSA:!0}),Q.configure=it,Q.uniq=V,Q.is=z,Q.pseudos={},Q})
|
@@ -0,0 +1,62 @@
|
|
1
|
+
(function ($) {
|
2
|
+
var q = function () {
|
3
|
+
var r
|
4
|
+
try {
|
5
|
+
r = require('qwery')
|
6
|
+
} catch (ex) {
|
7
|
+
r = require('qwery-mobile')
|
8
|
+
} finally {
|
9
|
+
return r
|
10
|
+
}
|
11
|
+
}()
|
12
|
+
|
13
|
+
$.pseudos = q.pseudos
|
14
|
+
|
15
|
+
$._select = function (s, r) {
|
16
|
+
// detect if sibling module 'bonzo' is available at run-time
|
17
|
+
// rather than load-time since technically it's not a dependency and
|
18
|
+
// can be loaded in any order
|
19
|
+
// hence the lazy function re-definition
|
20
|
+
return ($._select = (function () {
|
21
|
+
var b
|
22
|
+
if (typeof $.create == 'function') return function (s, r) {
|
23
|
+
return /^\s*</.test(s) ? $.create(s, r) : q(s, r)
|
24
|
+
}
|
25
|
+
try {
|
26
|
+
b = require('bonzo')
|
27
|
+
return function (s, r) {
|
28
|
+
return /^\s*</.test(s) ? b.create(s, r) : q(s, r)
|
29
|
+
}
|
30
|
+
} catch (e) { }
|
31
|
+
return q
|
32
|
+
})())(s, r)
|
33
|
+
}
|
34
|
+
|
35
|
+
$.ender({
|
36
|
+
find: function (s) {
|
37
|
+
var r = [], i, l, j, k, els
|
38
|
+
for (i = 0, l = this.length; i < l; i++) {
|
39
|
+
els = q(s, this[i])
|
40
|
+
for (j = 0, k = els.length; j < k; j++) r.push(els[j])
|
41
|
+
}
|
42
|
+
return $(q.uniq(r))
|
43
|
+
}
|
44
|
+
, and: function (s) {
|
45
|
+
var plus = $(s)
|
46
|
+
for (var i = this.length, j = 0, l = this.length + plus.length; i < l; i++, j++) {
|
47
|
+
this[i] = plus[j]
|
48
|
+
}
|
49
|
+
this.length += plus.length
|
50
|
+
return this
|
51
|
+
}
|
52
|
+
, is: function(s, r) {
|
53
|
+
var i, l
|
54
|
+
for (i = 0, l = this.length; i < l; i++) {
|
55
|
+
if (q.is(this[i], s, r)) {
|
56
|
+
return true
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return false
|
60
|
+
}
|
61
|
+
}, true)
|
62
|
+
}(ender));
|
@@ -0,0 +1,362 @@
|
|
1
|
+
(function (name, context, definition) {
|
2
|
+
if (typeof module != 'undefined' && module.exports) module.exports = definition()
|
3
|
+
else if (typeof define == 'function' && define.amd) define(definition)
|
4
|
+
else context[name] = definition()
|
5
|
+
})('qwery', this, function () {
|
6
|
+
var doc = document
|
7
|
+
, html = doc.documentElement
|
8
|
+
, byClass = 'getElementsByClassName'
|
9
|
+
, byTag = 'getElementsByTagName'
|
10
|
+
, qSA = 'querySelectorAll'
|
11
|
+
, useNativeQSA = 'useNativeQSA'
|
12
|
+
, tagName = 'tagName'
|
13
|
+
, nodeType = 'nodeType'
|
14
|
+
, select // main select() method, assign later
|
15
|
+
|
16
|
+
, id = /#([\w\-]+)/
|
17
|
+
, clas = /\.[\w\-]+/g
|
18
|
+
, idOnly = /^#([\w\-]+)$/
|
19
|
+
, classOnly = /^\.([\w\-]+)$/
|
20
|
+
, tagOnly = /^([\w\-]+)$/
|
21
|
+
, tagAndOrClass = /^([\w]+)?\.([\w\-]+)$/
|
22
|
+
, splittable = /(^|,)\s*[>~+]/
|
23
|
+
, normalizr = /^\s+|\s*([,\s\+\~>]|$)\s*/g
|
24
|
+
, splitters = /[\s\>\+\~]/
|
25
|
+
, splittersMore = /(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/
|
26
|
+
, specialChars = /([.*+?\^=!:${}()|\[\]\/\\])/g
|
27
|
+
, simple = /^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/
|
28
|
+
, attr = /\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/
|
29
|
+
, pseudo = /:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/
|
30
|
+
, easy = new RegExp(idOnly.source + '|' + tagOnly.source + '|' + classOnly.source)
|
31
|
+
, dividers = new RegExp('(' + splitters.source + ')' + splittersMore.source, 'g')
|
32
|
+
, tokenizr = new RegExp(splitters.source + splittersMore.source)
|
33
|
+
, chunker = new RegExp(simple.source + '(' + attr.source + ')?' + '(' + pseudo.source + ')?')
|
34
|
+
|
35
|
+
var walker = {
|
36
|
+
' ': function (node) {
|
37
|
+
return node && node !== html && node.parentNode
|
38
|
+
}
|
39
|
+
, '>': function (node, contestant) {
|
40
|
+
return node && node.parentNode == contestant.parentNode && node.parentNode
|
41
|
+
}
|
42
|
+
, '~': function (node) {
|
43
|
+
return node && node.previousSibling
|
44
|
+
}
|
45
|
+
, '+': function (node, contestant, p1, p2) {
|
46
|
+
if (!node) return false
|
47
|
+
return (p1 = previous(node)) && (p2 = previous(contestant)) && p1 == p2 && p1
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
function cache() {
|
52
|
+
this.c = {}
|
53
|
+
}
|
54
|
+
cache.prototype = {
|
55
|
+
g: function (k) {
|
56
|
+
return this.c[k] || undefined
|
57
|
+
}
|
58
|
+
, s: function (k, v, r) {
|
59
|
+
v = r ? new RegExp(v) : v
|
60
|
+
return (this.c[k] = v)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
var classCache = new cache()
|
65
|
+
, cleanCache = new cache()
|
66
|
+
, attrCache = new cache()
|
67
|
+
, tokenCache = new cache()
|
68
|
+
|
69
|
+
function classRegex(c) {
|
70
|
+
return classCache.g(c) || classCache.s(c, '(^|\\s+)' + c + '(\\s+|$)', 1)
|
71
|
+
}
|
72
|
+
|
73
|
+
// not quite as fast as inline loops in older browsers so don't use liberally
|
74
|
+
function each(a, fn) {
|
75
|
+
var i = 0, l = a.length
|
76
|
+
for (; i < l; i++) fn(a[i])
|
77
|
+
}
|
78
|
+
|
79
|
+
function flatten(ar) {
|
80
|
+
for (var r = [], i = 0, l = ar.length; i < l; ++i) arrayLike(ar[i]) ? (r = r.concat(ar[i])) : (r[r.length] = ar[i])
|
81
|
+
return r
|
82
|
+
}
|
83
|
+
|
84
|
+
function arrayify(ar) {
|
85
|
+
var i = 0, l = ar.length, r = []
|
86
|
+
for (; i < l; i++) r[i] = ar[i]
|
87
|
+
return r
|
88
|
+
}
|
89
|
+
|
90
|
+
function previous(n) {
|
91
|
+
while (n = n.previousSibling) if (n[nodeType] == 1) break;
|
92
|
+
return n
|
93
|
+
}
|
94
|
+
|
95
|
+
function q(query) {
|
96
|
+
return query.match(chunker)
|
97
|
+
}
|
98
|
+
|
99
|
+
// called using `this` as element and arguments from regex group results.
|
100
|
+
// given => div.hello[title="world"]:foo('bar')
|
101
|
+
// div.hello[title="world"]:foo('bar'), div, .hello, [title="world"], title, =, world, :foo('bar'), foo, ('bar'), bar]
|
102
|
+
function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value, wholePseudo, pseudo, wholePseudoVal, pseudoVal) {
|
103
|
+
var i, m, k, o, classes
|
104
|
+
if (this[nodeType] !== 1) return false
|
105
|
+
if (tag && tag !== '*' && this[tagName] && this[tagName].toLowerCase() !== tag) return false
|
106
|
+
if (idsAndClasses && (m = idsAndClasses.match(id)) && m[1] !== this.id) return false
|
107
|
+
if (idsAndClasses && (classes = idsAndClasses.match(clas))) {
|
108
|
+
for (i = classes.length; i--;) if (!classRegex(classes[i].slice(1)).test(this.className)) return false
|
109
|
+
}
|
110
|
+
if (pseudo && qwery.pseudos[pseudo] && !qwery.pseudos[pseudo](this, pseudoVal)) return false
|
111
|
+
if (wholeAttribute && !value) { // select is just for existance of attrib
|
112
|
+
o = this.attributes
|
113
|
+
for (k in o) {
|
114
|
+
if (Object.prototype.hasOwnProperty.call(o, k) && (o[k].name || k) == attribute) {
|
115
|
+
return this
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
if (wholeAttribute && !checkAttr(qualifier, getAttr(this, attribute) || '', value)) {
|
120
|
+
// select is for attrib equality
|
121
|
+
return false
|
122
|
+
}
|
123
|
+
return this
|
124
|
+
}
|
125
|
+
|
126
|
+
function clean(s) {
|
127
|
+
return cleanCache.g(s) || cleanCache.s(s, s.replace(specialChars, '\\$1'))
|
128
|
+
}
|
129
|
+
|
130
|
+
function checkAttr(qualify, actual, val) {
|
131
|
+
switch (qualify) {
|
132
|
+
case '=':
|
133
|
+
return actual == val
|
134
|
+
case '^=':
|
135
|
+
return actual.match(attrCache.g('^=' + val) || attrCache.s('^=' + val, '^' + clean(val), 1))
|
136
|
+
case '$=':
|
137
|
+
return actual.match(attrCache.g('$=' + val) || attrCache.s('$=' + val, clean(val) + '$', 1))
|
138
|
+
case '*=':
|
139
|
+
return actual.match(attrCache.g(val) || attrCache.s(val, clean(val), 1))
|
140
|
+
case '~=':
|
141
|
+
return actual.match(attrCache.g('~=' + val) || attrCache.s('~=' + val, '(?:^|\\s+)' + clean(val) + '(?:\\s+|$)', 1))
|
142
|
+
case '|=':
|
143
|
+
return actual.match(attrCache.g('|=' + val) || attrCache.s('|=' + val, '^' + clean(val) + '(-|$)', 1))
|
144
|
+
}
|
145
|
+
return 0
|
146
|
+
}
|
147
|
+
|
148
|
+
// given a selector, first check for simple cases then collect all base candidate matches and filter
|
149
|
+
function _qwery(selector, _root) {
|
150
|
+
var r = [], ret = [], i, l, m, token, tag, els, intr, item, root = _root
|
151
|
+
, tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
|
152
|
+
, dividedTokens = selector.match(dividers)
|
153
|
+
|
154
|
+
if (!tokens.length) return r
|
155
|
+
|
156
|
+
token = (tokens = tokens.slice(0)).pop() // copy cached tokens, take the last one
|
157
|
+
if (tokens.length && (m = tokens[tokens.length - 1].match(idOnly))) root = byId(_root, m[1])
|
158
|
+
if (!root) return r
|
159
|
+
|
160
|
+
intr = q(token)
|
161
|
+
// collect base candidates to filter
|
162
|
+
els = root !== _root && root[nodeType] !== 9 && dividedTokens && /^[+~]$/.test(dividedTokens[dividedTokens.length - 1]) ?
|
163
|
+
function (r) {
|
164
|
+
while (root = root.nextSibling) {
|
165
|
+
root[nodeType] == 1 && (intr[1] ? intr[1] == root[tagName].toLowerCase() : 1) && (r[r.length] = root)
|
166
|
+
}
|
167
|
+
return r
|
168
|
+
}([]) :
|
169
|
+
root[byTag](intr[1] || '*')
|
170
|
+
// filter elements according to the right-most part of the selector
|
171
|
+
for (i = 0, l = els.length; i < l; i++) {
|
172
|
+
if (item = interpret.apply(els[i], intr)) r[r.length] = item
|
173
|
+
}
|
174
|
+
if (!tokens.length) return r
|
175
|
+
|
176
|
+
// filter further according to the rest of the selector (the left side)
|
177
|
+
each(r, function (e) { if (ancestorMatch(e, tokens, dividedTokens)) ret[ret.length] = e })
|
178
|
+
return ret
|
179
|
+
}
|
180
|
+
|
181
|
+
// compare element to a selector
|
182
|
+
function is(el, selector, root) {
|
183
|
+
if (isNode(selector)) return el == selector
|
184
|
+
if (arrayLike(selector)) return !!~flatten(selector).indexOf(el) // if selector is an array, is el a member?
|
185
|
+
|
186
|
+
var selectors = selector.split(','), tokens, dividedTokens
|
187
|
+
while (selector = selectors.pop()) {
|
188
|
+
tokens = tokenCache.g(selector) || tokenCache.s(selector, selector.split(tokenizr))
|
189
|
+
dividedTokens = selector.match(dividers)
|
190
|
+
tokens = tokens.slice(0) // copy array
|
191
|
+
if (interpret.apply(el, q(tokens.pop())) && (!tokens.length || ancestorMatch(el, tokens, dividedTokens, root))) {
|
192
|
+
return true
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return false
|
196
|
+
}
|
197
|
+
|
198
|
+
// given elements matching the right-most part of a selector, filter out any that don't match the rest
|
199
|
+
function ancestorMatch(el, tokens, dividedTokens, root) {
|
200
|
+
var cand
|
201
|
+
// recursively work backwards through the tokens and up the dom, covering all options
|
202
|
+
function crawl(e, i, p) {
|
203
|
+
while (p = walker[dividedTokens[i]](p, e)) {
|
204
|
+
if (isNode(p) && (interpret.apply(p, q(tokens[i])))) {
|
205
|
+
if (i) {
|
206
|
+
if (cand = crawl(p, i - 1, p)) return cand
|
207
|
+
} else return p
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root))
|
212
|
+
}
|
213
|
+
|
214
|
+
function isNode(el, t) {
|
215
|
+
return el && typeof el === 'object' && (t = el[nodeType]) && (t == 1 || t == 9)
|
216
|
+
}
|
217
|
+
|
218
|
+
function uniq(ar) {
|
219
|
+
var a = [], i, j;
|
220
|
+
o:
|
221
|
+
for (i = 0; i < ar.length; ++i) {
|
222
|
+
for (j = 0; j < a.length; ++j) if (a[j] == ar[i]) continue o
|
223
|
+
a[a.length] = ar[i]
|
224
|
+
}
|
225
|
+
return a
|
226
|
+
}
|
227
|
+
|
228
|
+
function arrayLike(o) {
|
229
|
+
return (typeof o === 'object' && isFinite(o.length))
|
230
|
+
}
|
231
|
+
|
232
|
+
function normalizeRoot(root) {
|
233
|
+
if (!root) return doc
|
234
|
+
if (typeof root == 'string') return qwery(root)[0]
|
235
|
+
if (!root[nodeType] && arrayLike(root)) return root[0]
|
236
|
+
return root
|
237
|
+
}
|
238
|
+
|
239
|
+
function byId(root, id, el) {
|
240
|
+
// if doc, query on it, else query the parent doc or if a detached fragment rewrite the query and run on the fragment
|
241
|
+
return root[nodeType] === 9 ? root.getElementById(id) :
|
242
|
+
root.ownerDocument &&
|
243
|
+
(((el = root.ownerDocument.getElementById(id)) && isAncestor(el, root) && el) ||
|
244
|
+
(!isAncestor(root, root.ownerDocument) && select('[id="' + id + '"]', root)[0]))
|
245
|
+
}
|
246
|
+
|
247
|
+
function qwery(selector, _root) {
|
248
|
+
var m, el, root = normalizeRoot(_root)
|
249
|
+
|
250
|
+
// easy, fast cases that we can dispatch with simple DOM calls
|
251
|
+
if (!root || !selector) return []
|
252
|
+
if (selector === window || isNode(selector)) {
|
253
|
+
return !_root || (selector !== window && isNode(root) && isAncestor(selector, root)) ? [selector] : []
|
254
|
+
}
|
255
|
+
if (selector && arrayLike(selector)) return flatten(selector)
|
256
|
+
if (m = selector.match(easy)) {
|
257
|
+
if (m[1]) return (el = byId(root, m[1])) ? [el] : []
|
258
|
+
if (m[2]) return arrayify(root[byTag](m[2]))
|
259
|
+
if (hasByClass && m[3]) return arrayify(root[byClass](m[3]))
|
260
|
+
}
|
261
|
+
|
262
|
+
return select(selector, root)
|
263
|
+
}
|
264
|
+
|
265
|
+
// where the root is not document and a relationship selector is first we have to
|
266
|
+
// do some awkward adjustments to get it to work, even with qSA
|
267
|
+
function collectSelector(root, collector) {
|
268
|
+
return function (s) {
|
269
|
+
var oid, nid
|
270
|
+
if (splittable.test(s)) {
|
271
|
+
if (root[nodeType] !== 9) {
|
272
|
+
// make sure the el has an id, rewrite the query, set root to doc and run it
|
273
|
+
if (!(nid = oid = root.getAttribute('id'))) root.setAttribute('id', nid = '__qwerymeupscotty')
|
274
|
+
s = '[id="' + nid + '"]' + s // avoid byId and allow us to match context element
|
275
|
+
collector(root.parentNode || root, s, true)
|
276
|
+
oid || root.removeAttribute('id')
|
277
|
+
}
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
s.length && collector(root, s, false)
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
var isAncestor = 'compareDocumentPosition' in html ?
|
285
|
+
function (element, container) {
|
286
|
+
return (container.compareDocumentPosition(element) & 16) == 16
|
287
|
+
} : 'contains' in html ?
|
288
|
+
function (element, container) {
|
289
|
+
container = container[nodeType] === 9 || container == window ? html : container
|
290
|
+
return container !== element && container.contains(element)
|
291
|
+
} :
|
292
|
+
function (element, container) {
|
293
|
+
while (element = element.parentNode) if (element === container) return 1
|
294
|
+
return 0
|
295
|
+
}
|
296
|
+
, getAttr = function () {
|
297
|
+
// detect buggy IE src/href getAttribute() call
|
298
|
+
var e = doc.createElement('p')
|
299
|
+
return ((e.innerHTML = '<a href="#x">x</a>') && e.firstChild.getAttribute('href') != '#x') ?
|
300
|
+
function (e, a) {
|
301
|
+
return a === 'class' ? e.className : (a === 'href' || a === 'src') ?
|
302
|
+
e.getAttribute(a, 2) : e.getAttribute(a)
|
303
|
+
} :
|
304
|
+
function (e, a) { return e.getAttribute(a) }
|
305
|
+
}()
|
306
|
+
, hasByClass = !!doc[byClass]
|
307
|
+
// has native qSA support
|
308
|
+
, hasQSA = doc.querySelector && doc[qSA]
|
309
|
+
// use native qSA
|
310
|
+
, selectQSA = function (selector, root) {
|
311
|
+
var result = [], ss, e
|
312
|
+
try {
|
313
|
+
if (root[nodeType] === 9 || !splittable.test(selector)) {
|
314
|
+
// most work is done right here, defer to qSA
|
315
|
+
return arrayify(root[qSA](selector))
|
316
|
+
}
|
317
|
+
// special case where we need the services of `collectSelector()`
|
318
|
+
each(ss = selector.split(','), collectSelector(root, function (ctx, s) {
|
319
|
+
e = ctx[qSA](s)
|
320
|
+
if (e.length == 1) result[result.length] = e.item(0)
|
321
|
+
else if (e.length) result = result.concat(arrayify(e))
|
322
|
+
}))
|
323
|
+
return ss.length > 1 && result.length > 1 ? uniq(result) : result
|
324
|
+
} catch (ex) { }
|
325
|
+
return selectNonNative(selector, root)
|
326
|
+
}
|
327
|
+
// no native selector support
|
328
|
+
, selectNonNative = function (selector, root) {
|
329
|
+
var result = [], items, m, i, l, r, ss
|
330
|
+
selector = selector.replace(normalizr, '$1')
|
331
|
+
if (m = selector.match(tagAndOrClass)) {
|
332
|
+
r = classRegex(m[2])
|
333
|
+
items = root[byTag](m[1] || '*')
|
334
|
+
for (i = 0, l = items.length; i < l; i++) {
|
335
|
+
if (r.test(items[i].className)) result[result.length] = items[i]
|
336
|
+
}
|
337
|
+
return result
|
338
|
+
}
|
339
|
+
// more complex selector, get `_qwery()` to do the work for us
|
340
|
+
each(ss = selector.split(','), collectSelector(root, function (ctx, s, rewrite) {
|
341
|
+
r = _qwery(s, ctx)
|
342
|
+
for (i = 0, l = r.length; i < l; i++) {
|
343
|
+
if (ctx[nodeType] === 9 || rewrite || isAncestor(r[i], root)) result[result.length] = r[i]
|
344
|
+
}
|
345
|
+
}))
|
346
|
+
return ss.length > 1 && result.length > 1 ? uniq(result) : result
|
347
|
+
}
|
348
|
+
, configure = function (options) {
|
349
|
+
// configNativeQSA: use fully-internal selector or native qSA where present
|
350
|
+
if (typeof options[useNativeQSA] !== 'undefined')
|
351
|
+
select = !options[useNativeQSA] ? selectNonNative : hasQSA ? selectQSA : selectNonNative
|
352
|
+
}
|
353
|
+
|
354
|
+
configure({ useNativeQSA: true })
|
355
|
+
|
356
|
+
qwery.configure = configure
|
357
|
+
qwery.uniq = uniq
|
358
|
+
qwery.is = is
|
359
|
+
qwery.pseudos = {}
|
360
|
+
|
361
|
+
return qwery
|
362
|
+
});
|