author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-03-17 21:08:23 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-03-17 21:08:23 (UTC) |
commit | 928f3f3ed3981f7f81b69ed94f2a315205db39fa (patch) (unidiff) | |
tree | 8a47229b56e4c906de8512baf0c5ca100bc03dfb /frontend/gamma/js/MochiKit/Selector.js | |
parent | bf7d8191a3a6dbd092a88911098a3e7f6cf30cf7 (diff) | |
download | clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.zip clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.gz clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.bz2 |
Fixed frontend properties and updated MochiKit version
Diffstat (limited to 'frontend/gamma/js/MochiKit/Selector.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/Selector.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/frontend/gamma/js/MochiKit/Selector.js b/frontend/gamma/js/MochiKit/Selector.js index 6aec892..3187fe9 100644 --- a/frontend/gamma/js/MochiKit/Selector.js +++ b/frontend/gamma/js/MochiKit/Selector.js | |||
@@ -3,17 +3,17 @@ | |||
3 | MochiKit.Selector 1.5 | 3 | MochiKit.Selector 1.5 |
4 | 4 | ||
5 | See <http://mochikit.com/> for documentation, downloads, license, etc. | 5 | See <http://mochikit.com/> for documentation, downloads, license, etc. |
6 | 6 | ||
7 | (c) 2005 Bob Ippolito and others. All rights Reserved. | 7 | (c) 2005 Bob Ippolito and others. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Selector', '1.5', ['Base', 'DOM', 'Iter']); | 11 | MochiKit.Base.module(MochiKit, 'Selector', '1.5', ['Base', 'DOM', 'Iter']); |
12 | 12 | ||
13 | MochiKit.Selector.Selector = function (expression) { | 13 | MochiKit.Selector.Selector = function (expression) { |
14 | this.params = {classNames: [], pseudoClassNames: []}; | 14 | this.params = {classNames: [], pseudoClassNames: []}; |
15 | this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); | 15 | this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); |
16 | this.parseExpression(); | 16 | this.parseExpression(); |
17 | this.compileMatcher(); | 17 | this.compileMatcher(); |
18 | }; | 18 | }; |
19 | 19 | ||
@@ -122,18 +122,18 @@ MochiKit.Selector.Selector.prototype = { | |||
122 | var a, b; | 122 | var a, b; |
123 | if (match[0] == 'odd') { | 123 | if (match[0] == 'odd') { |
124 | a = 2; | 124 | a = 2; |
125 | b = 1; | 125 | b = 1; |
126 | } else if (match[0] == 'even') { | 126 | } else if (match[0] == 'even') { |
127 | a = 2; | 127 | a = 2; |
128 | b = 0; | 128 | b = 0; |
129 | } else { | 129 | } else { |
130 | a = match[2] && parseInt(match) || null; | 130 | a = match[2] && parseInt(match, 10) || null; |
131 | b = parseInt(match[3]); | 131 | b = parseInt(match[3], 10); |
132 | } | 132 | } |
133 | conditions.push('this.nthChild(element,' + a + ',' + b | 133 | conditions.push('this.nthChild(element,' + a + ',' + b |
134 | + ',' + !!pseudoClass.match('^nth-last') // Reverse | 134 | + ',' + !!pseudoClass.match('^nth-last') // Reverse |
135 | + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName | 135 | + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName |
136 | + ')'); | 136 | + ')'); |
137 | break; | 137 | break; |
138 | case 'first-child': | 138 | case 'first-child': |
139 | conditions.push('this.nthChild(element, null, 1)'); | 139 | conditions.push('this.nthChild(element, null, 1)'); |
@@ -162,27 +162,27 @@ MochiKit.Selector.Selector.prototype = { | |||
162 | case 'disabled': | 162 | case 'disabled': |
163 | conditions.push('(this.isUIElement(element) && element.disabled === true)'); | 163 | conditions.push('(this.isUIElement(element) && element.disabled === true)'); |
164 | break; | 164 | break; |
165 | case 'checked': | 165 | case 'checked': |
166 | conditions.push('(this.isUIElement(element) && element.checked === true)'); | 166 | conditions.push('(this.isUIElement(element) && element.checked === true)'); |
167 | break; | 167 | break; |
168 | case 'not': | 168 | case 'not': |
169 | var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); | 169 | var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); |
170 | conditions.push('!( ' + subselector.buildMatchExpression() + ')') | 170 | conditions.push('!( ' + subselector.buildMatchExpression() + ')'); |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
175 | if (clause = params.attributes) { | 175 | if (clause = params.attributes) { |
176 | MochiKit.Base.map(function (attribute) { | 176 | MochiKit.Base.map(function (attribute) { |
177 | var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; | 177 | var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; |
178 | var splitValueBy = function (delimiter) { | 178 | var splitValueBy = function (delimiter) { |
179 | return value + '.split(' + repr(delimiter) + ')'; | 179 | return value + '.split(' + repr(delimiter) + ')'; |
180 | } | 180 | }; |
181 | conditions.push(value + ' != null'); | 181 | conditions.push(value + ' != null'); |
182 | switch (attribute.operator) { | 182 | switch (attribute.operator) { |
183 | case '=': | 183 | case '=': |
184 | conditions.push(value + ' == ' + repr(attribute.value)); | 184 | conditions.push(value + ' == ' + repr(attribute.value)); |
185 | break; | 185 | break; |
186 | case '~=': | 186 | case '~=': |
187 | conditions.push('MochiKit.Base.findValue(' + splitValueBy(' ') + ', ' + repr(attribute.value) + ') > -1'); | 187 | conditions.push('MochiKit.Base.findValue(' + splitValueBy(' ') + ', ' + repr(attribute.value) + ') > -1'); |
188 | break; | 188 | break; |
@@ -347,16 +347,22 @@ MochiKit.Base.update(MochiKit.Selector, { | |||
347 | for (var i = 0; i < arr.length; i++) { | 347 | for (var i = 0; i < arr.length; i++) { |
348 | if (MochiKit.Base.findIdentical(res, arr[i]) < 0) { | 348 | if (MochiKit.Base.findIdentical(res, arr[i]) < 0) { |
349 | res.push(arr[i]); | 349 | res.push(arr[i]); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | return res; | 352 | return res; |
353 | }; | 353 | }; |
354 | return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { | 354 | return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { |
355 | try { | ||
356 | var res = element.querySelectorAll(expression); | ||
357 | return Array.prototype.slice.call(res, 0); | ||
358 | } catch (ignore) { | ||
359 | // No querySelectorAll or extended expression syntax used | ||
360 | } | ||
355 | var nextScope = ""; | 361 | var nextScope = ""; |
356 | var reducer = function (results, expr) { | 362 | var reducer = function (results, expr) { |
357 | var match = expr.match(/^[>+~]$/); | 363 | var match = expr.match(/^[>+~]$/); |
358 | if (match) { | 364 | if (match) { |
359 | nextScope = match[0]; | 365 | nextScope = match[0]; |
360 | return results; | 366 | return results; |
361 | } else { | 367 | } else { |
362 | var selector = new MochiKit.Selector.Selector(expr); | 368 | var selector = new MochiKit.Selector.Selector(expr); |