You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

946 lines
37 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js">/*
  19. * This is code is also distributed under MIT license for use
  20. * with jQuery and prototype JavaScript libraries.
  21. */
  22. <span id='Ext-DomQuery'>/**
  23. </span> * @class Ext.DomQuery
  24. Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
  25. &lt;p&gt;
  26. DomQuery supports most of the &lt;a href=&quot;http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors&quot;&gt;CSS3 selectors spec&lt;/a&gt;, along with some custom selectors and basic XPath.&lt;/p&gt;
  27. &lt;p&gt;
  28. All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example &quot;div.foo:nth-child(odd)[@foo=bar].bar:first&quot; would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.
  29. &lt;/p&gt;
  30. &lt;h4&gt;Element Selectors:&lt;/h4&gt;
  31. &lt;ul class=&quot;list&quot;&gt;
  32. &lt;li&gt; &lt;b&gt;*&lt;/b&gt; any element&lt;/li&gt;
  33. &lt;li&gt; &lt;b&gt;E&lt;/b&gt; an element with the tag E&lt;/li&gt;
  34. &lt;li&gt; &lt;b&gt;E F&lt;/b&gt; All descendent elements of E that have the tag F&lt;/li&gt;
  35. &lt;li&gt; &lt;b&gt;E &gt; F&lt;/b&gt; or &lt;b&gt;E/F&lt;/b&gt; all direct children elements of E that have the tag F&lt;/li&gt;
  36. &lt;li&gt; &lt;b&gt;E + F&lt;/b&gt; all elements with the tag F that are immediately preceded by an element with the tag E&lt;/li&gt;
  37. &lt;li&gt; &lt;b&gt;E ~ F&lt;/b&gt; all elements with the tag F that are preceded by a sibling element with the tag E&lt;/li&gt;
  38. &lt;/ul&gt;
  39. &lt;h4&gt;Attribute Selectors:&lt;/h4&gt;
  40. &lt;p&gt;The use of &amp;#64; and quotes are optional. For example, div[&amp;#64;foo='bar'] is also a valid attribute selector.&lt;/p&gt;
  41. &lt;ul class=&quot;list&quot;&gt;
  42. &lt;li&gt; &lt;b&gt;E[foo]&lt;/b&gt; has an attribute &quot;foo&quot;&lt;/li&gt;
  43. &lt;li&gt; &lt;b&gt;E[foo=bar]&lt;/b&gt; has an attribute &quot;foo&quot; that equals &quot;bar&quot;&lt;/li&gt;
  44. &lt;li&gt; &lt;b&gt;E[foo^=bar]&lt;/b&gt; has an attribute &quot;foo&quot; that starts with &quot;bar&quot;&lt;/li&gt;
  45. &lt;li&gt; &lt;b&gt;E[foo$=bar]&lt;/b&gt; has an attribute &quot;foo&quot; that ends with &quot;bar&quot;&lt;/li&gt;
  46. &lt;li&gt; &lt;b&gt;E[foo*=bar]&lt;/b&gt; has an attribute &quot;foo&quot; that contains the substring &quot;bar&quot;&lt;/li&gt;
  47. &lt;li&gt; &lt;b&gt;E[foo%=2]&lt;/b&gt; has an attribute &quot;foo&quot; that is evenly divisible by 2&lt;/li&gt;
  48. &lt;li&gt; &lt;b&gt;E[foo!=bar]&lt;/b&gt; attribute &quot;foo&quot; does not equal &quot;bar&quot;&lt;/li&gt;
  49. &lt;/ul&gt;
  50. &lt;h4&gt;Pseudo Classes:&lt;/h4&gt;
  51. &lt;ul class=&quot;list&quot;&gt;
  52. &lt;li&gt; &lt;b&gt;E:first-child&lt;/b&gt; E is the first child of its parent&lt;/li&gt;
  53. &lt;li&gt; &lt;b&gt;E:last-child&lt;/b&gt; E is the last child of its parent&lt;/li&gt;
  54. &lt;li&gt; &lt;b&gt;E:nth-child(&lt;i&gt;n&lt;/i&gt;)&lt;/b&gt; E is the &lt;i&gt;n&lt;/i&gt;th child of its parent (1 based as per the spec)&lt;/li&gt;
  55. &lt;li&gt; &lt;b&gt;E:nth-child(odd)&lt;/b&gt; E is an odd child of its parent&lt;/li&gt;
  56. &lt;li&gt; &lt;b&gt;E:nth-child(even)&lt;/b&gt; E is an even child of its parent&lt;/li&gt;
  57. &lt;li&gt; &lt;b&gt;E:only-child&lt;/b&gt; E is the only child of its parent&lt;/li&gt;
  58. &lt;li&gt; &lt;b&gt;E:checked&lt;/b&gt; E is an element that is has a checked attribute that is true (e.g. a radio or checkbox) &lt;/li&gt;
  59. &lt;li&gt; &lt;b&gt;E:first&lt;/b&gt; the first E in the resultset&lt;/li&gt;
  60. &lt;li&gt; &lt;b&gt;E:last&lt;/b&gt; the last E in the resultset&lt;/li&gt;
  61. &lt;li&gt; &lt;b&gt;E:nth(&lt;i&gt;n&lt;/i&gt;)&lt;/b&gt; the &lt;i&gt;n&lt;/i&gt;th E in the resultset (1 based)&lt;/li&gt;
  62. &lt;li&gt; &lt;b&gt;E:odd&lt;/b&gt; shortcut for :nth-child(odd)&lt;/li&gt;
  63. &lt;li&gt; &lt;b&gt;E:even&lt;/b&gt; shortcut for :nth-child(even)&lt;/li&gt;
  64. &lt;li&gt; &lt;b&gt;E:contains(foo)&lt;/b&gt; E's innerHTML contains the substring &quot;foo&quot;&lt;/li&gt;
  65. &lt;li&gt; &lt;b&gt;E:nodeValue(foo)&lt;/b&gt; E contains a textNode with a nodeValue that equals &quot;foo&quot;&lt;/li&gt;
  66. &lt;li&gt; &lt;b&gt;E:not(S)&lt;/b&gt; an E element that does not match simple selector S&lt;/li&gt;
  67. &lt;li&gt; &lt;b&gt;E:has(S)&lt;/b&gt; an E element that has a descendent that matches simple selector S&lt;/li&gt;
  68. &lt;li&gt; &lt;b&gt;E:next(S)&lt;/b&gt; an E element whose next sibling matches simple selector S&lt;/li&gt;
  69. &lt;li&gt; &lt;b&gt;E:prev(S)&lt;/b&gt; an E element whose previous sibling matches simple selector S&lt;/li&gt;
  70. &lt;li&gt; &lt;b&gt;E:any(S1|S2|S2)&lt;/b&gt; an E element which matches any of the simple selectors S1, S2 or S3//\\&lt;/li&gt;
  71. &lt;/ul&gt;
  72. &lt;h4&gt;CSS Value Selectors:&lt;/h4&gt;
  73. &lt;ul class=&quot;list&quot;&gt;
  74. &lt;li&gt; &lt;b&gt;E{display=none}&lt;/b&gt; css value &quot;display&quot; that equals &quot;none&quot;&lt;/li&gt;
  75. &lt;li&gt; &lt;b&gt;E{display^=none}&lt;/b&gt; css value &quot;display&quot; that starts with &quot;none&quot;&lt;/li&gt;
  76. &lt;li&gt; &lt;b&gt;E{display$=none}&lt;/b&gt; css value &quot;display&quot; that ends with &quot;none&quot;&lt;/li&gt;
  77. &lt;li&gt; &lt;b&gt;E{display*=none}&lt;/b&gt; css value &quot;display&quot; that contains the substring &quot;none&quot;&lt;/li&gt;
  78. &lt;li&gt; &lt;b&gt;E{display%=2}&lt;/b&gt; css value &quot;display&quot; that is evenly divisible by 2&lt;/li&gt;
  79. &lt;li&gt; &lt;b&gt;E{display!=none}&lt;/b&gt; css value &quot;display&quot; that does not equal &quot;none&quot;&lt;/li&gt;
  80. &lt;/ul&gt;
  81. * @singleton
  82. */
  83. Ext.DomQuery = function(){
  84. var cache = {},
  85. simpleCache = {},
  86. valueCache = {},
  87. nonSpace = /\S/,
  88. trimRe = /^\s+|\s+$/g,
  89. tplRe = /\{(\d+)\}/g,
  90. modeRe = /^(\s?[\/&gt;+~]\s?|\s|$)/,
  91. tagTokenRe = /^(#)?([\w\-\*]+)/,
  92. nthRe = /(\d*)n\+?(\d*)/,
  93. nthRe2 = /\D/,
  94. // This is for IE MSXML which does not support expandos.
  95. // IE runs the same speed using setAttribute, however FF slows way down
  96. // and Safari completely fails so they need to continue to use expandos.
  97. isIE = window.ActiveXObject ? true : false,
  98. key = 30803;
  99. // this eval is stop the compressor from
  100. // renaming the variable to something shorter
  101. eval(&quot;var batch = 30803;&quot;);
  102. // Retrieve the child node from a particular
  103. // parent at the specified index.
  104. function child(parent, index){
  105. var i = 0,
  106. n = parent.firstChild;
  107. while(n){
  108. if(n.nodeType == 1){
  109. if(++i == index){
  110. return n;
  111. }
  112. }
  113. n = n.nextSibling;
  114. }
  115. return null;
  116. }
  117. // retrieve the next element node
  118. function next(n){
  119. while((n = n.nextSibling) &amp;&amp; n.nodeType != 1);
  120. return n;
  121. }
  122. // retrieve the previous element node
  123. function prev(n){
  124. while((n = n.previousSibling) &amp;&amp; n.nodeType != 1);
  125. return n;
  126. }
  127. // Mark each child node with a nodeIndex skipping and
  128. // removing empty text nodes.
  129. function children(parent){
  130. var n = parent.firstChild,
  131. nodeIndex = -1,
  132. nextNode;
  133. while(n){
  134. nextNode = n.nextSibling;
  135. // clean worthless empty nodes.
  136. if(n.nodeType == 3 &amp;&amp; !nonSpace.test(n.nodeValue)){
  137. parent.removeChild(n);
  138. }else{
  139. // add an expando nodeIndex
  140. n.nodeIndex = ++nodeIndex;
  141. }
  142. n = nextNode;
  143. }
  144. return this;
  145. }
  146. // nodeSet - array of nodes
  147. // cls - CSS Class
  148. function byClassName(nodeSet, cls){
  149. if(!cls){
  150. return nodeSet;
  151. }
  152. var result = [], ri = -1;
  153. for(var i = 0, ci; ci = nodeSet[i]; i++){
  154. if((' '+ci.className+' ').indexOf(cls) != -1){
  155. result[++ri] = ci;
  156. }
  157. }
  158. return result;
  159. };
  160. function attrValue(n, attr){
  161. // if its an array, use the first node.
  162. if(!n.tagName &amp;&amp; typeof n.length != &quot;undefined&quot;){
  163. n = n[0];
  164. }
  165. if(!n){
  166. return null;
  167. }
  168. if(attr == &quot;for&quot;){
  169. return n.htmlFor;
  170. }
  171. if(attr == &quot;class&quot; || attr == &quot;className&quot;){
  172. return n.className;
  173. }
  174. return n.getAttribute(attr) || n[attr];
  175. };
  176. // ns - nodes
  177. // mode - false, /, &gt;, +, ~
  178. // tagName - defaults to &quot;*&quot;
  179. function getNodes(ns, mode, tagName){
  180. var result = [], ri = -1, cs;
  181. if(!ns){
  182. return result;
  183. }
  184. tagName = tagName || &quot;*&quot;;
  185. // convert to array
  186. if(typeof ns.getElementsByTagName != &quot;undefined&quot;){
  187. ns = [ns];
  188. }
  189. // no mode specified, grab all elements by tagName
  190. // at any depth
  191. if(!mode){
  192. for(var i = 0, ni; ni = ns[i]; i++){
  193. cs = ni.getElementsByTagName(tagName);
  194. for(var j = 0, ci; ci = cs[j]; j++){
  195. result[++ri] = ci;
  196. }
  197. }
  198. // Direct Child mode (/ or &gt;)
  199. // E &gt; F or E/F all direct children elements of E that have the tag
  200. } else if(mode == &quot;/&quot; || mode == &quot;&gt;&quot;){
  201. var utag = tagName.toUpperCase();
  202. for(var i = 0, ni, cn; ni = ns[i]; i++){
  203. cn = ni.childNodes;
  204. for(var j = 0, cj; cj = cn[j]; j++){
  205. if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
  206. result[++ri] = cj;
  207. }
  208. }
  209. }
  210. // Immediately Preceding mode (+)
  211. // E + F all elements with the tag F that are immediately preceded by an element with the tag E
  212. }else if(mode == &quot;+&quot;){
  213. var utag = tagName.toUpperCase();
  214. for(var i = 0, n; n = ns[i]; i++){
  215. while((n = n.nextSibling) &amp;&amp; n.nodeType != 1);
  216. if(n &amp;&amp; (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
  217. result[++ri] = n;
  218. }
  219. }
  220. // Sibling mode (~)
  221. // E ~ F all elements with the tag F that are preceded by a sibling element with the tag E
  222. }else if(mode == &quot;~&quot;){
  223. var utag = tagName.toUpperCase();
  224. for(var i = 0, n; n = ns[i]; i++){
  225. while((n = n.nextSibling)){
  226. if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
  227. result[++ri] = n;
  228. }
  229. }
  230. }
  231. }
  232. return result;
  233. }
  234. function concat(a, b){
  235. if(b.slice){
  236. return a.concat(b);
  237. }
  238. for(var i = 0, l = b.length; i &lt; l; i++){
  239. a[a.length] = b[i];
  240. }
  241. return a;
  242. }
  243. function byTag(cs, tagName){
  244. if(cs.tagName || cs == document){
  245. cs = [cs];
  246. }
  247. if(!tagName){
  248. return cs;
  249. }
  250. var result = [], ri = -1;
  251. tagName = tagName.toLowerCase();
  252. for(var i = 0, ci; ci = cs[i]; i++){
  253. if(ci.nodeType == 1 &amp;&amp; ci.tagName.toLowerCase() == tagName){
  254. result[++ri] = ci;
  255. }
  256. }
  257. return result;
  258. }
  259. function byId(cs, id){
  260. if(cs.tagName || cs == document){
  261. cs = [cs];
  262. }
  263. if(!id){
  264. return cs;
  265. }
  266. var result = [], ri = -1;
  267. for(var i = 0, ci; ci = cs[i]; i++){
  268. if(ci &amp;&amp; ci.id == id){
  269. result[++ri] = ci;
  270. return result;
  271. }
  272. }
  273. return result;
  274. }
  275. // operators are =, !=, ^=, $=, *=, %=, |= and ~=
  276. // custom can be &quot;{&quot;
  277. function byAttribute(cs, attr, value, op, custom){
  278. var result = [],
  279. ri = -1,
  280. useGetStyle = custom == &quot;{&quot;,
  281. fn = Ext.DomQuery.operators[op],
  282. a,
  283. xml,
  284. hasXml;
  285. for(var i = 0, ci; ci = cs[i]; i++){
  286. // skip non-element nodes.
  287. if(ci.nodeType != 1){
  288. continue;
  289. }
  290. // only need to do this for the first node
  291. if(!hasXml){
  292. xml = Ext.DomQuery.isXml(ci);
  293. hasXml = true;
  294. }
  295. // we only need to change the property names if we're dealing with html nodes, not XML
  296. if(!xml){
  297. if(useGetStyle){
  298. a = Ext.DomQuery.getStyle(ci, attr);
  299. } else if (attr == &quot;class&quot; || attr == &quot;className&quot;){
  300. a = ci.className;
  301. } else if (attr == &quot;for&quot;){
  302. a = ci.htmlFor;
  303. } else if (attr == &quot;href&quot;){
  304. // getAttribute href bug
  305. // http://www.glennjones.net/Post/809/getAttributehrefbug.htm
  306. a = ci.getAttribute(&quot;href&quot;, 2);
  307. } else{
  308. a = ci.getAttribute(attr);
  309. }
  310. }else{
  311. a = ci.getAttribute(attr);
  312. }
  313. if((fn &amp;&amp; fn(a, value)) || (!fn &amp;&amp; a)){
  314. result[++ri] = ci;
  315. }
  316. }
  317. return result;
  318. }
  319. function byPseudo(cs, name, value){
  320. return Ext.DomQuery.pseudos[name](cs, value);
  321. }
  322. function nodupIEXml(cs){
  323. var d = ++key,
  324. r;
  325. cs[0].setAttribute(&quot;_nodup&quot;, d);
  326. r = [cs[0]];
  327. for(var i = 1, len = cs.length; i &lt; len; i++){
  328. var c = cs[i];
  329. if(!c.getAttribute(&quot;_nodup&quot;) != d){
  330. c.setAttribute(&quot;_nodup&quot;, d);
  331. r[r.length] = c;
  332. }
  333. }
  334. for(var i = 0, len = cs.length; i &lt; len; i++){
  335. cs[i].removeAttribute(&quot;_nodup&quot;);
  336. }
  337. return r;
  338. }
  339. function nodup(cs){
  340. if(!cs){
  341. return [];
  342. }
  343. var len = cs.length, c, i, r = cs, cj, ri = -1;
  344. if(!len || typeof cs.nodeType != &quot;undefined&quot; || len == 1){
  345. return cs;
  346. }
  347. if(isIE &amp;&amp; typeof cs[0].selectSingleNode != &quot;undefined&quot;){
  348. return nodupIEXml(cs);
  349. }
  350. var d = ++key;
  351. cs[0]._nodup = d;
  352. for(i = 1; c = cs[i]; i++){
  353. if(c._nodup != d){
  354. c._nodup = d;
  355. }else{
  356. r = [];
  357. for(var j = 0; j &lt; i; j++){
  358. r[++ri] = cs[j];
  359. }
  360. for(j = i+1; cj = cs[j]; j++){
  361. if(cj._nodup != d){
  362. cj._nodup = d;
  363. r[++ri] = cj;
  364. }
  365. }
  366. return r;
  367. }
  368. }
  369. return r;
  370. }
  371. function quickDiffIEXml(c1, c2){
  372. var d = ++key,
  373. r = [];
  374. for(var i = 0, len = c1.length; i &lt; len; i++){
  375. c1[i].setAttribute(&quot;_qdiff&quot;, d);
  376. }
  377. for(var i = 0, len = c2.length; i &lt; len; i++){
  378. if(c2[i].getAttribute(&quot;_qdiff&quot;) != d){
  379. r[r.length] = c2[i];
  380. }
  381. }
  382. for(var i = 0, len = c1.length; i &lt; len; i++){
  383. c1[i].removeAttribute(&quot;_qdiff&quot;);
  384. }
  385. return r;
  386. }
  387. function quickDiff(c1, c2){
  388. var len1 = c1.length,
  389. d = ++key,
  390. r = [];
  391. if(!len1){
  392. return c2;
  393. }
  394. if(isIE &amp;&amp; typeof c1[0].selectSingleNode != &quot;undefined&quot;){
  395. return quickDiffIEXml(c1, c2);
  396. }
  397. for(var i = 0; i &lt; len1; i++){
  398. c1[i]._qdiff = d;
  399. }
  400. for(var i = 0, len = c2.length; i &lt; len; i++){
  401. if(c2[i]._qdiff != d){
  402. r[r.length] = c2[i];
  403. }
  404. }
  405. return r;
  406. }
  407. function quickId(ns, mode, root, id){
  408. if(ns == root){
  409. var d = root.ownerDocument || root;
  410. return d.getElementById(id);
  411. }
  412. ns = getNodes(ns, mode, &quot;*&quot;);
  413. return byId(ns, id);
  414. }
  415. return {
  416. getStyle : function(el, name){
  417. return Ext.fly(el).getStyle(name);
  418. },
  419. <span id='Ext-DomQuery-method-compile'> /**
  420. </span> * Compiles a selector/xpath query into a reusable function. The returned function
  421. * takes one parameter &quot;root&quot; (optional), which is the context node from where the query should start.
  422. * @param {String} selector The selector/xpath query
  423. * @param {String} type (optional) Either &quot;select&quot; (the default) or &quot;simple&quot; for a simple selector match
  424. * @return {Function}
  425. */
  426. compile : function(path, type){
  427. type = type || &quot;select&quot;;
  428. // setup fn preamble
  429. var fn = [&quot;var f = function(root){\n var mode; ++batch; var n = root || document;\n&quot;],
  430. mode,
  431. lastPath,
  432. matchers = Ext.DomQuery.matchers,
  433. matchersLn = matchers.length,
  434. modeMatch,
  435. // accept leading mode switch
  436. lmode = path.match(modeRe);
  437. if(lmode &amp;&amp; lmode[1]){
  438. fn[fn.length] = 'mode=&quot;'+lmode[1].replace(trimRe, &quot;&quot;)+'&quot;;';
  439. path = path.replace(lmode[1], &quot;&quot;);
  440. }
  441. // strip leading slashes
  442. while(path.substr(0, 1)==&quot;/&quot;){
  443. path = path.substr(1);
  444. }
  445. while(path &amp;&amp; lastPath != path){
  446. lastPath = path;
  447. var tokenMatch = path.match(tagTokenRe);
  448. if(type == &quot;select&quot;){
  449. if(tokenMatch){
  450. // ID Selector
  451. if(tokenMatch[1] == &quot;#&quot;){
  452. fn[fn.length] = 'n = quickId(n, mode, root, &quot;'+tokenMatch[2]+'&quot;);';
  453. }else{
  454. fn[fn.length] = 'n = getNodes(n, mode, &quot;'+tokenMatch[2]+'&quot;);';
  455. }
  456. path = path.replace(tokenMatch[0], &quot;&quot;);
  457. }else if(path.substr(0, 1) != '@'){
  458. fn[fn.length] = 'n = getNodes(n, mode, &quot;*&quot;);';
  459. }
  460. // type of &quot;simple&quot;
  461. }else{
  462. if(tokenMatch){
  463. if(tokenMatch[1] == &quot;#&quot;){
  464. fn[fn.length] = 'n = byId(n, &quot;'+tokenMatch[2]+'&quot;);';
  465. }else{
  466. fn[fn.length] = 'n = byTag(n, &quot;'+tokenMatch[2]+'&quot;);';
  467. }
  468. path = path.replace(tokenMatch[0], &quot;&quot;);
  469. }
  470. }
  471. while(!(modeMatch = path.match(modeRe))){
  472. var matched = false;
  473. for(var j = 0; j &lt; matchersLn; j++){
  474. var t = matchers[j];
  475. var m = path.match(t.re);
  476. if(m){
  477. fn[fn.length] = t.select.replace(tplRe, function(x, i){
  478. return m[i];
  479. });
  480. path = path.replace(m[0], &quot;&quot;);
  481. matched = true;
  482. break;
  483. }
  484. }
  485. // prevent infinite loop on bad selector
  486. if(!matched){
  487. throw 'Error parsing selector, parsing failed at &quot;' + path + '&quot;';
  488. }
  489. }
  490. if(modeMatch[1]){
  491. fn[fn.length] = 'mode=&quot;'+modeMatch[1].replace(trimRe, &quot;&quot;)+'&quot;;';
  492. path = path.replace(modeMatch[1], &quot;&quot;);
  493. }
  494. }
  495. // close fn out
  496. fn[fn.length] = &quot;return nodup(n);\n}&quot;;
  497. // eval fn and return it
  498. eval(fn.join(&quot;&quot;));
  499. return f;
  500. },
  501. <span id='Ext-DomQuery-method-jsSelect'> /**
  502. </span> * Selects a group of elements.
  503. * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
  504. * @param {Node/String} root (optional) The start of the query (defaults to document).
  505. * @return {Array} An Array of DOM elements which match the selector. If there are
  506. * no matches, and empty Array is returned.
  507. */
  508. jsSelect: function(path, root, type){
  509. // set root to doc if not specified.
  510. root = root || document;
  511. if(typeof root == &quot;string&quot;){
  512. root = document.getElementById(root);
  513. }
  514. var paths = path.split(&quot;,&quot;),
  515. results = [];
  516. // loop over each selector
  517. for(var i = 0, len = paths.length; i &lt; len; i++){
  518. var subPath = paths[i].replace(trimRe, &quot;&quot;);
  519. // compile and place in cache
  520. if(!cache[subPath]){
  521. cache[subPath] = Ext.DomQuery.compile(subPath);
  522. if(!cache[subPath]){
  523. throw subPath + &quot; is not a valid selector&quot;;
  524. }
  525. }
  526. var result = cache[subPath](root);
  527. if(result &amp;&amp; result != document){
  528. results = results.concat(result);
  529. }
  530. }
  531. // if there were multiple selectors, make sure dups
  532. // are eliminated
  533. if(paths.length &gt; 1){
  534. return nodup(results);
  535. }
  536. return results;
  537. },
  538. isXml: function(el) {
  539. var docEl = (el ? el.ownerDocument || el : 0).documentElement;
  540. return docEl ? docEl.nodeName !== &quot;HTML&quot; : false;
  541. },
  542. select : document.querySelectorAll ? function(path, root, type) {
  543. root = root || document;
  544. if (!Ext.DomQuery.isXml(root)) {
  545. try {
  546. var cs = root.querySelectorAll(path);
  547. return Ext.toArray(cs);
  548. }
  549. catch (ex) {}
  550. }
  551. return Ext.DomQuery.jsSelect.call(this, path, root, type);
  552. } : function(path, root, type) {
  553. return Ext.DomQuery.jsSelect.call(this, path, root, type);
  554. },
  555. <span id='Ext-DomQuery-method-selectNode'> /**
  556. </span> * Selects a single element.
  557. * @param {String} selector The selector/xpath query
  558. * @param {Node} root (optional) The start of the query (defaults to document).
  559. * @return {Element} The DOM element which matched the selector.
  560. */
  561. selectNode : function(path, root){
  562. return Ext.DomQuery.select(path, root)[0];
  563. },
  564. <span id='Ext-DomQuery-method-selectValue'> /**
  565. </span> * Selects the value of a node, optionally replacing null with the defaultValue.
  566. * @param {String} selector The selector/xpath query
  567. * @param {Node} root (optional) The start of the query (defaults to document).
  568. * @param {String} defaultValue (optional)
  569. * @return {String}
  570. */
  571. selectValue : function(path, root, defaultValue){
  572. path = path.replace(trimRe, &quot;&quot;);
  573. if(!valueCache[path]){
  574. valueCache[path] = Ext.DomQuery.compile(path, &quot;select&quot;);
  575. }
  576. var n = valueCache[path](root), v;
  577. n = n[0] ? n[0] : n;
  578. // overcome a limitation of maximum textnode size
  579. // Rumored to potentially crash IE6 but has not been confirmed.
  580. // http://reference.sitepoint.com/javascript/Node/normalize
  581. // https://developer.mozilla.org/En/DOM/Node.normalize
  582. if (typeof n.normalize == 'function') n.normalize();
  583. v = (n &amp;&amp; n.firstChild ? n.firstChild.nodeValue : null);
  584. return ((v === null||v === undefined||v==='') ? defaultValue : v);
  585. },
  586. <span id='Ext-DomQuery-method-selectNumber'> /**
  587. </span> * Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.
  588. * @param {String} selector The selector/xpath query
  589. * @param {Node} root (optional) The start of the query (defaults to document).
  590. * @param {Number} defaultValue (optional)
  591. * @return {Number}
  592. */
  593. selectNumber : function(path, root, defaultValue){
  594. var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
  595. return parseFloat(v);
  596. },
  597. <span id='Ext-DomQuery-method-is'> /**
  598. </span> * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
  599. * @param {String/HTMLElement/Array} el An element id, element or array of elements
  600. * @param {String} selector The simple selector to test
  601. * @return {Boolean}
  602. */
  603. is : function(el, ss){
  604. if(typeof el == &quot;string&quot;){
  605. el = document.getElementById(el);
  606. }
  607. var isArray = Ext.isArray(el),
  608. result = Ext.DomQuery.filter(isArray ? el : [el], ss);
  609. return isArray ? (result.length == el.length) : (result.length &gt; 0);
  610. },
  611. <span id='Ext-DomQuery-method-filter'> /**
  612. </span> * Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
  613. * @param {Array} el An array of elements to filter
  614. * @param {String} selector The simple selector to test
  615. * @param {Boolean} nonMatches If true, it returns the elements that DON'T match
  616. * the selector instead of the ones that match
  617. * @return {Array} An Array of DOM elements which match the selector. If there are
  618. * no matches, and empty Array is returned.
  619. */
  620. filter : function(els, ss, nonMatches){
  621. ss = ss.replace(trimRe, &quot;&quot;);
  622. if(!simpleCache[ss]){
  623. simpleCache[ss] = Ext.DomQuery.compile(ss, &quot;simple&quot;);
  624. }
  625. var result = simpleCache[ss](els);
  626. return nonMatches ? quickDiff(result, els) : result;
  627. },
  628. <span id='Ext-DomQuery-property-matchers'> /**
  629. </span> * Collection of matching regular expressions and code snippets.
  630. * Each capture group within () will be replace the {} in the select
  631. * statement as specified by their index.
  632. */
  633. matchers : [{
  634. re: /^\.([\w\-]+)/,
  635. select: 'n = byClassName(n, &quot; {1} &quot;);'
  636. }, {
  637. re: /^\:([\w\-]+)(?:\(((?:[^\s&gt;\/]*|.*?))\))?/,
  638. select: 'n = byPseudo(n, &quot;{1}&quot;, &quot;{2}&quot;);'
  639. },{
  640. re: /^(?:([\[\{])(?:@)?([\w\-]+)\s?(?:(=|.=)\s?([&quot;']?)(.*?)\4)?[\]\}])/,
  641. select: 'n = byAttribute(n, &quot;{2}&quot;, &quot;{5}&quot;, &quot;{3}&quot;, &quot;{1}&quot;);'
  642. }, {
  643. re: /^#([\w\-]+)/,
  644. select: 'n = byId(n, &quot;{1}&quot;);'
  645. },{
  646. re: /^@([\w\-]+)/,
  647. select: 'return {firstChild:{nodeValue:attrValue(n, &quot;{1}&quot;)}};'
  648. }
  649. ],
  650. <span id='Ext-DomQuery-property-operators'> /**
  651. </span> * Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
  652. * New operators can be added as long as the match the format &lt;i&gt;c&lt;/i&gt;= where &lt;i&gt;c&lt;/i&gt; is any character other than space, &amp;gt; &amp;lt;.
  653. */
  654. operators : {
  655. &quot;=&quot; : function(a, v){
  656. return a == v;
  657. },
  658. &quot;!=&quot; : function(a, v){
  659. return a != v;
  660. },
  661. &quot;^=&quot; : function(a, v){
  662. return a &amp;&amp; a.substr(0, v.length) == v;
  663. },
  664. &quot;$=&quot; : function(a, v){
  665. return a &amp;&amp; a.substr(a.length-v.length) == v;
  666. },
  667. &quot;*=&quot; : function(a, v){
  668. return a &amp;&amp; a.indexOf(v) !== -1;
  669. },
  670. &quot;%=&quot; : function(a, v){
  671. return (a % v) == 0;
  672. },
  673. &quot;|=&quot; : function(a, v){
  674. return a &amp;&amp; (a == v || a.substr(0, v.length+1) == v+'-');
  675. },
  676. &quot;~=&quot; : function(a, v){
  677. return a &amp;&amp; (' '+a+' ').indexOf(' '+v+' ') != -1;
  678. }
  679. },
  680. <span id='Ext-DomQuery-property-pseudos'> /**
  681. </span> * &lt;p&gt;Object hash of &quot;pseudo class&quot; filter functions which are used when filtering selections. Each function is passed
  682. * two parameters:&lt;/p&gt;&lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
  683. * &lt;li&gt;&lt;b&gt;c&lt;/b&gt; : Array&lt;div class=&quot;sub-desc&quot;&gt;An Array of DOM elements to filter.&lt;/div&gt;&lt;/li&gt;
  684. * &lt;li&gt;&lt;b&gt;v&lt;/b&gt; : String&lt;div class=&quot;sub-desc&quot;&gt;The argument (if any) supplied in the selector.&lt;/div&gt;&lt;/li&gt;
  685. * &lt;/ul&gt;&lt;/div&gt;
  686. * &lt;p&gt;A filter function returns an Array of DOM elements which conform to the pseudo class.&lt;/p&gt;
  687. * &lt;p&gt;In addition to the provided pseudo classes listed above such as &lt;code&gt;first-child&lt;/code&gt; and &lt;code&gt;nth-child&lt;/code&gt;,
  688. * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.&lt;/p&gt;
  689. * &lt;p&gt;For example, to filter &lt;code&gt;&amp;lt;a&gt;&lt;/code&gt; elements to only return links to &lt;i&gt;external&lt;/i&gt; resources:&lt;/p&gt;
  690. * &lt;code&gt;&lt;pre&gt;
  691. Ext.DomQuery.pseudos.external = function(c, v){
  692. var r = [], ri = -1;
  693. for(var i = 0, ci; ci = c[i]; i++){
  694. // Include in result set only if it's a link to an external resource
  695. if(ci.hostname != location.hostname){
  696. r[++ri] = ci;
  697. }
  698. }
  699. return r;
  700. };&lt;/pre&gt;&lt;/code&gt;
  701. * Then external links could be gathered with the following statement:&lt;code&gt;&lt;pre&gt;
  702. var externalLinks = Ext.select(&quot;a:external&quot;);
  703. &lt;/code&gt;&lt;/pre&gt;
  704. */
  705. pseudos : {
  706. &quot;first-child&quot; : function(c){
  707. var r = [], ri = -1, n;
  708. for(var i = 0, ci; ci = n = c[i]; i++){
  709. while((n = n.previousSibling) &amp;&amp; n.nodeType != 1);
  710. if(!n){
  711. r[++ri] = ci;
  712. }
  713. }
  714. return r;
  715. },
  716. &quot;last-child&quot; : function(c){
  717. var r = [], ri = -1, n;
  718. for(var i = 0, ci; ci = n = c[i]; i++){
  719. while((n = n.nextSibling) &amp;&amp; n.nodeType != 1);
  720. if(!n){
  721. r[++ri] = ci;
  722. }
  723. }
  724. return r;
  725. },
  726. &quot;nth-child&quot; : function(c, a) {
  727. var r = [], ri = -1,
  728. m = nthRe.exec(a == &quot;even&quot; &amp;&amp; &quot;2n&quot; || a == &quot;odd&quot; &amp;&amp; &quot;2n+1&quot; || !nthRe2.test(a) &amp;&amp; &quot;n+&quot; + a || a),
  729. f = (m[1] || 1) - 0, l = m[2] - 0;
  730. for(var i = 0, n; n = c[i]; i++){
  731. var pn = n.parentNode;
  732. if (batch != pn._batch) {
  733. var j = 0;
  734. for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
  735. if(cn.nodeType == 1){
  736. cn.nodeIndex = ++j;
  737. }
  738. }
  739. pn._batch = batch;
  740. }
  741. if (f == 1) {
  742. if (l == 0 || n.nodeIndex == l){
  743. r[++ri] = n;
  744. }
  745. } else if ((n.nodeIndex + l) % f == 0){
  746. r[++ri] = n;
  747. }
  748. }
  749. return r;
  750. },
  751. &quot;only-child&quot; : function(c){
  752. var r = [], ri = -1;;
  753. for(var i = 0, ci; ci = c[i]; i++){
  754. if(!prev(ci) &amp;&amp; !next(ci)){
  755. r[++ri] = ci;
  756. }
  757. }
  758. return r;
  759. },
  760. &quot;empty&quot; : function(c){
  761. var r = [], ri = -1;
  762. for(var i = 0, ci; ci = c[i]; i++){
  763. var cns = ci.childNodes, j = 0, cn, empty = true;
  764. while(cn = cns[j]){
  765. ++j;
  766. if(cn.nodeType == 1 || cn.nodeType == 3){
  767. empty = false;
  768. break;
  769. }
  770. }
  771. if(empty){
  772. r[++ri] = ci;
  773. }
  774. }
  775. return r;
  776. },
  777. &quot;contains&quot; : function(c, v){
  778. var r = [], ri = -1;
  779. for(var i = 0, ci; ci = c[i]; i++){
  780. if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
  781. r[++ri] = ci;
  782. }
  783. }
  784. return r;
  785. },
  786. &quot;nodeValue&quot; : function(c, v){
  787. var r = [], ri = -1;
  788. for(var i = 0, ci; ci = c[i]; i++){
  789. if(ci.firstChild &amp;&amp; ci.firstChild.nodeValue == v){
  790. r[++ri] = ci;
  791. }
  792. }
  793. return r;
  794. },
  795. &quot;checked&quot; : function(c){
  796. var r = [], ri = -1;
  797. for(var i = 0, ci; ci = c[i]; i++){
  798. if(ci.checked == true){
  799. r[++ri] = ci;
  800. }
  801. }
  802. return r;
  803. },
  804. &quot;not&quot; : function(c, ss){
  805. return Ext.DomQuery.filter(c, ss, true);
  806. },
  807. &quot;any&quot; : function(c, selectors){
  808. var ss = selectors.split('|'),
  809. r = [], ri = -1, s;
  810. for(var i = 0, ci; ci = c[i]; i++){
  811. for(var j = 0; s = ss[j]; j++){
  812. if(Ext.DomQuery.is(ci, s)){
  813. r[++ri] = ci;
  814. break;
  815. }
  816. }
  817. }
  818. return r;
  819. },
  820. &quot;odd&quot; : function(c){
  821. return this[&quot;nth-child&quot;](c, &quot;odd&quot;);
  822. },
  823. &quot;even&quot; : function(c){
  824. return this[&quot;nth-child&quot;](c, &quot;even&quot;);
  825. },
  826. &quot;nth&quot; : function(c, a){
  827. return c[a-1] || [];
  828. },
  829. &quot;first&quot; : function(c){
  830. return c[0] || [];
  831. },
  832. &quot;last&quot; : function(c){
  833. return c[c.length-1] || [];
  834. },
  835. &quot;has&quot; : function(c, ss){
  836. var s = Ext.DomQuery.select,
  837. r = [], ri = -1;
  838. for(var i = 0, ci; ci = c[i]; i++){
  839. if(s(ss, ci).length &gt; 0){
  840. r[++ri] = ci;
  841. }
  842. }
  843. return r;
  844. },
  845. &quot;next&quot; : function(c, ss){
  846. var is = Ext.DomQuery.is,
  847. r = [], ri = -1;
  848. for(var i = 0, ci; ci = c[i]; i++){
  849. var n = next(ci);
  850. if(n &amp;&amp; is(n, ss)){
  851. r[++ri] = ci;
  852. }
  853. }
  854. return r;
  855. },
  856. &quot;prev&quot; : function(c, ss){
  857. var is = Ext.DomQuery.is,
  858. r = [], ri = -1;
  859. for(var i = 0, ci; ci = c[i]; i++){
  860. var n = prev(ci);
  861. if(n &amp;&amp; is(n, ss)){
  862. r[++ri] = ci;
  863. }
  864. }
  865. return r;
  866. }
  867. }
  868. };
  869. }();
  870. <span id='Ext-method-query'>/**
  871. </span> * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
  872. * @param {String} path The selector/xpath query
  873. * @param {Node} root (optional) The start of the query (defaults to document).
  874. * @return {Array}
  875. * @member Ext
  876. * @method query
  877. */
  878. Ext.query = Ext.DomQuery.select;
  879. </pre>
  880. </body>
  881. </html>