opal-rails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +57 -7
- data/lib/assets/javascripts/rquery.js +3 -0
- data/lib/assets/javascripts/rquery/document.js.opal +100 -0
- data/lib/assets/javascripts/rquery/element.js.opal +361 -0
- data/lib/assets/javascripts/rquery/sizzle.js +1442 -0
- data/lib/opal-rails.rb +1 -0
- data/lib/opal/rails/haml_filter.rb +24 -0
- data/lib/opal/rails/version.rb +1 -1
- metadata +15 -10
@@ -0,0 +1,1442 @@
|
|
1
|
+
/*!
|
2
|
+
* Sizzle CSS Selector Engine
|
3
|
+
* Copyright 2011, The Dojo Foundation
|
4
|
+
* Released under the MIT, BSD, and GPL Licenses.
|
5
|
+
* More information: http://sizzlejs.com/
|
6
|
+
*/
|
7
|
+
(function(){
|
8
|
+
|
9
|
+
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
|
10
|
+
expando = "sizcache" + (Math.random() + '').replace('.', ''),
|
11
|
+
done = 0,
|
12
|
+
toString = Object.prototype.toString,
|
13
|
+
hasDuplicate = false,
|
14
|
+
baseHasDuplicate = true,
|
15
|
+
rBackslash = /\\/g,
|
16
|
+
rNonWord = /\W/;
|
17
|
+
|
18
|
+
// Here we check if the JavaScript engine is using some sort of
|
19
|
+
// optimization where it does not always call our comparision
|
20
|
+
// function. If that is the case, discard the hasDuplicate value.
|
21
|
+
// Thus far that includes Google Chrome.
|
22
|
+
[0, 0].sort(function() {
|
23
|
+
baseHasDuplicate = false;
|
24
|
+
return 0;
|
25
|
+
});
|
26
|
+
|
27
|
+
var Sizzle = function( selector, context, results, seed ) {
|
28
|
+
results = results || [];
|
29
|
+
context = context || document;
|
30
|
+
|
31
|
+
var origContext = context;
|
32
|
+
|
33
|
+
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
34
|
+
return [];
|
35
|
+
}
|
36
|
+
|
37
|
+
if ( !selector || typeof selector !== "string" ) {
|
38
|
+
return results;
|
39
|
+
}
|
40
|
+
|
41
|
+
var m, set, checkSet, extra, ret, cur, pop, i,
|
42
|
+
prune = true,
|
43
|
+
contextXML = Sizzle.isXML( context ),
|
44
|
+
parts = [],
|
45
|
+
soFar = selector;
|
46
|
+
|
47
|
+
// Reset the position of the chunker regexp (start from head)
|
48
|
+
do {
|
49
|
+
chunker.exec( "" );
|
50
|
+
m = chunker.exec( soFar );
|
51
|
+
|
52
|
+
if ( m ) {
|
53
|
+
soFar = m[3];
|
54
|
+
|
55
|
+
parts.push( m[1] );
|
56
|
+
|
57
|
+
if ( m[2] ) {
|
58
|
+
extra = m[3];
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
} while ( m );
|
63
|
+
|
64
|
+
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
65
|
+
|
66
|
+
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
67
|
+
set = posProcess( parts[0] + parts[1], context, seed );
|
68
|
+
|
69
|
+
} else {
|
70
|
+
set = Expr.relative[ parts[0] ] ?
|
71
|
+
[ context ] :
|
72
|
+
Sizzle( parts.shift(), context );
|
73
|
+
|
74
|
+
while ( parts.length ) {
|
75
|
+
selector = parts.shift();
|
76
|
+
|
77
|
+
if ( Expr.relative[ selector ] ) {
|
78
|
+
selector += parts.shift();
|
79
|
+
}
|
80
|
+
|
81
|
+
set = posProcess( selector, set, seed );
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
} else {
|
86
|
+
// Take a shortcut and set the context if the root selector is an ID
|
87
|
+
// (but not if it'll be faster if the inner selector is an ID)
|
88
|
+
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
89
|
+
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
90
|
+
|
91
|
+
ret = Sizzle.find( parts.shift(), context, contextXML );
|
92
|
+
context = ret.expr ?
|
93
|
+
Sizzle.filter( ret.expr, ret.set )[0] :
|
94
|
+
ret.set[0];
|
95
|
+
}
|
96
|
+
|
97
|
+
if ( context ) {
|
98
|
+
ret = seed ?
|
99
|
+
{ expr: parts.pop(), set: makeArray(seed) } :
|
100
|
+
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
101
|
+
|
102
|
+
set = ret.expr ?
|
103
|
+
Sizzle.filter( ret.expr, ret.set ) :
|
104
|
+
ret.set;
|
105
|
+
|
106
|
+
if ( parts.length > 0 ) {
|
107
|
+
checkSet = makeArray( set );
|
108
|
+
|
109
|
+
} else {
|
110
|
+
prune = false;
|
111
|
+
}
|
112
|
+
|
113
|
+
while ( parts.length ) {
|
114
|
+
cur = parts.pop();
|
115
|
+
pop = cur;
|
116
|
+
|
117
|
+
if ( !Expr.relative[ cur ] ) {
|
118
|
+
cur = "";
|
119
|
+
} else {
|
120
|
+
pop = parts.pop();
|
121
|
+
}
|
122
|
+
|
123
|
+
if ( pop == null ) {
|
124
|
+
pop = context;
|
125
|
+
}
|
126
|
+
|
127
|
+
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
128
|
+
}
|
129
|
+
|
130
|
+
} else {
|
131
|
+
checkSet = parts = [];
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
if ( !checkSet ) {
|
136
|
+
checkSet = set;
|
137
|
+
}
|
138
|
+
|
139
|
+
if ( !checkSet ) {
|
140
|
+
Sizzle.error( cur || selector );
|
141
|
+
}
|
142
|
+
|
143
|
+
if ( toString.call(checkSet) === "[object Array]" ) {
|
144
|
+
if ( !prune ) {
|
145
|
+
results.push.apply( results, checkSet );
|
146
|
+
|
147
|
+
} else if ( context && context.nodeType === 1 ) {
|
148
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
149
|
+
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
|
150
|
+
results.push( set[i] );
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
} else {
|
155
|
+
for ( i = 0; checkSet[i] != null; i++ ) {
|
156
|
+
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
157
|
+
results.push( set[i] );
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
} else {
|
163
|
+
makeArray( checkSet, results );
|
164
|
+
}
|
165
|
+
|
166
|
+
if ( extra ) {
|
167
|
+
Sizzle( extra, origContext, results, seed );
|
168
|
+
Sizzle.uniqueSort( results );
|
169
|
+
}
|
170
|
+
|
171
|
+
return results;
|
172
|
+
};
|
173
|
+
|
174
|
+
Sizzle.uniqueSort = function( results ) {
|
175
|
+
if ( sortOrder ) {
|
176
|
+
hasDuplicate = baseHasDuplicate;
|
177
|
+
results.sort( sortOrder );
|
178
|
+
|
179
|
+
if ( hasDuplicate ) {
|
180
|
+
for ( var i = 1; i < results.length; i++ ) {
|
181
|
+
if ( results[i] === results[ i - 1 ] ) {
|
182
|
+
results.splice( i--, 1 );
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
return results;
|
189
|
+
};
|
190
|
+
|
191
|
+
Sizzle.matches = function( expr, set ) {
|
192
|
+
return Sizzle( expr, null, null, set );
|
193
|
+
};
|
194
|
+
|
195
|
+
Sizzle.matchesSelector = function( node, expr ) {
|
196
|
+
return Sizzle( expr, null, null, [node] ).length > 0;
|
197
|
+
};
|
198
|
+
|
199
|
+
Sizzle.find = function( expr, context, isXML ) {
|
200
|
+
var set, i, len, match, type, left;
|
201
|
+
|
202
|
+
if ( !expr ) {
|
203
|
+
return [];
|
204
|
+
}
|
205
|
+
|
206
|
+
for ( i = 0, len = Expr.order.length; i < len; i++ ) {
|
207
|
+
type = Expr.order[i];
|
208
|
+
|
209
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
|
210
|
+
left = match[1];
|
211
|
+
match.splice( 1, 1 );
|
212
|
+
|
213
|
+
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
214
|
+
match[1] = (match[1] || "").replace( rBackslash, "" );
|
215
|
+
set = Expr.find[ type ]( match, context, isXML );
|
216
|
+
|
217
|
+
if ( set != null ) {
|
218
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
if ( !set ) {
|
226
|
+
set = typeof context.getElementsByTagName !== "undefined" ?
|
227
|
+
context.getElementsByTagName( "*" ) :
|
228
|
+
[];
|
229
|
+
}
|
230
|
+
|
231
|
+
return { set: set, expr: expr };
|
232
|
+
};
|
233
|
+
|
234
|
+
Sizzle.filter = function( expr, set, inplace, not ) {
|
235
|
+
var match, anyFound,
|
236
|
+
type, found, item, filter, left,
|
237
|
+
i, pass,
|
238
|
+
old = expr,
|
239
|
+
result = [],
|
240
|
+
curLoop = set,
|
241
|
+
isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
|
242
|
+
|
243
|
+
while ( expr && set.length ) {
|
244
|
+
for ( type in Expr.filter ) {
|
245
|
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
|
246
|
+
filter = Expr.filter[ type ];
|
247
|
+
left = match[1];
|
248
|
+
|
249
|
+
anyFound = false;
|
250
|
+
|
251
|
+
match.splice(1,1);
|
252
|
+
|
253
|
+
if ( left.substr( left.length - 1 ) === "\\" ) {
|
254
|
+
continue;
|
255
|
+
}
|
256
|
+
|
257
|
+
if ( curLoop === result ) {
|
258
|
+
result = [];
|
259
|
+
}
|
260
|
+
|
261
|
+
if ( Expr.preFilter[ type ] ) {
|
262
|
+
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
263
|
+
|
264
|
+
if ( !match ) {
|
265
|
+
anyFound = found = true;
|
266
|
+
|
267
|
+
} else if ( match === true ) {
|
268
|
+
continue;
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
if ( match ) {
|
273
|
+
for ( i = 0; (item = curLoop[i]) != null; i++ ) {
|
274
|
+
if ( item ) {
|
275
|
+
found = filter( item, match, i, curLoop );
|
276
|
+
pass = not ^ found;
|
277
|
+
|
278
|
+
if ( inplace && found != null ) {
|
279
|
+
if ( pass ) {
|
280
|
+
anyFound = true;
|
281
|
+
|
282
|
+
} else {
|
283
|
+
curLoop[i] = false;
|
284
|
+
}
|
285
|
+
|
286
|
+
} else if ( pass ) {
|
287
|
+
result.push( item );
|
288
|
+
anyFound = true;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
if ( found !== undefined ) {
|
295
|
+
if ( !inplace ) {
|
296
|
+
curLoop = result;
|
297
|
+
}
|
298
|
+
|
299
|
+
expr = expr.replace( Expr.match[ type ], "" );
|
300
|
+
|
301
|
+
if ( !anyFound ) {
|
302
|
+
return [];
|
303
|
+
}
|
304
|
+
|
305
|
+
break;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
// Improper expression
|
311
|
+
if ( expr === old ) {
|
312
|
+
if ( anyFound == null ) {
|
313
|
+
Sizzle.error( expr );
|
314
|
+
|
315
|
+
} else {
|
316
|
+
break;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
old = expr;
|
321
|
+
}
|
322
|
+
|
323
|
+
return curLoop;
|
324
|
+
};
|
325
|
+
|
326
|
+
Sizzle.error = function( msg ) {
|
327
|
+
throw new Error( "Syntax error, unrecognized expression: " + msg );
|
328
|
+
};
|
329
|
+
|
330
|
+
/**
|
331
|
+
* Utility function for retreiving the text value of an array of DOM nodes
|
332
|
+
* @param {Array|Element} elem
|
333
|
+
*/
|
334
|
+
var getText = Sizzle.getText = function( elem ) {
|
335
|
+
var i, node,
|
336
|
+
nodeType = elem.nodeType,
|
337
|
+
ret = "";
|
338
|
+
|
339
|
+
if ( nodeType ) {
|
340
|
+
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
|
341
|
+
// Use textContent for elements
|
342
|
+
// innerText usage removed for consistency of new lines (see #11153)
|
343
|
+
if ( typeof elem.textContent === "string" ) {
|
344
|
+
return elem.textContent;
|
345
|
+
} else {
|
346
|
+
// Traverse it's children
|
347
|
+
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
|
348
|
+
ret += getText( elem );
|
349
|
+
}
|
350
|
+
}
|
351
|
+
} else if ( nodeType === 3 || nodeType === 4 ) {
|
352
|
+
return elem.nodeValue;
|
353
|
+
}
|
354
|
+
} else {
|
355
|
+
|
356
|
+
// If no nodeType, this is expected to be an array
|
357
|
+
for ( i = 0; (node = elem[i]); i++ ) {
|
358
|
+
// Do not traverse comment nodes
|
359
|
+
if ( node.nodeType !== 8 ) {
|
360
|
+
ret += getText( node );
|
361
|
+
}
|
362
|
+
}
|
363
|
+
}
|
364
|
+
return ret;
|
365
|
+
};
|
366
|
+
|
367
|
+
var Expr = Sizzle.selectors = {
|
368
|
+
order: [ "ID", "NAME", "TAG" ],
|
369
|
+
|
370
|
+
match: {
|
371
|
+
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
372
|
+
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
|
373
|
+
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
|
374
|
+
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
|
375
|
+
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
|
376
|
+
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
|
377
|
+
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
|
378
|
+
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
|
379
|
+
},
|
380
|
+
|
381
|
+
leftMatch: {},
|
382
|
+
|
383
|
+
attrMap: {
|
384
|
+
"class": "className",
|
385
|
+
"for": "htmlFor"
|
386
|
+
},
|
387
|
+
|
388
|
+
attrHandle: {
|
389
|
+
href: function( elem ) {
|
390
|
+
return elem.getAttribute( "href" );
|
391
|
+
},
|
392
|
+
type: function( elem ) {
|
393
|
+
return elem.getAttribute( "type" );
|
394
|
+
}
|
395
|
+
},
|
396
|
+
|
397
|
+
relative: {
|
398
|
+
"+": function(checkSet, part){
|
399
|
+
var isPartStr = typeof part === "string",
|
400
|
+
isTag = isPartStr && !rNonWord.test( part ),
|
401
|
+
isPartStrNotTag = isPartStr && !isTag;
|
402
|
+
|
403
|
+
if ( isTag ) {
|
404
|
+
part = part.toLowerCase();
|
405
|
+
}
|
406
|
+
|
407
|
+
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
408
|
+
if ( (elem = checkSet[i]) ) {
|
409
|
+
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
410
|
+
|
411
|
+
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
|
412
|
+
elem || false :
|
413
|
+
elem === part;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
if ( isPartStrNotTag ) {
|
418
|
+
Sizzle.filter( part, checkSet, true );
|
419
|
+
}
|
420
|
+
},
|
421
|
+
|
422
|
+
">": function( checkSet, part ) {
|
423
|
+
var elem,
|
424
|
+
isPartStr = typeof part === "string",
|
425
|
+
i = 0,
|
426
|
+
l = checkSet.length;
|
427
|
+
|
428
|
+
if ( isPartStr && !rNonWord.test( part ) ) {
|
429
|
+
part = part.toLowerCase();
|
430
|
+
|
431
|
+
for ( ; i < l; i++ ) {
|
432
|
+
elem = checkSet[i];
|
433
|
+
|
434
|
+
if ( elem ) {
|
435
|
+
var parent = elem.parentNode;
|
436
|
+
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
} else {
|
441
|
+
for ( ; i < l; i++ ) {
|
442
|
+
elem = checkSet[i];
|
443
|
+
|
444
|
+
if ( elem ) {
|
445
|
+
checkSet[i] = isPartStr ?
|
446
|
+
elem.parentNode :
|
447
|
+
elem.parentNode === part;
|
448
|
+
}
|
449
|
+
}
|
450
|
+
|
451
|
+
if ( isPartStr ) {
|
452
|
+
Sizzle.filter( part, checkSet, true );
|
453
|
+
}
|
454
|
+
}
|
455
|
+
},
|
456
|
+
|
457
|
+
"": function(checkSet, part, isXML){
|
458
|
+
var nodeCheck,
|
459
|
+
doneName = done++,
|
460
|
+
checkFn = dirCheck;
|
461
|
+
|
462
|
+
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
463
|
+
part = part.toLowerCase();
|
464
|
+
nodeCheck = part;
|
465
|
+
checkFn = dirNodeCheck;
|
466
|
+
}
|
467
|
+
|
468
|
+
checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
|
469
|
+
},
|
470
|
+
|
471
|
+
"~": function( checkSet, part, isXML ) {
|
472
|
+
var nodeCheck,
|
473
|
+
doneName = done++,
|
474
|
+
checkFn = dirCheck;
|
475
|
+
|
476
|
+
if ( typeof part === "string" && !rNonWord.test( part ) ) {
|
477
|
+
part = part.toLowerCase();
|
478
|
+
nodeCheck = part;
|
479
|
+
checkFn = dirNodeCheck;
|
480
|
+
}
|
481
|
+
|
482
|
+
checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
|
483
|
+
}
|
484
|
+
},
|
485
|
+
|
486
|
+
find: {
|
487
|
+
ID: function( match, context, isXML ) {
|
488
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
489
|
+
var m = context.getElementById(match[1]);
|
490
|
+
// Check parentNode to catch when Blackberry 4.6 returns
|
491
|
+
// nodes that are no longer in the document #6963
|
492
|
+
return m && m.parentNode ? [m] : [];
|
493
|
+
}
|
494
|
+
},
|
495
|
+
|
496
|
+
NAME: function( match, context ) {
|
497
|
+
if ( typeof context.getElementsByName !== "undefined" ) {
|
498
|
+
var ret = [],
|
499
|
+
results = context.getElementsByName( match[1] );
|
500
|
+
|
501
|
+
for ( var i = 0, l = results.length; i < l; i++ ) {
|
502
|
+
if ( results[i].getAttribute("name") === match[1] ) {
|
503
|
+
ret.push( results[i] );
|
504
|
+
}
|
505
|
+
}
|
506
|
+
|
507
|
+
return ret.length === 0 ? null : ret;
|
508
|
+
}
|
509
|
+
},
|
510
|
+
|
511
|
+
TAG: function( match, context ) {
|
512
|
+
if ( typeof context.getElementsByTagName !== "undefined" ) {
|
513
|
+
return context.getElementsByTagName( match[1] );
|
514
|
+
}
|
515
|
+
}
|
516
|
+
},
|
517
|
+
preFilter: {
|
518
|
+
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
|
519
|
+
match = " " + match[1].replace( rBackslash, "" ) + " ";
|
520
|
+
|
521
|
+
if ( isXML ) {
|
522
|
+
return match;
|
523
|
+
}
|
524
|
+
|
525
|
+
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
526
|
+
if ( elem ) {
|
527
|
+
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
|
528
|
+
if ( !inplace ) {
|
529
|
+
result.push( elem );
|
530
|
+
}
|
531
|
+
|
532
|
+
} else if ( inplace ) {
|
533
|
+
curLoop[i] = false;
|
534
|
+
}
|
535
|
+
}
|
536
|
+
}
|
537
|
+
|
538
|
+
return false;
|
539
|
+
},
|
540
|
+
|
541
|
+
ID: function( match ) {
|
542
|
+
return match[1].replace( rBackslash, "" );
|
543
|
+
},
|
544
|
+
|
545
|
+
TAG: function( match, curLoop ) {
|
546
|
+
return match[1].replace( rBackslash, "" ).toLowerCase();
|
547
|
+
},
|
548
|
+
|
549
|
+
CHILD: function( match ) {
|
550
|
+
if ( match[1] === "nth" ) {
|
551
|
+
if ( !match[2] ) {
|
552
|
+
Sizzle.error( match[0] );
|
553
|
+
}
|
554
|
+
|
555
|
+
match[2] = match[2].replace(/^\+|\s*/g, '');
|
556
|
+
|
557
|
+
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
558
|
+
var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
|
559
|
+
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
|
560
|
+
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
561
|
+
|
562
|
+
// calculate the numbers (first)n+(last) including if they are negative
|
563
|
+
match[2] = (test[1] + (test[2] || 1)) - 0;
|
564
|
+
match[3] = test[3] - 0;
|
565
|
+
}
|
566
|
+
else if ( match[2] ) {
|
567
|
+
Sizzle.error( match[0] );
|
568
|
+
}
|
569
|
+
|
570
|
+
// TODO: Move to normal caching system
|
571
|
+
match[0] = done++;
|
572
|
+
|
573
|
+
return match;
|
574
|
+
},
|
575
|
+
|
576
|
+
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
|
577
|
+
var name = match[1] = match[1].replace( rBackslash, "" );
|
578
|
+
|
579
|
+
if ( !isXML && Expr.attrMap[name] ) {
|
580
|
+
match[1] = Expr.attrMap[name];
|
581
|
+
}
|
582
|
+
|
583
|
+
// Handle if an un-quoted value was used
|
584
|
+
match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
|
585
|
+
|
586
|
+
if ( match[2] === "~=" ) {
|
587
|
+
match[4] = " " + match[4] + " ";
|
588
|
+
}
|
589
|
+
|
590
|
+
return match;
|
591
|
+
},
|
592
|
+
|
593
|
+
PSEUDO: function( match, curLoop, inplace, result, not ) {
|
594
|
+
if ( match[1] === "not" ) {
|
595
|
+
// If we're dealing with a complex expression, or a simple one
|
596
|
+
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
|
597
|
+
match[3] = Sizzle(match[3], null, null, curLoop);
|
598
|
+
|
599
|
+
} else {
|
600
|
+
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
|
601
|
+
|
602
|
+
if ( !inplace ) {
|
603
|
+
result.push.apply( result, ret );
|
604
|
+
}
|
605
|
+
|
606
|
+
return false;
|
607
|
+
}
|
608
|
+
|
609
|
+
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
610
|
+
return true;
|
611
|
+
}
|
612
|
+
|
613
|
+
return match;
|
614
|
+
},
|
615
|
+
|
616
|
+
POS: function( match ) {
|
617
|
+
match.unshift( true );
|
618
|
+
|
619
|
+
return match;
|
620
|
+
}
|
621
|
+
},
|
622
|
+
|
623
|
+
filters: {
|
624
|
+
enabled: function( elem ) {
|
625
|
+
return elem.disabled === false && elem.type !== "hidden";
|
626
|
+
},
|
627
|
+
|
628
|
+
disabled: function( elem ) {
|
629
|
+
return elem.disabled === true;
|
630
|
+
},
|
631
|
+
|
632
|
+
checked: function( elem ) {
|
633
|
+
return elem.checked === true;
|
634
|
+
},
|
635
|
+
|
636
|
+
selected: function( elem ) {
|
637
|
+
// Accessing this property makes selected-by-default
|
638
|
+
// options in Safari work properly
|
639
|
+
if ( elem.parentNode ) {
|
640
|
+
elem.parentNode.selectedIndex;
|
641
|
+
}
|
642
|
+
|
643
|
+
return elem.selected === true;
|
644
|
+
},
|
645
|
+
|
646
|
+
parent: function( elem ) {
|
647
|
+
return !!elem.firstChild;
|
648
|
+
},
|
649
|
+
|
650
|
+
empty: function( elem ) {
|
651
|
+
return !elem.firstChild;
|
652
|
+
},
|
653
|
+
|
654
|
+
has: function( elem, i, match ) {
|
655
|
+
return !!Sizzle( match[3], elem ).length;
|
656
|
+
},
|
657
|
+
|
658
|
+
header: function( elem ) {
|
659
|
+
return (/h\d/i).test( elem.nodeName );
|
660
|
+
},
|
661
|
+
|
662
|
+
text: function( elem ) {
|
663
|
+
var attr = elem.getAttribute( "type" ), type = elem.type;
|
664
|
+
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
|
665
|
+
// use getAttribute instead to test this case
|
666
|
+
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
|
667
|
+
},
|
668
|
+
|
669
|
+
radio: function( elem ) {
|
670
|
+
return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
|
671
|
+
},
|
672
|
+
|
673
|
+
checkbox: function( elem ) {
|
674
|
+
return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
|
675
|
+
},
|
676
|
+
|
677
|
+
file: function( elem ) {
|
678
|
+
return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
|
679
|
+
},
|
680
|
+
|
681
|
+
password: function( elem ) {
|
682
|
+
return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
|
683
|
+
},
|
684
|
+
|
685
|
+
submit: function( elem ) {
|
686
|
+
var name = elem.nodeName.toLowerCase();
|
687
|
+
return (name === "input" || name === "button") && "submit" === elem.type;
|
688
|
+
},
|
689
|
+
|
690
|
+
image: function( elem ) {
|
691
|
+
return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
|
692
|
+
},
|
693
|
+
|
694
|
+
reset: function( elem ) {
|
695
|
+
var name = elem.nodeName.toLowerCase();
|
696
|
+
return (name === "input" || name === "button") && "reset" === elem.type;
|
697
|
+
},
|
698
|
+
|
699
|
+
button: function( elem ) {
|
700
|
+
var name = elem.nodeName.toLowerCase();
|
701
|
+
return name === "input" && "button" === elem.type || name === "button";
|
702
|
+
},
|
703
|
+
|
704
|
+
input: function( elem ) {
|
705
|
+
return (/input|select|textarea|button/i).test( elem.nodeName );
|
706
|
+
},
|
707
|
+
|
708
|
+
focus: function( elem ) {
|
709
|
+
return elem === elem.ownerDocument.activeElement;
|
710
|
+
}
|
711
|
+
},
|
712
|
+
setFilters: {
|
713
|
+
first: function( elem, i ) {
|
714
|
+
return i === 0;
|
715
|
+
},
|
716
|
+
|
717
|
+
last: function( elem, i, match, array ) {
|
718
|
+
return i === array.length - 1;
|
719
|
+
},
|
720
|
+
|
721
|
+
even: function( elem, i ) {
|
722
|
+
return i % 2 === 0;
|
723
|
+
},
|
724
|
+
|
725
|
+
odd: function( elem, i ) {
|
726
|
+
return i % 2 === 1;
|
727
|
+
},
|
728
|
+
|
729
|
+
lt: function( elem, i, match ) {
|
730
|
+
return i < match[3] - 0;
|
731
|
+
},
|
732
|
+
|
733
|
+
gt: function( elem, i, match ) {
|
734
|
+
return i > match[3] - 0;
|
735
|
+
},
|
736
|
+
|
737
|
+
nth: function( elem, i, match ) {
|
738
|
+
return match[3] - 0 === i;
|
739
|
+
},
|
740
|
+
|
741
|
+
eq: function( elem, i, match ) {
|
742
|
+
return match[3] - 0 === i;
|
743
|
+
}
|
744
|
+
},
|
745
|
+
filter: {
|
746
|
+
PSEUDO: function( elem, match, i, array ) {
|
747
|
+
var name = match[1],
|
748
|
+
filter = Expr.filters[ name ];
|
749
|
+
|
750
|
+
if ( filter ) {
|
751
|
+
return filter( elem, i, match, array );
|
752
|
+
|
753
|
+
} else if ( name === "contains" ) {
|
754
|
+
return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
|
755
|
+
|
756
|
+
} else if ( name === "not" ) {
|
757
|
+
var not = match[3];
|
758
|
+
|
759
|
+
for ( var j = 0, l = not.length; j < l; j++ ) {
|
760
|
+
if ( not[j] === elem ) {
|
761
|
+
return false;
|
762
|
+
}
|
763
|
+
}
|
764
|
+
|
765
|
+
return true;
|
766
|
+
|
767
|
+
} else {
|
768
|
+
Sizzle.error( name );
|
769
|
+
}
|
770
|
+
},
|
771
|
+
|
772
|
+
CHILD: function( elem, match ) {
|
773
|
+
var first, last,
|
774
|
+
doneName, parent, cache,
|
775
|
+
count, diff,
|
776
|
+
type = match[1],
|
777
|
+
node = elem;
|
778
|
+
|
779
|
+
switch ( type ) {
|
780
|
+
case "only":
|
781
|
+
case "first":
|
782
|
+
while ( (node = node.previousSibling) ) {
|
783
|
+
if ( node.nodeType === 1 ) {
|
784
|
+
return false;
|
785
|
+
}
|
786
|
+
}
|
787
|
+
|
788
|
+
if ( type === "first" ) {
|
789
|
+
return true;
|
790
|
+
}
|
791
|
+
|
792
|
+
node = elem;
|
793
|
+
|
794
|
+
/* falls through */
|
795
|
+
case "last":
|
796
|
+
while ( (node = node.nextSibling) ) {
|
797
|
+
if ( node.nodeType === 1 ) {
|
798
|
+
return false;
|
799
|
+
}
|
800
|
+
}
|
801
|
+
|
802
|
+
return true;
|
803
|
+
|
804
|
+
case "nth":
|
805
|
+
first = match[2];
|
806
|
+
last = match[3];
|
807
|
+
|
808
|
+
if ( first === 1 && last === 0 ) {
|
809
|
+
return true;
|
810
|
+
}
|
811
|
+
|
812
|
+
doneName = match[0];
|
813
|
+
parent = elem.parentNode;
|
814
|
+
|
815
|
+
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
|
816
|
+
count = 0;
|
817
|
+
|
818
|
+
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
819
|
+
if ( node.nodeType === 1 ) {
|
820
|
+
node.nodeIndex = ++count;
|
821
|
+
}
|
822
|
+
}
|
823
|
+
|
824
|
+
parent[ expando ] = doneName;
|
825
|
+
}
|
826
|
+
|
827
|
+
diff = elem.nodeIndex - last;
|
828
|
+
|
829
|
+
if ( first === 0 ) {
|
830
|
+
return diff === 0;
|
831
|
+
|
832
|
+
} else {
|
833
|
+
return ( diff % first === 0 && diff / first >= 0 );
|
834
|
+
}
|
835
|
+
}
|
836
|
+
},
|
837
|
+
|
838
|
+
ID: function( elem, match ) {
|
839
|
+
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
840
|
+
},
|
841
|
+
|
842
|
+
TAG: function( elem, match ) {
|
843
|
+
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
|
844
|
+
},
|
845
|
+
|
846
|
+
CLASS: function( elem, match ) {
|
847
|
+
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
848
|
+
.indexOf( match ) > -1;
|
849
|
+
},
|
850
|
+
|
851
|
+
ATTR: function( elem, match ) {
|
852
|
+
var name = match[1],
|
853
|
+
result = Sizzle.attr ?
|
854
|
+
Sizzle.attr( elem, name ) :
|
855
|
+
Expr.attrHandle[ name ] ?
|
856
|
+
Expr.attrHandle[ name ]( elem ) :
|
857
|
+
elem[ name ] != null ?
|
858
|
+
elem[ name ] :
|
859
|
+
elem.getAttribute( name ),
|
860
|
+
value = result + "",
|
861
|
+
type = match[2],
|
862
|
+
check = match[4];
|
863
|
+
|
864
|
+
return result == null ?
|
865
|
+
type === "!=" :
|
866
|
+
!type && Sizzle.attr ?
|
867
|
+
result != null :
|
868
|
+
type === "=" ?
|
869
|
+
value === check :
|
870
|
+
type === "*=" ?
|
871
|
+
value.indexOf(check) >= 0 :
|
872
|
+
type === "~=" ?
|
873
|
+
(" " + value + " ").indexOf(check) >= 0 :
|
874
|
+
!check ?
|
875
|
+
value && result !== false :
|
876
|
+
type === "!=" ?
|
877
|
+
value !== check :
|
878
|
+
type === "^=" ?
|
879
|
+
value.indexOf(check) === 0 :
|
880
|
+
type === "$=" ?
|
881
|
+
value.substr(value.length - check.length) === check :
|
882
|
+
type === "|=" ?
|
883
|
+
value === check || value.substr(0, check.length + 1) === check + "-" :
|
884
|
+
false;
|
885
|
+
},
|
886
|
+
|
887
|
+
POS: function( elem, match, i, array ) {
|
888
|
+
var name = match[2],
|
889
|
+
filter = Expr.setFilters[ name ];
|
890
|
+
|
891
|
+
if ( filter ) {
|
892
|
+
return filter( elem, i, match, array );
|
893
|
+
}
|
894
|
+
}
|
895
|
+
}
|
896
|
+
};
|
897
|
+
|
898
|
+
var origPOS = Expr.match.POS,
|
899
|
+
fescape = function(all, num){
|
900
|
+
return "\\" + (num - 0 + 1);
|
901
|
+
};
|
902
|
+
|
903
|
+
for ( var type in Expr.match ) {
|
904
|
+
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
|
905
|
+
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
|
906
|
+
}
|
907
|
+
// Expose origPOS
|
908
|
+
// "global" as in regardless of relation to brackets/parens
|
909
|
+
Expr.match.globalPOS = origPOS;
|
910
|
+
|
911
|
+
var makeArray = function( array, results ) {
|
912
|
+
array = Array.prototype.slice.call( array, 0 );
|
913
|
+
|
914
|
+
if ( results ) {
|
915
|
+
results.push.apply( results, array );
|
916
|
+
return results;
|
917
|
+
}
|
918
|
+
|
919
|
+
return array;
|
920
|
+
};
|
921
|
+
|
922
|
+
// Perform a simple check to determine if the browser is capable of
|
923
|
+
// converting a NodeList to an array using builtin methods.
|
924
|
+
// Also verifies that the returned array holds DOM nodes
|
925
|
+
// (which is not the case in the Blackberry browser)
|
926
|
+
try {
|
927
|
+
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
|
928
|
+
|
929
|
+
// Provide a fallback method if it does not work
|
930
|
+
} catch( e ) {
|
931
|
+
makeArray = function( array, results ) {
|
932
|
+
var i = 0,
|
933
|
+
ret = results || [];
|
934
|
+
|
935
|
+
if ( toString.call(array) === "[object Array]" ) {
|
936
|
+
Array.prototype.push.apply( ret, array );
|
937
|
+
|
938
|
+
} else {
|
939
|
+
if ( typeof array.length === "number" ) {
|
940
|
+
for ( var l = array.length; i < l; i++ ) {
|
941
|
+
ret.push( array[i] );
|
942
|
+
}
|
943
|
+
|
944
|
+
} else {
|
945
|
+
for ( ; array[i]; i++ ) {
|
946
|
+
ret.push( array[i] );
|
947
|
+
}
|
948
|
+
}
|
949
|
+
}
|
950
|
+
|
951
|
+
return ret;
|
952
|
+
};
|
953
|
+
}
|
954
|
+
|
955
|
+
var sortOrder, siblingCheck;
|
956
|
+
|
957
|
+
if ( document.documentElement.compareDocumentPosition ) {
|
958
|
+
sortOrder = function( a, b ) {
|
959
|
+
if ( a === b ) {
|
960
|
+
hasDuplicate = true;
|
961
|
+
return 0;
|
962
|
+
}
|
963
|
+
|
964
|
+
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
|
965
|
+
return a.compareDocumentPosition ? -1 : 1;
|
966
|
+
}
|
967
|
+
|
968
|
+
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
|
969
|
+
};
|
970
|
+
|
971
|
+
} else {
|
972
|
+
sortOrder = function( a, b ) {
|
973
|
+
// The nodes are identical, we can exit early
|
974
|
+
if ( a === b ) {
|
975
|
+
hasDuplicate = true;
|
976
|
+
return 0;
|
977
|
+
|
978
|
+
// Fallback to using sourceIndex (in IE) if it's available on both nodes
|
979
|
+
} else if ( a.sourceIndex && b.sourceIndex ) {
|
980
|
+
return a.sourceIndex - b.sourceIndex;
|
981
|
+
}
|
982
|
+
|
983
|
+
var al, bl,
|
984
|
+
ap = [],
|
985
|
+
bp = [],
|
986
|
+
aup = a.parentNode,
|
987
|
+
bup = b.parentNode,
|
988
|
+
cur = aup;
|
989
|
+
|
990
|
+
// If the nodes are siblings (or identical) we can do a quick check
|
991
|
+
if ( aup === bup ) {
|
992
|
+
return siblingCheck( a, b );
|
993
|
+
|
994
|
+
// If no parents were found then the nodes are disconnected
|
995
|
+
} else if ( !aup ) {
|
996
|
+
return -1;
|
997
|
+
|
998
|
+
} else if ( !bup ) {
|
999
|
+
return 1;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
// Otherwise they're somewhere else in the tree so we need
|
1003
|
+
// to build up a full list of the parentNodes for comparison
|
1004
|
+
while ( cur ) {
|
1005
|
+
ap.unshift( cur );
|
1006
|
+
cur = cur.parentNode;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
cur = bup;
|
1010
|
+
|
1011
|
+
while ( cur ) {
|
1012
|
+
bp.unshift( cur );
|
1013
|
+
cur = cur.parentNode;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
al = ap.length;
|
1017
|
+
bl = bp.length;
|
1018
|
+
|
1019
|
+
// Start walking down the tree looking for a discrepancy
|
1020
|
+
for ( var i = 0; i < al && i < bl; i++ ) {
|
1021
|
+
if ( ap[i] !== bp[i] ) {
|
1022
|
+
return siblingCheck( ap[i], bp[i] );
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
// We ended someplace up the tree so do a sibling check
|
1027
|
+
return i === al ?
|
1028
|
+
siblingCheck( a, bp[i], -1 ) :
|
1029
|
+
siblingCheck( ap[i], b, 1 );
|
1030
|
+
};
|
1031
|
+
|
1032
|
+
siblingCheck = function( a, b, ret ) {
|
1033
|
+
if ( a === b ) {
|
1034
|
+
return ret;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
var cur = a.nextSibling;
|
1038
|
+
|
1039
|
+
while ( cur ) {
|
1040
|
+
if ( cur === b ) {
|
1041
|
+
return -1;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
cur = cur.nextSibling;
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
return 1;
|
1048
|
+
};
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
// Check to see if the browser returns elements by name when
|
1052
|
+
// querying by getElementById (and provide a workaround)
|
1053
|
+
(function(){
|
1054
|
+
// We're going to inject a fake input element with a specified name
|
1055
|
+
var form = document.createElement("div"),
|
1056
|
+
id = "script" + (new Date()).getTime(),
|
1057
|
+
root = document.documentElement;
|
1058
|
+
|
1059
|
+
form.innerHTML = "<a name='" + id + "'/>";
|
1060
|
+
|
1061
|
+
// Inject it into the root element, check its status, and remove it quickly
|
1062
|
+
root.insertBefore( form, root.firstChild );
|
1063
|
+
|
1064
|
+
// The workaround has to do additional checks after a getElementById
|
1065
|
+
// Which slows things down for other browsers (hence the branching)
|
1066
|
+
if ( document.getElementById( id ) ) {
|
1067
|
+
Expr.find.ID = function( match, context, isXML ) {
|
1068
|
+
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
1069
|
+
var m = context.getElementById(match[1]);
|
1070
|
+
|
1071
|
+
return m ?
|
1072
|
+
m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
|
1073
|
+
[m] :
|
1074
|
+
undefined :
|
1075
|
+
[];
|
1076
|
+
}
|
1077
|
+
};
|
1078
|
+
|
1079
|
+
Expr.filter.ID = function( elem, match ) {
|
1080
|
+
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
1081
|
+
|
1082
|
+
return elem.nodeType === 1 && node && node.nodeValue === match;
|
1083
|
+
};
|
1084
|
+
}
|
1085
|
+
|
1086
|
+
root.removeChild( form );
|
1087
|
+
|
1088
|
+
// release memory in IE
|
1089
|
+
root = form = null;
|
1090
|
+
})();
|
1091
|
+
|
1092
|
+
(function(){
|
1093
|
+
// Check to see if the browser returns only elements
|
1094
|
+
// when doing getElementsByTagName("*")
|
1095
|
+
|
1096
|
+
// Create a fake element
|
1097
|
+
var div = document.createElement("div");
|
1098
|
+
div.appendChild( document.createComment("") );
|
1099
|
+
|
1100
|
+
// Make sure no comments are found
|
1101
|
+
if ( div.getElementsByTagName("*").length > 0 ) {
|
1102
|
+
Expr.find.TAG = function( match, context ) {
|
1103
|
+
var results = context.getElementsByTagName( match[1] );
|
1104
|
+
|
1105
|
+
// Filter out possible comments
|
1106
|
+
if ( match[1] === "*" ) {
|
1107
|
+
var tmp = [];
|
1108
|
+
|
1109
|
+
for ( var i = 0; results[i]; i++ ) {
|
1110
|
+
if ( results[i].nodeType === 1 ) {
|
1111
|
+
tmp.push( results[i] );
|
1112
|
+
}
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
results = tmp;
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
return results;
|
1119
|
+
};
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
// Check to see if an attribute returns normalized href attributes
|
1123
|
+
div.innerHTML = "<a href='#'></a>";
|
1124
|
+
|
1125
|
+
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
1126
|
+
div.firstChild.getAttribute("href") !== "#" ) {
|
1127
|
+
|
1128
|
+
Expr.attrHandle.href = function( elem ) {
|
1129
|
+
return elem.getAttribute( "href", 2 );
|
1130
|
+
};
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
// release memory in IE
|
1134
|
+
div = null;
|
1135
|
+
})();
|
1136
|
+
|
1137
|
+
if ( document.querySelectorAll ) {
|
1138
|
+
(function(){
|
1139
|
+
var oldSizzle = Sizzle,
|
1140
|
+
div = document.createElement("div"),
|
1141
|
+
id = "__sizzle__";
|
1142
|
+
|
1143
|
+
div.innerHTML = "<p class='TEST'></p>";
|
1144
|
+
|
1145
|
+
// Safari can't handle uppercase or unicode characters when
|
1146
|
+
// in quirks mode.
|
1147
|
+
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
1148
|
+
return;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
Sizzle = function( query, context, extra, seed ) {
|
1152
|
+
context = context || document;
|
1153
|
+
|
1154
|
+
// Only use querySelectorAll on non-XML documents
|
1155
|
+
// (ID selectors don't work in non-HTML documents)
|
1156
|
+
if ( !seed && !Sizzle.isXML(context) ) {
|
1157
|
+
// See if we find a selector to speed up
|
1158
|
+
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
|
1159
|
+
|
1160
|
+
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
|
1161
|
+
// Speed-up: Sizzle("TAG")
|
1162
|
+
if ( match[1] ) {
|
1163
|
+
return makeArray( context.getElementsByTagName( query ), extra );
|
1164
|
+
|
1165
|
+
// Speed-up: Sizzle(".CLASS")
|
1166
|
+
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
|
1167
|
+
return makeArray( context.getElementsByClassName( match[2] ), extra );
|
1168
|
+
}
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
if ( context.nodeType === 9 ) {
|
1172
|
+
// Speed-up: Sizzle("body")
|
1173
|
+
// The body element only exists once, optimize finding it
|
1174
|
+
if ( query === "body" && context.body ) {
|
1175
|
+
return makeArray( [ context.body ], extra );
|
1176
|
+
|
1177
|
+
// Speed-up: Sizzle("#ID")
|
1178
|
+
} else if ( match && match[3] ) {
|
1179
|
+
var elem = context.getElementById( match[3] );
|
1180
|
+
|
1181
|
+
// Check parentNode to catch when Blackberry 4.6 returns
|
1182
|
+
// nodes that are no longer in the document #6963
|
1183
|
+
if ( elem && elem.parentNode ) {
|
1184
|
+
// Handle the case where IE and Opera return items
|
1185
|
+
// by name instead of ID
|
1186
|
+
if ( elem.id === match[3] ) {
|
1187
|
+
return makeArray( [ elem ], extra );
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
} else {
|
1191
|
+
return makeArray( [], extra );
|
1192
|
+
}
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
try {
|
1196
|
+
return makeArray( context.querySelectorAll(query), extra );
|
1197
|
+
} catch(qsaError) {}
|
1198
|
+
|
1199
|
+
// qSA works strangely on Element-rooted queries
|
1200
|
+
// We can work around this by specifying an extra ID on the root
|
1201
|
+
// and working up from there (Thanks to Andrew Dupont for the technique)
|
1202
|
+
// IE 8 doesn't work on object elements
|
1203
|
+
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
|
1204
|
+
var oldContext = context,
|
1205
|
+
old = context.getAttribute( "id" ),
|
1206
|
+
nid = old || id,
|
1207
|
+
hasParent = context.parentNode,
|
1208
|
+
relativeHierarchySelector = /^\s*[+~]/.test( query );
|
1209
|
+
|
1210
|
+
if ( !old ) {
|
1211
|
+
context.setAttribute( "id", nid );
|
1212
|
+
} else {
|
1213
|
+
nid = nid.replace( /'/g, "\\$&" );
|
1214
|
+
}
|
1215
|
+
if ( relativeHierarchySelector && hasParent ) {
|
1216
|
+
context = context.parentNode;
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
try {
|
1220
|
+
if ( !relativeHierarchySelector || hasParent ) {
|
1221
|
+
return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
} catch(pseudoError) {
|
1225
|
+
} finally {
|
1226
|
+
if ( !old ) {
|
1227
|
+
oldContext.removeAttribute( "id" );
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
}
|
1232
|
+
|
1233
|
+
return oldSizzle(query, context, extra, seed);
|
1234
|
+
};
|
1235
|
+
|
1236
|
+
for ( var prop in oldSizzle ) {
|
1237
|
+
Sizzle[ prop ] = oldSizzle[ prop ];
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
// release memory in IE
|
1241
|
+
div = null;
|
1242
|
+
})();
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
(function(){
|
1246
|
+
var html = document.documentElement,
|
1247
|
+
matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
|
1248
|
+
|
1249
|
+
if ( matches ) {
|
1250
|
+
// Check to see if it's possible to do matchesSelector
|
1251
|
+
// on a disconnected node (IE 9 fails this)
|
1252
|
+
var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
|
1253
|
+
pseudoWorks = false;
|
1254
|
+
|
1255
|
+
try {
|
1256
|
+
// This should fail with an exception
|
1257
|
+
// Gecko does not error, returns false instead
|
1258
|
+
matches.call( document.documentElement, "[test!='']:sizzle" );
|
1259
|
+
|
1260
|
+
} catch( pseudoError ) {
|
1261
|
+
pseudoWorks = true;
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
Sizzle.matchesSelector = function( node, expr ) {
|
1265
|
+
// Make sure that attribute selectors are quoted
|
1266
|
+
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
|
1267
|
+
|
1268
|
+
if ( !Sizzle.isXML( node ) ) {
|
1269
|
+
try {
|
1270
|
+
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
|
1271
|
+
var ret = matches.call( node, expr );
|
1272
|
+
|
1273
|
+
// IE 9's matchesSelector returns false on disconnected nodes
|
1274
|
+
if ( ret || !disconnectedMatch ||
|
1275
|
+
// As well, disconnected nodes are said to be in a document
|
1276
|
+
// fragment in IE 9, so check for that
|
1277
|
+
node.document && node.document.nodeType !== 11 ) {
|
1278
|
+
return ret;
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
} catch(e) {}
|
1282
|
+
}
|
1283
|
+
|
1284
|
+
return Sizzle(expr, null, null, [node]).length > 0;
|
1285
|
+
};
|
1286
|
+
}
|
1287
|
+
})();
|
1288
|
+
|
1289
|
+
(function(){
|
1290
|
+
var div = document.createElement("div");
|
1291
|
+
|
1292
|
+
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
1293
|
+
|
1294
|
+
// Opera can't find a second classname (in 9.6)
|
1295
|
+
// Also, make sure that getElementsByClassName actually exists
|
1296
|
+
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
|
1297
|
+
return;
|
1298
|
+
}
|
1299
|
+
|
1300
|
+
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
1301
|
+
div.lastChild.className = "e";
|
1302
|
+
|
1303
|
+
if ( div.getElementsByClassName("e").length === 1 ) {
|
1304
|
+
return;
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
Expr.order.splice(1, 0, "CLASS");
|
1308
|
+
Expr.find.CLASS = function( match, context, isXML ) {
|
1309
|
+
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
1310
|
+
return context.getElementsByClassName(match[1]);
|
1311
|
+
}
|
1312
|
+
};
|
1313
|
+
|
1314
|
+
// release memory in IE
|
1315
|
+
div = null;
|
1316
|
+
})();
|
1317
|
+
|
1318
|
+
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
1319
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
1320
|
+
var elem = checkSet[i];
|
1321
|
+
|
1322
|
+
if ( elem ) {
|
1323
|
+
var match = false;
|
1324
|
+
|
1325
|
+
elem = elem[dir];
|
1326
|
+
|
1327
|
+
while ( elem ) {
|
1328
|
+
if ( elem[ expando ] === doneName ) {
|
1329
|
+
match = checkSet[elem.sizset];
|
1330
|
+
break;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
if ( elem.nodeType === 1 && !isXML ){
|
1334
|
+
elem[ expando ] = doneName;
|
1335
|
+
elem.sizset = i;
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
if ( elem.nodeName.toLowerCase() === cur ) {
|
1339
|
+
match = elem;
|
1340
|
+
break;
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
elem = elem[dir];
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
checkSet[i] = match;
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
1352
|
+
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
1353
|
+
var elem = checkSet[i];
|
1354
|
+
|
1355
|
+
if ( elem ) {
|
1356
|
+
var match = false;
|
1357
|
+
|
1358
|
+
elem = elem[dir];
|
1359
|
+
|
1360
|
+
while ( elem ) {
|
1361
|
+
if ( elem[ expando ] === doneName ) {
|
1362
|
+
match = checkSet[elem.sizset];
|
1363
|
+
break;
|
1364
|
+
}
|
1365
|
+
|
1366
|
+
if ( elem.nodeType === 1 ) {
|
1367
|
+
if ( !isXML ) {
|
1368
|
+
elem[ expando ] = doneName;
|
1369
|
+
elem.sizset = i;
|
1370
|
+
}
|
1371
|
+
|
1372
|
+
if ( typeof cur !== "string" ) {
|
1373
|
+
if ( elem === cur ) {
|
1374
|
+
match = true;
|
1375
|
+
break;
|
1376
|
+
}
|
1377
|
+
|
1378
|
+
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
1379
|
+
match = elem;
|
1380
|
+
break;
|
1381
|
+
}
|
1382
|
+
}
|
1383
|
+
|
1384
|
+
elem = elem[dir];
|
1385
|
+
}
|
1386
|
+
|
1387
|
+
checkSet[i] = match;
|
1388
|
+
}
|
1389
|
+
}
|
1390
|
+
}
|
1391
|
+
|
1392
|
+
if ( document.documentElement.contains ) {
|
1393
|
+
Sizzle.contains = function( a, b ) {
|
1394
|
+
return a !== b && (a.contains ? a.contains(b) : true);
|
1395
|
+
};
|
1396
|
+
|
1397
|
+
} else if ( document.documentElement.compareDocumentPosition ) {
|
1398
|
+
Sizzle.contains = function( a, b ) {
|
1399
|
+
return !!(a.compareDocumentPosition(b) & 16);
|
1400
|
+
};
|
1401
|
+
|
1402
|
+
} else {
|
1403
|
+
Sizzle.contains = function() {
|
1404
|
+
return false;
|
1405
|
+
};
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
Sizzle.isXML = function( elem ) {
|
1409
|
+
// documentElement is verified for cases where it doesn't yet exist
|
1410
|
+
// (such as loading iframes in IE - #4833)
|
1411
|
+
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
|
1412
|
+
|
1413
|
+
return documentElement ? documentElement.nodeName !== "HTML" : false;
|
1414
|
+
};
|
1415
|
+
|
1416
|
+
var posProcess = function( selector, context, seed ) {
|
1417
|
+
var match,
|
1418
|
+
tmpSet = [],
|
1419
|
+
later = "",
|
1420
|
+
root = context.nodeType ? [context] : context;
|
1421
|
+
|
1422
|
+
// Position selectors must be done after the filter
|
1423
|
+
// And so must :not(positional) so we move all PSEUDOs to the end
|
1424
|
+
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
1425
|
+
later += match[0];
|
1426
|
+
selector = selector.replace( Expr.match.PSEUDO, "" );
|
1427
|
+
}
|
1428
|
+
|
1429
|
+
selector = Expr.relative[selector] ? selector + "*" : selector;
|
1430
|
+
|
1431
|
+
for ( var i = 0, l = root.length; i < l; i++ ) {
|
1432
|
+
Sizzle( selector, root[i], tmpSet, seed );
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
return Sizzle.filter( later, tmpSet );
|
1436
|
+
};
|
1437
|
+
|
1438
|
+
// EXPOSE
|
1439
|
+
|
1440
|
+
window.Sizzle = Sizzle;
|
1441
|
+
|
1442
|
+
})();
|