PageRenderTime 53ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/source/Plug-in/ext/ext-core-debug.js

http://prosporous.googlecode.com/
JavaScript | 2229 lines | 1857 code | 365 blank | 7 comment | 609 complexity | 7b1fa621de361992b8dcd0e87e1a91b4 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /*
  2. * Ext JS Library 2.2
  3. * Copyright(c) 2006-2008, Ext JS, LLC.
  4. * licensing@extjs.com
  5. *
  6. * http://extjs.com/license
  7. */
  8. Ext.DomHelper = function(){
  9. var tempTableEl = null;
  10. var emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
  11. var tableRe = /^table|tbody|tr|td$/i;
  12. var createHtml = function(o){
  13. if(typeof o == 'string'){
  14. return o;
  15. }
  16. var b = "";
  17. if (Ext.isArray(o)) {
  18. for (var i = 0, l = o.length; i < l; i++) {
  19. b += createHtml(o[i]);
  20. }
  21. return b;
  22. }
  23. if(!o.tag){
  24. o.tag = "div";
  25. }
  26. b += "<" + o.tag;
  27. for(var attr in o){
  28. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
  29. if(attr == "style"){
  30. var s = o["style"];
  31. if(typeof s == "function"){
  32. s = s.call();
  33. }
  34. if(typeof s == "string"){
  35. b += ' style="' + s + '"';
  36. }else if(typeof s == "object"){
  37. b += ' style="';
  38. for(var key in s){
  39. if(typeof s[key] != "function"){
  40. b += key + ":" + s[key] + ";";
  41. }
  42. }
  43. b += '"';
  44. }
  45. }else{
  46. if(attr == "cls"){
  47. b += ' class="' + o["cls"] + '"';
  48. }else if(attr == "htmlFor"){
  49. b += ' for="' + o["htmlFor"] + '"';
  50. }else{
  51. b += " " + attr + '="' + o[attr] + '"';
  52. }
  53. }
  54. }
  55. if(emptyTags.test(o.tag)){
  56. b += "/>";
  57. }else{
  58. b += ">";
  59. var cn = o.children || o.cn;
  60. if(cn){
  61. b += createHtml(cn);
  62. } else if(o.html){
  63. b += o.html;
  64. }
  65. b += "</" + o.tag + ">";
  66. }
  67. return b;
  68. };
  69. var createDom = function(o, parentNode){
  70. var el;
  71. if (Ext.isArray(o)) { el = document.createDocumentFragment(); for(var i = 0, l = o.length; i < l; i++) {
  72. createDom(o[i], el);
  73. }
  74. } else if (typeof o == "string") { el = document.createTextNode(o);
  75. } else {
  76. el = document.createElement(o.tag||'div');
  77. var useSet = !!el.setAttribute; for(var attr in o){
  78. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || attr == "style" || typeof o[attr] == "function") continue;
  79. if(attr=="cls"){
  80. el.className = o["cls"];
  81. }else{
  82. if(useSet) el.setAttribute(attr, o[attr]);
  83. else el[attr] = o[attr];
  84. }
  85. }
  86. Ext.DomHelper.applyStyles(el, o.style);
  87. var cn = o.children || o.cn;
  88. if(cn){
  89. createDom(cn, el);
  90. } else if(o.html){
  91. el.innerHTML = o.html;
  92. }
  93. }
  94. if(parentNode){
  95. parentNode.appendChild(el);
  96. }
  97. return el;
  98. };
  99. var ieTable = function(depth, s, h, e){
  100. tempTableEl.innerHTML = [s, h, e].join('');
  101. var i = -1, el = tempTableEl;
  102. while(++i < depth){
  103. el = el.firstChild;
  104. }
  105. return el;
  106. };
  107. var ts = '<table>',
  108. te = '</table>',
  109. tbs = ts+'<tbody>',
  110. tbe = '</tbody>'+te,
  111. trs = tbs + '<tr>',
  112. tre = '</tr>'+tbe;
  113. var insertIntoTable = function(tag, where, el, html){
  114. if(!tempTableEl){
  115. tempTableEl = document.createElement('div');
  116. }
  117. var node;
  118. var before = null;
  119. if(tag == 'td'){
  120. if(where == 'afterbegin' || where == 'beforeend'){ return;
  121. }
  122. if(where == 'beforebegin'){
  123. before = el;
  124. el = el.parentNode;
  125. } else{
  126. before = el.nextSibling;
  127. el = el.parentNode;
  128. }
  129. node = ieTable(4, trs, html, tre);
  130. }
  131. else if(tag == 'tr'){
  132. if(where == 'beforebegin'){
  133. before = el;
  134. el = el.parentNode;
  135. node = ieTable(3, tbs, html, tbe);
  136. } else if(where == 'afterend'){
  137. before = el.nextSibling;
  138. el = el.parentNode;
  139. node = ieTable(3, tbs, html, tbe);
  140. } else{ if(where == 'afterbegin'){
  141. before = el.firstChild;
  142. }
  143. node = ieTable(4, trs, html, tre);
  144. }
  145. } else if(tag == 'tbody'){
  146. if(where == 'beforebegin'){
  147. before = el;
  148. el = el.parentNode;
  149. node = ieTable(2, ts, html, te);
  150. } else if(where == 'afterend'){
  151. before = el.nextSibling;
  152. el = el.parentNode;
  153. node = ieTable(2, ts, html, te);
  154. } else{
  155. if(where == 'afterbegin'){
  156. before = el.firstChild;
  157. }
  158. node = ieTable(3, tbs, html, tbe);
  159. }
  160. } else{ if(where == 'beforebegin' || where == 'afterend'){ return;
  161. }
  162. if(where == 'afterbegin'){
  163. before = el.firstChild;
  164. }
  165. node = ieTable(2, ts, html, te);
  166. }
  167. el.insertBefore(node, before);
  168. return node;
  169. };
  170. return {
  171. useDom : false,
  172. markup : function(o){
  173. return createHtml(o);
  174. },
  175. applyStyles : function(el, styles){
  176. if(styles){
  177. el = Ext.fly(el);
  178. if(typeof styles == "string"){
  179. var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
  180. var matches;
  181. while ((matches = re.exec(styles)) != null){
  182. el.setStyle(matches[1], matches[2]);
  183. }
  184. }else if (typeof styles == "object"){
  185. for (var style in styles){
  186. el.setStyle(style, styles[style]);
  187. }
  188. }else if (typeof styles == "function"){
  189. Ext.DomHelper.applyStyles(el, styles.call());
  190. }
  191. }
  192. },
  193. insertHtml : function(where, el, html){
  194. where = where.toLowerCase();
  195. if(el.insertAdjacentHTML){
  196. if(tableRe.test(el.tagName)){
  197. var rs;
  198. if(rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html)){
  199. return rs;
  200. }
  201. }
  202. switch(where){
  203. case "beforebegin":
  204. el.insertAdjacentHTML('BeforeBegin', html);
  205. return el.previousSibling;
  206. case "afterbegin":
  207. el.insertAdjacentHTML('AfterBegin', html);
  208. return el.firstChild;
  209. case "beforeend":
  210. el.insertAdjacentHTML('BeforeEnd', html);
  211. return el.lastChild;
  212. case "afterend":
  213. el.insertAdjacentHTML('AfterEnd', html);
  214. return el.nextSibling;
  215. }
  216. throw 'Illegal insertion point -> "' + where + '"';
  217. }
  218. var range = el.ownerDocument.createRange();
  219. var frag;
  220. switch(where){
  221. case "beforebegin":
  222. range.setStartBefore(el);
  223. frag = range.createContextualFragment(html);
  224. el.parentNode.insertBefore(frag, el);
  225. return el.previousSibling;
  226. case "afterbegin":
  227. if(el.firstChild){
  228. range.setStartBefore(el.firstChild);
  229. frag = range.createContextualFragment(html);
  230. el.insertBefore(frag, el.firstChild);
  231. return el.firstChild;
  232. }else{
  233. el.innerHTML = html;
  234. return el.firstChild;
  235. }
  236. case "beforeend":
  237. if(el.lastChild){
  238. range.setStartAfter(el.lastChild);
  239. frag = range.createContextualFragment(html);
  240. el.appendChild(frag);
  241. return el.lastChild;
  242. }else{
  243. el.innerHTML = html;
  244. return el.lastChild;
  245. }
  246. case "afterend":
  247. range.setStartAfter(el);
  248. frag = range.createContextualFragment(html);
  249. el.parentNode.insertBefore(frag, el.nextSibling);
  250. return el.nextSibling;
  251. }
  252. throw 'Illegal insertion point -> "' + where + '"';
  253. },
  254. insertBefore : function(el, o, returnElement){
  255. return this.doInsert(el, o, returnElement, "beforeBegin");
  256. },
  257. insertAfter : function(el, o, returnElement){
  258. return this.doInsert(el, o, returnElement, "afterEnd", "nextSibling");
  259. },
  260. insertFirst : function(el, o, returnElement){
  261. return this.doInsert(el, o, returnElement, "afterBegin", "firstChild");
  262. },
  263. doInsert : function(el, o, returnElement, pos, sibling){
  264. el = Ext.getDom(el);
  265. var newNode;
  266. if(this.useDom){
  267. newNode = createDom(o, null);
  268. (sibling === "firstChild" ? el : el.parentNode).insertBefore(newNode, sibling ? el[sibling] : el);
  269. }else{
  270. var html = createHtml(o);
  271. newNode = this.insertHtml(pos, el, html);
  272. }
  273. return returnElement ? Ext.get(newNode, true) : newNode;
  274. },
  275. append : function(el, o, returnElement){
  276. el = Ext.getDom(el);
  277. var newNode;
  278. if(this.useDom){
  279. newNode = createDom(o, null);
  280. el.appendChild(newNode);
  281. }else{
  282. var html = createHtml(o);
  283. newNode = this.insertHtml("beforeEnd", el, html);
  284. }
  285. return returnElement ? Ext.get(newNode, true) : newNode;
  286. },
  287. overwrite : function(el, o, returnElement){
  288. el = Ext.getDom(el);
  289. el.innerHTML = createHtml(o);
  290. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  291. },
  292. createTemplate : function(o){
  293. var html = createHtml(o);
  294. return new Ext.Template(html);
  295. }
  296. };
  297. }();
  298. Ext.Template = function(html){
  299. var a = arguments;
  300. if(Ext.isArray(html)){
  301. html = html.join("");
  302. }else if(a.length > 1){
  303. var buf = [];
  304. for(var i = 0, len = a.length; i < len; i++){
  305. if(typeof a[i] == 'object'){
  306. Ext.apply(this, a[i]);
  307. }else{
  308. buf[buf.length] = a[i];
  309. }
  310. }
  311. html = buf.join('');
  312. }
  313. this.html = html;
  314. if(this.compiled){
  315. this.compile();
  316. }
  317. };
  318. Ext.Template.prototype = {
  319. applyTemplate : function(values){
  320. if(this.compiled){
  321. return this.compiled(values);
  322. }
  323. var useF = this.disableFormats !== true;
  324. var fm = Ext.util.Format, tpl = this;
  325. var fn = function(m, name, format, args){
  326. if(format && useF){
  327. if(format.substr(0, 5) == "this."){
  328. return tpl.call(format.substr(5), values[name], values);
  329. }else{
  330. if(args){
  331. var re = /^\s*['"](.*)["']\s*$/;
  332. args = args.split(',');
  333. for(var i = 0, len = args.length; i < len; i++){
  334. args[i] = args[i].replace(re, "$1");
  335. }
  336. args = [values[name]].concat(args);
  337. }else{
  338. args = [values[name]];
  339. }
  340. return fm[format].apply(fm, args);
  341. }
  342. }else{
  343. return values[name] !== undefined ? values[name] : "";
  344. }
  345. };
  346. return this.html.replace(this.re, fn);
  347. },
  348. set : function(html, compile){
  349. this.html = html;
  350. this.compiled = null;
  351. if(compile){
  352. this.compile();
  353. }
  354. return this;
  355. },
  356. disableFormats : false,
  357. re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
  358. compile : function(){
  359. var fm = Ext.util.Format;
  360. var useF = this.disableFormats !== true;
  361. var sep = Ext.isGecko ? "+" : ",";
  362. var fn = function(m, name, format, args){
  363. if(format && useF){
  364. args = args ? ',' + args : "";
  365. if(format.substr(0, 5) != "this."){
  366. format = "fm." + format + '(';
  367. }else{
  368. format = 'this.call("'+ format.substr(5) + '", ';
  369. args = ", values";
  370. }
  371. }else{
  372. args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
  373. }
  374. return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
  375. };
  376. var body;
  377. if(Ext.isGecko){
  378. body = "this.compiled = function(values){ return '" +
  379. this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
  380. "';};";
  381. }else{
  382. body = ["this.compiled = function(values){ return ['"];
  383. body.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
  384. body.push("'].join('');};");
  385. body = body.join('');
  386. }
  387. eval(body);
  388. return this;
  389. },
  390. call : function(fnName, value, allValues){
  391. return this[fnName](value, allValues);
  392. },
  393. insertFirst: function(el, values, returnElement){
  394. return this.doInsert('afterBegin', el, values, returnElement);
  395. },
  396. insertBefore: function(el, values, returnElement){
  397. return this.doInsert('beforeBegin', el, values, returnElement);
  398. },
  399. insertAfter : function(el, values, returnElement){
  400. return this.doInsert('afterEnd', el, values, returnElement);
  401. },
  402. append : function(el, values, returnElement){
  403. return this.doInsert('beforeEnd', el, values, returnElement);
  404. },
  405. doInsert : function(where, el, values, returnEl){
  406. el = Ext.getDom(el);
  407. var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
  408. return returnEl ? Ext.get(newNode, true) : newNode;
  409. },
  410. overwrite : function(el, values, returnElement){
  411. el = Ext.getDom(el);
  412. el.innerHTML = this.applyTemplate(values);
  413. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  414. }
  415. };
  416. Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
  417. Ext.DomHelper.Template = Ext.Template;
  418. Ext.Template.from = function(el, config){
  419. el = Ext.getDom(el);
  420. return new Ext.Template(el.value || el.innerHTML, config || '');
  421. };
  422. Ext.DomQuery = function(){
  423. var cache = {}, simpleCache = {}, valueCache = {};
  424. var nonSpace = /\S/;
  425. var trimRe = /^\s+|\s+$/g;
  426. var tplRe = /\{(\d+)\}/g;
  427. var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
  428. var tagTokenRe = /^(#)?([\w-\*]+)/;
  429. var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;
  430. function child(p, index){
  431. var i = 0;
  432. var n = p.firstChild;
  433. while(n){
  434. if(n.nodeType == 1){
  435. if(++i == index){
  436. return n;
  437. }
  438. }
  439. n = n.nextSibling;
  440. }
  441. return null;
  442. };
  443. function next(n){
  444. while((n = n.nextSibling) && n.nodeType != 1);
  445. return n;
  446. };
  447. function prev(n){
  448. while((n = n.previousSibling) && n.nodeType != 1);
  449. return n;
  450. };
  451. function children(d){
  452. var n = d.firstChild, ni = -1;
  453. while(n){
  454. var nx = n.nextSibling;
  455. if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
  456. d.removeChild(n);
  457. }else{
  458. n.nodeIndex = ++ni;
  459. }
  460. n = nx;
  461. }
  462. return this;
  463. };
  464. function byClassName(c, a, v){
  465. if(!v){
  466. return c;
  467. }
  468. var r = [], ri = -1, cn;
  469. for(var i = 0, ci; ci = c[i]; i++){
  470. if((' '+ci.className+' ').indexOf(v) != -1){
  471. r[++ri] = ci;
  472. }
  473. }
  474. return r;
  475. };
  476. function attrValue(n, attr){
  477. if(!n.tagName && typeof n.length != "undefined"){
  478. n = n[0];
  479. }
  480. if(!n){
  481. return null;
  482. }
  483. if(attr == "for"){
  484. return n.htmlFor;
  485. }
  486. if(attr == "class" || attr == "className"){
  487. return n.className;
  488. }
  489. return n.getAttribute(attr) || n[attr];
  490. };
  491. function getNodes(ns, mode, tagName){
  492. var result = [], ri = -1, cs;
  493. if(!ns){
  494. return result;
  495. }
  496. tagName = tagName || "*";
  497. if(typeof ns.getElementsByTagName != "undefined"){
  498. ns = [ns];
  499. }
  500. if(!mode){
  501. for(var i = 0, ni; ni = ns[i]; i++){
  502. cs = ni.getElementsByTagName(tagName);
  503. for(var j = 0, ci; ci = cs[j]; j++){
  504. result[++ri] = ci;
  505. }
  506. }
  507. }else if(mode == "/" || mode == ">"){
  508. var utag = tagName.toUpperCase();
  509. for(var i = 0, ni, cn; ni = ns[i]; i++){
  510. cn = ni.children || ni.childNodes;
  511. for(var j = 0, cj; cj = cn[j]; j++){
  512. if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
  513. result[++ri] = cj;
  514. }
  515. }
  516. }
  517. }else if(mode == "+"){
  518. var utag = tagName.toUpperCase();
  519. for(var i = 0, n; n = ns[i]; i++){
  520. while((n = n.nextSibling) && n.nodeType != 1);
  521. if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
  522. result[++ri] = n;
  523. }
  524. }
  525. }else if(mode == "~"){
  526. for(var i = 0, n; n = ns[i]; i++){
  527. while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));
  528. if(n){
  529. result[++ri] = n;
  530. }
  531. }
  532. }
  533. return result;
  534. };
  535. function concat(a, b){
  536. if(b.slice){
  537. return a.concat(b);
  538. }
  539. for(var i = 0, l = b.length; i < l; i++){
  540. a[a.length] = b[i];
  541. }
  542. return a;
  543. }
  544. function byTag(cs, tagName){
  545. if(cs.tagName || cs == document){
  546. cs = [cs];
  547. }
  548. if(!tagName){
  549. return cs;
  550. }
  551. var r = [], ri = -1;
  552. tagName = tagName.toLowerCase();
  553. for(var i = 0, ci; ci = cs[i]; i++){
  554. if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
  555. r[++ri] = ci;
  556. }
  557. }
  558. return r;
  559. };
  560. function byId(cs, attr, id){
  561. if(cs.tagName || cs == document){
  562. cs = [cs];
  563. }
  564. if(!id){
  565. return cs;
  566. }
  567. var r = [], ri = -1;
  568. for(var i = 0,ci; ci = cs[i]; i++){
  569. if(ci && ci.id == id){
  570. r[++ri] = ci;
  571. return r;
  572. }
  573. }
  574. return r;
  575. };
  576. function byAttribute(cs, attr, value, op, custom){
  577. var r = [], ri = -1, st = custom=="{";
  578. var f = Ext.DomQuery.operators[op];
  579. for(var i = 0, ci; ci = cs[i]; i++){
  580. var a;
  581. if(st){
  582. a = Ext.DomQuery.getStyle(ci, attr);
  583. }
  584. else if(attr == "class" || attr == "className"){
  585. a = ci.className;
  586. }else if(attr == "for"){
  587. a = ci.htmlFor;
  588. }else if(attr == "href"){
  589. a = ci.getAttribute("href", 2);
  590. }else{
  591. a = ci.getAttribute(attr);
  592. }
  593. if((f && f(a, value)) || (!f && a)){
  594. r[++ri] = ci;
  595. }
  596. }
  597. return r;
  598. };
  599. function byPseudo(cs, name, value){
  600. return Ext.DomQuery.pseudos[name](cs, value);
  601. };
  602. var isIE = window.ActiveXObject ? true : false;
  603. eval("var batch = 30803;");
  604. var key = 30803;
  605. function nodupIEXml(cs){
  606. var d = ++key;
  607. cs[0].setAttribute("_nodup", d);
  608. var r = [cs[0]];
  609. for(var i = 1, len = cs.length; i < len; i++){
  610. var c = cs[i];
  611. if(!c.getAttribute("_nodup") != d){
  612. c.setAttribute("_nodup", d);
  613. r[r.length] = c;
  614. }
  615. }
  616. for(var i = 0, len = cs.length; i < len; i++){
  617. cs[i].removeAttribute("_nodup");
  618. }
  619. return r;
  620. }
  621. function nodup(cs){
  622. if(!cs){
  623. return [];
  624. }
  625. var len = cs.length, c, i, r = cs, cj, ri = -1;
  626. if(!len || typeof cs.nodeType != "undefined" || len == 1){
  627. return cs;
  628. }
  629. if(isIE && typeof cs[0].selectSingleNode != "undefined"){
  630. return nodupIEXml(cs);
  631. }
  632. var d = ++key;
  633. cs[0]._nodup = d;
  634. for(i = 1; c = cs[i]; i++){
  635. if(c._nodup != d){
  636. c._nodup = d;
  637. }else{
  638. r = [];
  639. for(var j = 0; j < i; j++){
  640. r[++ri] = cs[j];
  641. }
  642. for(j = i+1; cj = cs[j]; j++){
  643. if(cj._nodup != d){
  644. cj._nodup = d;
  645. r[++ri] = cj;
  646. }
  647. }
  648. return r;
  649. }
  650. }
  651. return r;
  652. }
  653. function quickDiffIEXml(c1, c2){
  654. var d = ++key;
  655. for(var i = 0, len = c1.length; i < len; i++){
  656. c1[i].setAttribute("_qdiff", d);
  657. }
  658. var r = [];
  659. for(var i = 0, len = c2.length; i < len; i++){
  660. if(c2[i].getAttribute("_qdiff") != d){
  661. r[r.length] = c2[i];
  662. }
  663. }
  664. for(var i = 0, len = c1.length; i < len; i++){
  665. c1[i].removeAttribute("_qdiff");
  666. }
  667. return r;
  668. }
  669. function quickDiff(c1, c2){
  670. var len1 = c1.length;
  671. if(!len1){
  672. return c2;
  673. }
  674. if(isIE && c1[0].selectSingleNode){
  675. return quickDiffIEXml(c1, c2);
  676. }
  677. var d = ++key;
  678. for(var i = 0; i < len1; i++){
  679. c1[i]._qdiff = d;
  680. }
  681. var r = [];
  682. for(var i = 0, len = c2.length; i < len; i++){
  683. if(c2[i]._qdiff != d){
  684. r[r.length] = c2[i];
  685. }
  686. }
  687. return r;
  688. }
  689. function quickId(ns, mode, root, id){
  690. if(ns == root){
  691. var d = root.ownerDocument || root;
  692. return d.getElementById(id);
  693. }
  694. ns = getNodes(ns, mode, "*");
  695. return byId(ns, null, id);
  696. }
  697. return {
  698. getStyle : function(el, name){
  699. return Ext.fly(el).getStyle(name);
  700. },
  701. compile : function(path, type){
  702. type = type || "select";
  703. var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
  704. var q = path, mode, lq;
  705. var tk = Ext.DomQuery.matchers;
  706. var tklen = tk.length;
  707. var mm;
  708. var lmode = q.match(modeRe);
  709. if(lmode && lmode[1]){
  710. fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
  711. q = q.replace(lmode[1], "");
  712. }
  713. while(path.substr(0, 1)=="/"){
  714. path = path.substr(1);
  715. }
  716. while(q && lq != q){
  717. lq = q;
  718. var tm = q.match(tagTokenRe);
  719. if(type == "select"){
  720. if(tm){
  721. if(tm[1] == "#"){
  722. fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
  723. }else{
  724. fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
  725. }
  726. q = q.replace(tm[0], "");
  727. }else if(q.substr(0, 1) != '@'){
  728. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  729. }
  730. }else{
  731. if(tm){
  732. if(tm[1] == "#"){
  733. fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
  734. }else{
  735. fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
  736. }
  737. q = q.replace(tm[0], "");
  738. }
  739. }
  740. while(!(mm = q.match(modeRe))){
  741. var matched = false;
  742. for(var j = 0; j < tklen; j++){
  743. var t = tk[j];
  744. var m = q.match(t.re);
  745. if(m){
  746. fn[fn.length] = t.select.replace(tplRe, function(x, i){
  747. return m[i];
  748. });
  749. q = q.replace(m[0], "");
  750. matched = true;
  751. break;
  752. }
  753. }
  754. if(!matched){
  755. throw 'Error parsing selector, parsing failed at "' + q + '"';
  756. }
  757. }
  758. if(mm[1]){
  759. fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
  760. q = q.replace(mm[1], "");
  761. }
  762. }
  763. fn[fn.length] = "return nodup(n);\n}";
  764. eval(fn.join(""));
  765. return f;
  766. },
  767. select : function(path, root, type){
  768. if(!root || root == document){
  769. root = document;
  770. }
  771. if(typeof root == "string"){
  772. root = document.getElementById(root);
  773. }
  774. var paths = path.split(",");
  775. var results = [];
  776. for(var i = 0, len = paths.length; i < len; i++){
  777. var p = paths[i].replace(trimRe, "");
  778. if(!cache[p]){
  779. cache[p] = Ext.DomQuery.compile(p);
  780. if(!cache[p]){
  781. throw p + " is not a valid selector";
  782. }
  783. }
  784. var result = cache[p](root);
  785. if(result && result != document){
  786. results = results.concat(result);
  787. }
  788. }
  789. if(paths.length > 1){
  790. return nodup(results);
  791. }
  792. return results;
  793. },
  794. selectNode : function(path, root){
  795. return Ext.DomQuery.select(path, root)[0];
  796. },
  797. selectValue : function(path, root, defaultValue){
  798. path = path.replace(trimRe, "");
  799. if(!valueCache[path]){
  800. valueCache[path] = Ext.DomQuery.compile(path, "select");
  801. }
  802. var n = valueCache[path](root);
  803. n = n[0] ? n[0] : n;
  804. var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
  805. return ((v === null||v === undefined||v==='') ? defaultValue : v);
  806. },
  807. selectNumber : function(path, root, defaultValue){
  808. var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
  809. return parseFloat(v);
  810. },
  811. is : function(el, ss){
  812. if(typeof el == "string"){
  813. el = document.getElementById(el);
  814. }
  815. var isArray = Ext.isArray(el);
  816. var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
  817. return isArray ? (result.length == el.length) : (result.length > 0);
  818. },
  819. filter : function(els, ss, nonMatches){
  820. ss = ss.replace(trimRe, "");
  821. if(!simpleCache[ss]){
  822. simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
  823. }
  824. var result = simpleCache[ss](els);
  825. return nonMatches ? quickDiff(result, els) : result;
  826. },
  827. matchers : [{
  828. re: /^\.([\w-]+)/,
  829. select: 'n = byClassName(n, null, " {1} ");'
  830. }, {
  831. re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  832. select: 'n = byPseudo(n, "{1}", "{2}");'
  833. },{
  834. re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  835. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  836. }, {
  837. re: /^#([\w-]+)/,
  838. select: 'n = byId(n, null, "{1}");'
  839. },{
  840. re: /^@([\w-]+)/,
  841. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  842. }
  843. ],
  844. operators : {
  845. "=" : function(a, v){
  846. return a == v;
  847. },
  848. "!=" : function(a, v){
  849. return a != v;
  850. },
  851. "^=" : function(a, v){
  852. return a && a.substr(0, v.length) == v;
  853. },
  854. "$=" : function(a, v){
  855. return a && a.substr(a.length-v.length) == v;
  856. },
  857. "*=" : function(a, v){
  858. return a && a.indexOf(v) !== -1;
  859. },
  860. "%=" : function(a, v){
  861. return (a % v) == 0;
  862. },
  863. "|=" : function(a, v){
  864. return a && (a == v || a.substr(0, v.length+1) == v+'-');
  865. },
  866. "~=" : function(a, v){
  867. return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
  868. }
  869. },
  870. pseudos : {
  871. "first-child" : function(c){
  872. var r = [], ri = -1, n;
  873. for(var i = 0, ci; ci = n = c[i]; i++){
  874. while((n = n.previousSibling) && n.nodeType != 1);
  875. if(!n){
  876. r[++ri] = ci;
  877. }
  878. }
  879. return r;
  880. },
  881. "last-child" : function(c){
  882. var r = [], ri = -1, n;
  883. for(var i = 0, ci; ci = n = c[i]; i++){
  884. while((n = n.nextSibling) && n.nodeType != 1);
  885. if(!n){
  886. r[++ri] = ci;
  887. }
  888. }
  889. return r;
  890. },
  891. "nth-child" : function(c, a) {
  892. var r = [], ri = -1;
  893. var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
  894. var f = (m[1] || 1) - 0, l = m[2] - 0;
  895. for(var i = 0, n; n = c[i]; i++){
  896. var pn = n.parentNode;
  897. if (batch != pn._batch) {
  898. var j = 0;
  899. for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
  900. if(cn.nodeType == 1){
  901. cn.nodeIndex = ++j;
  902. }
  903. }
  904. pn._batch = batch;
  905. }
  906. if (f == 1) {
  907. if (l == 0 || n.nodeIndex == l){
  908. r[++ri] = n;
  909. }
  910. } else if ((n.nodeIndex + l) % f == 0){
  911. r[++ri] = n;
  912. }
  913. }
  914. return r;
  915. },
  916. "only-child" : function(c){
  917. var r = [], ri = -1;;
  918. for(var i = 0, ci; ci = c[i]; i++){
  919. if(!prev(ci) && !next(ci)){
  920. r[++ri] = ci;
  921. }
  922. }
  923. return r;
  924. },
  925. "empty" : function(c){
  926. var r = [], ri = -1;
  927. for(var i = 0, ci; ci = c[i]; i++){
  928. var cns = ci.childNodes, j = 0, cn, empty = true;
  929. while(cn = cns[j]){
  930. ++j;
  931. if(cn.nodeType == 1 || cn.nodeType == 3){
  932. empty = false;
  933. break;
  934. }
  935. }
  936. if(empty){
  937. r[++ri] = ci;
  938. }
  939. }
  940. return r;
  941. },
  942. "contains" : function(c, v){
  943. var r = [], ri = -1;
  944. for(var i = 0, ci; ci = c[i]; i++){
  945. if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
  946. r[++ri] = ci;
  947. }
  948. }
  949. return r;
  950. },
  951. "nodeValue" : function(c, v){
  952. var r = [], ri = -1;
  953. for(var i = 0, ci; ci = c[i]; i++){
  954. if(ci.firstChild && ci.firstChild.nodeValue == v){
  955. r[++ri] = ci;
  956. }
  957. }
  958. return r;
  959. },
  960. "checked" : function(c){
  961. var r = [], ri = -1;
  962. for(var i = 0, ci; ci = c[i]; i++){
  963. if(ci.checked == true){
  964. r[++ri] = ci;
  965. }
  966. }
  967. return r;
  968. },
  969. "not" : function(c, ss){
  970. return Ext.DomQuery.filter(c, ss, true);
  971. },
  972. "any" : function(c, selectors){
  973. var ss = selectors.split('|');
  974. var r = [], ri = -1, s;
  975. for(var i = 0, ci; ci = c[i]; i++){
  976. for(var j = 0; s = ss[j]; j++){
  977. if(Ext.DomQuery.is(ci, s)){
  978. r[++ri] = ci;
  979. break;
  980. }
  981. }
  982. }
  983. return r;
  984. },
  985. "odd" : function(c){
  986. return this["nth-child"](c, "odd");
  987. },
  988. "even" : function(c){
  989. return this["nth-child"](c, "even");
  990. },
  991. "nth" : function(c, a){
  992. return c[a-1] || [];
  993. },
  994. "first" : function(c){
  995. return c[0] || [];
  996. },
  997. "last" : function(c){
  998. return c[c.length-1] || [];
  999. },
  1000. "has" : function(c, ss){
  1001. var s = Ext.DomQuery.select;
  1002. var r = [], ri = -1;
  1003. for(var i = 0, ci; ci = c[i]; i++){
  1004. if(s(ss, ci).length > 0){
  1005. r[++ri] = ci;
  1006. }
  1007. }
  1008. return r;
  1009. },
  1010. "next" : function(c, ss){
  1011. var is = Ext.DomQuery.is;
  1012. var r = [], ri = -1;
  1013. for(var i = 0, ci; ci = c[i]; i++){
  1014. var n = next(ci);
  1015. if(n && is(n, ss)){
  1016. r[++ri] = ci;
  1017. }
  1018. }
  1019. return r;
  1020. },
  1021. "prev" : function(c, ss){
  1022. var is = Ext.DomQuery.is;
  1023. var r = [], ri = -1;
  1024. for(var i = 0, ci; ci = c[i]; i++){
  1025. var n = prev(ci);
  1026. if(n && is(n, ss)){
  1027. r[++ri] = ci;
  1028. }
  1029. }
  1030. return r;
  1031. }
  1032. }
  1033. };
  1034. }();
  1035. Ext.query = Ext.DomQuery.select;
  1036. Ext.util.Observable = function(){
  1037. if(this.listeners){
  1038. this.on(this.listeners);
  1039. delete this.listeners;
  1040. }
  1041. };
  1042. Ext.util.Observable.prototype = {
  1043. fireEvent : function(){
  1044. if(this.eventsSuspended !== true){
  1045. var ce = this.events[arguments[0].toLowerCase()];
  1046. if(typeof ce == "object"){
  1047. return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
  1048. }
  1049. }
  1050. return true;
  1051. },
  1052. filterOptRe : /^(?:scope|delay|buffer|single)$/,
  1053. addListener : function(eventName, fn, scope, o){
  1054. if(typeof eventName == "object"){
  1055. o = eventName;
  1056. for(var e in o){
  1057. if(this.filterOptRe.test(e)){
  1058. continue;
  1059. }
  1060. if(typeof o[e] == "function"){
  1061. this.addListener(e, o[e], o.scope, o);
  1062. }else{
  1063. this.addListener(e, o[e].fn, o[e].scope, o[e]);
  1064. }
  1065. }
  1066. return;
  1067. }
  1068. o = (!o || typeof o == "boolean") ? {} : o;
  1069. eventName = eventName.toLowerCase();
  1070. var ce = this.events[eventName] || true;
  1071. if(typeof ce == "boolean"){
  1072. ce = new Ext.util.Event(this, eventName);
  1073. this.events[eventName] = ce;
  1074. }
  1075. ce.addListener(fn, scope, o);
  1076. },
  1077. removeListener : function(eventName, fn, scope){
  1078. var ce = this.events[eventName.toLowerCase()];
  1079. if(typeof ce == "object"){
  1080. ce.removeListener(fn, scope);
  1081. }
  1082. },
  1083. purgeListeners : function(){
  1084. for(var evt in this.events){
  1085. if(typeof this.events[evt] == "object"){
  1086. this.events[evt].clearListeners();
  1087. }
  1088. }
  1089. },
  1090. relayEvents : function(o, events){
  1091. var createHandler = function(ename){
  1092. return function(){
  1093. return this.fireEvent.apply(this, Ext.combine(ename, Array.prototype.slice.call(arguments, 0)));
  1094. };
  1095. };
  1096. for(var i = 0, len = events.length; i < len; i++){
  1097. var ename = events[i];
  1098. if(!this.events[ename]){ this.events[ename] = true; };
  1099. o.on(ename, createHandler(ename), this);
  1100. }
  1101. },
  1102. addEvents : function(o){
  1103. if(!this.events){
  1104. this.events = {};
  1105. }
  1106. if(typeof o == 'string'){
  1107. for(var i = 0, a = arguments, v; v = a[i]; i++){
  1108. if(!this.events[a[i]]){
  1109. this.events[a[i]] = true;
  1110. }
  1111. }
  1112. }else{
  1113. Ext.applyIf(this.events, o);
  1114. }
  1115. },
  1116. hasListener : function(eventName){
  1117. var e = this.events[eventName];
  1118. return typeof e == "object" && e.listeners.length > 0;
  1119. },
  1120. suspendEvents : function(){
  1121. this.eventsSuspended = true;
  1122. },
  1123. resumeEvents : function(){
  1124. this.eventsSuspended = false;
  1125. },
  1126. getMethodEvent : function(method){
  1127. if(!this.methodEvents){
  1128. this.methodEvents = {};
  1129. }
  1130. var e = this.methodEvents[method];
  1131. if(!e){
  1132. e = {};
  1133. this.methodEvents[method] = e;
  1134. e.originalFn = this[method];
  1135. e.methodName = method;
  1136. e.before = [];
  1137. e.after = [];
  1138. var returnValue, v, cancel;
  1139. var obj = this;
  1140. var makeCall = function(fn, scope, args){
  1141. if((v = fn.apply(scope || obj, args)) !== undefined){
  1142. if(typeof v === 'object'){
  1143. if(v.returnValue !== undefined){
  1144. returnValue = v.returnValue;
  1145. }else{
  1146. returnValue = v;
  1147. }
  1148. if(v.cancel === true){
  1149. cancel = true;
  1150. }
  1151. }else if(v === false){
  1152. cancel = true;
  1153. }else {
  1154. returnValue = v;
  1155. }
  1156. }
  1157. }
  1158. this[method] = function(){
  1159. returnValue = v = undefined; cancel = false;
  1160. var args = Array.prototype.slice.call(arguments, 0);
  1161. for(var i = 0, len = e.before.length; i < len; i++){
  1162. makeCall(e.before[i].fn, e.before[i].scope, args);
  1163. if(cancel){
  1164. return returnValue;
  1165. }
  1166. }
  1167. if((v = e.originalFn.apply(obj, args)) !== undefined){
  1168. returnValue = v;
  1169. }
  1170. for(var i = 0, len = e.after.length; i < len; i++){
  1171. makeCall(e.after[i].fn, e.after[i].scope, args);
  1172. if(cancel){
  1173. return returnValue;
  1174. }
  1175. }
  1176. return returnValue;
  1177. };
  1178. }
  1179. return e;
  1180. },
  1181. beforeMethod : function(method, fn, scope){
  1182. var e = this.getMethodEvent(method);
  1183. e.before.push({fn: fn, scope: scope});
  1184. },
  1185. afterMethod : function(method, fn, scope){
  1186. var e = this.getMethodEvent(method);
  1187. e.after.push({fn: fn, scope: scope});
  1188. },
  1189. removeMethodListener : function(method, fn, scope){
  1190. var e = this.getMethodEvent(method);
  1191. for(var i = 0, len = e.before.length; i < len; i++){
  1192. if(e.before[i].fn == fn && e.before[i].scope == scope){
  1193. e.before.splice(i, 1);
  1194. return;
  1195. }
  1196. }
  1197. for(var i = 0, len = e.after.length; i < len; i++){
  1198. if(e.after[i].fn == fn && e.after[i].scope == scope){
  1199. e.after.splice(i, 1);
  1200. return;
  1201. }
  1202. }
  1203. }
  1204. };
  1205. Ext.util.Observable.prototype.on = Ext.util.Observable.prototype.addListener;
  1206. Ext.util.Observable.prototype.un = Ext.util.Observable.prototype.removeListener;
  1207. Ext.util.Observable.capture = function(o, fn, scope){
  1208. o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
  1209. };
  1210. Ext.util.Observable.releaseCapture = function(o){
  1211. o.fireEvent = Ext.util.Observable.prototype.fireEvent;
  1212. };
  1213. (function(){
  1214. var createBuffered = function(h, o, scope){
  1215. var task = new Ext.util.DelayedTask();
  1216. return function(){
  1217. task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
  1218. };
  1219. };
  1220. var createSingle = function(h, e, fn, scope){
  1221. return function(){
  1222. e.removeListener(fn, scope);
  1223. return h.apply(scope, arguments);
  1224. };
  1225. };
  1226. var createDelayed = function(h, o, scope){
  1227. return function(){
  1228. var args = Array.prototype.slice.call(arguments, 0);
  1229. setTimeout(function(){
  1230. h.apply(scope, args);
  1231. }, o.delay || 10);
  1232. };
  1233. };
  1234. Ext.util.Event = function(obj, name){
  1235. this.name = name;
  1236. this.obj = obj;
  1237. this.listeners = [];
  1238. };
  1239. Ext.util.Event.prototype = {
  1240. addListener : function(fn, scope, options){
  1241. scope = scope || this.obj;
  1242. if(!this.isListening(fn, scope)){
  1243. var l = this.createListener(fn, scope, options);
  1244. if(!this.firing){
  1245. this.listeners.push(l);
  1246. }else{ this.listeners = this.listeners.slice(0);
  1247. this.listeners.push(l);
  1248. }
  1249. }
  1250. },
  1251. createListener : function(fn, scope, o){
  1252. o = o || {};
  1253. scope = scope || this.obj;
  1254. var l = {fn: fn, scope: scope, options: o};
  1255. var h = fn;
  1256. if(o.delay){
  1257. h = createDelayed(h, o, scope);
  1258. }
  1259. if(o.single){
  1260. h = createSingle(h, this, fn, scope);
  1261. }
  1262. if(o.buffer){
  1263. h = createBuffered(h, o, scope);
  1264. }
  1265. l.fireFn = h;
  1266. return l;
  1267. },
  1268. findListener : function(fn, scope){
  1269. scope = scope || this.obj;
  1270. var ls = this.listeners;
  1271. for(var i = 0, len = ls.length; i < len; i++){
  1272. var l = ls[i];
  1273. if(l.fn == fn && l.scope == scope){
  1274. return i;
  1275. }
  1276. }
  1277. return -1;
  1278. },
  1279. isListening : function(fn, scope){
  1280. return this.findListener(fn, scope) != -1;
  1281. },
  1282. removeListener : function(fn, scope){
  1283. var index;
  1284. if((index = this.findListener(fn, scope)) != -1){
  1285. if(!this.firing){
  1286. this.listeners.splice(index, 1);
  1287. }else{
  1288. this.listeners = this.listeners.slice(0);
  1289. this.listeners.splice(index, 1);
  1290. }
  1291. return true;
  1292. }
  1293. return false;
  1294. },
  1295. clearListeners : function(){
  1296. this.listeners = [];
  1297. },
  1298. fire : function(){
  1299. var ls = this.listeners, scope, len = ls.length;
  1300. if(len > 0){
  1301. this.firing = true;
  1302. var args = Array.prototype.slice.call(arguments, 0);
  1303. for(var i = 0; i < len; i++){
  1304. var l = ls[i];
  1305. if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
  1306. this.firing = false;
  1307. return false;
  1308. }
  1309. }
  1310. this.firing = false;
  1311. }
  1312. return true;
  1313. }
  1314. };
  1315. })();
  1316. Ext.EventManager = function(){
  1317. var docReadyEvent, docReadyProcId, docReadyState = false;
  1318. var resizeEvent, resizeTask, textEvent, textSize;
  1319. var E = Ext.lib.Event;
  1320. var D = Ext.lib.Dom;
  1321. var xname = 'Ex' + 't';
  1322. var elHash = {};
  1323. var addListener = function(el, ename, fn, wrap, scope){
  1324. var id = Ext.id(el);
  1325. if(!elHash[id]){
  1326. elHash[id] = {};
  1327. }
  1328. var es = elHash[id];
  1329. if(!es[ename]){
  1330. es[ename] = [];
  1331. }
  1332. var ls = es[ename];
  1333. ls.push({
  1334. id: id,
  1335. ename: ename,
  1336. fn: fn,
  1337. wrap: wrap,
  1338. scope: scope
  1339. });
  1340. E.on(el, ename, wrap);
  1341. if(ename == "mousewheel" && el.addEventListener){ el.addEventListener("DOMMouseScroll", wrap, false);
  1342. E.on(window, 'unload', function(){
  1343. el.removeEventListener("DOMMouseScroll", wrap, false);
  1344. });
  1345. }
  1346. if(ename == "mousedown" && el == document){ Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
  1347. }
  1348. }
  1349. var removeListener = function(el, ename, fn, scope){
  1350. el = Ext.getDom(el);
  1351. var id = Ext.id(el), es = elHash[id], wrap;
  1352. if(es){
  1353. var ls = es[ename], l;
  1354. if(ls){
  1355. for(var i = 0, len = ls.length; i < len; i++){
  1356. l = ls[i];
  1357. if(l.fn == fn && (!scope || l.scope == scope)){
  1358. wrap = l.wrap;
  1359. E.un(el, ename, wrap);
  1360. ls.splice(i, 1);
  1361. break;
  1362. }
  1363. }
  1364. }
  1365. }
  1366. if(ename == "mousewheel" && el.addEventListener && wrap){
  1367. el.removeEventListener("DOMMouseScroll", wrap, false);
  1368. }
  1369. if(ename == "mousedown" && el == document && wrap){ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
  1370. }
  1371. }
  1372. var removeAll = function(el){
  1373. el = Ext.getDom(el);
  1374. var id = Ext.id(el), es = elHash[id], ls;
  1375. if(es){
  1376. for(var ename in es){
  1377. if(es.hasOwnProperty(ename)){
  1378. ls = es[ename];
  1379. for(var i = 0, len = ls.length; i < len; i++){
  1380. E.un(el, ename, ls[i].wrap);
  1381. ls[i] = null;
  1382. }
  1383. }
  1384. es[ename] = null;
  1385. }
  1386. delete elHash[id];
  1387. }
  1388. }
  1389. var fireDocReady = function(){
  1390. if(!docReadyState){
  1391. docReadyState = Ext.isReady = true;
  1392. if(Ext.isGecko || Ext.isOpera) {
  1393. document.removeEventListener("DOMContentLoaded", fireDocReady, false);
  1394. }
  1395. }
  1396. if(docReadyProcId){
  1397. clearInterval(docReadyProcId);
  1398. docReadyProcId = null;
  1399. }
  1400. if(docReadyEvent){
  1401. docReadyEvent.fire();
  1402. docReadyEvent.clearListeners();
  1403. }
  1404. };
  1405. var initDocReady = function(){
  1406. docReadyEvent = new Ext.util.Event();
  1407. if(Ext.isReady){
  1408. return;
  1409. }
  1410. E.on(window, 'load', fireDocReady);
  1411. if(Ext.isGecko || Ext.isOpera) {
  1412. document.addEventListener('DOMContentLoaded', fireDocReady, false);
  1413. }
  1414. else if(Ext.isIE){
  1415. docReadyProcId = setInterval(function(){
  1416. try{
  1417. Ext.isReady || (document.documentElement.doScroll('left'));
  1418. }catch(e){
  1419. return;
  1420. }
  1421. fireDocReady(); }, 5);
  1422. document.onreadystatechange = function(){
  1423. if(document.readyState == 'complete'){
  1424. document.onreadystatechange = null;
  1425. fireDocReady();
  1426. }
  1427. };
  1428. }
  1429. else if(Ext.isSafari){
  1430. docReadyProcId = setInterval(function(){
  1431. var rs = document.readyState;
  1432. if(rs == 'complete') {
  1433. fireDocReady();
  1434. }
  1435. }, 10);
  1436. }
  1437. };
  1438. var createBuffered = function(h, o){
  1439. var task = new Ext.util.DelayedTask(h);
  1440. return function(e){
  1441. e = new Ext.EventObjectImpl(e);
  1442. task.delay(o.buffer, h, null, [e]);
  1443. };
  1444. };
  1445. var createSingle = function(h, el, ename, fn, scope){
  1446. return function(e){
  1447. Ext.EventManager.removeListener(el, ename, fn, scope);
  1448. h(e);
  1449. };
  1450. };
  1451. var createDelayed = function(h, o){
  1452. return function(e){
  1453. e = new Ext.EventObjectImpl(e);
  1454. setTimeout(function(){
  1455. h(e);
  1456. }, o.delay || 10);
  1457. };
  1458. };
  1459. var listen = function(element, ename, opt, fn, scope){
  1460. var o = (!opt || typeof opt == "boolean") ? {} : opt;
  1461. fn = fn || o.fn; scope = scope || o.scope;
  1462. var el = Ext.getDom(element);
  1463. if(!el){
  1464. throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
  1465. }
  1466. var h = function(e){
  1467. if(!window[xname]){
  1468. return;
  1469. }
  1470. e = Ext.EventObject.setEvent(e);
  1471. var t;
  1472. if(o.delegate){
  1473. t = e.getTarget(o.delegate, el);
  1474. if(!t){
  1475. return;
  1476. }
  1477. }else{
  1478. t = e.target;
  1479. }
  1480. if(o.stopEvent === true){
  1481. e.stopEvent();
  1482. }
  1483. if(o.preventDefault === true){
  1484. e.preventDefault();
  1485. }
  1486. if(o.stopPropagation === true){
  1487. e.stopPropagation();
  1488. }
  1489. if(o.normalized === false){
  1490. e = e.browserEvent;
  1491. }
  1492. fn.call(scope || el, e, t, o);
  1493. };
  1494. if(o.delay){
  1495. h = createDelayed(h, o);
  1496. }
  1497. if(o.single){
  1498. h = createSingle(h, el, ename, fn, scope);
  1499. }
  1500. if(o.buffer){
  1501. h = createBuffered(h, o);
  1502. }
  1503. addListener(el, ename, fn, h, scope);
  1504. return h;
  1505. };
  1506. var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
  1507. var pub = {
  1508. addListener : function(element, eventName, fn, scope, options){
  1509. if(typeof eventName == "object"){
  1510. var o = eventName;
  1511. for(var e in o){
  1512. if(propRe.test(e)){
  1513. continue;
  1514. }
  1515. if(typeof o[e] == "function"){
  1516. listen(element, e, o, o[e], o.scope);
  1517. }else{
  1518. listen(element, e, o[e]);
  1519. }
  1520. }
  1521. return;
  1522. }
  1523. return listen(element, eventName, options, fn, scope);
  1524. },
  1525. removeListener : function(element, eventName, fn, scope){
  1526. return removeListener(element, eventName, fn, scope);
  1527. },
  1528. removeAll : function(element){
  1529. return removeAll(element);
  1530. },
  1531. onDocumentReady : function(fn, scope, options){
  1532. if(!docReadyEvent){
  1533. initDocReady();
  1534. }
  1535. if(docReadyState || Ext.isReady){ options || (options = {});
  1536. fn.defer(options.delay||0, scope);
  1537. }else{
  1538. docReadyEvent.addListener(fn, scope, options);
  1539. }
  1540. },
  1541. onWindowResize : function(fn, scope, options){
  1542. if(!resizeEvent){
  1543. resizeEvent = new Ext.util.Event();
  1544. resizeTask = new Ext.util.DelayedTask(function(){
  1545. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1546. });
  1547. E.on(window, "resize", this.fireWindowResize, this);
  1548. }
  1549. resizeEvent.addListener(fn, scope, options);
  1550. },
  1551. fireWindowResize : function(){
  1552. if(resizeEvent){
  1553. if((Ext.isIE||Ext.isAir) && resizeTask){
  1554. resizeTask.delay(50);
  1555. }else{
  1556. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1557. }
  1558. }
  1559. },
  1560. onTextResize : function(fn, scope, options){
  1561. if(!textEvent){
  1562. textEvent = new Ext.util.Event();
  1563. var textEl = new Ext.Element(document.createElement('div'));
  1564. textEl.dom.className = 'x-text-resize';
  1565. textEl.dom.innerHTML = 'X';
  1566. textEl.appendTo(document.body);
  1567. textSize = textEl.dom.offsetHeight;
  1568. setInterval(function(){
  1569. if(textEl.dom.offsetHeight != textSize){
  1570. textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
  1571. }
  1572. }, this.textResizeInterval);
  1573. }
  1574. textEvent.addListener(fn, scope, options);
  1575. },
  1576. removeResizeListener : function(fn, scope){
  1577. if(resizeEvent){
  1578. resizeEvent.removeListener(fn, scope);
  1579. }
  1580. },
  1581. fireResize : function(){
  1582. if(resizeEvent){
  1583. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1584. }
  1585. },
  1586. ieDeferSrc : false,
  1587. textResizeInterval : 50
  1588. };
  1589. pub.on = pub.addListener;
  1590. pub.un = pub.removeListener;
  1591. pub.stoppedMouseDownEvent = new Ext.util.Event();
  1592. return pub;
  1593. }();
  1594. Ext.onReady = Ext.EventManager.onDocumentReady;
  1595. (function(){
  1596. var initExtCss = function(){
  1597. var bd = document.body || document.getElementsByTagName('body')[0];
  1598. if(!bd){ return false; }
  1599. var cls = [' ',
  1600. Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
  1601. : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
  1602. : Ext.isOpera ? "ext-opera"
  1603. : Ext.isSafari ? "ext-safari" : ""];
  1604. if(Ext.isMac){
  1605. cls.push("ext-mac");
  1606. }
  1607. if(Ext.isLinux){
  1608. cls.push("ext-linux");
  1609. }
  1610. if(Ext.isBorderBox){
  1611. cls.push('ext-border-box');
  1612. }
  1613. if(Ext.isStrict){ var p = bd.parentNode;
  1614. if(p){
  1615. p.className += ' ext-strict';
  1616. }
  1617. }
  1618. bd.className += cls.join(' ');
  1619. return true;
  1620. }
  1621. if(!initExtCss()){
  1622. Ext.onReady(initExtCss);
  1623. }
  1624. })();
  1625. Ext.EventObject = function(){
  1626. var E = Ext.lib.Event;
  1627. var safariKeys = {
  1628. 3 : 13, 63234 : 37, 63235 : 39, 63232 : 38, 63233 : 40, 63276 : 33, 63277 : 34, 63272 : 46, 63273 : 36, 63275 : 35 };
  1629. var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
  1630. (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
  1631. Ext.EventObjectImpl = function(e){
  1632. if(e){
  1633. this.setEvent(e.browserEvent || e);
  1634. }
  1635. };
  1636. Ext.EventObjectImpl.prototype = {
  1637. browserEvent : null,
  1638. button : -1,
  1639. shiftKey : false,
  1640. ctrlKey : false,
  1641. altKey : false,
  1642. BACKSPACE: 8,
  1643. TAB: 9,
  1644. NUM_CENTER: 12,
  1645. ENTER: 13,
  1646. RETURN: 13,
  1647. SHIFT: 16,
  1648. CTRL: 17,
  1649. CONTROL : 17,
  1650. ALT: 18,
  1651. PAUSE: 19,
  1652. CAPS_LOCK: 20,
  1653. ESC: 27,
  1654. SPACE: 32,
  1655. PAGE_UP: 33,
  1656. PAGEUP : 33,
  1657. PAGE_DOWN: 34,
  1658. PAGEDOWN : 34,
  1659. END: 35,
  1660. HOME: 36,
  1661. LEFT: 37,
  1662. UP: 38,
  1663. RIGHT: 39,
  1664. DOWN: 40,
  1665. PRINT_SCREEN: 44,
  1666. INSERT: 45,
  1667. DELETE: 46,
  1668. ZERO: 48,
  1669. ONE: 49,
  1670. TWO: 50,
  1671. THREE: 51,
  1672. FOUR: 52,
  1673. FIVE: 53,
  1674. SIX: 54,
  1675. SEVEN: 55,
  1676. EIGHT: 56,
  1677. NINE: 57,
  1678. A: 65,
  1679. B: 66,
  1680. C: 67,
  1681. D: 68,
  1682. E: 69,
  1683. F: 70,
  1684. G: 71,
  1685. H: 72,
  1686. I: 73,
  1687. J: 74,
  1688. K: 75,
  1689. L: 76,
  1690. M: 77,
  1691. N: 78,
  1692. O: 79,
  1693. P: 80,
  1694. Q: 81,
  1695. R: 82,
  1696. S: 83,
  1697. T: 84,
  1698. U: 85,
  1699. V: 86,
  1700. W: 87,
  1701. X: 88,
  1702. Y: 89,
  1703. Z: 90,
  1704. CONTEXT_MENU: 93,
  1705. NUM_ZERO: 96,
  1706. NUM_ONE: 97,
  1707. NUM_TWO: 98,
  1708. NUM_THREE: 99,
  1709. NUM_FOUR: 100,
  1710. NUM_FIVE: 101,
  1711. NUM_SIX: 102,
  1712. NUM_SEVEN: 103,
  1713. NUM_EIGHT: 104,
  1714. NUM_NINE: 105,
  1715. NUM_MULTIPLY: 106,
  1716. NUM_PLUS: 107,
  1717. NUM_MINUS: 109,
  1718. NUM_PERIOD: 110,
  1719. NUM_DIVISION: 111,
  1720. F1: 112,
  1721. F2: 113,
  1722. F3: 114,
  1723. F4: 115,
  1724. F5: 116,
  1725. F6: 117,
  1726. F7: 118,
  1727. F8: 119,
  1728. F9: 120,
  1729. F10: 121,
  1730. F11: 122,
  1731. F12: 123,
  1732. setEvent : function(e){
  1733. if(e == this || (e && e.browserEvent)){ return e;
  1734. }
  1735. this.browserEvent = e;
  1736. if(e){
  1737. this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
  1738. if(e.type == 'click' && this.button == -1){
  1739. this.button = 0;
  1740. }
  1741. this.type = e.type;
  1742. this.shiftKey = e.shiftKey;
  1743. this.ctrlKey = e.ctrlKey || e.metaKey;
  1744. this.altKey = e.altKey;
  1745. this.keyCode = e.keyCode;
  1746. this.charCode = e.charCode;
  1747. this.target = E.getTarget(e);
  1748. this.xy = E.getXY(e);
  1749. }else{
  1750. this.button = -1;
  1751. this.shiftKey = false;
  1752. this.ctrlKey = false;
  1753. this.altKey = false;
  1754. this.keyCode = 0;
  1755. this.charCode = 0;
  1756. this.target = null;
  1757. this.xy = [0, 0];
  1758. }
  1759. return this;
  1760. },
  1761. stopEvent : function(){
  1762. if(this.browserEvent){
  1763. if(this.browserEvent.type == 'mousedown'){
  1764. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1765. }
  1766. E.stopEvent(this.browserEvent);
  1767. }
  1768. },
  1769. preventDefault : function(){
  1770. if(this.browserEvent){
  1771. E.preventDefault(this.browserEvent);
  1772. }
  1773. },
  1774. isNavKeyPress : function(){
  1775. var k = this.keyCode;
  1776. k = Ext.isSafari ? (safariKeys[k] || k) : k;
  1777. return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
  1778. },
  1779. isSpecialKey : function(){
  1780. var k = this.keyCode;
  1781. return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
  1782. (k == 16) || (k == 17) ||
  1783. (k >= 18 && k <= 20) ||
  1784. (k >= 33 && k <= 35) ||
  1785. (k >= 36 && k <= 39) ||
  1786. (k >= 44 && k <= 45);
  1787. },
  1788. stopPropagation : function(){
  1789. if(this.browserEvent){
  1790. if(this.browserEvent.type == 'mousedown'){
  1791. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1792. }
  1793. E.stopPropagation(this.browserEvent);
  1794. }
  1795. },
  1796. getCharCode : function(){
  1797. return this.charCode || this.keyCode;
  1798. },
  1799. getKey : function(){
  1800. var k = this.keyCode || this.charCode;
  1801. return Ext.isSafari ? (safariKeys[k] || k) : k;
  1802. },
  1803. getPageX : function(){
  1804. return this.xy[0];
  1805. },
  1806. getPageY : function(){
  1807. return this.xy[1];
  1808. },
  1809. getTime : function(){
  1810. if(this.browserEvent){
  1811. return E.getTime(this.browserEvent);
  1812. }
  1813. return null;
  1814. },
  1815. getXY : function(){
  1816. return this.xy;
  1817. },
  1818. getTarget : function(selector, maxDepth, returnEl){
  1819. return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
  1820. },
  1821. getRelatedTarget : function(){
  1822. if(this.browserEvent){
  1823. return E.getRelatedTarget(this.browserEvent);
  1824. }
  1825. return null;
  1826. },
  1827. getWheelDelta : function(){
  1828. var e = this.browserEvent;
  1829. var delta = 0;
  1830. if(e.wheelDelta){
  1831. delta = e.wheelDelta/120;
  1832. }else if(e.detail){
  1833. delta = -e.detail/3;
  1834. }
  1835. return delta;
  1836. },
  1837. hasModifier : function(){
  1838. return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
  1839. },
  1840. within : function(el, related){
  1841. var t = this[related ? "getRelatedTarget" : "getTarget"]();
  1842. return t && Ext.fly(el).contains(t);
  1843. },
  1844. getPoint : function(){
  1845. return new Ext.lib.Point(this.xy[0], this.xy[1]);
  1846. }
  1847. };
  1848. return new Ext.EventObjectImpl();
  1849. }();
  1850. (function(){
  1851. var D = Ext.lib.Dom;
  1852. var E = Ext.lib.Event;
  1853. var A = Ext.lib.Anim;
  1854. var propCache = {};
  1855. var camelRe = /(-[a-z])/gi;
  1856. var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
  1857. var view = document.defaultView;
  1858. Ext.Element = function(element, forceNew){
  1859. var dom = typeof element == "string" ?
  1860. document.getElementById(element) : element;
  1861. if(!dom){ return null;
  1862. }
  1863. var id = dom.id;
  1864. if(forceNew !== true && id && Ext.Element.cache[id]){