right-rails 1.0.6 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1127 @@
1
+ /**
2
+ * Sizzle engine support for RightJS
3
+ *
4
+ * Copyright (C) 2010 Nikolay Nemshilov
5
+ */
6
+ /*!
7
+ * Sizzle CSS Selector Engine - v1.0
8
+ * Copyright 2009, The Dojo Foundation
9
+ * Released under the MIT, BSD, and GPL Licenses.
10
+ * More information: http://sizzlejs.com/
11
+ */
12
+
13
+ /**
14
+ * sizzle initialization script
15
+ *
16
+ * Copyright (C) 2010 Nikolay Nemshilov
17
+ */
18
+
19
+
20
+
21
+ (function(){
22
+
23
+ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
24
+ done = 0,
25
+ toString = Object.prototype.toString,
26
+ hasDuplicate = false,
27
+ baseHasDuplicate = true;
28
+
29
+ // Here we check if the JavaScript engine is using some sort of
30
+ // optimization where it does not always call our comparision
31
+ // function. If that is the case, discard the hasDuplicate value.
32
+ // Thus far that includes Google Chrome.
33
+ [0, 0].sort(function(){
34
+ baseHasDuplicate = false;
35
+ return 0;
36
+ });
37
+
38
+ var Sizzle = function(selector, context, results, seed) {
39
+ results = results || [];
40
+ context = context || document;
41
+
42
+ var origContext = context;
43
+
44
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
45
+ return [];
46
+ }
47
+
48
+ if ( !selector || typeof selector !== "string" ) {
49
+ return results;
50
+ }
51
+
52
+ var parts = [], m, set, checkSet, extra, prune = true, contextXML = Sizzle.isXML(context),
53
+ soFar = selector, ret, cur, pop, i;
54
+
55
+ // Reset the position of the chunker regexp (start from head)
56
+ do {
57
+ chunker.exec("");
58
+ m = chunker.exec(soFar);
59
+
60
+ if ( m ) {
61
+ soFar = m[3];
62
+
63
+ parts.push( m[1] );
64
+
65
+ if ( m[2] ) {
66
+ extra = m[3];
67
+ break;
68
+ }
69
+ }
70
+ } while ( m );
71
+
72
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
73
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
74
+ set = posProcess( parts[0] + parts[1], context );
75
+ } else {
76
+ set = Expr.relative[ parts[0] ] ?
77
+ [ context ] :
78
+ Sizzle( parts.shift(), context );
79
+
80
+ while ( parts.length ) {
81
+ selector = parts.shift();
82
+
83
+ if ( Expr.relative[ selector ] ) {
84
+ selector += parts.shift();
85
+ }
86
+
87
+ set = posProcess( selector, set );
88
+ }
89
+ }
90
+ } else {
91
+ // Take a shortcut and set the context if the root selector is an ID
92
+ // (but not if it'll be faster if the inner selector is an ID)
93
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
94
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
95
+ ret = Sizzle.find( parts.shift(), context, contextXML );
96
+ context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
97
+ }
98
+
99
+ if ( context ) {
100
+ ret = seed ?
101
+ { expr: parts.pop(), set: makeArray(seed) } :
102
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
103
+ set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
104
+
105
+ if ( parts.length > 0 ) {
106
+ checkSet = makeArray(set);
107
+ } else {
108
+ prune = false;
109
+ }
110
+
111
+ while ( parts.length ) {
112
+ cur = parts.pop();
113
+ pop = cur;
114
+
115
+ if ( !Expr.relative[ cur ] ) {
116
+ cur = "";
117
+ } else {
118
+ pop = parts.pop();
119
+ }
120
+
121
+ if ( pop == null ) {
122
+ pop = context;
123
+ }
124
+
125
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
126
+ }
127
+ } else {
128
+ checkSet = parts = [];
129
+ }
130
+ }
131
+
132
+ if ( !checkSet ) {
133
+ checkSet = set;
134
+ }
135
+
136
+ if ( !checkSet ) {
137
+ Sizzle.error( cur || selector );
138
+ }
139
+
140
+ if ( toString.call(checkSet) === "[object Array]" ) {
141
+ if ( !prune ) {
142
+ results.push.apply( results, checkSet );
143
+ } else if ( context && context.nodeType === 1 ) {
144
+ for ( i = 0; checkSet[i] != null; i++ ) {
145
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
146
+ results.push( set[i] );
147
+ }
148
+ }
149
+ } else {
150
+ for ( i = 0; checkSet[i] != null; i++ ) {
151
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
152
+ results.push( set[i] );
153
+ }
154
+ }
155
+ }
156
+ } else {
157
+ makeArray( checkSet, results );
158
+ }
159
+
160
+ if ( extra ) {
161
+ Sizzle( extra, origContext, results, seed );
162
+ Sizzle.uniqueSort( results );
163
+ }
164
+
165
+ return results;
166
+ };
167
+
168
+ Sizzle.uniqueSort = function(results){
169
+ if ( sortOrder ) {
170
+ hasDuplicate = baseHasDuplicate;
171
+ results.sort(sortOrder);
172
+
173
+ if ( hasDuplicate ) {
174
+ for ( var i = 1; i < results.length; i++ ) {
175
+ if ( results[i] === results[i-1] ) {
176
+ results.splice(i--, 1);
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ return results;
183
+ };
184
+
185
+ Sizzle.matches = function(expr, set){
186
+ return Sizzle(expr, null, null, set);
187
+ };
188
+
189
+ Sizzle.find = function(expr, context, isXML){
190
+ var set;
191
+
192
+ if ( !expr ) {
193
+ return [];
194
+ }
195
+
196
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
197
+ var type = Expr.order[i], match;
198
+
199
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
200
+ var left = match[1];
201
+ match.splice(1,1);
202
+
203
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
204
+ match[1] = (match[1] || "").replace(/\\/g, "");
205
+ set = Expr.find[ type ]( match, context, isXML );
206
+ if ( set != null ) {
207
+ expr = expr.replace( Expr.match[ type ], "" );
208
+ break;
209
+ }
210
+ }
211
+ }
212
+ }
213
+
214
+ if ( !set ) {
215
+ set = context.getElementsByTagName("*");
216
+ }
217
+
218
+ return {set: set, expr: expr};
219
+ };
220
+
221
+ Sizzle.filter = function(expr, set, inplace, not){
222
+ var old = expr, result = [], curLoop = set, match, anyFound,
223
+ isXMLFilter = set && set[0] && Sizzle.isXML(set[0]);
224
+
225
+ while ( expr && set.length ) {
226
+ for ( var type in Expr.filter ) {
227
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
228
+ var filter = Expr.filter[ type ], found, item, left = match[1];
229
+ anyFound = false;
230
+
231
+ match.splice(1,1);
232
+
233
+ if ( left.substr( left.length - 1 ) === "\\" ) {
234
+ continue;
235
+ }
236
+
237
+ if ( curLoop === result ) {
238
+ result = [];
239
+ }
240
+
241
+ if ( Expr.preFilter[ type ] ) {
242
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
243
+
244
+ if ( !match ) {
245
+ anyFound = found = true;
246
+ } else if ( match === true ) {
247
+ continue;
248
+ }
249
+ }
250
+
251
+ if ( match ) {
252
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
253
+ if ( item ) {
254
+ found = filter( item, match, i, curLoop );
255
+ var pass = not ^ !!found;
256
+
257
+ if ( inplace && found != null ) {
258
+ if ( pass ) {
259
+ anyFound = true;
260
+ } else {
261
+ curLoop[i] = false;
262
+ }
263
+ } else if ( pass ) {
264
+ result.push( item );
265
+ anyFound = true;
266
+ }
267
+ }
268
+ }
269
+ }
270
+
271
+ if ( found !== undefined ) {
272
+ if ( !inplace ) {
273
+ curLoop = result;
274
+ }
275
+
276
+ expr = expr.replace( Expr.match[ type ], "" );
277
+
278
+ if ( !anyFound ) {
279
+ return [];
280
+ }
281
+
282
+ break;
283
+ }
284
+ }
285
+ }
286
+
287
+ // Improper expression
288
+ if ( expr === old ) {
289
+ if ( anyFound == null ) {
290
+ Sizzle.error( expr );
291
+ } else {
292
+ break;
293
+ }
294
+ }
295
+
296
+ old = expr;
297
+ }
298
+
299
+ return curLoop;
300
+ };
301
+
302
+ Sizzle.error = function( msg ) {
303
+ throw "Syntax error, unrecognized expression: " + msg;
304
+ };
305
+
306
+ var Expr = Sizzle.selectors = {
307
+ order: [ "ID", "NAME", "TAG" ],
308
+ match: {
309
+ ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
310
+ CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
311
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
312
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
313
+ TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
314
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
315
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
316
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
317
+ },
318
+ leftMatch: {},
319
+ attrMap: {
320
+ "class": "className",
321
+ "for": "htmlFor"
322
+ },
323
+ attrHandle: {
324
+ href: function(elem){
325
+ return elem.getAttribute("href");
326
+ }
327
+ },
328
+ relative: {
329
+ "+": function(checkSet, part){
330
+ var isPartStr = typeof part === "string",
331
+ isTag = isPartStr && !/\W/.test(part),
332
+ isPartStrNotTag = isPartStr && !isTag;
333
+
334
+ if ( isTag ) {
335
+ part = part.toLowerCase();
336
+ }
337
+
338
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
339
+ if ( (elem = checkSet[i]) ) {
340
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
341
+
342
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
343
+ elem || false :
344
+ elem === part;
345
+ }
346
+ }
347
+
348
+ if ( isPartStrNotTag ) {
349
+ Sizzle.filter( part, checkSet, true );
350
+ }
351
+ },
352
+ ">": function(checkSet, part){
353
+ var isPartStr = typeof part === "string",
354
+ elem, i = 0, l = checkSet.length;
355
+
356
+ if ( isPartStr && !/\W/.test(part) ) {
357
+ part = part.toLowerCase();
358
+
359
+ for ( ; i < l; i++ ) {
360
+ elem = checkSet[i];
361
+ if ( elem ) {
362
+ var parent = elem.parentNode;
363
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
364
+ }
365
+ }
366
+ } else {
367
+ for ( ; i < l; i++ ) {
368
+ elem = checkSet[i];
369
+ if ( elem ) {
370
+ checkSet[i] = isPartStr ?
371
+ elem.parentNode :
372
+ elem.parentNode === part;
373
+ }
374
+ }
375
+
376
+ if ( isPartStr ) {
377
+ Sizzle.filter( part, checkSet, true );
378
+ }
379
+ }
380
+ },
381
+ "": function(checkSet, part, isXML){
382
+ var doneName = done++, checkFn = dirCheck, nodeCheck;
383
+
384
+ if ( typeof part === "string" && !/\W/.test(part) ) {
385
+ part = part.toLowerCase();
386
+ nodeCheck = part;
387
+ checkFn = dirNodeCheck;
388
+ }
389
+
390
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
391
+ },
392
+ "~": function(checkSet, part, isXML){
393
+ var doneName = done++, checkFn = dirCheck, nodeCheck;
394
+
395
+ if ( typeof part === "string" && !/\W/.test(part) ) {
396
+ part = part.toLowerCase();
397
+ nodeCheck = part;
398
+ checkFn = dirNodeCheck;
399
+ }
400
+
401
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
402
+ }
403
+ },
404
+ find: {
405
+ ID: function(match, context, isXML){
406
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
407
+ var m = context.getElementById(match[1]);
408
+ // Check parentNode to catch when Blackberry 4.6 returns
409
+ // nodes that are no longer in the document #6963
410
+ return m && m.parentNode ? [m] : [];
411
+ }
412
+ },
413
+ NAME: function(match, context){
414
+ if ( typeof context.getElementsByName !== "undefined" ) {
415
+ var ret = [], results = context.getElementsByName(match[1]);
416
+
417
+ for ( var i = 0, l = results.length; i < l; i++ ) {
418
+ if ( results[i].getAttribute("name") === match[1] ) {
419
+ ret.push( results[i] );
420
+ }
421
+ }
422
+
423
+ return ret.length === 0 ? null : ret;
424
+ }
425
+ },
426
+ TAG: function(match, context){
427
+ return context.getElementsByTagName(match[1]);
428
+ }
429
+ },
430
+ preFilter: {
431
+ CLASS: function(match, curLoop, inplace, result, not, isXML){
432
+ match = " " + match[1].replace(/\\/g, "") + " ";
433
+
434
+ if ( isXML ) {
435
+ return match;
436
+ }
437
+
438
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
439
+ if ( elem ) {
440
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
441
+ if ( !inplace ) {
442
+ result.push( elem );
443
+ }
444
+ } else if ( inplace ) {
445
+ curLoop[i] = false;
446
+ }
447
+ }
448
+ }
449
+
450
+ return false;
451
+ },
452
+ ID: function(match){
453
+ return match[1].replace(/\\/g, "");
454
+ },
455
+ TAG: function(match, curLoop){
456
+ return match[1].toLowerCase();
457
+ },
458
+ CHILD: function(match){
459
+ if ( match[1] === "nth" ) {
460
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
461
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
462
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
463
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
464
+
465
+ // calculate the numbers (first)n+(last) including if they are negative
466
+ match[2] = (test[1] + (test[2] || 1)) - 0;
467
+ match[3] = test[3] - 0;
468
+ }
469
+
470
+ // TODO: Move to normal caching system
471
+ match[0] = done++;
472
+
473
+ return match;
474
+ },
475
+ ATTR: function(match, curLoop, inplace, result, not, isXML){
476
+ var name = match[1].replace(/\\/g, "");
477
+
478
+ if ( !isXML && Expr.attrMap[name] ) {
479
+ match[1] = Expr.attrMap[name];
480
+ }
481
+
482
+ if ( match[2] === "~=" ) {
483
+ match[4] = " " + match[4] + " ";
484
+ }
485
+
486
+ return match;
487
+ },
488
+ PSEUDO: function(match, curLoop, inplace, result, not){
489
+ if ( match[1] === "not" ) {
490
+ // If we're dealing with a complex expression, or a simple one
491
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
492
+ match[3] = Sizzle(match[3], null, null, curLoop);
493
+ } else {
494
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
495
+ if ( !inplace ) {
496
+ result.push.apply( result, ret );
497
+ }
498
+ return false;
499
+ }
500
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
501
+ return true;
502
+ }
503
+
504
+ return match;
505
+ },
506
+ POS: function(match){
507
+ match.unshift( true );
508
+ return match;
509
+ }
510
+ },
511
+ filters: {
512
+ enabled: function(elem){
513
+ return elem.disabled === false && elem.type !== "hidden";
514
+ },
515
+ disabled: function(elem){
516
+ return elem.disabled === true;
517
+ },
518
+ checked: function(elem){
519
+ return elem.checked === true;
520
+ },
521
+ selected: function(elem){
522
+ // Accessing this property makes selected-by-default
523
+ // options in Safari work properly
524
+ elem.parentNode.selectedIndex;
525
+ return elem.selected === true;
526
+ },
527
+ parent: function(elem){
528
+ return !!elem.firstChild;
529
+ },
530
+ empty: function(elem){
531
+ return !elem.firstChild;
532
+ },
533
+ has: function(elem, i, match){
534
+ return !!Sizzle( match[3], elem ).length;
535
+ },
536
+ header: function(elem){
537
+ return (/h\d/i).test( elem.nodeName );
538
+ },
539
+ text: function(elem){
540
+ return "text" === elem.type;
541
+ },
542
+ radio: function(elem){
543
+ return "radio" === elem.type;
544
+ },
545
+ checkbox: function(elem){
546
+ return "checkbox" === elem.type;
547
+ },
548
+ file: function(elem){
549
+ return "file" === elem.type;
550
+ },
551
+ password: function(elem){
552
+ return "password" === elem.type;
553
+ },
554
+ submit: function(elem){
555
+ return "submit" === elem.type;
556
+ },
557
+ image: function(elem){
558
+ return "image" === elem.type;
559
+ },
560
+ reset: function(elem){
561
+ return "reset" === elem.type;
562
+ },
563
+ button: function(elem){
564
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
565
+ },
566
+ input: function(elem){
567
+ return (/input|select|textarea|button/i).test(elem.nodeName);
568
+ }
569
+ },
570
+ setFilters: {
571
+ first: function(elem, i){
572
+ return i === 0;
573
+ },
574
+ last: function(elem, i, match, array){
575
+ return i === array.length - 1;
576
+ },
577
+ even: function(elem, i){
578
+ return i % 2 === 0;
579
+ },
580
+ odd: function(elem, i){
581
+ return i % 2 === 1;
582
+ },
583
+ lt: function(elem, i, match){
584
+ return i < match[3] - 0;
585
+ },
586
+ gt: function(elem, i, match){
587
+ return i > match[3] - 0;
588
+ },
589
+ nth: function(elem, i, match){
590
+ return match[3] - 0 === i;
591
+ },
592
+ eq: function(elem, i, match){
593
+ return match[3] - 0 === i;
594
+ }
595
+ },
596
+ filter: {
597
+ PSEUDO: function(elem, match, i, array){
598
+ var name = match[1], filter = Expr.filters[ name ];
599
+
600
+ if ( filter ) {
601
+ return filter( elem, i, match, array );
602
+ } else if ( name === "contains" ) {
603
+ return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
604
+ } else if ( name === "not" ) {
605
+ var not = match[3];
606
+
607
+ for ( var j = 0, l = not.length; j < l; j++ ) {
608
+ if ( not[j] === elem ) {
609
+ return false;
610
+ }
611
+ }
612
+
613
+ return true;
614
+ } else {
615
+ Sizzle.error( "Syntax error, unrecognized expression: " + name );
616
+ }
617
+ },
618
+ CHILD: function(elem, match){
619
+ var type = match[1], node = elem;
620
+ switch (type) {
621
+ case 'only':
622
+ case 'first':
623
+ while ( (node = node.previousSibling) ) {
624
+ if ( node.nodeType === 1 ) {
625
+ return false;
626
+ }
627
+ }
628
+ if ( type === "first" ) {
629
+ return true;
630
+ }
631
+ node = elem;
632
+ case 'last':
633
+ while ( (node = node.nextSibling) ) {
634
+ if ( node.nodeType === 1 ) {
635
+ return false;
636
+ }
637
+ }
638
+ return true;
639
+ case 'nth':
640
+ var first = match[2], last = match[3];
641
+
642
+ if ( first === 1 && last === 0 ) {
643
+ return true;
644
+ }
645
+
646
+ var doneName = match[0],
647
+ parent = elem.parentNode;
648
+
649
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
650
+ var count = 0;
651
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
652
+ if ( node.nodeType === 1 ) {
653
+ node.nodeIndex = ++count;
654
+ }
655
+ }
656
+ parent.sizcache = doneName;
657
+ }
658
+
659
+ var diff = elem.nodeIndex - last;
660
+ if ( first === 0 ) {
661
+ return diff === 0;
662
+ } else {
663
+ return ( diff % first === 0 && diff / first >= 0 );
664
+ }
665
+ }
666
+ },
667
+ ID: function(elem, match){
668
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
669
+ },
670
+ TAG: function(elem, match){
671
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
672
+ },
673
+ CLASS: function(elem, match){
674
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
675
+ .indexOf( match ) > -1;
676
+ },
677
+ ATTR: function(elem, match){
678
+ var name = match[1],
679
+ result = Expr.attrHandle[ name ] ?
680
+ Expr.attrHandle[ name ]( elem ) :
681
+ elem[ name ] != null ?
682
+ elem[ name ] :
683
+ elem.getAttribute( name ),
684
+ value = result + "",
685
+ type = match[2],
686
+ check = match[4];
687
+
688
+ return result == null ?
689
+ type === "!=" :
690
+ type === "=" ?
691
+ value === check :
692
+ type === "*=" ?
693
+ value.indexOf(check) >= 0 :
694
+ type === "~=" ?
695
+ (" " + value + " ").indexOf(check) >= 0 :
696
+ !check ?
697
+ value && result !== false :
698
+ type === "!=" ?
699
+ value !== check :
700
+ type === "^=" ?
701
+ value.indexOf(check) === 0 :
702
+ type === "$=" ?
703
+ value.substr(value.length - check.length) === check :
704
+ type === "|=" ?
705
+ value === check || value.substr(0, check.length + 1) === check + "-" :
706
+ false;
707
+ },
708
+ POS: function(elem, match, i, array){
709
+ var name = match[2], filter = Expr.setFilters[ name ];
710
+
711
+ if ( filter ) {
712
+ return filter( elem, i, match, array );
713
+ }
714
+ }
715
+ }
716
+ };
717
+
718
+ var origPOS = Expr.match.POS,
719
+ fescape = function(all, num){
720
+ return "\\" + (num - 0 + 1);
721
+ };
722
+
723
+ for ( var type in Expr.match ) {
724
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
725
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
726
+ }
727
+
728
+ var makeArray = function(array, results) {
729
+ array = Array.prototype.slice.call( array, 0 );
730
+
731
+ if ( results ) {
732
+ results.push.apply( results, array );
733
+ return results;
734
+ }
735
+
736
+ return array;
737
+ };
738
+
739
+ // Perform a simple check to determine if the browser is capable of
740
+ // converting a NodeList to an array using builtin methods.
741
+ // Also verifies that the returned array holds DOM nodes
742
+ // (which is not the case in the Blackberry browser)
743
+ try {
744
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
745
+
746
+ // Provide a fallback method if it does not work
747
+ } catch(e){
748
+ makeArray = function(array, results) {
749
+ var ret = results || [], i = 0;
750
+
751
+ if ( toString.call(array) === "[object Array]" ) {
752
+ Array.prototype.push.apply( ret, array );
753
+ } else {
754
+ if ( typeof array.length === "number" ) {
755
+ for ( var l = array.length; i < l; i++ ) {
756
+ ret.push( array[i] );
757
+ }
758
+ } else {
759
+ for ( ; array[i]; i++ ) {
760
+ ret.push( array[i] );
761
+ }
762
+ }
763
+ }
764
+
765
+ return ret;
766
+ };
767
+ }
768
+
769
+ var sortOrder, siblingCheck;
770
+
771
+ if ( document.documentElement.compareDocumentPosition ) {
772
+ sortOrder = function( a, b ) {
773
+ if ( a === b ) {
774
+ hasDuplicate = true;
775
+ return 0;
776
+ }
777
+
778
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
779
+ return a.compareDocumentPosition ? -1 : 1;
780
+ }
781
+
782
+ return a.compareDocumentPosition(b) & 4 ? -1 : 1;
783
+ };
784
+ } else {
785
+ sortOrder = function( a, b ) {
786
+ var ap = [], bp = [], aup = a.parentNode, bup = b.parentNode,
787
+ cur = aup, al, bl;
788
+
789
+ // The nodes are identical, we can exit early
790
+ if ( a === b ) {
791
+ hasDuplicate = true;
792
+ return 0;
793
+
794
+ // If the nodes are siblings (or identical) we can do a quick check
795
+ } else if ( aup === bup ) {
796
+ return siblingCheck( a, b );
797
+
798
+ // If no parents were found then the nodes are disconnected
799
+ } else if ( !aup ) {
800
+ return -1;
801
+
802
+ } else if ( !bup ) {
803
+ return 1;
804
+ }
805
+
806
+ // Otherwise they're somewhere else in the tree so we need
807
+ // to build up a full list of the parentNodes for comparison
808
+ while ( cur ) {
809
+ ap.unshift( cur );
810
+ cur = cur.parentNode;
811
+ }
812
+
813
+ cur = bup;
814
+
815
+ while ( cur ) {
816
+ bp.unshift( cur );
817
+ cur = cur.parentNode;
818
+ }
819
+
820
+ al = ap.length;
821
+ bl = bp.length;
822
+
823
+ // Start walking down the tree looking for a discrepancy
824
+ for ( var i = 0; i < al && i < bl; i++ ) {
825
+ if ( ap[i] !== bp[i] ) {
826
+ return siblingCheck( ap[i], bp[i] );
827
+ }
828
+ }
829
+
830
+ // We ended someplace up the tree so do a sibling check
831
+ return i === al ?
832
+ siblingCheck( a, bp[i], -1 ) :
833
+ siblingCheck( ap[i], b, 1 );
834
+ };
835
+
836
+ siblingCheck = function( a, b, ret ) {
837
+ if ( a === b ) {
838
+ return ret;
839
+ }
840
+
841
+ var cur = a.nextSibling;
842
+
843
+ while ( cur ) {
844
+ if ( cur === b ) {
845
+ return -1;
846
+ }
847
+
848
+ cur = cur.nextSibling;
849
+ }
850
+
851
+ return 1;
852
+ };
853
+ }
854
+
855
+ // Utility function for retreiving the text value of an array of DOM nodes
856
+ Sizzle.getText = function( elems ) {
857
+ var ret = "", elem;
858
+
859
+ for ( var i = 0; elems[i]; i++ ) {
860
+ elem = elems[i];
861
+
862
+ // Get the text from text nodes and CDATA nodes
863
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
864
+ ret += elem.nodeValue;
865
+
866
+ // Traverse everything else, except comment nodes
867
+ } else if ( elem.nodeType !== 8 ) {
868
+ ret += Sizzle.getText( elem.childNodes );
869
+ }
870
+ }
871
+
872
+ return ret;
873
+ };
874
+
875
+ // Check to see if the browser returns elements by name when
876
+ // querying by getElementById (and provide a workaround)
877
+ (function(){
878
+ // We're going to inject a fake input element with a specified name
879
+ var form = document.createElement("div"),
880
+ id = "script" + (new Date()).getTime();
881
+ form.innerHTML = "<a name='" + id + "'/>";
882
+
883
+ // Inject it into the root element, check its status, and remove it quickly
884
+ var root = document.documentElement;
885
+ root.insertBefore( form, root.firstChild );
886
+
887
+ // The workaround has to do additional checks after a getElementById
888
+ // Which slows things down for other browsers (hence the branching)
889
+ if ( document.getElementById( id ) ) {
890
+ Expr.find.ID = function(match, context, isXML){
891
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
892
+ var m = context.getElementById(match[1]);
893
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
894
+ }
895
+ };
896
+
897
+ Expr.filter.ID = function(elem, match){
898
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
899
+ return elem.nodeType === 1 && node && node.nodeValue === match;
900
+ };
901
+ }
902
+
903
+ root.removeChild( form );
904
+ root = form = null; // release memory in IE
905
+ })();
906
+
907
+ (function(){
908
+ // Check to see if the browser returns only elements
909
+ // when doing getElementsByTagName("*")
910
+
911
+ // Create a fake element
912
+ var div = document.createElement("div");
913
+ div.appendChild( document.createComment("") );
914
+
915
+ // Make sure no comments are found
916
+ if ( div.getElementsByTagName("*").length > 0 ) {
917
+ Expr.find.TAG = function(match, context){
918
+ var results = context.getElementsByTagName(match[1]);
919
+
920
+ // Filter out possible comments
921
+ if ( match[1] === "*" ) {
922
+ var tmp = [];
923
+
924
+ for ( var i = 0; results[i]; i++ ) {
925
+ if ( results[i].nodeType === 1 ) {
926
+ tmp.push( results[i] );
927
+ }
928
+ }
929
+
930
+ results = tmp;
931
+ }
932
+
933
+ return results;
934
+ };
935
+ }
936
+
937
+ // Check to see if an attribute returns normalized href attributes
938
+ div.innerHTML = "<a href='#'></a>";
939
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
940
+ div.firstChild.getAttribute("href") !== "#" ) {
941
+ Expr.attrHandle.href = function(elem){
942
+ return elem.getAttribute("href", 2);
943
+ };
944
+ }
945
+
946
+ div = null; // release memory in IE
947
+ })();
948
+
949
+ if ( document.querySelectorAll ) {
950
+ (function(){
951
+ var oldSizzle = Sizzle, div = document.createElement("div");
952
+ div.innerHTML = "<p class='TEST'></p>";
953
+
954
+ // Safari can't handle uppercase or unicode characters when
955
+ // in quirks mode.
956
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
957
+ return;
958
+ }
959
+
960
+ Sizzle = function(query, context, extra, seed){
961
+ context = context || document;
962
+
963
+ // Only use querySelectorAll on non-XML documents
964
+ // (ID selectors don't work in non-HTML documents)
965
+ if ( !seed && context.nodeType === 9 && !Sizzle.isXML(context) ) {
966
+ try {
967
+ return makeArray( context.querySelectorAll(query), extra );
968
+ } catch(e){}
969
+ }
970
+
971
+ return oldSizzle(query, context, extra, seed);
972
+ };
973
+
974
+ for ( var prop in oldSizzle ) {
975
+ Sizzle[ prop ] = oldSizzle[ prop ];
976
+ }
977
+
978
+ div = null; // release memory in IE
979
+ })();
980
+ }
981
+
982
+ (function(){
983
+ var div = document.createElement("div");
984
+
985
+ div.innerHTML = "<div class='test e'></div><div class='test'></div>";
986
+
987
+ // Opera can't find a second classname (in 9.6)
988
+ // Also, make sure that getElementsByClassName actually exists
989
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
990
+ return;
991
+ }
992
+
993
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
994
+ div.lastChild.className = "e";
995
+
996
+ if ( div.getElementsByClassName("e").length === 1 ) {
997
+ return;
998
+ }
999
+
1000
+ Expr.order.splice(1, 0, "CLASS");
1001
+ Expr.find.CLASS = function(match, context, isXML) {
1002
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
1003
+ return context.getElementsByClassName(match[1]);
1004
+ }
1005
+ };
1006
+
1007
+ div = null; // release memory in IE
1008
+ })();
1009
+
1010
+ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
1011
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
1012
+ var elem = checkSet[i];
1013
+ if ( elem ) {
1014
+ elem = elem[dir];
1015
+ var match = false;
1016
+
1017
+ while ( elem ) {
1018
+ if ( elem.sizcache === doneName ) {
1019
+ match = checkSet[elem.sizset];
1020
+ break;
1021
+ }
1022
+
1023
+ if ( elem.nodeType === 1 && !isXML ){
1024
+ elem.sizcache = doneName;
1025
+ elem.sizset = i;
1026
+ }
1027
+
1028
+ if ( elem.nodeName.toLowerCase() === cur ) {
1029
+ match = elem;
1030
+ break;
1031
+ }
1032
+
1033
+ elem = elem[dir];
1034
+ }
1035
+
1036
+ checkSet[i] = match;
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
1042
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
1043
+ var elem = checkSet[i];
1044
+ if ( elem ) {
1045
+ elem = elem[dir];
1046
+ var match = false;
1047
+
1048
+ while ( elem ) {
1049
+ if ( elem.sizcache === doneName ) {
1050
+ match = checkSet[elem.sizset];
1051
+ break;
1052
+ }
1053
+
1054
+ if ( elem.nodeType === 1 ) {
1055
+ if ( !isXML ) {
1056
+ elem.sizcache = doneName;
1057
+ elem.sizset = i;
1058
+ }
1059
+ if ( typeof cur !== "string" ) {
1060
+ if ( elem === cur ) {
1061
+ match = true;
1062
+ break;
1063
+ }
1064
+
1065
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
1066
+ match = elem;
1067
+ break;
1068
+ }
1069
+ }
1070
+
1071
+ elem = elem[dir];
1072
+ }
1073
+
1074
+ checkSet[i] = match;
1075
+ }
1076
+ }
1077
+ }
1078
+
1079
+ Sizzle.contains = document.compareDocumentPosition ? function(a, b){
1080
+ return !!(a.compareDocumentPosition(b) & 16);
1081
+ } : function(a, b){
1082
+ return a !== b && (a.contains ? a.contains(b) : true);
1083
+ };
1084
+
1085
+ Sizzle.isXML = function(elem){
1086
+ // documentElement is verified for cases where it doesn't yet exist
1087
+ // (such as loading iframes in IE - #4833)
1088
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
1089
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
1090
+ };
1091
+
1092
+ var posProcess = function(selector, context){
1093
+ var tmpSet = [], later = "", match,
1094
+ root = context.nodeType ? [context] : context;
1095
+
1096
+ // Position selectors must be done after the filter
1097
+ // And so must :not(positional) so we move all PSEUDOs to the end
1098
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
1099
+ later += match[0];
1100
+ selector = selector.replace( Expr.match.PSEUDO, "" );
1101
+ }
1102
+
1103
+ selector = Expr.relative[selector] ? selector + "*" : selector;
1104
+
1105
+ for ( var i = 0, l = root.length; i < l; i++ ) {
1106
+ Sizzle( selector, root[i], tmpSet );
1107
+ }
1108
+
1109
+ return Sizzle.filter( later, tmpSet );
1110
+ };
1111
+
1112
+ // EXPOSE
1113
+
1114
+ window.Sizzle = Sizzle;
1115
+
1116
+ })();
1117
+
1118
+
1119
+ RightJS([RightJS.Document, RightJS.Element]).each('include', {
1120
+ first: function(rule) {
1121
+ return this.find(rule)[0];
1122
+ },
1123
+
1124
+ find: function(rule) {
1125
+ return RightJS(Sizzle(rule, this._)).map(RightJS.$);
1126
+ }
1127
+ });