envjs 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.jslintrbrc +29 -0
  2. data/.project +17 -0
  3. data/CHANGELOG.rdoc +3 -0
  4. data/DTD/xhtml-lat1.ent +196 -0
  5. data/DTD/xhtml-special.ent +80 -0
  6. data/DTD/xhtml-symbol.ent +237 -0
  7. data/DTD/xhtml.soc +14 -0
  8. data/DTD/xhtml1-frameset.dtd +1235 -0
  9. data/DTD/xhtml1-strict.dtd +978 -0
  10. data/DTD/xhtml1-transitional.dtd +1201 -0
  11. data/DTD/xhtml1.dcl +192 -0
  12. data/Makefile +7 -0
  13. data/Manifest.txt +287 -0
  14. data/{README → README.rdoc} +24 -3
  15. data/Rakefile +196 -0
  16. data/Wakefile +24 -0
  17. data/build.properties +9 -0
  18. data/build.xml +247 -0
  19. data/gm/jquery.js +6002 -0
  20. data/gm/mainx.js +2648 -0
  21. data/gm/sensx.js +135 -0
  22. data/gm/t.js +6 -0
  23. data/gm/x.html +76 -0
  24. data/htmlparser/BrowserTreeBuilder.java +456 -0
  25. data/htmlparser/README +34 -0
  26. data/htmlparser/build.sh +38 -0
  27. data/jsl/jsl +0 -0
  28. data/jsl/jsl.default.conf +129 -0
  29. data/jsl/jsl.exe +0 -0
  30. data/lib/envjs.rb +2 -0
  31. data/lib/envjs/env.js +22 -3
  32. data/lib/envjs/event_loop.js +2 -0
  33. data/lib/envjs/static.js +155 -21
  34. data/licenses/GPL-LICENSE.txt +278 -0
  35. data/licenses/MIT-LICENSE.txt +20 -0
  36. data/src/base64.js +80 -0
  37. data/src/build.js +6 -0
  38. data/src/cruft/bad.html +24 -0
  39. data/src/cruft/dom.js +606 -0
  40. data/src/cruft/element.js +297 -0
  41. data/src/cruft/good.html +30 -0
  42. data/src/cruft/good.js +32 -0
  43. data/src/cruft/internal.js +81 -0
  44. data/src/cruft/parser.js +458 -0
  45. data/src/css/properties.js +293 -0
  46. data/src/css/rule.js +22 -0
  47. data/src/css/sizzle.js +717 -0
  48. data/src/css/stylesheet.js +52 -0
  49. data/src/dom/attr.js +55 -0
  50. data/src/dom/cdatasection.js +31 -0
  51. data/src/dom/characterdata.js +119 -0
  52. data/src/dom/comment.js +30 -0
  53. data/src/dom/doctype.js +9 -0
  54. data/src/dom/document.js +553 -0
  55. data/src/dom/dom.js +134 -0
  56. data/src/dom/element.js +217 -0
  57. data/src/dom/entities.js +273 -0
  58. data/src/dom/exception.js +28 -0
  59. data/src/dom/fragment.js +37 -0
  60. data/src/dom/implementation.js +602 -0
  61. data/src/dom/instruction.js +51 -0
  62. data/src/dom/namednodemap.js +374 -0
  63. data/src/dom/namespace.js +50 -0
  64. data/src/dom/node.js +618 -0
  65. data/src/dom/nodelist.js +195 -0
  66. data/src/dom/parser.js +1207 -0
  67. data/src/dom/text.js +73 -0
  68. data/src/event/event.js +39 -0
  69. data/src/event/mouseevent.js +4 -0
  70. data/src/event/uievent.js +8 -0
  71. data/src/html/a.js +110 -0
  72. data/src/html/anchor.js +80 -0
  73. data/src/html/area.js +57 -0
  74. data/src/html/base.js +26 -0
  75. data/src/html/blockquote-q.js +19 -0
  76. data/src/html/body.js +19 -0
  77. data/src/html/button.js +21 -0
  78. data/src/html/canvas.js +14 -0
  79. data/src/html/col-colgroup.js +49 -0
  80. data/src/html/collection.js +72 -0
  81. data/src/html/cookie.js +151 -0
  82. data/src/html/del-ins.js +25 -0
  83. data/src/html/div.js +28 -0
  84. data/src/html/document.js +359 -0
  85. data/src/html/element.js +380 -0
  86. data/src/html/fieldset.js +19 -0
  87. data/src/html/form.js +484 -0
  88. data/src/html/frame.js +89 -0
  89. data/src/html/frameset.js +25 -0
  90. data/src/html/head.js +44 -0
  91. data/src/html/html.js +0 -0
  92. data/src/html/htmlparser.js +340 -0
  93. data/src/html/iframe.js +26 -0
  94. data/src/html/image.js +0 -0
  95. data/src/html/img.js +62 -0
  96. data/src/html/input-elements.js +307 -0
  97. data/src/html/input.js +65 -0
  98. data/src/html/label.js +26 -0
  99. data/src/html/legend.js +19 -0
  100. data/src/html/link.js +82 -0
  101. data/src/html/map.js +22 -0
  102. data/src/html/meta.js +37 -0
  103. data/src/html/object.js +89 -0
  104. data/src/html/optgroup.js +25 -0
  105. data/src/html/option.js +97 -0
  106. data/src/html/param.js +38 -0
  107. data/src/html/script.js +122 -0
  108. data/src/html/select.js +129 -0
  109. data/src/html/style.js +31 -0
  110. data/src/html/table.js +199 -0
  111. data/src/html/tbody-thead-tfoot.js +91 -0
  112. data/src/html/td-th.js +18 -0
  113. data/src/html/textarea.js +25 -0
  114. data/src/html/title.js +20 -0
  115. data/src/html/tr.js +114 -0
  116. data/src/intro.js +141 -0
  117. data/src/outro.js +70 -0
  118. data/src/parser/html5.detailed.js +10762 -0
  119. data/src/parser/html5.min.js +503 -0
  120. data/src/parser/html5.pretty.js +10815 -0
  121. data/src/parser/intro.js +42 -0
  122. data/src/parser/outro.js +9 -0
  123. data/src/platform/core.js +323 -0
  124. data/src/platform/johnson.js +479 -0
  125. data/src/platform/rhino.js +327 -0
  126. data/src/platform/static/intro.js +41 -0
  127. data/src/platform/static/outro.js +30 -0
  128. data/src/profile/aop.js +238 -0
  129. data/src/profile/profile.js +402 -0
  130. data/src/serializer/xml.js +21 -0
  131. data/src/svg/animatedstring.js +25 -0
  132. data/src/svg/document.js +25 -0
  133. data/src/svg/element.js +22 -0
  134. data/src/svg/locatable.js +17 -0
  135. data/src/svg/rect.js +18 -0
  136. data/src/svg/rectelement.js +24 -0
  137. data/src/svg/stylable.js +49 -0
  138. data/src/svg/svgelement.js +22 -0
  139. data/src/svg/transformable.js +15 -0
  140. data/src/window/css.js +15 -0
  141. data/src/window/dialog.js +16 -0
  142. data/src/window/document.js +28 -0
  143. data/src/window/event.js +262 -0
  144. data/src/window/history.js +62 -0
  145. data/src/window/location.js +138 -0
  146. data/src/window/navigator.js +48 -0
  147. data/src/window/screen.js +53 -0
  148. data/src/window/timer.js +21 -0
  149. data/src/window/window.js +284 -0
  150. data/src/window/xhr.js +127 -0
  151. data/src/xpath/expression.js +49 -0
  152. data/src/xpath/implementation.js +2482 -0
  153. data/src/xpath/result.js +67 -0
  154. data/src/xpath/util.js +551 -0
  155. data/src/xpath/xmltoken.js +149 -0
  156. data/src/xslt/COPYING +34 -0
  157. data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
  158. data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
  159. data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
  160. data/src/xslt/ajaxslt-0.8.1/README +102 -0
  161. data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
  162. data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
  163. data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
  164. data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
  165. data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
  166. data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
  167. data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
  168. data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
  169. data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
  170. data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
  171. data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
  172. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
  173. data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
  174. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
  175. data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
  176. data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
  177. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
  178. data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
  179. data/src/xslt/implementation.js +625 -0
  180. data/src/xslt/processor.js +37 -0
  181. data/src/xslt/util.js +449 -0
  182. data/test/foo.html +8 -0
  183. data/test/foo.js +40 -0
  184. data/test/jquery.js +6002 -0
  185. data/test/x.js +1 -0
  186. data/test/y.js +1 -0
  187. metadata +245 -14
@@ -0,0 +1,293 @@
1
+ /*
2
+ * CSS2Properties - DOM Level 2 CSS
3
+ */
4
+ var CSS2Properties = function(element){
5
+ //this.onSetCallback = options.onSet?options.onSet:(function(){});
6
+ this.styleIndex = __supportedStyles__();
7
+ this.nameMap = {};
8
+ this.__previous__ = {};
9
+ this.__element__ = element;
10
+ __cssTextToStyles__(this, element.getAttribute('style')||'');
11
+ };
12
+ __extend__(CSS2Properties.prototype, {
13
+ get cssText(){
14
+ var css = '';
15
+ for(var i=0;i<this.length;i++){
16
+ css+=this[i]+":"+this.getPropertyValue(this[i])+';'
17
+ }
18
+ return css;
19
+ },
20
+ set cssText(cssText){
21
+ __cssTextToStyles__(this, cssText);
22
+ },
23
+ getPropertyCSSValue : function(name){
24
+ //?
25
+ },
26
+ getPropertyPriority : function(){
27
+
28
+ },
29
+ getPropertyValue : function(name){
30
+ if(name in this.styleIndex){
31
+ //$info(name +' in style index');
32
+ return this[name];
33
+ }else if(name in this.nameMap){
34
+ return this[__toCamelCase__(name)];
35
+ }
36
+ //$info(name +' not found');
37
+ return null;
38
+ },
39
+ item : function(index){
40
+ return this[index];
41
+ },
42
+ removeProperty: function(name){
43
+ this.styleIndex[name] = null;
44
+ },
45
+ setProperty: function(name, value){
46
+ //$info('setting css property '+name+' : '+value);
47
+ name = __toCamelCase__(name);
48
+ if(name in this.styleIndex){
49
+ //$info('setting camel case css property ');
50
+ if (value!==undefined){
51
+ this.styleIndex[name] = value;
52
+ }
53
+ if(name!==__toDashed__(name)){
54
+ //$info('setting dashed name css property ');
55
+ name = __toDashed__(name);
56
+ this[name] = value;
57
+ if(!(name in this.nameMap)){
58
+ Array.prototype.push.apply(this, [name]);
59
+ this.nameMap[name] = this.length;
60
+ }
61
+
62
+ }
63
+ }
64
+ //$info('finished setting css property '+name+' : '+value);
65
+ },
66
+ toString:function(){
67
+ if (this.length >0){
68
+ return "{\n\t"+Array.prototype.join.apply(this,[';\n\t'])+"}\n";
69
+ }else{
70
+ return '';
71
+ }
72
+ }
73
+ });
74
+
75
+
76
+
77
+ var __cssTextToStyles__ = function(css2props, cssText){
78
+ //var styleArray=[];
79
+ var style, styles = cssText.split(';');
80
+ for ( var i = 0; i < styles.length; i++ ) {
81
+ //$log("Adding style property " + styles[i]);
82
+ style = styles[i].split(':');
83
+ //$log(" style " + style[0]);
84
+ if ( style.length == 2 ){
85
+ //$log(" value " + style[1]);
86
+ css2props.setProperty( style[0].replace(" ",'','g'), style[1].replace(" ",'','g'));
87
+ }
88
+ }
89
+ };
90
+
91
+ var __toCamelCase__ = function(name) {
92
+ //$info('__toCamelCase__'+name);
93
+ if(name){
94
+ return name.replace(/\-(\w)/g, function(all, letter){
95
+ return letter.toUpperCase();
96
+ });
97
+ }
98
+ return name;
99
+ };
100
+
101
+ var __toDashed__ = function(camelCaseName) {
102
+ //$info("__toDashed__"+camelCaseName);
103
+ if(camelCaseName){
104
+ return camelCaseName.replace(/[A-Z]/g, function(all) {
105
+ return "-" + all.toLowerCase();
106
+ });
107
+ }
108
+ return camelCaseName;
109
+ };
110
+
111
+ //Obviously these arent all supported but by commenting out various sections
112
+ //this provides a single location to configure what is exposed as supported.
113
+ var __supportedStyles__ = function(){
114
+ return {
115
+ azimuth: null,
116
+ background: null,
117
+ backgroundAttachment: null,
118
+ backgroundColor: null,
119
+ backgroundImage: null,
120
+ backgroundPosition: null,
121
+ backgroundRepeat: null,
122
+ border: null,
123
+ borderBottom: null,
124
+ borderBottomColor: null,
125
+ borderBottomStyle: null,
126
+ borderBottomWidth: null,
127
+ borderCollapse: null,
128
+ borderColor: null,
129
+ borderLeft: null,
130
+ borderLeftColor: null,
131
+ borderLeftStyle: null,
132
+ borderLeftWidth: null,
133
+ borderRight: null,
134
+ borderRightColor: null,
135
+ borderRightStyle: null,
136
+ borderRightWidth: null,
137
+ borderSpacing: null,
138
+ borderStyle: null,
139
+ borderTop: null,
140
+ borderTopColor: null,
141
+ borderTopStyle: null,
142
+ borderTopWidth: null,
143
+ borderWidth: null,
144
+ bottom: null,
145
+ captionSide: null,
146
+ clear: null,
147
+ clip: null,
148
+ color: null,
149
+ content: null,
150
+ counterIncrement: null,
151
+ counterReset: null,
152
+ cssFloat: null,
153
+ cue: null,
154
+ cueAfter: null,
155
+ cueBefore: null,
156
+ cursor: null,
157
+ direction: 'ltr',
158
+ display: null,
159
+ elevation: null,
160
+ emptyCells: null,
161
+ font: null,
162
+ fontFamily: null,
163
+ fontSize: "1em",
164
+ fontSizeAdjust: null,
165
+ fontStretch: null,
166
+ fontStyle: null,
167
+ fontVariant: null,
168
+ fontWeight: null,
169
+ height: '1px',
170
+ left: null,
171
+ letterSpacing: null,
172
+ lineHeight: null,
173
+ listStyle: null,
174
+ listStyleImage: null,
175
+ listStylePosition: null,
176
+ listStyleType: null,
177
+ margin: null,
178
+ marginBottom: "0px",
179
+ marginLeft: "0px",
180
+ marginRight: "0px",
181
+ marginTop: "0px",
182
+ markerOffset: null,
183
+ marks: null,
184
+ maxHeight: null,
185
+ maxWidth: null,
186
+ minHeight: null,
187
+ minWidth: null,
188
+ opacity: 1,
189
+ orphans: null,
190
+ outline: null,
191
+ outlineColor: null,
192
+ outlineOffset: null,
193
+ outlineStyle: null,
194
+ outlineWidth: null,
195
+ overflow: null,
196
+ overflowX: null,
197
+ overflowY: null,
198
+ padding: null,
199
+ paddingBottom: "0px",
200
+ paddingLeft: "0px",
201
+ paddingRight: "0px",
202
+ paddingTop: "0px",
203
+ page: null,
204
+ pageBreakAfter: null,
205
+ pageBreakBefore: null,
206
+ pageBreakInside: null,
207
+ pause: null,
208
+ pauseAfter: null,
209
+ pauseBefore: null,
210
+ pitch: null,
211
+ pitchRange: null,
212
+ position: null,
213
+ quotes: null,
214
+ richness: null,
215
+ right: null,
216
+ size: null,
217
+ speak: null,
218
+ speakHeader: null,
219
+ speakNumeral: null,
220
+ speakPunctuation: null,
221
+ speechRate: null,
222
+ stress: null,
223
+ tableLayout: null,
224
+ textAlign: null,
225
+ textDecoration: null,
226
+ textIndent: null,
227
+ textShadow: null,
228
+ textTransform: null,
229
+ top: null,
230
+ unicodeBidi: null,
231
+ verticalAlign: null,
232
+ visibility: null,
233
+ voiceFamily: null,
234
+ volume: null,
235
+ whiteSpace: null,
236
+ widows: null,
237
+ width: '1px',
238
+ wordSpacing: null,
239
+ zIndex: 1
240
+ };
241
+ };
242
+
243
+ var __displayMap__ = {
244
+ "DIV" : "block",
245
+ "P" : "block",
246
+ "A" : "inline",
247
+ "CODE" : "inline",
248
+ "PRE" : "block",
249
+ "SPAN" : "inline",
250
+ "TABLE" : "table",
251
+ "THEAD" : "table-header-group",
252
+ "TBODY" : "table-row-group",
253
+ "TR" : "table-row",
254
+ "TH" : "table-cell",
255
+ "TD" : "table-cell",
256
+ "UL" : "block",
257
+ "LI" : "list-item"
258
+ };
259
+ var __styleMap__ = __supportedStyles__();
260
+
261
+ for(var style in __supportedStyles__()){
262
+ (function(name){
263
+ if(name === 'width' || name === 'height'){
264
+ CSS2Properties.prototype.__defineGetter__(name, function(){
265
+ if(this.display==='none'){
266
+ return '0px';
267
+ }
268
+ //$info(name+' = '+this.getPropertyValue(name));
269
+ return this.styleIndex[name];
270
+ });
271
+ }else if(name === 'display'){
272
+ //display will be set to a tagName specific value if ""
273
+ CSS2Properties.prototype.__defineGetter__(name, function(){
274
+ var val = this.styleIndex[name];
275
+ val = val?val:__displayMap__[this.__element__.tagName];
276
+ //$log(" css2properties.get " + name + "="+val+" for("+this.__element__.tagName+")");
277
+ return val;
278
+ });
279
+ }else{
280
+ CSS2Properties.prototype.__defineGetter__(name, function(){
281
+ //$log(" css2properties.get " + name + "="+this.styleIndex[name]);
282
+ return this.styleIndex[name];
283
+ });
284
+ }
285
+ CSS2Properties.prototype.__defineSetter__(name, function(value){
286
+ //$log(" css2properties.set " + name +"="+value);
287
+ this.setProperty(name, value);
288
+ });
289
+ })(style);
290
+ };
291
+
292
+
293
+ // $w.CSS2Properties = CSS2Properties;
data/src/css/rule.js ADDED
@@ -0,0 +1,22 @@
1
+ /*
2
+ * CSSRule - DOM Level 2
3
+ */
4
+ var CSSRule = function(options){
5
+ var $style,
6
+ $selectorText = options.selectorText?options.selectorText:"";
7
+ $style = new CSS2Properties({
8
+ cssText:options.cssText?options.cssText:null
9
+ });
10
+ return __extend__(this, {
11
+ get style(){
12
+ return $style;
13
+ },
14
+ get selectorText(){
15
+ return $selectorText;
16
+ },
17
+ set selectorText(selectorText){
18
+ $selectorText = selectorText;
19
+ }
20
+ });
21
+ };
22
+ // $w.CSSRule = CSSRule;
data/src/css/sizzle.js ADDED
@@ -0,0 +1,717 @@
1
+ /*
2
+ * Sizzle CSS Selector Engine
3
+ * Copyright 2008, John Resig (http://ejohn.org/)
4
+ * released under the MIT License
5
+ */
6
+ (function(){
7
+
8
+ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]+\]|[^[\]]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g;
9
+
10
+ var cache = null;
11
+ var done = 0;
12
+
13
+ if ( document.addEventListener && !document.querySelectorAll ) {
14
+ cache = {};
15
+ function invalidate(){ cache = {}; }
16
+ document.addEventListener("DOMAttrModified", invalidate, false);
17
+ document.addEventListener("DOMNodeInserted", invalidate, false);
18
+ document.addEventListener("DOMNodeRemoved", invalidate, false);
19
+ }
20
+
21
+ var Sizzle = function(selector, context, results) {
22
+ var doCache = !results;
23
+ results = results || [];
24
+ context = context || document;
25
+
26
+ if ( context.nodeType !== 1 && context.nodeType !== 9 )
27
+ return [];
28
+
29
+ if ( !selector || typeof selector !== "string" ) {
30
+ return results;
31
+ }
32
+
33
+ if ( cache && context === document && cache[ selector ] ) {
34
+ results.push.apply( results, cache[ selector ] );
35
+ return results;
36
+ }
37
+
38
+ var parts = [], m, set, checkSet, check, mode, extra;
39
+
40
+ // Reset the position of the chunker regexp (start from head)
41
+ chunker.lastIndex = 0;
42
+
43
+ while ( (m = chunker.exec(selector)) !== null ) {
44
+ parts.push( m[1] );
45
+
46
+ if ( m[2] ) {
47
+ extra = RegExp.rightContext;
48
+ break;
49
+ }
50
+ }
51
+
52
+ var ret = Sizzle.find( parts.pop(), context );
53
+ set = Sizzle.filter( ret.expr, ret.set );
54
+
55
+ if ( parts.length > 0 ) {
56
+ checkSet = makeArray(set);
57
+ }
58
+
59
+ while ( parts.length ) {
60
+ var cur = parts.pop(), pop = cur;
61
+
62
+ if ( !Expr.relative[ cur ] ) {
63
+ cur = "";
64
+ } else {
65
+ pop = parts.pop();
66
+ }
67
+
68
+ if ( pop == null ) {
69
+ pop = context;
70
+ }
71
+
72
+ var later = "", match;
73
+
74
+ // Position selectors must be done after the filter
75
+ if ( typeof pop === "string" ) {
76
+ while ( (match = Expr.match.POS.exec( pop )) ) {
77
+ later += match[0];
78
+ pop = pop.replace( Expr.match.POS, "" );
79
+ }
80
+ }
81
+
82
+ Expr.relative[ cur ]( checkSet, pop );
83
+
84
+ if ( later ) {
85
+ Sizzle.filter( later, checkSet, true );
86
+ }
87
+ }
88
+
89
+ if ( !checkSet ) {
90
+ checkSet = set;
91
+ }
92
+
93
+ if ( !checkSet ) {
94
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
95
+ }
96
+ if ( checkSet instanceof Array ) {
97
+ if ( context.nodeType === 1 ) {
98
+ for ( var i = 0; checkSet[i] != null; i++ ) {
99
+ if ( checkSet[i] && checkSet[i].nodeType === 1 && contains(context, checkSet[i]) ) {
100
+ results.push( set[i] );
101
+ }
102
+ }
103
+ } else {
104
+ for ( var i = 0; checkSet[i] != null; i++ ) {
105
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
106
+ results.push( set[i] );
107
+ }
108
+ }
109
+ }
110
+ } else {
111
+ makeArray( checkSet, results );
112
+ }
113
+
114
+ if ( extra ) {
115
+ arguments.callee( extra, context, results );
116
+ }
117
+
118
+ if ( cache && doCache ) {
119
+ cache[selector] = results.slice(0);
120
+ }
121
+
122
+ return results;
123
+ };
124
+
125
+ Sizzle.find = function(expr, context){
126
+ var set, match;
127
+
128
+ if ( !expr ) {
129
+ return [];
130
+ }
131
+
132
+ var later = "", match;
133
+
134
+ // Pseudo-selectors could contain other selectors (like :not)
135
+ while ( (match = Expr.match.PSEUDO.exec( expr )) ) {
136
+ var left = RegExp.leftContext;
137
+
138
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
139
+ later += match[0];
140
+ expr = expr.replace( Expr.match.PSEUDO, "" );
141
+ } else {
142
+ // TODO: Need a better solution, fails: .class\:foo:realfoo(#id)
143
+ break;
144
+ }
145
+ }
146
+
147
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
148
+ var type = Expr.order[i];
149
+
150
+ if ( (match = Expr.match[ type ].exec( expr )) ) {
151
+ var left = RegExp.leftContext;
152
+
153
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
154
+ match[1] = (match[1] || "").replace(/\\/g, "");
155
+ set = Expr.find[ type ]( match, context );
156
+
157
+ if ( set != null ) {
158
+ expr = expr.replace( Expr.match[ type ], "" );
159
+ break;
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ if ( !set ) {
166
+ set = context.getElementsByTagName("*");
167
+ }
168
+
169
+ expr += later;
170
+
171
+ return {set: set, expr: expr};
172
+ };
173
+
174
+ Sizzle.filter = function(expr, set, inplace){
175
+ var old = expr, result = [], curLoop = set, match;
176
+
177
+ while ( expr && set.length ) {
178
+ for ( var type in Expr.filter ) {
179
+ if ( (match = Expr.match[ type ].exec( expr )) != null ) {
180
+ var anyFound = false, filter = Expr.filter[ type ], goodArray = null;
181
+ match[1] = (match[1] || "").replace(/\\/g, "");
182
+
183
+ if ( curLoop == result ) {
184
+ result = [];
185
+ }
186
+
187
+ if ( Expr.preFilter[ type ] ) {
188
+ match = Expr.preFilter[ type ]( match, curLoop );
189
+
190
+ if ( match[0] === true ) {
191
+ goodArray = [];
192
+ var last = null, elem;
193
+ for ( var i = 0; (elem = curLoop[i]) !== undefined; i++ ) {
194
+ if ( elem && last !== elem ) {
195
+ goodArray.push( elem );
196
+ last = elem;
197
+ }
198
+ }
199
+ }
200
+
201
+ }
202
+
203
+ var goodPos = 0, found, item;
204
+
205
+ for ( var i = 0; (item = curLoop[i]) !== undefined; i++ ) {
206
+ if ( item ) {
207
+ if ( goodArray && item != goodArray[goodPos] ) {
208
+ goodPos++;
209
+ }
210
+
211
+ found = filter( item, match, goodPos, goodArray );
212
+ if ( inplace && found != null ) {
213
+ curLoop[i] = found ? curLoop[i] : false;
214
+ } else if ( found ) {
215
+ result.push( item );
216
+ anyFound = true;
217
+ }
218
+ }
219
+ }
220
+
221
+ if ( found !== undefined ) {
222
+ if ( !inplace ) {
223
+ curLoop = result;
224
+ }
225
+
226
+ expr = expr.replace( Expr.match[ type ], "" );
227
+
228
+ if ( !anyFound ) {
229
+ return [];
230
+ }
231
+
232
+ break;
233
+ }
234
+ }
235
+ }
236
+
237
+
238
+ expr = expr.replace(/\s*,\s*/, "");
239
+
240
+ // Improper expression
241
+ if ( expr == old ) {
242
+ throw "Syntax error, unrecognized expression: " + expr;
243
+ }
244
+
245
+ old = expr;
246
+ }
247
+
248
+ return curLoop;
249
+ };
250
+
251
+ var Expr = Sizzle.selectors = {
252
+ order: [ "ID", "NAME", "TAG" ],
253
+ match: {
254
+ ID: /#((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
255
+ CLASS: /\.((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
256
+ NAME: /\[name=((?:[\w\u0128-\uFFFF_-]|\\.)+)\]/,
257
+ ATTR: /\[((?:[\w\u0128-\uFFFF_-]|\\.)+)\s*(?:(\S{0,1}=)\s*(['"]*)(.*?)\3|)\]/,
258
+ TAG: /^((?:[\w\u0128-\uFFFF\*_-]|\\.)+)/,
259
+ CHILD: /:(only|nth|last|first)-child\(?(even|odd|[\dn+-]*)\)?/,
260
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)\(?(\d*)\)?/,
261
+ PSEUDO: /:((?:[\w\u0128-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
262
+ },
263
+ attrMap: {
264
+ "class": "className"
265
+ },
266
+ relative: {
267
+ "+": function(checkSet, part){
268
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
269
+ var elem = checkSet[i];
270
+ if ( elem ) {
271
+ var cur = elem.previousSibling;
272
+ while ( cur && cur.nodeType !== 1 ) {
273
+ cur = cur.previousSibling;
274
+ }
275
+ checkSet[i] = cur || false;
276
+ }
277
+ }
278
+
279
+ Sizzle.filter( part, checkSet, true );
280
+ },
281
+ ">": function(checkSet, part){
282
+ if ( typeof part === "string" && !/\W/.test(part) ) {
283
+ part = part.toUpperCase();
284
+
285
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
286
+ var elem = checkSet[i];
287
+ if ( elem ) {
288
+ var parent = elem.parentNode;
289
+ checkSet[i] = parent.nodeName === part ? parent : false;
290
+ }
291
+ }
292
+ } else {
293
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
294
+ var elem = checkSet[i];
295
+ if ( elem ) {
296
+ checkSet[i] = elem.parentNode;
297
+ if ( typeof part !== "string" ) {
298
+ checkSet[i] = checkSet[i] == part;
299
+ }
300
+ }
301
+ }
302
+
303
+ if ( typeof part === "string" ) {
304
+ Sizzle.filter( part, checkSet, true );
305
+ }
306
+ }
307
+ },
308
+ "": function(checkSet, part){
309
+ var doneName = "done" + (done++), checkFn = dirCheck;
310
+
311
+ if ( !part.match(/\W/) ) {
312
+ var nodeCheck = part = part.toUpperCase();
313
+ checkFn = dirNodeCheck;
314
+ }
315
+
316
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck);
317
+ },
318
+ "~": function(checkSet, part){
319
+ var doneName = "done" + (done++), checkFn = dirCheck;
320
+
321
+ if ( !part.match(/\W/) ) {
322
+ var nodeCheck = part = part.toUpperCase();
323
+ checkFn = dirNodeCheck;
324
+ }
325
+
326
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck);
327
+ }
328
+ },
329
+ find: {
330
+ ID: function(match, context){
331
+ if ( context.getElementById ) {
332
+ var m = context.getElementById(match[1]);
333
+ return m ? [m] : [];
334
+ }
335
+ },
336
+ NAME: function(match, context){
337
+ return context.getElementsByName(match[1]);
338
+ },
339
+ TAG: function(match, context){
340
+ return context.getElementsByTagName(match[1]);
341
+ }
342
+ },
343
+ preFilter: {
344
+ CLASS: function(match){
345
+ return new RegExp( "(?:^|\\s)" + match[1] + "(?:\\s|$)" );
346
+ },
347
+ ID: function(match){
348
+ return match[1];
349
+ },
350
+ TAG: function(match){
351
+ return match[1].toUpperCase();
352
+ },
353
+ CHILD: function(match){
354
+ if ( match[1] == "nth" ) {
355
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
356
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
357
+ match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
358
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
359
+
360
+ // calculate the numbers (first)n+(last) including if they are negative
361
+ match[2] = (test[1] + (test[2] || 1)) - 0;
362
+ match[3] = test[3] - 0;
363
+ }
364
+
365
+ // TODO: Move to normal caching system
366
+ match[0] = typeof get_length == "undefined" ? "done" + (done++) : "nodeCache";
367
+
368
+ return match;
369
+ },
370
+ ATTR: function(match){
371
+ var name = match[1];
372
+
373
+ if ( Expr.attrMap[name] ) {
374
+ match[1] = Expr.attrMap[name];
375
+ }
376
+
377
+ return match;
378
+ },
379
+ PSEUDO: function(match){
380
+ if ( match[1] === "not" ) {
381
+ match[3] = match[3].split(/\s*,\s*/);
382
+ }
383
+
384
+ return match;
385
+ },
386
+ POS: function(match){
387
+ match.unshift( true );
388
+ return match;
389
+ }
390
+ },
391
+ filters: {
392
+ enabled: function(elem){
393
+ return elem.disabled === false && elem.type !== "hidden";
394
+ },
395
+ disabled: function(elem){
396
+ return elem.disabled === true;
397
+ },
398
+ checked: function(elem){
399
+ return elem.checked === true;
400
+ },
401
+ selected: function(elem){
402
+ // Accessing this property makes selected-by-default
403
+ // options in Safari work properly
404
+ elem.parentNode.selectedIndex;
405
+ return elem.selected === true;
406
+ },
407
+ parent: function(elem){
408
+ return !!elem.firstChild;
409
+ },
410
+ empty: function(elem){
411
+ return !elem.firstChild;
412
+ },
413
+ has: function(elem, i, match){
414
+ return !!Sizzle( match[3], elem ).length;
415
+ },
416
+ header: function(elem){
417
+ return /h\d/i.test( elem.nodeName );
418
+ },
419
+ text: function(elem){
420
+ return "text" === elem.type;
421
+ },
422
+ radio: function(elem){
423
+ return "radio" === elem.type;
424
+ },
425
+ checkbox: function(elem){
426
+ return "checkbox" === elem.type;
427
+ },
428
+ file: function(elem){
429
+ return "file" === elem.type;
430
+ },
431
+ password: function(elem){
432
+ return "password" === elem.type;
433
+ },
434
+ submit: function(elem){
435
+ return "submit" === elem.type;
436
+ },
437
+ image: function(elem){
438
+ return "image" === elem.type;
439
+ },
440
+ reset: function(elem){
441
+ return "reset" === elem.type;
442
+ },
443
+ button: function(elem){
444
+ return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
445
+ },
446
+ input: function(elem){
447
+ return /input|select|textarea|button/i.test(elem.nodeName);
448
+ }
449
+ },
450
+ setFilters: {
451
+ first: function(elem, i){
452
+ return i === 0;
453
+ },
454
+ last: function(elem, i, match, array){
455
+ return i === array.length - 1;
456
+ },
457
+ even: function(elem, i){
458
+ return i % 2 === 0;
459
+ },
460
+ odd: function(elem, i){
461
+ return i % 2 === 1;
462
+ },
463
+ lt: function(elem, i, match){
464
+ return i < match[3] - 0;
465
+ },
466
+ gt: function(elem, i, match){
467
+ return i > match[3] - 0;
468
+ },
469
+ nth: function(elem, i, match){
470
+ return match[3] - 0 == i;
471
+ },
472
+ eq: function(elem, i, match){
473
+ return match[3] - 0 == i;
474
+ }
475
+ },
476
+ filter: {
477
+ CHILD: function(elem, match){
478
+ var type = match[1], parent = elem.parentNode;
479
+
480
+ var doneName = match[0];
481
+
482
+ if ( !parent[ doneName ] ) {
483
+ var count = 1;
484
+
485
+ for ( var node = parent.firstChild; node; node = node.nextSibling ) {
486
+ if ( node.nodeType == 1 ) {
487
+ node.nodeIndex = count++;
488
+ }
489
+ }
490
+
491
+ parent[ doneName ] = count - 1;
492
+ }
493
+
494
+ if ( type == "first" ) {
495
+ return elem.nodeIndex == 1;
496
+ } else if ( type == "last" ) {
497
+ return elem.nodeIndex == parent[ doneName ];
498
+ } else if ( type == "only" ) {
499
+ return parent[ doneName ] == 1;
500
+ } else if ( type == "nth" ) {
501
+ var add = false, first = match[2], last = match[3];
502
+
503
+ if ( first == 1 && last == 0 ) {
504
+ return true;
505
+ }
506
+
507
+ if ( first == 0 ) {
508
+ if ( elem.nodeIndex == last ) {
509
+ add = true;
510
+ }
511
+ } else if ( (elem.nodeIndex - last) % first == 0 && (elem.nodeIndex - last) / first >= 0 ) {
512
+ add = true;
513
+ }
514
+
515
+ return add;
516
+ }
517
+ },
518
+ PSEUDO: function(elem, match, i, array){
519
+ var name = match[1], filter = Expr.filters[ name ];
520
+
521
+ if ( filter ) {
522
+ return filter( elem, i, match, array )
523
+ } else if ( name === "contains" ) {
524
+ return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
525
+ } else if ( name === "not" ) {
526
+ var not = match[3];
527
+
528
+ for ( var i = 0, l = not.length; i < l; i++ ) {
529
+ if ( Sizzle.filter(not[i], [elem]).length > 0 ) {
530
+ return false;
531
+ }
532
+ }
533
+
534
+ return true;
535
+ }
536
+ },
537
+ ID: function(elem, match){
538
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
539
+ },
540
+ TAG: function(elem, match){
541
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
542
+ },
543
+ CLASS: function(elem, match){
544
+ return match.test( elem.className );
545
+ },
546
+ ATTR: function(elem, match){
547
+ var result = elem[ match[1] ], value = result + "", type = match[2], check = match[4];
548
+ return result == null ?
549
+ false :
550
+ type === "=" ?
551
+ value === check :
552
+ type === "*=" || type === "~=" ?
553
+ value.indexOf(check) >= 0 :
554
+ !match[4] ?
555
+ result :
556
+ type === "!=" ?
557
+ value != check :
558
+ type === "^=" ?
559
+ value.indexOf(check) === 0 :
560
+ type === "$=" ?
561
+ value.substr(value.length - check.length) === check :
562
+ type === "|=" ?
563
+ value === check || value.substr(0, check.length + 1) === check + "-" :
564
+ false;
565
+ },
566
+ POS: function(elem, match, i, array){
567
+ var name = match[2], filter = Expr.setFilters[ name ];
568
+
569
+ if ( filter ) {
570
+ return filter( elem, i, match, array );
571
+ }
572
+ }
573
+ }
574
+ };
575
+
576
+ function makeArray(array, results) {
577
+ array = Array.prototype.slice.call( array );
578
+
579
+ if ( results ) {
580
+ results.push.apply( results, array );
581
+ return results;
582
+ }
583
+
584
+ return array;
585
+ }
586
+
587
+ // TODO: Need a proper check here
588
+ if ( document.all && !window.opera ) {
589
+ function makeArray(array, results) {
590
+ if ( array instanceof Array ) {
591
+ return Array.prototype.slice.call( array );
592
+ }
593
+
594
+ var ret = results || [];
595
+
596
+ for ( var i = 0; array[i]; i++ ) {
597
+ ret.push( array[i] );
598
+ }
599
+
600
+ return ret;
601
+ }
602
+
603
+ Expr.find.ID = function(match, context){
604
+ if ( context.getElementById ) {
605
+ var m = context.getElementById(match[1]);
606
+ return m ? m.id === match[1] || m.getAttributeNode && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
607
+ }
608
+ };
609
+
610
+ Expr.filter.ID = function(elem, match){
611
+ var node = elem.getAttributeNode && elem.getAttributeNode("id");
612
+ return elem.nodeType === 1 && node && node.nodeValue === match;
613
+ };
614
+ }
615
+
616
+ if ( document.querySelectorAll ) (function(){
617
+ var oldSizzle = Sizzle;
618
+
619
+ window.Sizzle = Sizzle = function(query, context, extra){
620
+ context = context || document;
621
+
622
+ if ( context === document ) {
623
+ try {
624
+ return makeArray( context.querySelectorAll(query) );
625
+ } catch(e){}
626
+ }
627
+
628
+ return oldSizzle(query, context, extra);
629
+ };
630
+
631
+ Sizzle.find = oldSizzle.find;
632
+ Sizzle.filter = oldSizzle.filter;
633
+ Sizzle.selectors = oldSizzle.selectors;
634
+ })();
635
+
636
+ if ( document.getElementsByClassName ) {
637
+ Expr.order.splice(1, 0, "CLASS");
638
+ Expr.find.CLASS = function(match, context) {
639
+ return context.getElementsByClassName(match[1]);
640
+ };
641
+ }
642
+
643
+ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck ) {
644
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
645
+ var elem = checkSet[i];
646
+ if ( elem ) {
647
+ elem = elem[dir]
648
+ var match = false;
649
+
650
+ while ( elem && elem.nodeType ) {
651
+ var done = elem[doneName];
652
+ if ( done ) {
653
+ match = checkSet[ done ];
654
+ break;
655
+ }
656
+
657
+ if ( elem.nodeType === 1 )
658
+ elem[doneName] = i;
659
+
660
+ if ( elem.nodeName === cur ) {
661
+ match = elem;
662
+ break;
663
+ }
664
+
665
+ elem = elem[dir];
666
+ }
667
+
668
+ checkSet[i] = match;
669
+ }
670
+ }
671
+ }
672
+
673
+ function dirCheck( dir, cur, doneName, checkSet, nodeCheck ) {
674
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
675
+ var elem = checkSet[i];
676
+ if ( elem ) {
677
+ elem = elem[dir]
678
+ var match = false;
679
+
680
+ while ( elem && elem.nodeType ) {
681
+ if ( elem[doneName] ) {
682
+ match = checkSet[ elem[doneName] ];
683
+ break;
684
+ }
685
+
686
+ if ( elem.nodeType === 1 ) {
687
+ elem[doneName] = i;
688
+
689
+ if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
690
+ match = elem;
691
+ break;
692
+ }
693
+ }
694
+
695
+ elem = elem[dir];
696
+ }
697
+
698
+ checkSet[i] = match;
699
+ }
700
+ }
701
+ }
702
+
703
+ if ( document.compareDocumentPosition ) {
704
+ function contains(a, b){
705
+ return a.compareDocumentPosition(b) & 16;
706
+ }
707
+ } else {
708
+ function contains(a, b){
709
+ return a !== b && a.contains(b);
710
+ }
711
+ }
712
+
713
+ // EXPOSE
714
+
715
+ window.Sizzle = Sizzle;
716
+
717
+ })();