Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
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.

5913 lines
171 KiB

  1. /*
  2. * Ext JS Library 2.2.1
  3. * Copyright(c) 2006-2009, 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. // build as innerHTML where available
  13. var createHtml = function(o){
  14. if(typeof o == 'string'){
  15. return o;
  16. }
  17. var b = "";
  18. if (Ext.isArray(o)) {
  19. for (var i = 0, l = o.length; i < l; i++) {
  20. b += createHtml(o[i]);
  21. }
  22. return b;
  23. }
  24. if(!o.tag){
  25. o.tag = "div";
  26. }
  27. b += "<" + o.tag;
  28. for(var attr in o){
  29. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
  30. if(attr == "style"){
  31. var s = o["style"];
  32. if(typeof s == "function"){
  33. s = s.call();
  34. }
  35. if(typeof s == "string"){
  36. b += ' style="' + s + '"';
  37. }else if(typeof s == "object"){
  38. b += ' style="';
  39. for(var key in s){
  40. if(typeof s[key] != "function"){
  41. b += key + ":" + s[key] + ";";
  42. }
  43. }
  44. b += '"';
  45. }
  46. }else{
  47. if(attr == "cls"){
  48. b += ' class="' + o["cls"] + '"';
  49. }else if(attr == "htmlFor"){
  50. b += ' for="' + o["htmlFor"] + '"';
  51. }else{
  52. b += " " + attr + '="' + o[attr] + '"';
  53. }
  54. }
  55. }
  56. if(emptyTags.test(o.tag)){
  57. b += "/>";
  58. }else{
  59. b += ">";
  60. var cn = o.children || o.cn;
  61. if(cn){
  62. b += createHtml(cn);
  63. } else if(o.html){
  64. b += o.html;
  65. }
  66. b += "</" + o.tag + ">";
  67. }
  68. return b;
  69. };
  70. // build as dom
  71. var createDom = function(o, parentNode){
  72. var el;
  73. if (Ext.isArray(o)) { // Allow Arrays of siblings to be inserted
  74. el = document.createDocumentFragment(); // in one shot using a DocumentFragment
  75. for(var i = 0, l = o.length; i < l; i++) {
  76. createDom(o[i], el);
  77. }
  78. } else if (typeof o == "string") { // Allow a string as a child spec.
  79. el = document.createTextNode(o);
  80. } else {
  81. el = document.createElement(o.tag||'div');
  82. var useSet = !!el.setAttribute; // In IE some elements don't have setAttribute
  83. for(var attr in o){
  84. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || attr == "style" || typeof o[attr] == "function") continue;
  85. if(attr=="cls"){
  86. el.className = o["cls"];
  87. }else{
  88. if(useSet) el.setAttribute(attr, o[attr]);
  89. else el[attr] = o[attr];
  90. }
  91. }
  92. Ext.DomHelper.applyStyles(el, o.style);
  93. var cn = o.children || o.cn;
  94. if(cn){
  95. createDom(cn, el);
  96. } else if(o.html){
  97. el.innerHTML = o.html;
  98. }
  99. }
  100. if(parentNode){
  101. parentNode.appendChild(el);
  102. }
  103. return el;
  104. };
  105. var ieTable = function(depth, s, h, e){
  106. tempTableEl.innerHTML = [s, h, e].join('');
  107. var i = -1, el = tempTableEl;
  108. while(++i < depth){
  109. el = el.firstChild;
  110. }
  111. return el;
  112. };
  113. // kill repeat to save bytes
  114. var ts = '<table>',
  115. te = '</table>',
  116. tbs = ts+'<tbody>',
  117. tbe = '</tbody>'+te,
  118. trs = tbs + '<tr>',
  119. tre = '</tr>'+tbe;
  120. var insertIntoTable = function(tag, where, el, html){
  121. if(!tempTableEl){
  122. tempTableEl = document.createElement('div');
  123. }
  124. var node;
  125. var before = null;
  126. if(tag == 'td'){
  127. if(where == 'afterbegin' || where == 'beforeend'){ // INTO a TD
  128. return;
  129. }
  130. if(where == 'beforebegin'){
  131. before = el;
  132. el = el.parentNode;
  133. } else{
  134. before = el.nextSibling;
  135. el = el.parentNode;
  136. }
  137. node = ieTable(4, trs, html, tre);
  138. }
  139. else if(tag == 'tr'){
  140. if(where == 'beforebegin'){
  141. before = el;
  142. el = el.parentNode;
  143. node = ieTable(3, tbs, html, tbe);
  144. } else if(where == 'afterend'){
  145. before = el.nextSibling;
  146. el = el.parentNode;
  147. node = ieTable(3, tbs, html, tbe);
  148. } else{ // INTO a TR
  149. if(where == 'afterbegin'){
  150. before = el.firstChild;
  151. }
  152. node = ieTable(4, trs, html, tre);
  153. }
  154. } else if(tag == 'tbody'){
  155. if(where == 'beforebegin'){
  156. before = el;
  157. el = el.parentNode;
  158. node = ieTable(2, ts, html, te);
  159. } else if(where == 'afterend'){
  160. before = el.nextSibling;
  161. el = el.parentNode;
  162. node = ieTable(2, ts, html, te);
  163. } else{
  164. if(where == 'afterbegin'){
  165. before = el.firstChild;
  166. }
  167. node = ieTable(3, tbs, html, tbe);
  168. }
  169. } else{ // TABLE
  170. if(where == 'beforebegin' || where == 'afterend'){ // OUTSIDE the table
  171. return;
  172. }
  173. if(where == 'afterbegin'){
  174. before = el.firstChild;
  175. }
  176. node = ieTable(2, ts, html, te);
  177. }
  178. el.insertBefore(node, before);
  179. return node;
  180. };
  181. return {
  182. useDom : false,
  183. markup : function(o){
  184. return createHtml(o);
  185. },
  186. applyStyles : function(el, styles){
  187. if(styles){
  188. el = Ext.fly(el);
  189. if(typeof styles == "string"){
  190. var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
  191. var matches;
  192. while ((matches = re.exec(styles)) != null){
  193. el.setStyle(matches[1], matches[2]);
  194. }
  195. }else if (typeof styles == "object"){
  196. for (var style in styles){
  197. el.setStyle(style, styles[style]);
  198. }
  199. }else if (typeof styles == "function"){
  200. Ext.DomHelper.applyStyles(el, styles.call());
  201. }
  202. }
  203. },
  204. insertHtml : function(where, el, html){
  205. where = where.toLowerCase();
  206. if(el.insertAdjacentHTML){
  207. if(tableRe.test(el.tagName)){
  208. var rs;
  209. if(rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html)){
  210. return rs;
  211. }
  212. }
  213. switch(where){
  214. case "beforebegin":
  215. el.insertAdjacentHTML('BeforeBegin', html);
  216. return el.previousSibling;
  217. case "afterbegin":
  218. el.insertAdjacentHTML('AfterBegin', html);
  219. return el.firstChild;
  220. case "beforeend":
  221. el.insertAdjacentHTML('BeforeEnd', html);
  222. return el.lastChild;
  223. case "afterend":
  224. el.insertAdjacentHTML('AfterEnd', html);
  225. return el.nextSibling;
  226. }
  227. throw 'Illegal insertion point -> "' + where + '"';
  228. }
  229. var range = el.ownerDocument.createRange();
  230. var frag;
  231. switch(where){
  232. case "beforebegin":
  233. range.setStartBefore(el);
  234. frag = range.createContextualFragment(html);
  235. el.parentNode.insertBefore(frag, el);
  236. return el.previousSibling;
  237. case "afterbegin":
  238. if(el.firstChild){
  239. range.setStartBefore(el.firstChild);
  240. frag = range.createContextualFragment(html);
  241. el.insertBefore(frag, el.firstChild);
  242. return el.firstChild;
  243. }else{
  244. el.innerHTML = html;
  245. return el.firstChild;
  246. }
  247. case "beforeend":
  248. if(el.lastChild){
  249. range.setStartAfter(el.lastChild);
  250. frag = range.createContextualFragment(html);
  251. el.appendChild(frag);
  252. return el.lastChild;
  253. }else{
  254. el.innerHTML = html;
  255. return el.lastChild;
  256. }
  257. case "afterend":
  258. range.setStartAfter(el);
  259. frag = range.createContextualFragment(html);
  260. el.parentNode.insertBefore(frag, el.nextSibling);
  261. return el.nextSibling;
  262. }
  263. throw 'Illegal insertion point -> "' + where + '"';
  264. },
  265. insertBefore : function(el, o, returnElement){
  266. return this.doInsert(el, o, returnElement, "beforeBegin");
  267. },
  268. insertAfter : function(el, o, returnElement){
  269. return this.doInsert(el, o, returnElement, "afterEnd", "nextSibling");
  270. },
  271. insertFirst : function(el, o, returnElement){
  272. return this.doInsert(el, o, returnElement, "afterBegin", "firstChild");
  273. },
  274. // private
  275. doInsert : function(el, o, returnElement, pos, sibling){
  276. el = Ext.getDom(el);
  277. var newNode;
  278. if(this.useDom){
  279. newNode = createDom(o, null);
  280. (sibling === "firstChild" ? el : el.parentNode).insertBefore(newNode, sibling ? el[sibling] : el);
  281. }else{
  282. var html = createHtml(o);
  283. newNode = this.insertHtml(pos, el, html);
  284. }
  285. return returnElement ? Ext.get(newNode, true) : newNode;
  286. },
  287. append : function(el, o, returnElement){
  288. el = Ext.getDom(el);
  289. var newNode;
  290. if(this.useDom){
  291. newNode = createDom(o, null);
  292. el.appendChild(newNode);
  293. }else{
  294. var html = createHtml(o);
  295. newNode = this.insertHtml("beforeEnd", el, html);
  296. }
  297. return returnElement ? Ext.get(newNode, true) : newNode;
  298. },
  299. overwrite : function(el, o, returnElement){
  300. el = Ext.getDom(el);
  301. el.innerHTML = createHtml(o);
  302. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  303. },
  304. createTemplate : function(o){
  305. var html = createHtml(o);
  306. return new Ext.Template(html);
  307. }
  308. };
  309. }();
  310. Ext.Template = function(html){
  311. var a = arguments;
  312. if(Ext.isArray(html)){
  313. html = html.join("");
  314. }else if(a.length > 1){
  315. var buf = [];
  316. for(var i = 0, len = a.length; i < len; i++){
  317. if(typeof a[i] == 'object'){
  318. Ext.apply(this, a[i]);
  319. }else{
  320. buf[buf.length] = a[i];
  321. }
  322. }
  323. html = buf.join('');
  324. }
  325. this.html = html;
  326. if(this.compiled){
  327. this.compile();
  328. }
  329. };
  330. Ext.Template.prototype = {
  331. applyTemplate : function(values){
  332. if(this.compiled){
  333. return this.compiled(values);
  334. }
  335. var useF = this.disableFormats !== true;
  336. var fm = Ext.util.Format, tpl = this;
  337. var fn = function(m, name, format, args){
  338. if(format && useF){
  339. if(format.substr(0, 5) == "this."){
  340. return tpl.call(format.substr(5), values[name], values);
  341. }else{
  342. if(args){
  343. // quoted values are required for strings in compiled templates,
  344. // but for non compiled we need to strip them
  345. // quoted reversed for jsmin
  346. var re = /^\s*['"](.*)["']\s*$/;
  347. args = args.split(',');
  348. for(var i = 0, len = args.length; i < len; i++){
  349. args[i] = args[i].replace(re, "$1");
  350. }
  351. args = [values[name]].concat(args);
  352. }else{
  353. args = [values[name]];
  354. }
  355. return fm[format].apply(fm, args);
  356. }
  357. }else{
  358. return values[name] !== undefined ? values[name] : "";
  359. }
  360. };
  361. return this.html.replace(this.re, fn);
  362. },
  363. set : function(html, compile){
  364. this.html = html;
  365. this.compiled = null;
  366. if(compile){
  367. this.compile();
  368. }
  369. return this;
  370. },
  371. disableFormats : false,
  372. re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
  373. compile : function(){
  374. var fm = Ext.util.Format;
  375. var useF = this.disableFormats !== true;
  376. var sep = Ext.isGecko ? "+" : ",";
  377. var fn = function(m, name, format, args){
  378. if(format && useF){
  379. args = args ? ',' + args : "";
  380. if(format.substr(0, 5) != "this."){
  381. format = "fm." + format + '(';
  382. }else{
  383. format = 'this.call("'+ format.substr(5) + '", ';
  384. args = ", values";
  385. }
  386. }else{
  387. args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
  388. }
  389. return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
  390. };
  391. var body;
  392. // branched to use + in gecko and [].join() in others
  393. if(Ext.isGecko){
  394. body = "this.compiled = function(values){ return '" +
  395. this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
  396. "';};";
  397. }else{
  398. body = ["this.compiled = function(values){ return ['"];
  399. body.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
  400. body.push("'].join('');};");
  401. body = body.join('');
  402. }
  403. eval(body);
  404. return this;
  405. },
  406. // private function used to call members
  407. call : function(fnName, value, allValues){
  408. return this[fnName](value, allValues);
  409. },
  410. insertFirst: function(el, values, returnElement){
  411. return this.doInsert('afterBegin', el, values, returnElement);
  412. },
  413. insertBefore: function(el, values, returnElement){
  414. return this.doInsert('beforeBegin', el, values, returnElement);
  415. },
  416. insertAfter : function(el, values, returnElement){
  417. return this.doInsert('afterEnd', el, values, returnElement);
  418. },
  419. append : function(el, values, returnElement){
  420. return this.doInsert('beforeEnd', el, values, returnElement);
  421. },
  422. doInsert : function(where, el, values, returnEl){
  423. el = Ext.getDom(el);
  424. var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
  425. return returnEl ? Ext.get(newNode, true) : newNode;
  426. },
  427. overwrite : function(el, values, returnElement){
  428. el = Ext.getDom(el);
  429. el.innerHTML = this.applyTemplate(values);
  430. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  431. }
  432. };
  433. Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
  434. // backwards compat
  435. Ext.DomHelper.Template = Ext.Template;
  436. Ext.Template.from = function(el, config){
  437. el = Ext.getDom(el);
  438. return new Ext.Template(el.value || el.innerHTML, config || '');
  439. };
  440. Ext.DomQuery = function(){
  441. var cache = {}, simpleCache = {}, valueCache = {};
  442. var nonSpace = /\S/;
  443. var trimRe = /^\s+|\s+$/g;
  444. var tplRe = /\{(\d+)\}/g;
  445. var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
  446. var tagTokenRe = /^(#)?([\w-\*]+)/;
  447. var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;
  448. function child(p, index){
  449. var i = 0;
  450. var n = p.firstChild;
  451. while(n){
  452. if(n.nodeType == 1){
  453. if(++i == index){
  454. return n;
  455. }
  456. }
  457. n = n.nextSibling;
  458. }
  459. return null;
  460. };
  461. function next(n){
  462. while((n = n.nextSibling) && n.nodeType != 1);
  463. return n;
  464. };
  465. function prev(n){
  466. while((n = n.previousSibling) && n.nodeType != 1);
  467. return n;
  468. };
  469. function children(d){
  470. var n = d.firstChild, ni = -1;
  471. while(n){
  472. var nx = n.nextSibling;
  473. if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
  474. d.removeChild(n);
  475. }else{
  476. n.nodeIndex = ++ni;
  477. }
  478. n = nx;
  479. }
  480. return this;
  481. };
  482. function byClassName(c, a, v){
  483. if(!v){
  484. return c;
  485. }
  486. var r = [], ri = -1, cn;
  487. for(var i = 0, ci; ci = c[i]; i++){
  488. if((' '+ci.className+' ').indexOf(v) != -1){
  489. r[++ri] = ci;
  490. }
  491. }
  492. return r;
  493. };
  494. function attrValue(n, attr){
  495. if(!n.tagName && typeof n.length != "undefined"){
  496. n = n[0];
  497. }
  498. if(!n){
  499. return null;
  500. }
  501. if(attr == "for"){
  502. return n.htmlFor;
  503. }
  504. if(attr == "class" || attr == "className"){
  505. return n.className;
  506. }
  507. return n.getAttribute(attr) || n[attr];
  508. };
  509. function getNodes(ns, mode, tagName){
  510. var result = [], ri = -1, cs;
  511. if(!ns){
  512. return result;
  513. }
  514. tagName = tagName || "*";
  515. if(typeof ns.getElementsByTagName != "undefined"){
  516. ns = [ns];
  517. }
  518. if(!mode){
  519. for(var i = 0, ni; ni = ns[i]; i++){
  520. cs = ni.getElementsByTagName(tagName);
  521. for(var j = 0, ci; ci = cs[j]; j++){
  522. result[++ri] = ci;
  523. }
  524. }
  525. }else if(mode == "/" || mode == ">"){
  526. var utag = tagName.toUpperCase();
  527. for(var i = 0, ni, cn; ni = ns[i]; i++){
  528. cn = ni.children || ni.childNodes;
  529. for(var j = 0, cj; cj = cn[j]; j++){
  530. if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
  531. result[++ri] = cj;
  532. }
  533. }
  534. }
  535. }else if(mode == "+"){
  536. var utag = tagName.toUpperCase();
  537. for(var i = 0, n; n = ns[i]; i++){
  538. while((n = n.nextSibling) && n.nodeType != 1);
  539. if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
  540. result[++ri] = n;
  541. }
  542. }
  543. }else if(mode == "~"){
  544. for(var i = 0, n; n = ns[i]; i++){
  545. while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));
  546. if(n){
  547. result[++ri] = n;
  548. }
  549. }
  550. }
  551. return result;
  552. };
  553. function concat(a, b){
  554. if(b.slice){
  555. return a.concat(b);
  556. }
  557. for(var i = 0, l = b.length; i < l; i++){
  558. a[a.length] = b[i];
  559. }
  560. return a;
  561. }
  562. function byTag(cs, tagName){
  563. if(cs.tagName || cs == document){
  564. cs = [cs];
  565. }
  566. if(!tagName){
  567. return cs;
  568. }
  569. var r = [], ri = -1;
  570. tagName = tagName.toLowerCase();
  571. for(var i = 0, ci; ci = cs[i]; i++){
  572. if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
  573. r[++ri] = ci;
  574. }
  575. }
  576. return r;
  577. };
  578. function byId(cs, attr, id){
  579. if(cs.tagName || cs == document){
  580. cs = [cs];
  581. }
  582. if(!id){
  583. return cs;
  584. }
  585. var r = [], ri = -1;
  586. for(var i = 0,ci; ci = cs[i]; i++){
  587. if(ci && ci.id == id){
  588. r[++ri] = ci;
  589. return r;
  590. }
  591. }
  592. return r;
  593. };
  594. function byAttribute(cs, attr, value, op, custom){
  595. var r = [], ri = -1, st = custom=="{";
  596. var f = Ext.DomQuery.operators[op];
  597. for(var i = 0, ci; ci = cs[i]; i++){
  598. var a;
  599. if(st){
  600. a = Ext.DomQuery.getStyle(ci, attr);
  601. }
  602. else if(attr == "class" || attr == "className"){
  603. a = ci.className;
  604. }else if(attr == "for"){
  605. a = ci.htmlFor;
  606. }else if(attr == "href"){
  607. a = ci.getAttribute("href", 2);
  608. }else{
  609. a = ci.getAttribute(attr);
  610. }
  611. if((f && f(a, value)) || (!f && a)){
  612. r[++ri] = ci;
  613. }
  614. }
  615. return r;
  616. };
  617. function byPseudo(cs, name, value){
  618. return Ext.DomQuery.pseudos[name](cs, value);
  619. };
  620. // This is for IE MSXML which does not support expandos.
  621. // IE runs the same speed using setAttribute, however FF slows way down
  622. // and Safari completely fails so they need to continue to use expandos.
  623. var isIE = window.ActiveXObject ? true : false;
  624. // this eval is stop the compressor from
  625. // renaming the variable to something shorter
  626. eval("var batch = 30803;");
  627. var key = 30803;
  628. function nodupIEXml(cs){
  629. var d = ++key;
  630. cs[0].setAttribute("_nodup", d);
  631. var r = [cs[0]];
  632. for(var i = 1, len = cs.length; i < len; i++){
  633. var c = cs[i];
  634. if(!c.getAttribute("_nodup") != d){
  635. c.setAttribute("_nodup", d);
  636. r[r.length] = c;
  637. }
  638. }
  639. for(var i = 0, len = cs.length; i < len; i++){
  640. cs[i].removeAttribute("_nodup");
  641. }
  642. return r;
  643. }
  644. function nodup(cs){
  645. if(!cs){
  646. return [];
  647. }
  648. var len = cs.length, c, i, r = cs, cj, ri = -1;
  649. if(!len || typeof cs.nodeType != "undefined" || len == 1){
  650. return cs;
  651. }
  652. if(isIE && typeof cs[0].selectSingleNode != "undefined"){
  653. return nodupIEXml(cs);
  654. }
  655. var d = ++key;
  656. cs[0]._nodup = d;
  657. for(i = 1; c = cs[i]; i++){
  658. if(c._nodup != d){
  659. c._nodup = d;
  660. }else{
  661. r = [];
  662. for(var j = 0; j < i; j++){
  663. r[++ri] = cs[j];
  664. }
  665. for(j = i+1; cj = cs[j]; j++){
  666. if(cj._nodup != d){
  667. cj._nodup = d;
  668. r[++ri] = cj;
  669. }
  670. }
  671. return r;
  672. }
  673. }
  674. return r;
  675. }
  676. function quickDiffIEXml(c1, c2){
  677. var d = ++key;
  678. for(var i = 0, len = c1.length; i < len; i++){
  679. c1[i].setAttribute("_qdiff", d);
  680. }
  681. var r = [];
  682. for(var i = 0, len = c2.length; i < len; i++){
  683. if(c2[i].getAttribute("_qdiff") != d){
  684. r[r.length] = c2[i];
  685. }
  686. }
  687. for(var i = 0, len = c1.length; i < len; i++){
  688. c1[i].removeAttribute("_qdiff");
  689. }
  690. return r;
  691. }
  692. function quickDiff(c1, c2){
  693. var len1 = c1.length;
  694. if(!len1){
  695. return c2;
  696. }
  697. if(isIE && c1[0].selectSingleNode){
  698. return quickDiffIEXml(c1, c2);
  699. }
  700. var d = ++key;
  701. for(var i = 0; i < len1; i++){
  702. c1[i]._qdiff = d;
  703. }
  704. var r = [];
  705. for(var i = 0, len = c2.length; i < len; i++){
  706. if(c2[i]._qdiff != d){
  707. r[r.length] = c2[i];
  708. }
  709. }
  710. return r;
  711. }
  712. function quickId(ns, mode, root, id){
  713. if(ns == root){
  714. var d = root.ownerDocument || root;
  715. return d.getElementById(id);
  716. }
  717. ns = getNodes(ns, mode, "*");
  718. return byId(ns, null, id);
  719. }
  720. return {
  721. getStyle : function(el, name){
  722. return Ext.fly(el).getStyle(name);
  723. },
  724. compile : function(path, type){
  725. type = type || "select";
  726. var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
  727. var q = path, mode, lq;
  728. var tk = Ext.DomQuery.matchers;
  729. var tklen = tk.length;
  730. var mm;
  731. // accept leading mode switch
  732. var lmode = q.match(modeRe);
  733. if(lmode && lmode[1]){
  734. fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
  735. q = q.replace(lmode[1], "");
  736. }
  737. // strip leading slashes
  738. while(path.substr(0, 1)=="/"){
  739. path = path.substr(1);
  740. }
  741. while(q && lq != q){
  742. lq = q;
  743. var tm = q.match(tagTokenRe);
  744. if(type == "select"){
  745. if(tm){
  746. if(tm[1] == "#"){
  747. fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
  748. }else{
  749. fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
  750. }
  751. q = q.replace(tm[0], "");
  752. }else if(q.substr(0, 1) != '@'){
  753. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  754. }
  755. }else{
  756. if(tm){
  757. if(tm[1] == "#"){
  758. fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
  759. }else{
  760. fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
  761. }
  762. q = q.replace(tm[0], "");
  763. }
  764. }
  765. while(!(mm = q.match(modeRe))){
  766. var matched = false;
  767. for(var j = 0; j < tklen; j++){
  768. var t = tk[j];
  769. var m = q.match(t.re);
  770. if(m){
  771. fn[fn.length] = t.select.replace(tplRe, function(x, i){
  772. return m[i];
  773. });
  774. q = q.replace(m[0], "");
  775. matched = true;
  776. break;
  777. }
  778. }
  779. // prevent infinite loop on bad selector
  780. if(!matched){
  781. throw 'Error parsing selector, parsing failed at "' + q + '"';
  782. }
  783. }
  784. if(mm[1]){
  785. fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
  786. q = q.replace(mm[1], "");
  787. }
  788. }
  789. fn[fn.length] = "return nodup(n);\n}";
  790. eval(fn.join(""));
  791. return f;
  792. },
  793. select : function(path, root, type){
  794. if(!root || root == document){
  795. root = document;
  796. }
  797. if(typeof root == "string"){
  798. root = document.getElementById(root);
  799. }
  800. var paths = path.split(",");
  801. var results = [];
  802. for(var i = 0, len = paths.length; i < len; i++){
  803. var p = paths[i].replace(trimRe, "");
  804. if(!cache[p]){
  805. cache[p] = Ext.DomQuery.compile(p);
  806. if(!cache[p]){
  807. throw p + " is not a valid selector";
  808. }
  809. }
  810. var result = cache[p](root);
  811. if(result && result != document){
  812. results = results.concat(result);
  813. }
  814. }
  815. if(paths.length > 1){
  816. return nodup(results);
  817. }
  818. return results;
  819. },
  820. selectNode : function(path, root){
  821. return Ext.DomQuery.select(path, root)[0];
  822. },
  823. selectValue : function(path, root, defaultValue){
  824. path = path.replace(trimRe, "");
  825. if(!valueCache[path]){
  826. valueCache[path] = Ext.DomQuery.compile(path, "select");
  827. }
  828. var n = valueCache[path](root);
  829. n = n[0] ? n[0] : n;
  830. var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
  831. return ((v === null||v === undefined||v==='') ? defaultValue : v);
  832. },
  833. selectNumber : function(path, root, defaultValue){
  834. var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
  835. return parseFloat(v);
  836. },
  837. is : function(el, ss){
  838. if(typeof el == "string"){
  839. el = document.getElementById(el);
  840. }
  841. var isArray = Ext.isArray(el);
  842. var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
  843. return isArray ? (result.length == el.length) : (result.length > 0);
  844. },
  845. filter : function(els, ss, nonMatches){
  846. ss = ss.replace(trimRe, "");
  847. if(!simpleCache[ss]){
  848. simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
  849. }
  850. var result = simpleCache[ss](els);
  851. return nonMatches ? quickDiff(result, els) : result;
  852. },
  853. matchers : [{
  854. re: /^\.([\w-]+)/,
  855. select: 'n = byClassName(n, null, " {1} ");'
  856. }, {
  857. re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  858. select: 'n = byPseudo(n, "{1}", "{2}");'
  859. },{
  860. re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  861. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  862. }, {
  863. re: /^#([\w-]+)/,
  864. select: 'n = byId(n, null, "{1}");'
  865. },{
  866. re: /^@([\w-]+)/,
  867. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  868. }
  869. ],
  870. operators : {
  871. "=" : function(a, v){
  872. return a == v;
  873. },
  874. "!=" : function(a, v){
  875. return a != v;
  876. },
  877. "^=" : function(a, v){
  878. return a && a.substr(0, v.length) == v;
  879. },
  880. "$=" : function(a, v){
  881. return a && a.substr(a.length-v.length) == v;
  882. },
  883. "*=" : function(a, v){
  884. return a && a.indexOf(v) !== -1;
  885. },
  886. "%=" : function(a, v){
  887. return (a % v) == 0;
  888. },
  889. "|=" : function(a, v){
  890. return a && (a == v || a.substr(0, v.length+1) == v+'-');
  891. },
  892. "~=" : function(a, v){
  893. return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
  894. }
  895. },
  896. pseudos : {
  897. "first-child" : function(c){
  898. var r = [], ri = -1, n;
  899. for(var i = 0, ci; ci = n = c[i]; i++){
  900. while((n = n.previousSibling) && n.nodeType != 1);
  901. if(!n){
  902. r[++ri] = ci;
  903. }
  904. }
  905. return r;
  906. },
  907. "last-child" : function(c){
  908. var r = [], ri = -1, n;
  909. for(var i = 0, ci; ci = n = c[i]; i++){
  910. while((n = n.nextSibling) && n.nodeType != 1);
  911. if(!n){
  912. r[++ri] = ci;
  913. }
  914. }
  915. return r;
  916. },
  917. "nth-child" : function(c, a) {
  918. var r = [], ri = -1;
  919. var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
  920. var f = (m[1] || 1) - 0, l = m[2] - 0;
  921. for(var i = 0, n; n = c[i]; i++){
  922. var pn = n.parentNode;
  923. if (batch != pn._batch) {
  924. var j = 0;
  925. for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
  926. if(cn.nodeType == 1){
  927. cn.nodeIndex = ++j;
  928. }
  929. }
  930. pn._batch = batch;
  931. }
  932. if (f == 1) {
  933. if (l == 0 || n.nodeIndex == l){
  934. r[++ri] = n;
  935. }
  936. } else if ((n.nodeIndex + l) % f == 0){
  937. r[++ri] = n;
  938. }
  939. }
  940. return r;
  941. },
  942. "only-child" : function(c){
  943. var r = [], ri = -1;;
  944. for(var i = 0, ci; ci = c[i]; i++){
  945. if(!prev(ci) && !next(ci)){
  946. r[++ri] = ci;
  947. }
  948. }
  949. return r;
  950. },
  951. "empty" : function(c){
  952. var r = [], ri = -1;
  953. for(var i = 0, ci; ci = c[i]; i++){
  954. var cns = ci.childNodes, j = 0, cn, empty = true;
  955. while(cn = cns[j]){
  956. ++j;
  957. if(cn.nodeType == 1 || cn.nodeType == 3){
  958. empty = false;
  959. break;
  960. }
  961. }
  962. if(empty){
  963. r[++ri] = ci;
  964. }
  965. }
  966. return r;
  967. },
  968. "contains" : function(c, v){
  969. var r = [], ri = -1;
  970. for(var i = 0, ci; ci = c[i]; i++){
  971. if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
  972. r[++ri] = ci;
  973. }
  974. }
  975. return r;
  976. },
  977. "nodeValue" : function(c, v){
  978. var r = [], ri = -1;
  979. for(var i = 0, ci; ci = c[i]; i++){
  980. if(ci.firstChild && ci.firstChild.nodeValue == v){
  981. r[++ri] = ci;
  982. }
  983. }
  984. return r;
  985. },
  986. "checked" : function(c){
  987. var r = [], ri = -1;
  988. for(var i = 0, ci; ci = c[i]; i++){
  989. if(ci.checked == true){
  990. r[++ri] = ci;
  991. }
  992. }
  993. return r;
  994. },
  995. "not" : function(c, ss){
  996. return Ext.DomQuery.filter(c, ss, true);
  997. },
  998. "any" : function(c, selectors){
  999. var ss = selectors.split('|');
  1000. var r = [], ri = -1, s;
  1001. for(var i = 0, ci; ci = c[i]; i++){
  1002. for(var j = 0; s = ss[j]; j++){
  1003. if(Ext.DomQuery.is(ci, s)){
  1004. r[++ri] = ci;
  1005. break;
  1006. }
  1007. }
  1008. }
  1009. return r;
  1010. },
  1011. "odd" : function(c){
  1012. return this["nth-child"](c, "odd");
  1013. },
  1014. "even" : function(c){
  1015. return this["nth-child"](c, "even");
  1016. },
  1017. "nth" : function(c, a){
  1018. return c[a-1] || [];
  1019. },
  1020. "first" : function(c){
  1021. return c[0] || [];
  1022. },
  1023. "last" : function(c){
  1024. return c[c.length-1] || [];
  1025. },
  1026. "has" : function(c, ss){
  1027. var s = Ext.DomQuery.select;
  1028. var r = [], ri = -1;
  1029. for(var i = 0, ci; ci = c[i]; i++){
  1030. if(s(ss, ci).length > 0){
  1031. r[++ri] = ci;
  1032. }
  1033. }
  1034. return r;
  1035. },
  1036. "next" : function(c, ss){
  1037. var is = Ext.DomQuery.is;
  1038. var r = [], ri = -1;
  1039. for(var i = 0, ci; ci = c[i]; i++){
  1040. var n = next(ci);
  1041. if(n && is(n, ss)){
  1042. r[++ri] = ci;
  1043. }
  1044. }
  1045. return r;
  1046. },
  1047. "prev" : function(c, ss){
  1048. var is = Ext.DomQuery.is;
  1049. var r = [], ri = -1;
  1050. for(var i = 0, ci; ci = c[i]; i++){
  1051. var n = prev(ci);
  1052. if(n && is(n, ss)){
  1053. r[++ri] = ci;
  1054. }
  1055. }
  1056. return r;
  1057. }
  1058. }
  1059. };
  1060. }();
  1061. Ext.query = Ext.DomQuery.select;
  1062. Ext.util.Observable = function(){
  1063. if(this.listeners){
  1064. this.on(this.listeners);
  1065. delete this.listeners;
  1066. }
  1067. };
  1068. Ext.util.Observable.prototype = {
  1069. fireEvent : function(){
  1070. if(this.eventsSuspended !== true){
  1071. var ce = this.events[arguments[0].toLowerCase()];
  1072. if(typeof ce == "object"){
  1073. return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
  1074. }
  1075. }
  1076. return true;
  1077. },
  1078. // private
  1079. filterOptRe : /^(?:scope|delay|buffer|single)$/,
  1080. addListener : function(eventName, fn, scope, o){
  1081. if(typeof eventName == "object"){
  1082. o = eventName;
  1083. for(var e in o){
  1084. if(this.filterOptRe.test(e)){
  1085. continue;
  1086. }
  1087. if(typeof o[e] == "function"){
  1088. // shared options
  1089. this.addListener(e, o[e], o.scope, o);
  1090. }else{
  1091. // individual options
  1092. this.addListener(e, o[e].fn, o[e].scope, o[e]);
  1093. }
  1094. }
  1095. return;
  1096. }
  1097. o = (!o || typeof o == "boolean") ? {} : o;
  1098. eventName = eventName.toLowerCase();
  1099. var ce = this.events[eventName] || true;
  1100. if(typeof ce == "boolean"){
  1101. ce = new Ext.util.Event(this, eventName);
  1102. this.events[eventName] = ce;
  1103. }
  1104. ce.addListener(fn, scope, o);
  1105. },
  1106. removeListener : function(eventName, fn, scope){
  1107. var ce = this.events[eventName.toLowerCase()];
  1108. if(typeof ce == "object"){
  1109. ce.removeListener(fn, scope);
  1110. }
  1111. },
  1112. purgeListeners : function(){
  1113. for(var evt in this.events){
  1114. if(typeof this.events[evt] == "object"){
  1115. this.events[evt].clearListeners();
  1116. }
  1117. }
  1118. },
  1119. relayEvents : function(o, events){
  1120. var createHandler = function(ename){
  1121. return function(){
  1122. return this.fireEvent.apply(this, Ext.combine(ename, Array.prototype.slice.call(arguments, 0)));
  1123. };
  1124. };
  1125. for(var i = 0, len = events.length; i < len; i++){
  1126. var ename = events[i];
  1127. if(!this.events[ename]){ this.events[ename] = true; };
  1128. o.on(ename, createHandler(ename), this);
  1129. }
  1130. },
  1131. addEvents : function(o){
  1132. if(!this.events){
  1133. this.events = {};
  1134. }
  1135. if(typeof o == 'string'){
  1136. for(var i = 0, a = arguments, v; v = a[i]; i++){
  1137. if(!this.events[a[i]]){
  1138. this.events[a[i]] = true;
  1139. }
  1140. }
  1141. }else{
  1142. Ext.applyIf(this.events, o);
  1143. }
  1144. },
  1145. hasListener : function(eventName){
  1146. var e = this.events[eventName];
  1147. return typeof e == "object" && e.listeners.length > 0;
  1148. },
  1149. suspendEvents : function(){
  1150. this.eventsSuspended = true;
  1151. },
  1152. resumeEvents : function(){
  1153. this.eventsSuspended = false;
  1154. },
  1155. // these are considered experimental
  1156. // allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call
  1157. // private
  1158. getMethodEvent : function(method){
  1159. if(!this.methodEvents){
  1160. this.methodEvents = {};
  1161. }
  1162. var e = this.methodEvents[method];
  1163. if(!e){
  1164. e = {};
  1165. this.methodEvents[method] = e;
  1166. e.originalFn = this[method];
  1167. e.methodName = method;
  1168. e.before = [];
  1169. e.after = [];
  1170. var returnValue, v, cancel;
  1171. var obj = this;
  1172. var makeCall = function(fn, scope, args){
  1173. if((v = fn.apply(scope || obj, args)) !== undefined){
  1174. if(typeof v === 'object'){
  1175. if(v.returnValue !== undefined){
  1176. returnValue = v.returnValue;
  1177. }else{
  1178. returnValue = v;
  1179. }
  1180. if(v.cancel === true){
  1181. cancel = true;
  1182. }
  1183. }else if(v === false){
  1184. cancel = true;
  1185. }else {
  1186. returnValue = v;
  1187. }
  1188. }
  1189. }
  1190. this[method] = function(){
  1191. returnValue = v = undefined; cancel = false;
  1192. var args = Array.prototype.slice.call(arguments, 0);
  1193. for(var i = 0, len = e.before.length; i < len; i++){
  1194. makeCall(e.before[i].fn, e.before[i].scope, args);
  1195. if(cancel){
  1196. return returnValue;
  1197. }
  1198. }
  1199. if((v = e.originalFn.apply(obj, args)) !== undefined){
  1200. returnValue = v;
  1201. }
  1202. for(var i = 0, len = e.after.length; i < len; i++){
  1203. makeCall(e.after[i].fn, e.after[i].scope, args);
  1204. if(cancel){
  1205. return returnValue;
  1206. }
  1207. }
  1208. return returnValue;
  1209. };
  1210. }
  1211. return e;
  1212. },
  1213. // adds an "interceptor" called before the original method
  1214. beforeMethod : function(method, fn, scope){
  1215. var e = this.getMethodEvent(method);
  1216. e.before.push({fn: fn, scope: scope});
  1217. },
  1218. // adds a "sequence" called after the original method
  1219. afterMethod : function(method, fn, scope){
  1220. var e = this.getMethodEvent(method);
  1221. e.after.push({fn: fn, scope: scope});
  1222. },
  1223. removeMethodListener : function(method, fn, scope){
  1224. var e = this.getMethodEvent(method);
  1225. for(var i = 0, len = e.before.length; i < len; i++){
  1226. if(e.before[i].fn == fn && e.before[i].scope == scope){
  1227. e.before.splice(i, 1);
  1228. return;
  1229. }
  1230. }
  1231. for(var i = 0, len = e.after.length; i < len; i++){
  1232. if(e.after[i].fn == fn && e.after[i].scope == scope){
  1233. e.after.splice(i, 1);
  1234. return;
  1235. }
  1236. }
  1237. }
  1238. };
  1239. Ext.util.Observable.prototype.on = Ext.util.Observable.prototype.addListener;
  1240. Ext.util.Observable.prototype.un = Ext.util.Observable.prototype.removeListener;
  1241. Ext.util.Observable.capture = function(o, fn, scope){
  1242. o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
  1243. };
  1244. Ext.util.Observable.releaseCapture = function(o){
  1245. o.fireEvent = Ext.util.Observable.prototype.fireEvent;
  1246. };
  1247. (function(){
  1248. var createBuffered = function(h, o, scope){
  1249. var task = new Ext.util.DelayedTask();
  1250. return function(){
  1251. task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
  1252. };
  1253. };
  1254. var createSingle = function(h, e, fn, scope){
  1255. return function(){
  1256. e.removeListener(fn, scope);
  1257. return h.apply(scope, arguments);
  1258. };
  1259. };
  1260. var createDelayed = function(h, o, scope){
  1261. return function(){
  1262. var args = Array.prototype.slice.call(arguments, 0);
  1263. setTimeout(function(){
  1264. h.apply(scope, args);
  1265. }, o.delay || 10);
  1266. };
  1267. };
  1268. Ext.util.Event = function(obj, name){
  1269. this.name = name;
  1270. this.obj = obj;
  1271. this.listeners = [];
  1272. };
  1273. Ext.util.Event.prototype = {
  1274. addListener : function(fn, scope, options){
  1275. scope = scope || this.obj;
  1276. if(!this.isListening(fn, scope)){
  1277. var l = this.createListener(fn, scope, options);
  1278. if(!this.firing){
  1279. this.listeners.push(l);
  1280. }else{ // if we are currently firing this event, don't disturb the listener loop
  1281. this.listeners = this.listeners.slice(0);
  1282. this.listeners.push(l);
  1283. }
  1284. }
  1285. },
  1286. createListener : function(fn, scope, o){
  1287. o = o || {};
  1288. scope = scope || this.obj;
  1289. var l = {fn: fn, scope: scope, options: o};
  1290. var h = fn;
  1291. if(o.delay){
  1292. h = createDelayed(h, o, scope);
  1293. }
  1294. if(o.single){
  1295. h = createSingle(h, this, fn, scope);
  1296. }
  1297. if(o.buffer){
  1298. h = createBuffered(h, o, scope);
  1299. }
  1300. l.fireFn = h;
  1301. return l;
  1302. },
  1303. findListener : function(fn, scope){
  1304. scope = scope || this.obj;
  1305. var ls = this.listeners;
  1306. for(var i = 0, len = ls.length; i < len; i++){
  1307. var l = ls[i];
  1308. if(l.fn == fn && l.scope == scope){
  1309. return i;
  1310. }
  1311. }
  1312. return -1;
  1313. },
  1314. isListening : function(fn, scope){
  1315. return this.findListener(fn, scope) != -1;
  1316. },
  1317. removeListener : function(fn, scope){
  1318. var index;
  1319. if((index = this.findListener(fn, scope)) != -1){
  1320. if(!this.firing){
  1321. this.listeners.splice(index, 1);
  1322. }else{
  1323. this.listeners = this.listeners.slice(0);
  1324. this.listeners.splice(index, 1);
  1325. }
  1326. return true;
  1327. }
  1328. return false;
  1329. },
  1330. clearListeners : function(){
  1331. this.listeners = [];
  1332. },
  1333. fire : function(){
  1334. var ls = this.listeners, scope, len = ls.length;
  1335. if(len > 0){
  1336. this.firing = true;
  1337. var args = Array.prototype.slice.call(arguments, 0);
  1338. for(var i = 0; i < len; i++){
  1339. var l = ls[i];
  1340. if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
  1341. this.firing = false;
  1342. return false;
  1343. }
  1344. }
  1345. this.firing = false;
  1346. }
  1347. return true;
  1348. }
  1349. };
  1350. })();
  1351. Ext.EventManager = function(){
  1352. var docReadyEvent, docReadyProcId, docReadyState = false;
  1353. var resizeEvent, resizeTask, textEvent, textSize;
  1354. var E = Ext.lib.Event;
  1355. var D = Ext.lib.Dom;
  1356. // fix parser confusion
  1357. var xname = 'Ex' + 't';
  1358. var elHash = {};
  1359. var addListener = function(el, ename, fn, wrap, scope){
  1360. var id = Ext.id(el);
  1361. if(!elHash[id]){
  1362. elHash[id] = {};
  1363. }
  1364. var es = elHash[id];
  1365. if(!es[ename]){
  1366. es[ename] = [];
  1367. }
  1368. var ls = es[ename];
  1369. ls.push({
  1370. id: id,
  1371. ename: ename,
  1372. fn: fn,
  1373. wrap: wrap,
  1374. scope: scope
  1375. });
  1376. E.on(el, ename, wrap);
  1377. if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery
  1378. el.addEventListener("DOMMouseScroll", wrap, false);
  1379. E.on(window, 'unload', function(){
  1380. el.removeEventListener("DOMMouseScroll", wrap, false);
  1381. });
  1382. }
  1383. if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
  1384. Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
  1385. }
  1386. }
  1387. var removeListener = function(el, ename, fn, scope){
  1388. el = Ext.getDom(el);
  1389. var id = Ext.id(el), es = elHash[id], wrap;
  1390. if(es){
  1391. var ls = es[ename], l;
  1392. if(ls){
  1393. for(var i = 0, len = ls.length; i < len; i++){
  1394. l = ls[i];
  1395. if(l.fn == fn && (!scope || l.scope == scope)){
  1396. wrap = l.wrap;
  1397. E.un(el, ename, wrap);
  1398. ls.splice(i, 1);
  1399. break;
  1400. }
  1401. }
  1402. }
  1403. }
  1404. if(ename == "mousewheel" && el.addEventListener && wrap){
  1405. el.removeEventListener("DOMMouseScroll", wrap, false);
  1406. }
  1407. if(ename == "mousedown" && el == document && wrap){ // fix stopped mousedowns on the document
  1408. Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
  1409. }
  1410. }
  1411. var removeAll = function(el){
  1412. el = Ext.getDom(el);
  1413. var id = Ext.id(el), es = elHash[id], ls;
  1414. if(es){
  1415. for(var ename in es){
  1416. if(es.hasOwnProperty(ename)){
  1417. ls = es[ename];
  1418. for(var i = 0, len = ls.length; i < len; i++){
  1419. E.un(el, ename, ls[i].wrap);
  1420. ls[i] = null;
  1421. }
  1422. }
  1423. es[ename] = null;
  1424. }
  1425. delete elHash[id];
  1426. }
  1427. }
  1428. var fireDocReady = function(){
  1429. if(!docReadyState){
  1430. docReadyState = true;
  1431. Ext.isReady = true;
  1432. if(docReadyProcId){
  1433. clearInterval(docReadyProcId);
  1434. }
  1435. if(Ext.isGecko || Ext.isOpera) {
  1436. document.removeEventListener("DOMContentLoaded", fireDocReady, false);
  1437. }
  1438. if(Ext.isIE){
  1439. var defer = document.getElementById("ie-deferred-loader");
  1440. if(defer){
  1441. defer.onreadystatechange = null;
  1442. defer.parentNode.removeChild(defer);
  1443. }
  1444. }
  1445. if(docReadyEvent){
  1446. docReadyEvent.fire();
  1447. docReadyEvent.clearListeners();
  1448. }
  1449. }
  1450. };
  1451. var initDocReady = function(){
  1452. docReadyEvent = new Ext.util.Event();
  1453. if(Ext.isGecko || Ext.isOpera) {
  1454. document.addEventListener("DOMContentLoaded", fireDocReady, false);
  1455. }else if(Ext.isIE){
  1456. document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
  1457. var defer = document.getElementById("ie-deferred-loader");
  1458. defer.onreadystatechange = function(){
  1459. if(this.readyState == "complete"){
  1460. fireDocReady();
  1461. }
  1462. };
  1463. }else if(Ext.isSafari){
  1464. docReadyProcId = setInterval(function(){
  1465. var rs = document.readyState;
  1466. if(rs == "complete") {
  1467. fireDocReady();
  1468. }
  1469. }, 10);
  1470. }
  1471. // no matter what, make sure it fires on load
  1472. E.on(window, "load", fireDocReady);
  1473. };
  1474. var createBuffered = function(h, o){
  1475. var task = new Ext.util.DelayedTask(h);
  1476. return function(e){
  1477. // create new event object impl so new events don't wipe out properties
  1478. e = new Ext.EventObjectImpl(e);
  1479. task.delay(o.buffer, h, null, [e]);
  1480. };
  1481. };
  1482. var createSingle = function(h, el, ename, fn, scope){
  1483. return function(e){
  1484. Ext.EventManager.removeListener(el, ename, fn, scope);
  1485. h(e);
  1486. };
  1487. };
  1488. var createDelayed = function(h, o){
  1489. return function(e){
  1490. // create new event object impl so new events don't wipe out properties
  1491. e = new Ext.EventObjectImpl(e);
  1492. setTimeout(function(){
  1493. h(e);
  1494. }, o.delay || 10);
  1495. };
  1496. };
  1497. var listen = function(element, ename, opt, fn, scope){
  1498. var o = (!opt || typeof opt == "boolean") ? {} : opt;
  1499. fn = fn || o.fn; scope = scope || o.scope;
  1500. var el = Ext.getDom(element);
  1501. if(!el){
  1502. throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
  1503. }
  1504. var h = function(e){
  1505. // prevent errors while unload occurring
  1506. if(!window[xname]){
  1507. return;
  1508. }
  1509. e = Ext.EventObject.setEvent(e);
  1510. var t;
  1511. if(o.delegate){
  1512. t = e.getTarget(o.delegate, el);
  1513. if(!t){
  1514. return;
  1515. }
  1516. }else{
  1517. t = e.target;
  1518. }
  1519. if(o.stopEvent === true){
  1520. e.stopEvent();
  1521. }
  1522. if(o.preventDefault === true){
  1523. e.preventDefault();
  1524. }
  1525. if(o.stopPropagation === true){
  1526. e.stopPropagation();
  1527. }
  1528. if(o.normalized === false){
  1529. e = e.browserEvent;
  1530. }
  1531. fn.call(scope || el, e, t, o);
  1532. };
  1533. if(o.delay){
  1534. h = createDelayed(h, o);
  1535. }
  1536. if(o.single){
  1537. h = createSingle(h, el, ename, fn, scope);
  1538. }
  1539. if(o.buffer){
  1540. h = createBuffered(h, o);
  1541. }
  1542. addListener(el, ename, fn, h, scope);
  1543. return h;
  1544. };
  1545. var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
  1546. var pub = {
  1547. addListener : function(element, eventName, fn, scope, options){
  1548. if(typeof eventName == "object"){
  1549. var o = eventName;
  1550. for(var e in o){
  1551. if(propRe.test(e)){
  1552. continue;
  1553. }
  1554. if(typeof o[e] == "function"){
  1555. // shared options
  1556. listen(element, e, o, o[e], o.scope);
  1557. }else{
  1558. // individual options
  1559. listen(element, e, o[e]);
  1560. }
  1561. }
  1562. return;
  1563. }
  1564. return listen(element, eventName, options, fn, scope);
  1565. },
  1566. removeListener : function(element, eventName, fn, scope){
  1567. return removeListener(element, eventName, fn, scope);
  1568. },
  1569. removeAll : function(element){
  1570. return removeAll(element);
  1571. },
  1572. onDocumentReady : function(fn, scope, options){
  1573. if(docReadyState){ // if it already fired
  1574. docReadyEvent.addListener(fn, scope, options);
  1575. docReadyEvent.fire();
  1576. docReadyEvent.clearListeners();
  1577. return;
  1578. }
  1579. if(!docReadyEvent){
  1580. initDocReady();
  1581. }
  1582. options = options || {};
  1583. if(!options.delay){
  1584. options.delay = 1;
  1585. }
  1586. docReadyEvent.addListener(fn, scope, options);
  1587. },
  1588. // private
  1589. doResizeEvent: function(){
  1590. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1591. },
  1592. onWindowResize : function(fn, scope, options){
  1593. if(!resizeEvent){
  1594. resizeEvent = new Ext.util.Event();
  1595. resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
  1596. E.on(window, "resize", this.fireWindowResize, this);
  1597. }
  1598. resizeEvent.addListener(fn, scope, options);
  1599. },
  1600. // exposed only to allow manual firing
  1601. fireWindowResize : function(){
  1602. if(resizeEvent){
  1603. if((Ext.isIE||Ext.isAir) && resizeTask){
  1604. resizeTask.delay(50);
  1605. }else{
  1606. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1607. }
  1608. }
  1609. },
  1610. onTextResize : function(fn, scope, options){
  1611. if(!textEvent){
  1612. textEvent = new Ext.util.Event();
  1613. var textEl = new Ext.Element(document.createElement('div'));
  1614. textEl.dom.className = 'x-text-resize';
  1615. textEl.dom.innerHTML = 'X';
  1616. textEl.appendTo(document.body);
  1617. textSize = textEl.dom.offsetHeight;
  1618. setInterval(function(){
  1619. if(textEl.dom.offsetHeight != textSize){
  1620. textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
  1621. }
  1622. }, this.textResizeInterval);
  1623. }
  1624. textEvent.addListener(fn, scope, options);
  1625. },
  1626. removeResizeListener : function(fn, scope){
  1627. if(resizeEvent){
  1628. resizeEvent.removeListener(fn, scope);
  1629. }
  1630. },
  1631. // private
  1632. fireResize : function(){
  1633. if(resizeEvent){
  1634. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1635. }
  1636. },
  1637. ieDeferSrc : false,
  1638. textResizeInterval : 50
  1639. };
  1640. pub.on = pub.addListener;
  1641. pub.un = pub.removeListener;
  1642. pub.stoppedMouseDownEvent = new Ext.util.Event();
  1643. return pub;
  1644. }();
  1645. Ext.onReady = Ext.EventManager.onDocumentReady;
  1646. // Initialize doc classes
  1647. (function(){
  1648. var initExtCss = function(){
  1649. // find the body element
  1650. var bd = document.body || document.getElementsByTagName('body')[0];
  1651. if(!bd){ return false; }
  1652. var cls = [' ',
  1653. Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : (Ext.isIE7 ? 'ext-ie7' : 'ext-ie8'))
  1654. : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
  1655. : Ext.isOpera ? "ext-opera"
  1656. : Ext.isSafari ? "ext-safari"
  1657. : Ext.isChrome ? "ext-chrome" : ""];
  1658. if(Ext.isMac){
  1659. cls.push("ext-mac");
  1660. }
  1661. if(Ext.isLinux){
  1662. cls.push("ext-linux");
  1663. }
  1664. if(Ext.isBorderBox){
  1665. cls.push('ext-border-box');
  1666. }
  1667. if(Ext.isStrict){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
  1668. var p = bd.parentNode;
  1669. if(p){
  1670. p.className += ' ext-strict';
  1671. }
  1672. }
  1673. bd.className += cls.join(' ');
  1674. return true;
  1675. }
  1676. if(!initExtCss()){
  1677. Ext.onReady(initExtCss);
  1678. }
  1679. })();
  1680. Ext.EventObject = function(){
  1681. var E = Ext.lib.Event;
  1682. // safari keypress events for special keys return bad keycodes
  1683. var safariKeys = {
  1684. 3 : 13, // enter
  1685. 63234 : 37, // left
  1686. 63235 : 39, // right
  1687. 63232 : 38, // up
  1688. 63233 : 40, // down
  1689. 63276 : 33, // page up
  1690. 63277 : 34, // page down
  1691. 63272 : 46, // delete
  1692. 63273 : 36, // home
  1693. 63275 : 35 // end
  1694. };
  1695. // normalize button clicks
  1696. var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
  1697. (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
  1698. Ext.EventObjectImpl = function(e){
  1699. if(e){
  1700. this.setEvent(e.browserEvent || e);
  1701. }
  1702. };
  1703. Ext.EventObjectImpl.prototype = {
  1704. browserEvent : null,
  1705. button : -1,
  1706. shiftKey : false,
  1707. ctrlKey : false,
  1708. altKey : false,
  1709. BACKSPACE: 8,
  1710. TAB: 9,
  1711. NUM_CENTER: 12,
  1712. ENTER: 13,
  1713. RETURN: 13,
  1714. SHIFT: 16,
  1715. CTRL: 17,
  1716. CONTROL : 17, // legacy
  1717. ALT: 18,
  1718. PAUSE: 19,
  1719. CAPS_LOCK: 20,
  1720. ESC: 27,
  1721. SPACE: 32,
  1722. PAGE_UP: 33,
  1723. PAGEUP : 33, // legacy
  1724. PAGE_DOWN: 34,
  1725. PAGEDOWN : 34, // legacy
  1726. END: 35,
  1727. HOME: 36,
  1728. LEFT: 37,
  1729. UP: 38,
  1730. RIGHT: 39,
  1731. DOWN: 40,
  1732. PRINT_SCREEN: 44,
  1733. INSERT: 45,
  1734. DELETE: 46,
  1735. ZERO: 48,
  1736. ONE: 49,
  1737. TWO: 50,
  1738. THREE: 51,
  1739. FOUR: 52,
  1740. FIVE: 53,
  1741. SIX: 54,
  1742. SEVEN: 55,
  1743. EIGHT: 56,
  1744. NINE: 57,
  1745. A: 65,
  1746. B: 66,
  1747. C: 67,
  1748. D: 68,
  1749. E: 69,
  1750. F: 70,
  1751. G: 71,
  1752. H: 72,
  1753. I: 73,
  1754. J: 74,
  1755. K: 75,
  1756. L: 76,
  1757. M: 77,
  1758. N: 78,
  1759. O: 79,
  1760. P: 80,
  1761. Q: 81,
  1762. R: 82,
  1763. S: 83,
  1764. T: 84,
  1765. U: 85,
  1766. V: 86,
  1767. W: 87,
  1768. X: 88,
  1769. Y: 89,
  1770. Z: 90,
  1771. CONTEXT_MENU: 93,
  1772. NUM_ZERO: 96,
  1773. NUM_ONE: 97,
  1774. NUM_TWO: 98,
  1775. NUM_THREE: 99,
  1776. NUM_FOUR: 100,
  1777. NUM_FIVE: 101,
  1778. NUM_SIX: 102,
  1779. NUM_SEVEN: 103,
  1780. NUM_EIGHT: 104,
  1781. NUM_NINE: 105,
  1782. NUM_MULTIPLY: 106,
  1783. NUM_PLUS: 107,
  1784. NUM_MINUS: 109,
  1785. NUM_PERIOD: 110,
  1786. NUM_DIVISION: 111,
  1787. F1: 112,
  1788. F2: 113,
  1789. F3: 114,
  1790. F4: 115,
  1791. F5: 116,
  1792. F6: 117,
  1793. F7: 118,
  1794. F8: 119,
  1795. F9: 120,
  1796. F10: 121,
  1797. F11: 122,
  1798. F12: 123,
  1799. setEvent : function(e){
  1800. if(e == this || (e && e.browserEvent)){ // already wrapped
  1801. return e;
  1802. }
  1803. this.browserEvent = e;
  1804. if(e){
  1805. // normalize buttons
  1806. this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
  1807. if(e.type == 'click' && this.button == -1){
  1808. this.button = 0;
  1809. }
  1810. this.type = e.type;
  1811. this.shiftKey = e.shiftKey;
  1812. // mac metaKey behaves like ctrlKey
  1813. this.ctrlKey = e.ctrlKey || e.metaKey;
  1814. this.altKey = e.altKey;
  1815. // in getKey these will be normalized for the mac
  1816. this.keyCode = e.keyCode;
  1817. this.charCode = e.charCode;
  1818. // cache the target for the delayed and or buffered events
  1819. this.target = E.getTarget(e);
  1820. // same for XY
  1821. this.xy = E.getXY(e);
  1822. }else{
  1823. this.button = -1;
  1824. this.shiftKey = false;
  1825. this.ctrlKey = false;
  1826. this.altKey = false;
  1827. this.keyCode = 0;
  1828. this.charCode = 0;
  1829. this.target = null;
  1830. this.xy = [0, 0];
  1831. }
  1832. return this;
  1833. },
  1834. stopEvent : function(){
  1835. if(this.browserEvent){
  1836. if(this.browserEvent.type == 'mousedown'){
  1837. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1838. }
  1839. E.stopEvent(this.browserEvent);
  1840. }
  1841. },
  1842. preventDefault : function(){
  1843. if(this.browserEvent){
  1844. E.preventDefault(this.browserEvent);
  1845. }
  1846. },
  1847. isNavKeyPress : function(){
  1848. var k = this.keyCode;
  1849. k = Ext.isSafari ? (safariKeys[k] || k) : k;
  1850. return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
  1851. },
  1852. isSpecialKey : function(){
  1853. var k = this.keyCode;
  1854. return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
  1855. (k == 16) || (k == 17) ||
  1856. (k >= 18 && k <= 20) ||
  1857. (k >= 33 && k <= 35) ||
  1858. (k >= 36 && k <= 39) ||
  1859. (k >= 44 && k <= 45);
  1860. },
  1861. stopPropagation : function(){
  1862. if(this.browserEvent){
  1863. if(this.browserEvent.type == 'mousedown'){
  1864. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1865. }
  1866. E.stopPropagation(this.browserEvent);
  1867. }
  1868. },
  1869. getCharCode : function(){
  1870. return this.charCode || this.keyCode;
  1871. },
  1872. getKey : function(){
  1873. var k = this.keyCode || this.charCode;
  1874. return Ext.isSafari ? (safariKeys[k] || k) : k;
  1875. },
  1876. getPageX : function(){
  1877. return this.xy[0];
  1878. },
  1879. getPageY : function(){
  1880. return this.xy[1];
  1881. },
  1882. getTime : function(){
  1883. if(this.browserEvent){
  1884. return E.getTime(this.browserEvent);
  1885. }
  1886. return null;
  1887. },
  1888. getXY : function(){
  1889. return this.xy;
  1890. },
  1891. getTarget : function(selector, maxDepth, returnEl){
  1892. return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
  1893. },
  1894. getRelatedTarget : function(){
  1895. if(this.browserEvent){
  1896. return E.getRelatedTarget(this.browserEvent);
  1897. }
  1898. return null;
  1899. },
  1900. getWheelDelta : function(){
  1901. var e = this.browserEvent;
  1902. var delta = 0;
  1903. if(e.wheelDelta){
  1904. delta = e.wheelDelta/120;
  1905. }else if(e.detail){
  1906. delta = -e.detail/3;
  1907. }
  1908. return delta;
  1909. },
  1910. hasModifier : function(){
  1911. return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
  1912. },
  1913. within : function(el, related, allowEl){
  1914. var t = this[related ? "getRelatedTarget" : "getTarget"]();
  1915. return t && ((allowEl ? (t === Ext.getDom(el)) : false) || Ext.fly(el).contains(t));
  1916. },
  1917. getPoint : function(){
  1918. return new Ext.lib.Point(this.xy[0], this.xy[1]);
  1919. }
  1920. };
  1921. return new Ext.EventObjectImpl();
  1922. }();
  1923. (function(){
  1924. var D = Ext.lib.Dom;
  1925. var E = Ext.lib.Event;
  1926. var A = Ext.lib.Anim;
  1927. // local style camelizing for speed
  1928. var propCache = {};
  1929. var camelRe = /(-[a-z])/gi;
  1930. var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
  1931. var view = document.defaultView;
  1932. Ext.Element = function(element, forceNew){
  1933. var dom = typeof element == "string" ?
  1934. document.getElementById(element) : element;
  1935. if(!dom){ // invalid id/element
  1936. return null;
  1937. }
  1938. var id = dom.id;
  1939. if(forceNew !== true && id && Ext.Element.cache[id]){ // element object already exists
  1940. return Ext.Element.cache[id];
  1941. }
  1942. this.dom = dom;
  1943. this.id = id || Ext.id(dom);
  1944. };
  1945. var El = Ext.Element;
  1946. El.prototype = {
  1947. originalDisplay : "",
  1948. visibilityMode : 1,
  1949. defaultUnit : "px",
  1950. setVisibilityMode : function(visMode){
  1951. this.visibilityMode = visMode;
  1952. return this;
  1953. },
  1954. enableDisplayMode : function(display){
  1955. this.setVisibilityMode(El.DISPLAY);
  1956. if(typeof display != "undefined") this.originalDisplay = display;
  1957. return this;
  1958. },
  1959. findParent : function(simpleSelector, maxDepth, returnEl){
  1960. var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
  1961. maxDepth = maxDepth || 50;
  1962. if(typeof maxDepth != "number"){
  1963. stopEl = Ext.getDom(maxDepth);
  1964. maxDepth = 10;
  1965. }
  1966. while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
  1967. if(dq.is(p, simpleSelector)){
  1968. return returnEl ? Ext.get(p) : p;
  1969. }
  1970. depth++;
  1971. p = p.parentNode;
  1972. }
  1973. return null;
  1974. },
  1975. findParentNode : function(simpleSelector, maxDepth, returnEl){
  1976. var p = Ext.fly(this.dom.parentNode, '_internal');
  1977. return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
  1978. },
  1979. up : function(simpleSelector, maxDepth){
  1980. return this.findParentNode(simpleSelector, maxDepth, true);
  1981. },
  1982. is : function(simpleSelector){
  1983. return Ext.DomQuery.is(this.dom, simpleSelector);
  1984. },
  1985. animate : function(args, duration, onComplete, easing, animType){
  1986. this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
  1987. return this;
  1988. },
  1989. anim : function(args, opt, animType, defaultDur, defaultEase, cb){
  1990. animType = animType || 'run';
  1991. opt = opt || {};
  1992. var anim = Ext.lib.Anim[animType](
  1993. this.dom, args,
  1994. (opt.duration || defaultDur) || .35,
  1995. (opt.easing || defaultEase) || 'easeOut',
  1996. function(){
  1997. Ext.callback(cb, this);
  1998. Ext.callback(opt.callback, opt.scope || this, [this, opt]);
  1999. },
  2000. this
  2001. );
  2002. opt.anim = anim;
  2003. return anim;
  2004. },
  2005. // private legacy anim prep
  2006. preanim : function(a, i){
  2007. return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
  2008. },
  2009. clean : function(forceReclean){
  2010. if(this.isCleaned && forceReclean !== true){
  2011. return this;
  2012. }
  2013. var ns = /\S/;
  2014. var d = this.dom, n = d.firstChild, ni = -1;
  2015. while(n){
  2016. var nx = n.nextSibling;
  2017. if(n.nodeType == 3 && !ns.test(n.nodeValue)){
  2018. d.removeChild(n);
  2019. }else{
  2020. n.nodeIndex = ++ni;
  2021. }
  2022. n = nx;
  2023. }
  2024. this.isCleaned = true;
  2025. return this;
  2026. },
  2027. scrollIntoView : function(container, hscroll){
  2028. var c = Ext.getDom(container) || Ext.getBody().dom;
  2029. var el = this.dom;
  2030. var o = this.getOffsetsTo(c),
  2031. l = o[0] + c.scrollLeft,
  2032. t = o[1] + c.scrollTop,
  2033. b = t+el.offsetHeight,
  2034. r = l+el.offsetWidth;
  2035. var ch = c.clientHeight;
  2036. var ct = parseInt(c.scrollTop, 10);
  2037. var cl = parseInt(c.scrollLeft, 10);
  2038. var cb = ct + ch;
  2039. var cr = cl + c.clientWidth;
  2040. if(el.offsetHeight > ch || t < ct){
  2041. c.scrollTop = t;
  2042. }else if(b > cb){
  2043. c.scrollTop = b-ch;
  2044. }
  2045. c.scrollTop = c.scrollTop; // corrects IE, other browsers will ignore
  2046. if(hscroll !== false){
  2047. if(el.offsetWidth > c.clientWidth || l < cl){
  2048. c.scrollLeft = l;
  2049. }else if(r > cr){
  2050. c.scrollLeft = r-c.clientWidth;
  2051. }
  2052. c.scrollLeft = c.scrollLeft;
  2053. }
  2054. return this;
  2055. },
  2056. // private
  2057. scrollChildIntoView : function(child, hscroll){
  2058. Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
  2059. },
  2060. autoHeight : function(animate, duration, onComplete, easing){
  2061. var oldHeight = this.getHeight();
  2062. this.clip();
  2063. this.setHeight(1); // force clipping
  2064. setTimeout(function(){
  2065. var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari
  2066. if(!animate){
  2067. this.setHeight(height);
  2068. this.unclip();
  2069. if(typeof onComplete == "function"){
  2070. onComplete();
  2071. }
  2072. }else{
  2073. this.setHeight(oldHeight); // restore original height
  2074. this.setHeight(height, animate, duration, function(){
  2075. this.unclip();
  2076. if(typeof onComplete == "function") onComplete();
  2077. }.createDelegate(this), easing);
  2078. }
  2079. }.createDelegate(this), 0);
  2080. return this;
  2081. },
  2082. contains : function(el){
  2083. if(!el){return false;}
  2084. return D.isAncestor(this.dom, el.dom ? el.dom : el);
  2085. },
  2086. isVisible : function(deep) {
  2087. var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
  2088. if(deep !== true || !vis){
  2089. return vis;
  2090. }
  2091. var p = this.dom.parentNode;
  2092. while(p && p.tagName.toLowerCase() != "body"){
  2093. if(!Ext.fly(p, '_isVisible').isVisible()){
  2094. return false;
  2095. }
  2096. p = p.parentNode;
  2097. }
  2098. return true;
  2099. },
  2100. select : function(selector, unique){
  2101. return El.select(selector, unique, this.dom);
  2102. },
  2103. query : function(selector){
  2104. return Ext.DomQuery.select(selector, this.dom);
  2105. },
  2106. child : function(selector, returnDom){
  2107. var n = Ext.DomQuery.selectNode(selector, this.dom);
  2108. return returnDom ? n : Ext.get(n);
  2109. },
  2110. down : function(selector, returnDom){
  2111. var n = Ext.DomQuery.selectNode(" > " + selector, this.dom);
  2112. return returnDom ? n : Ext.get(n);
  2113. },
  2114. initDD : function(group, config, overrides){
  2115. var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
  2116. return Ext.apply(dd, overrides);
  2117. },
  2118. initDDProxy : function(group, config, overrides){
  2119. var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
  2120. return Ext.apply(dd, overrides);
  2121. },
  2122. initDDTarget : function(group, config, overrides){
  2123. var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
  2124. return Ext.apply(dd, overrides);
  2125. },
  2126. setVisible : function(visible, animate){
  2127. if(!animate || !A){
  2128. if(this.visibilityMode == El.DISPLAY){
  2129. this.setDisplayed(visible);
  2130. }else{
  2131. this.fixDisplay();
  2132. this.dom.style.visibility = visible ? "visible" : "hidden";
  2133. }
  2134. }else{
  2135. // closure for composites
  2136. var dom = this.dom;
  2137. var visMode = this.visibilityMode;
  2138. if(visible){
  2139. this.setOpacity(.01);
  2140. this.setVisible(true);
  2141. }
  2142. this.anim({opacity: { to: (visible?1:0) }},
  2143. this.preanim(arguments, 1),
  2144. null, .35, 'easeIn', function(){
  2145. if(!visible){
  2146. if(visMode == El.DISPLAY){
  2147. dom.style.display = "none";
  2148. }else{
  2149. dom.style.visibility = "hidden";
  2150. }
  2151. Ext.get(dom).setOpacity(1);
  2152. }
  2153. });
  2154. }
  2155. return this;
  2156. },
  2157. isDisplayed : function() {
  2158. return this.getStyle("display") != "none";
  2159. },
  2160. toggle : function(animate){
  2161. this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
  2162. return this;
  2163. },
  2164. setDisplayed : function(value) {
  2165. if(typeof value == "boolean"){
  2166. value = value ? this.originalDisplay : "none";
  2167. }
  2168. this.setStyle("display", value);
  2169. return this;
  2170. },
  2171. focus : function() {
  2172. try{
  2173. this.dom.focus();
  2174. }catch(e){}
  2175. return this;
  2176. },
  2177. blur : function() {
  2178. try{
  2179. this.dom.blur();
  2180. }catch(e){}
  2181. return this;
  2182. },
  2183. addClass : function(className){
  2184. if(Ext.isArray(className)){
  2185. for(var i = 0, len = className.length; i < len; i++) {
  2186. this.addClass(className[i]);
  2187. }
  2188. }else{
  2189. if(className && !this.hasClass(className)){
  2190. this.dom.className = this.dom.className + " " + className;
  2191. }
  2192. }
  2193. return this;
  2194. },
  2195. radioClass : function(className){
  2196. var siblings = this.dom.parentNode.childNodes;
  2197. for(var i = 0; i < siblings.length; i++) {
  2198. var s = siblings[i];
  2199. if(s.nodeType == 1){
  2200. Ext.get(s).removeClass(className);
  2201. }
  2202. }
  2203. this.addClass(className);
  2204. return this;
  2205. },
  2206. removeClass : function(className){
  2207. if(!className || !this.dom.className){
  2208. return this;
  2209. }
  2210. if(Ext.isArray(className)){
  2211. for(var i = 0, len = className.length; i < len; i++) {
  2212. this.removeClass(className[i]);
  2213. }
  2214. }else{
  2215. if(this.hasClass(className)){
  2216. var re = this.classReCache[className];
  2217. if (!re) {
  2218. re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g");
  2219. this.classReCache[className] = re;
  2220. }
  2221. this.dom.className =
  2222. this.dom.className.replace(re, " ");
  2223. }
  2224. }
  2225. return this;
  2226. },
  2227. // private
  2228. classReCache: {},
  2229. toggleClass : function(className){
  2230. if(this.hasClass(className)){
  2231. this.removeClass(className);
  2232. }else{
  2233. this.addClass(className);
  2234. }
  2235. return this;
  2236. },
  2237. hasClass : function(className){
  2238. return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
  2239. },
  2240. replaceClass : function(oldClassName, newClassName){
  2241. this.removeClass(oldClassName);
  2242. this.addClass(newClassName);
  2243. return this;
  2244. },
  2245. getStyles : function(){
  2246. var a = arguments, len = a.length, r = {};
  2247. for(var i = 0; i < len; i++){
  2248. r[a[i]] = this.getStyle(a[i]);
  2249. }
  2250. return r;
  2251. },
  2252. getStyle : function(){
  2253. return view && view.getComputedStyle ?
  2254. function(prop){
  2255. var el = this.dom, v, cs, camel;
  2256. if(prop == 'float'){
  2257. prop = "cssFloat";
  2258. }
  2259. if(v = el.style[prop]){
  2260. return v;
  2261. }
  2262. if(cs = view.getComputedStyle(el, "")){
  2263. if(!(camel = propCache[prop])){
  2264. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2265. }
  2266. return cs[camel];
  2267. }
  2268. return null;
  2269. } :
  2270. function(prop){
  2271. var el = this.dom, v, cs, camel;
  2272. if(prop == 'opacity'){
  2273. if(typeof el.style.filter == 'string'){
  2274. var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
  2275. if(m){
  2276. var fv = parseFloat(m[1]);
  2277. if(!isNaN(fv)){
  2278. return fv ? fv / 100 : 0;
  2279. }
  2280. }
  2281. }
  2282. return 1;
  2283. }else if(prop == 'float'){
  2284. prop = "styleFloat";
  2285. }
  2286. if(!(camel = propCache[prop])){
  2287. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2288. }
  2289. if(v = el.style[camel]){
  2290. return v;
  2291. }
  2292. if(cs = el.currentStyle){
  2293. return cs[camel];
  2294. }
  2295. return null;
  2296. };
  2297. }(),
  2298. setStyle : function(prop, value){
  2299. if(typeof prop == "string"){
  2300. var camel;
  2301. if(!(camel = propCache[prop])){
  2302. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2303. }
  2304. if(camel == 'opacity') {
  2305. this.setOpacity(value);
  2306. }else{
  2307. this.dom.style[camel] = value;
  2308. }
  2309. }else{
  2310. for(var style in prop){
  2311. if(typeof prop[style] != "function"){
  2312. this.setStyle(style, prop[style]);
  2313. }
  2314. }
  2315. }
  2316. return this;
  2317. },
  2318. applyStyles : function(style){
  2319. Ext.DomHelper.applyStyles(this.dom, style);
  2320. return this;
  2321. },
  2322. getX : function(){
  2323. return D.getX(this.dom);
  2324. },
  2325. getY : function(){
  2326. return D.getY(this.dom);
  2327. },
  2328. getXY : function(){
  2329. return D.getXY(this.dom);
  2330. },
  2331. getOffsetsTo : function(el){
  2332. var o = this.getXY();
  2333. var e = Ext.fly(el, '_internal').getXY();
  2334. return [o[0]-e[0],o[1]-e[1]];
  2335. },
  2336. setX : function(x, animate){
  2337. if(!animate || !A){
  2338. D.setX(this.dom, x);
  2339. }else{
  2340. this.setXY([x, this.getY()], this.preanim(arguments, 1));
  2341. }
  2342. return this;
  2343. },
  2344. setY : function(y, animate){
  2345. if(!animate || !A){
  2346. D.setY(this.dom, y);
  2347. }else{
  2348. this.setXY([this.getX(), y], this.preanim(arguments, 1));
  2349. }
  2350. return this;
  2351. },
  2352. setLeft : function(left){
  2353. this.setStyle("left", this.addUnits(left));
  2354. return this;
  2355. },
  2356. setTop : function(top){
  2357. this.setStyle("top", this.addUnits(top));
  2358. return this;
  2359. },
  2360. setRight : function(right){
  2361. this.setStyle("right", this.addUnits(right));
  2362. return this;
  2363. },
  2364. setBottom : function(bottom){
  2365. this.setStyle("bottom", this.addUnits(bottom));
  2366. return this;
  2367. },
  2368. setXY : function(pos, animate){
  2369. if(!animate || !A){
  2370. D.setXY(this.dom, pos);
  2371. }else{
  2372. this.anim({points: {to: pos}}, this.preanim(arguments, 1), 'motion');
  2373. }
  2374. return this;
  2375. },
  2376. setLocation : function(x, y, animate){
  2377. this.setXY([x, y], this.preanim(arguments, 2));
  2378. return this;
  2379. },
  2380. moveTo : function(x, y, animate){
  2381. this.setXY([x, y], this.preanim(arguments, 2));
  2382. return this;
  2383. },
  2384. getRegion : function(){
  2385. return D.getRegion(this.dom);
  2386. },
  2387. getHeight : function(contentHeight){
  2388. var h = this.dom.offsetHeight || 0;
  2389. h = contentHeight !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb");
  2390. return h < 0 ? 0 : h;
  2391. },
  2392. getWidth : function(contentWidth){
  2393. var w = this.dom.offsetWidth || 0;
  2394. w = contentWidth !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr");
  2395. return w < 0 ? 0 : w;
  2396. },
  2397. getComputedHeight : function(){
  2398. var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
  2399. if(!h){
  2400. h = parseInt(this.getStyle('height'), 10) || 0;
  2401. if(!this.isBorderBox()){
  2402. h += this.getFrameWidth('tb');
  2403. }
  2404. }
  2405. return h;
  2406. },
  2407. getComputedWidth : function(){
  2408. var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
  2409. if(!w){
  2410. w = parseInt(this.getStyle('width'), 10) || 0;
  2411. if(!this.isBorderBox()){
  2412. w += this.getFrameWidth('lr');
  2413. }
  2414. }
  2415. return w;
  2416. },
  2417. getSize : function(contentSize){
  2418. return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
  2419. },
  2420. getStyleSize : function(){
  2421. var w, h, d = this.dom, s = d.style;
  2422. if(s.width && s.width != 'auto'){
  2423. w = parseInt(s.width, 10);
  2424. if(Ext.isBorderBox){
  2425. w -= this.getFrameWidth('lr');
  2426. }
  2427. }
  2428. if(s.height && s.height != 'auto'){
  2429. h = parseInt(s.height, 10);
  2430. if(Ext.isBorderBox){
  2431. h -= this.getFrameWidth('tb');
  2432. }
  2433. }
  2434. return {width: w || this.getWidth(true), height: h || this.getHeight(true)};
  2435. },
  2436. getViewSize : function(){
  2437. var d = this.dom, doc = document, aw = 0, ah = 0;
  2438. if(d == doc || d == doc.body){
  2439. return {width : D.getViewWidth(), height: D.getViewHeight()};
  2440. }else{
  2441. return {
  2442. width : d.clientWidth,
  2443. height: d.clientHeight
  2444. };
  2445. }
  2446. },
  2447. getValue : function(asNumber){
  2448. return asNumber ? parseInt(this.dom.value, 10) : this.dom.value;
  2449. },
  2450. // private
  2451. adjustWidth : function(width){
  2452. if(typeof width == "number"){
  2453. if(this.autoBoxAdjust && !this.isBorderBox()){
  2454. width -= (this.getBorderWidth("lr") + this.getPadding("lr"));
  2455. }
  2456. if(width < 0){
  2457. width = 0;
  2458. }
  2459. }
  2460. return width;
  2461. },
  2462. // private
  2463. adjustHeight : function(height){
  2464. if(typeof height == "number"){
  2465. if(this.autoBoxAdjust && !this.isBorderBox()){
  2466. height -= (this.getBorderWidth("tb") + this.getPadding("tb"));
  2467. }
  2468. if(height < 0){
  2469. height = 0;
  2470. }
  2471. }
  2472. return height;
  2473. },
  2474. setWidth : function(width, animate){
  2475. width = this.adjustWidth(width);
  2476. if(!animate || !A){
  2477. this.dom.style.width = this.addUnits(width);
  2478. }else{
  2479. this.anim({width: {to: width}}, this.preanim(arguments, 1));
  2480. }
  2481. return this;
  2482. },
  2483. setHeight : function(height, animate){
  2484. height = this.adjustHeight(height);
  2485. if(!animate || !A){
  2486. this.dom.style.height = this.addUnits(height);
  2487. }else{
  2488. this.anim({height: {to: height}}, this.preanim(arguments, 1));
  2489. }
  2490. return this;
  2491. },
  2492. setSize : function(width, height, animate){
  2493. if(typeof width == "object"){ // in case of object from getSize()
  2494. height = width.height; width = width.width;
  2495. }
  2496. width = this.adjustWidth(width); height = this.adjustHeight(height);
  2497. if(!animate || !A){
  2498. this.dom.style.width = this.addUnits(width);
  2499. this.dom.style.height = this.addUnits(height);
  2500. }else{
  2501. this.anim({width: {to: width}, height: {to: height}}, this.preanim(arguments, 2));
  2502. }
  2503. return this;
  2504. },
  2505. setBounds : function(x, y, width, height, animate){
  2506. if(!animate || !A){
  2507. this.setSize(width, height);
  2508. this.setLocation(x, y);
  2509. }else{
  2510. width = this.adjustWidth(width); height = this.adjustHeight(height);
  2511. this.anim({points: {to: [x, y]}, width: {to: width}, height: {to: height}},
  2512. this.preanim(arguments, 4), 'motion');
  2513. }
  2514. return this;
  2515. },
  2516. setRegion : function(region, animate){
  2517. this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.preanim(arguments, 1));
  2518. return this;
  2519. },
  2520. addListener : function(eventName, fn, scope, options){
  2521. Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
  2522. },
  2523. removeListener : function(eventName, fn, scope){
  2524. Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
  2525. return this;
  2526. },
  2527. removeAllListeners : function(){
  2528. Ext.EventManager.removeAll(this.dom);
  2529. return this;
  2530. },
  2531. relayEvent : function(eventName, observable){
  2532. this.on(eventName, function(e){
  2533. observable.fireEvent(eventName, e);
  2534. });
  2535. },
  2536. setOpacity : function(opacity, animate){
  2537. if(!animate || !A){
  2538. var s = this.dom.style;
  2539. if(Ext.isIE){
  2540. s.zoom = 1;
  2541. s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
  2542. (opacity == 1 ? "" : " alpha(opacity=" + opacity * 100 + ")");
  2543. }else{
  2544. s.opacity = opacity;
  2545. }
  2546. }else{
  2547. this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn');
  2548. }
  2549. return this;
  2550. },
  2551. getLeft : function(local){
  2552. if(!local){
  2553. return this.getX();
  2554. }else{
  2555. return parseInt(this.getStyle("left"), 10) || 0;
  2556. }
  2557. },
  2558. getRight : function(local){
  2559. if(!local){
  2560. return this.getX() + this.getWidth();
  2561. }else{
  2562. return (this.getLeft(true) + this.getWidth()) || 0;
  2563. }
  2564. },
  2565. getTop : function(local) {
  2566. if(!local){
  2567. return this.getY();
  2568. }else{
  2569. return parseInt(this.getStyle("top"), 10) || 0;
  2570. }
  2571. },
  2572. getBottom : function(local){
  2573. if(!local){
  2574. return this.getY() + this.getHeight();
  2575. }else{
  2576. return (this.getTop(true) + this.getHeight()) || 0;
  2577. }
  2578. },
  2579. position : function(pos, zIndex, x, y){
  2580. if(!pos){
  2581. if(this.getStyle('position') == 'static'){
  2582. this.setStyle('position', 'relative');
  2583. }
  2584. }else{
  2585. this.setStyle("position", pos);
  2586. }
  2587. if(zIndex){
  2588. this.setStyle("z-index", zIndex);
  2589. }
  2590. if(x !== undefined && y !== undefined){
  2591. this.setXY([x, y]);
  2592. }else if(x !== undefined){
  2593. this.setX(x);
  2594. }else if(y !== undefined){
  2595. this.setY(y);
  2596. }
  2597. },
  2598. clearPositioning : function(value){
  2599. value = value ||'';
  2600. this.setStyle({
  2601. "left": value,
  2602. "right": value,
  2603. "top": value,
  2604. "bottom": value,
  2605. "z-index": "",
  2606. "position" : "static"
  2607. });
  2608. return this;
  2609. },
  2610. getPositioning : function(){
  2611. var l = this.getStyle("left");
  2612. var t = this.getStyle("top");
  2613. return {
  2614. "position" : this.getStyle("position"),
  2615. "left" : l,
  2616. "right" : l ? "" : this.getStyle("right"),
  2617. "top" : t,
  2618. "bottom" : t ? "" : this.getStyle("bottom"),
  2619. "z-index" : this.getStyle("z-index")
  2620. };
  2621. },
  2622. getBorderWidth : function(side){
  2623. return this.addStyles(side, El.borders);
  2624. },
  2625. getPadding : function(side){
  2626. return this.addStyles(side, El.paddings);
  2627. },
  2628. setPositioning : function(pc){
  2629. this.applyStyles(pc);
  2630. if(pc.right == "auto"){
  2631. this.dom.style.right = "";
  2632. }
  2633. if(pc.bottom == "auto"){
  2634. this.dom.style.bottom = "";
  2635. }
  2636. return this;
  2637. },
  2638. // private
  2639. fixDisplay : function(){
  2640. if(this.getStyle("display") == "none"){
  2641. this.setStyle("visibility", "hidden");
  2642. this.setStyle("display", this.originalDisplay); // first try reverting to default
  2643. if(this.getStyle("display") == "none"){ // if that fails, default to block
  2644. this.setStyle("display", "block");
  2645. }
  2646. }
  2647. },
  2648. // private
  2649. setOverflow : function(v){
  2650. if(v=='auto' && Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
  2651. this.dom.style.overflow = 'hidden';
  2652. (function(){this.dom.style.overflow = 'auto';}).defer(1, this);
  2653. }else{
  2654. this.dom.style.overflow = v;
  2655. }
  2656. },
  2657. setLeftTop : function(left, top){
  2658. this.dom.style.left = this.addUnits(left);
  2659. this.dom.style.top = this.addUnits(top);
  2660. return this;
  2661. },
  2662. move : function(direction, distance, animate){
  2663. var xy = this.getXY();
  2664. direction = direction.toLowerCase();
  2665. switch(direction){
  2666. case "l":
  2667. case "left":
  2668. this.moveTo(xy[0]-distance, xy[1], this.preanim(arguments, 2));
  2669. break;
  2670. case "r":
  2671. case "right":
  2672. this.moveTo(xy[0]+distance, xy[1], this.preanim(arguments, 2));
  2673. break;
  2674. case "t":
  2675. case "top":
  2676. case "up":
  2677. this.moveTo(xy[0], xy[1]-distance, this.preanim(arguments, 2));
  2678. break;
  2679. case "b":
  2680. case "bottom":
  2681. case "down":
  2682. this.moveTo(xy[0], xy[1]+distance, this.preanim(arguments, 2));
  2683. break;
  2684. }
  2685. return this;
  2686. },
  2687. clip : function(){
  2688. if(!this.isClipped){
  2689. this.isClipped = true;
  2690. this.originalClip = {
  2691. "o": this.getStyle("overflow"),
  2692. "x": this.getStyle("overflow-x"),
  2693. "y": this.getStyle("overflow-y")
  2694. };
  2695. this.setStyle("overflow", "hidden");
  2696. this.setStyle("overflow-x", "hidden");
  2697. this.setStyle("overflow-y", "hidden");
  2698. }
  2699. return this;
  2700. },
  2701. unclip : function(){
  2702. if(this.isClipped){
  2703. this.isClipped = false;
  2704. var o = this.originalClip;
  2705. if(o.o){this.setStyle("overflow", o.o);}
  2706. if(o.x){this.setStyle("overflow-x", o.x);}
  2707. if(o.y){this.setStyle("overflow-y", o.y);}
  2708. }
  2709. return this;
  2710. },
  2711. getAnchorXY : function(anchor, local, s){
  2712. //Passing a different size is useful for pre-calculating anchors,
  2713. //especially for anchored animations that change the el size.
  2714. var w, h, vp = false;
  2715. if(!s){
  2716. var d = this.dom;
  2717. if(d == document.body || d == document){
  2718. vp = true;
  2719. w = D.getViewWidth(); h = D.getViewHeight();
  2720. }else{
  2721. w = this.getWidth(); h = this.getHeight();
  2722. }
  2723. }else{
  2724. w = s.width; h = s.height;
  2725. }
  2726. var x = 0, y = 0, r = Math.round;
  2727. switch((anchor || "tl").toLowerCase()){
  2728. case "c":
  2729. x = r(w*.5);
  2730. y = r(h*.5);
  2731. break;
  2732. case "t":
  2733. x = r(w*.5);
  2734. y = 0;
  2735. break;
  2736. case "l":
  2737. x = 0;
  2738. y = r(h*.5);
  2739. break;
  2740. case "r":
  2741. x = w;
  2742. y = r(h*.5);
  2743. break;
  2744. case "b":
  2745. x = r(w*.5);
  2746. y = h;
  2747. break;
  2748. case "tl":
  2749. x = 0;
  2750. y = 0;
  2751. break;
  2752. case "bl":
  2753. x = 0;
  2754. y = h;
  2755. break;
  2756. case "br":
  2757. x = w;
  2758. y = h;
  2759. break;
  2760. case "tr":
  2761. x = w;
  2762. y = 0;
  2763. break;
  2764. }
  2765. if(local === true){
  2766. return [x, y];
  2767. }
  2768. if(vp){
  2769. var sc = this.getScroll();
  2770. return [x + sc.left, y + sc.top];
  2771. }
  2772. //Add the element's offset xy
  2773. var o = this.getXY();
  2774. return [x+o[0], y+o[1]];
  2775. },
  2776. getAlignToXY : function(el, p, o){
  2777. el = Ext.get(el);
  2778. if(!el || !el.dom){
  2779. throw "Element.alignToXY with an element that doesn't exist";
  2780. }
  2781. var d = this.dom;
  2782. var c = false; //constrain to viewport
  2783. var p1 = "", p2 = "";
  2784. o = o || [0,0];
  2785. if(!p){
  2786. p = "tl-bl";
  2787. }else if(p == "?"){
  2788. p = "tl-bl?";
  2789. }else if(p.indexOf("-") == -1){
  2790. p = "tl-" + p;
  2791. }
  2792. p = p.toLowerCase();
  2793. var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
  2794. if(!m){
  2795. throw "Element.alignTo with an invalid alignment " + p;
  2796. }
  2797. p1 = m[1]; p2 = m[2]; c = !!m[3];
  2798. //Subtract the aligned el's internal xy from the target's offset xy
  2799. //plus custom offset to get the aligned el's new offset xy
  2800. var a1 = this.getAnchorXY(p1, true);
  2801. var a2 = el.getAnchorXY(p2, false);
  2802. var x = a2[0] - a1[0] + o[0];
  2803. var y = a2[1] - a1[1] + o[1];
  2804. if(c){
  2805. //constrain the aligned el to viewport if necessary
  2806. var w = this.getWidth(), h = this.getHeight(), r = el.getRegion();
  2807. // 5px of margin for ie
  2808. var dw = D.getViewWidth()-5, dh = D.getViewHeight()-5;
  2809. //If we are at a viewport boundary and the aligned el is anchored on a target border that is
  2810. //perpendicular to the vp border, allow the aligned el to slide on that border,
  2811. //otherwise swap the aligned el to the opposite border of the target.
  2812. var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
  2813. var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
  2814. var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
  2815. var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
  2816. var doc = document;
  2817. var scrollX = (doc.documentElement.scrollLeft || doc.body.scrollLeft || 0)+5;
  2818. var scrollY = (doc.documentElement.scrollTop || doc.body.scrollTop || 0)+5;
  2819. if((x+w) > dw + scrollX){
  2820. x = swapX ? r.left-w : dw+scrollX-w;
  2821. }
  2822. if(x < scrollX){
  2823. x = swapX ? r.right : scrollX;
  2824. }
  2825. if((y+h) > dh + scrollY){
  2826. y = swapY ? r.top-h : dh+scrollY-h;
  2827. }
  2828. if (y < scrollY){
  2829. y = swapY ? r.bottom : scrollY;
  2830. }
  2831. }
  2832. return [x,y];
  2833. },
  2834. // private
  2835. getConstrainToXY : function(){
  2836. var os = {top:0, left:0, bottom:0, right: 0};
  2837. return function(el, local, offsets, proposedXY){
  2838. el = Ext.get(el);
  2839. offsets = offsets ? Ext.applyIf(offsets, os) : os;
  2840. var vw, vh, vx = 0, vy = 0;
  2841. if(el.dom == document.body || el.dom == document){
  2842. vw = Ext.lib.Dom.getViewWidth();
  2843. vh = Ext.lib.Dom.getViewHeight();
  2844. }else{
  2845. vw = el.dom.clientWidth;
  2846. vh = el.dom.clientHeight;
  2847. if(!local){
  2848. var vxy = el.getXY();
  2849. vx = vxy[0];
  2850. vy = vxy[1];
  2851. }
  2852. }
  2853. var s = el.getScroll();
  2854. vx += offsets.left + s.left;
  2855. vy += offsets.top + s.top;
  2856. vw -= offsets.right;
  2857. vh -= offsets.bottom;
  2858. var vr = vx+vw;
  2859. var vb = vy+vh;
  2860. var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
  2861. var x = xy[0], y = xy[1];
  2862. var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
  2863. // only move it if it needs it
  2864. var moved = false;
  2865. // first validate right/bottom
  2866. if((x + w) > vr){
  2867. x = vr - w;
  2868. moved = true;
  2869. }
  2870. if((y + h) > vb){
  2871. y = vb - h;
  2872. moved = true;
  2873. }
  2874. // then make sure top/left isn't negative
  2875. if(x < vx){
  2876. x = vx;
  2877. moved = true;
  2878. }
  2879. if(y < vy){
  2880. y = vy;
  2881. moved = true;
  2882. }
  2883. return moved ? [x, y] : false;
  2884. };
  2885. }(),
  2886. // private
  2887. adjustForConstraints : function(xy, parent, offsets){
  2888. return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
  2889. },
  2890. alignTo : function(element, position, offsets, animate){
  2891. var xy = this.getAlignToXY(element, position, offsets);
  2892. this.setXY(xy, this.preanim(arguments, 3));
  2893. return this;
  2894. },
  2895. anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
  2896. var action = function(){
  2897. this.alignTo(el, alignment, offsets, animate);
  2898. Ext.callback(callback, this);
  2899. };
  2900. Ext.EventManager.onWindowResize(action, this);
  2901. var tm = typeof monitorScroll;
  2902. if(tm != 'undefined'){
  2903. Ext.EventManager.on(window, 'scroll', action, this,
  2904. {buffer: tm == 'number' ? monitorScroll : 50});
  2905. }
  2906. action.call(this); // align immediately
  2907. return this;
  2908. },
  2909. clearOpacity : function(){
  2910. if (window.ActiveXObject) {
  2911. if(typeof this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){
  2912. this.dom.style.filter = "";
  2913. }
  2914. } else {
  2915. this.dom.style.opacity = "";
  2916. this.dom.style["-moz-opacity"] = "";
  2917. this.dom.style["-khtml-opacity"] = "";
  2918. }
  2919. return this;
  2920. },
  2921. hide : function(animate){
  2922. this.setVisible(false, this.preanim(arguments, 0));
  2923. return this;
  2924. },
  2925. show : function(animate){
  2926. this.setVisible(true, this.preanim(arguments, 0));
  2927. return this;
  2928. },
  2929. addUnits : function(size){
  2930. return Ext.Element.addUnits(size, this.defaultUnit);
  2931. },
  2932. update : function(html, loadScripts, callback){
  2933. if(typeof html == "undefined"){
  2934. html = "";
  2935. }
  2936. if(loadScripts !== true){
  2937. this.dom.innerHTML = html;
  2938. if(typeof callback == "function"){
  2939. callback();
  2940. }
  2941. return this;
  2942. }
  2943. var id = Ext.id();
  2944. var dom = this.dom;
  2945. html += '<span id="' + id + '"></span>';
  2946. E.onAvailable(id, function(){
  2947. var hd = document.getElementsByTagName("head")[0];
  2948. var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
  2949. var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
  2950. var typeRe = /\stype=([\'\"])(.*?)\1/i;
  2951. var match;
  2952. while(match = re.exec(html)){
  2953. var attrs = match[1];
  2954. var srcMatch = attrs ? attrs.match(srcRe) : false;
  2955. if(srcMatch && srcMatch[2]){
  2956. var s = document.createElement("script");
  2957. s.src = srcMatch[2];
  2958. var typeMatch = attrs.match(typeRe);
  2959. if(typeMatch && typeMatch[2]){
  2960. s.type = typeMatch[2];
  2961. }
  2962. hd.appendChild(s);
  2963. }else if(match[2] && match[2].length > 0){
  2964. if(window.execScript) {
  2965. window.execScript(match[2]);
  2966. } else {
  2967. window.eval(match[2]);
  2968. }
  2969. }
  2970. }
  2971. var el = document.getElementById(id);
  2972. if(el){Ext.removeNode(el);}
  2973. if(typeof callback == "function"){
  2974. callback();
  2975. }
  2976. });
  2977. dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
  2978. return this;
  2979. },
  2980. load : function(){
  2981. var um = this.getUpdater();
  2982. um.update.apply(um, arguments);
  2983. return this;
  2984. },
  2985. getUpdater : function(){
  2986. if(!this.updateManager){
  2987. this.updateManager = new Ext.Updater(this);
  2988. }
  2989. return this.updateManager;
  2990. },
  2991. unselectable : function(){
  2992. this.dom.unselectable = "on";
  2993. this.swallowEvent("selectstart", true);
  2994. this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
  2995. this.addClass("x-unselectable");
  2996. return this;
  2997. },
  2998. getCenterXY : function(){
  2999. return this.getAlignToXY(document, 'c-c');
  3000. },
  3001. center : function(centerIn){
  3002. this.alignTo(centerIn || document, 'c-c');
  3003. return this;
  3004. },
  3005. isBorderBox : function(){
  3006. return noBoxAdjust[this.dom.tagName.toLowerCase()] || Ext.isBorderBox;
  3007. },
  3008. getBox : function(contentBox, local){
  3009. var xy;
  3010. if(!local){
  3011. xy = this.getXY();
  3012. }else{
  3013. var left = parseInt(this.getStyle("left"), 10) || 0;
  3014. var top = parseInt(this.getStyle("top"), 10) || 0;
  3015. xy = [left, top];
  3016. }
  3017. var el = this.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
  3018. if(!contentBox){
  3019. bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
  3020. }else{
  3021. var l = this.getBorderWidth("l")+this.getPadding("l");
  3022. var r = this.getBorderWidth("r")+this.getPadding("r");
  3023. var t = this.getBorderWidth("t")+this.getPadding("t");
  3024. var b = this.getBorderWidth("b")+this.getPadding("b");
  3025. bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
  3026. }
  3027. bx.right = bx.x + bx.width;
  3028. bx.bottom = bx.y + bx.height;
  3029. return bx;
  3030. },
  3031. getFrameWidth : function(sides, onlyContentBox){
  3032. return onlyContentBox && Ext.isBorderBox ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
  3033. },
  3034. setBox : function(box, adjust, animate){
  3035. var w = box.width, h = box.height;
  3036. if((adjust && !this.autoBoxAdjust) && !this.isBorderBox()){
  3037. w -= (this.getBorderWidth("lr") + this.getPadding("lr"));
  3038. h -= (this.getBorderWidth("tb") + this.getPadding("tb"));
  3039. }
  3040. this.setBounds(box.x, box.y, w, h, this.preanim(arguments, 2));
  3041. return this;
  3042. },
  3043. repaint : function(){
  3044. var dom = this.dom;
  3045. this.addClass("x-repaint");
  3046. setTimeout(function(){
  3047. Ext.get(dom).removeClass("x-repaint");
  3048. }, 1);
  3049. return this;
  3050. },
  3051. getMargins : function(side){
  3052. if(!side){
  3053. return {
  3054. top: parseInt(this.getStyle("margin-top"), 10) || 0,
  3055. left: parseInt(this.getStyle("margin-left"), 10) || 0,
  3056. bottom: parseInt(this.getStyle("margin-bottom"), 10) || 0,
  3057. right: parseInt(this.getStyle("margin-right"), 10) || 0
  3058. };
  3059. }else{
  3060. return this.addStyles(side, El.margins);
  3061. }
  3062. },
  3063. // private
  3064. addStyles : function(sides, styles){
  3065. var val = 0, v, w;
  3066. for(var i = 0, len = sides.length; i < len; i++){
  3067. v = this.getStyle(styles[sides.charAt(i)]);
  3068. if(v){
  3069. w = parseInt(v, 10);
  3070. if(w){ val += (w >= 0 ? w : -1 * w); }
  3071. }
  3072. }
  3073. return val;
  3074. },
  3075. createProxy : function(config, renderTo, matchBox){
  3076. config = typeof config == "object" ?
  3077. config : {tag : "div", cls: config};
  3078. var proxy;
  3079. if(renderTo){
  3080. proxy = Ext.DomHelper.append(renderTo, config, true);
  3081. }else {
  3082. proxy = Ext.DomHelper.insertBefore(this.dom, config, true);
  3083. }
  3084. if(matchBox){
  3085. proxy.setBox(this.getBox());
  3086. }
  3087. return proxy;
  3088. },
  3089. mask : function(msg, msgCls){
  3090. if(this.getStyle("position") == "static"){
  3091. this.addClass("x-masked-relative");
  3092. }
  3093. if(this._maskMsg){
  3094. this._maskMsg.remove();
  3095. }
  3096. if(this._mask){
  3097. this._mask.remove();
  3098. }
  3099. this._mask = Ext.DomHelper.append(this.dom, {cls:"ext-el-mask"}, true);
  3100. this.addClass("x-masked");
  3101. this._mask.setDisplayed(true);
  3102. if(typeof msg == 'string'){
  3103. this._maskMsg = Ext.DomHelper.append(this.dom, {cls:"ext-el-mask-msg", cn:{tag:'div'}}, true);
  3104. var mm = this._maskMsg;
  3105. mm.dom.className = msgCls ? "ext-el-mask-msg " + msgCls : "ext-el-mask-msg";
  3106. mm.dom.firstChild.innerHTML = msg;
  3107. mm.setDisplayed(true);
  3108. mm.center(this);
  3109. }
  3110. if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && this.getStyle('height') == 'auto'){ // ie will not expand full height automatically
  3111. this._mask.setSize(this.getWidth(), this.getHeight());
  3112. }
  3113. return this._mask;
  3114. },
  3115. unmask : function(){
  3116. if(this._mask){
  3117. if(this._maskMsg){
  3118. this._maskMsg.remove();
  3119. delete this._maskMsg;
  3120. }
  3121. this._mask.remove();
  3122. delete this._mask;
  3123. }
  3124. this.removeClass(["x-masked", "x-masked-relative"]);
  3125. },
  3126. isMasked : function(){
  3127. return this._mask && this._mask.isVisible();
  3128. },
  3129. createShim : function(){
  3130. var el = document.createElement('iframe');
  3131. el.frameBorder = '0';
  3132. el.className = 'ext-shim';
  3133. if(Ext.isIE && Ext.isSecure){
  3134. el.src = Ext.SSL_SECURE_URL;
  3135. }
  3136. var shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
  3137. shim.autoBoxAdjust = false;
  3138. return shim;
  3139. },
  3140. remove : function(){
  3141. Ext.removeNode(this.dom);
  3142. delete El.cache[this.dom.id];
  3143. },
  3144. hover : function(overFn, outFn, scope){
  3145. var preOverFn = function(e){
  3146. if(!e.within(this, true)){
  3147. overFn.apply(scope || this, arguments);
  3148. }
  3149. };
  3150. var preOutFn = function(e){
  3151. if(!e.within(this, true)){
  3152. outFn.apply(scope || this, arguments);
  3153. }
  3154. };
  3155. this.on("mouseover", preOverFn, this.dom);
  3156. this.on("mouseout", preOutFn, this.dom);
  3157. return this;
  3158. },
  3159. addClassOnOver : function(className){
  3160. this.hover(
  3161. function(){
  3162. Ext.fly(this, '_internal').addClass(className);
  3163. },
  3164. function(){
  3165. Ext.fly(this, '_internal').removeClass(className);
  3166. }
  3167. );
  3168. return this;
  3169. },
  3170. addClassOnFocus : function(className){
  3171. this.on("focus", function(){
  3172. Ext.fly(this, '_internal').addClass(className);
  3173. }, this.dom);
  3174. this.on("blur", function(){
  3175. Ext.fly(this, '_internal').removeClass(className);
  3176. }, this.dom);
  3177. return this;
  3178. },
  3179. addClassOnClick : function(className){
  3180. var dom = this.dom;
  3181. this.on("mousedown", function(){
  3182. Ext.fly(dom, '_internal').addClass(className);
  3183. var d = Ext.getDoc();
  3184. var fn = function(){
  3185. Ext.fly(dom, '_internal').removeClass(className);
  3186. d.removeListener("mouseup", fn);
  3187. };
  3188. d.on("mouseup", fn);
  3189. });
  3190. return this;
  3191. },
  3192. swallowEvent : function(eventName, preventDefault){
  3193. var fn = function(e){
  3194. e.stopPropagation();
  3195. if(preventDefault){
  3196. e.preventDefault();
  3197. }
  3198. };
  3199. if(Ext.isArray(eventName)){
  3200. for(var i = 0, len = eventName.length; i < len; i++){
  3201. this.on(eventName[i], fn);
  3202. }
  3203. return this;
  3204. }
  3205. this.on(eventName, fn);
  3206. return this;
  3207. },
  3208. parent : function(selector, returnDom){
  3209. return this.matchNode('parentNode', 'parentNode', selector, returnDom);
  3210. },
  3211. next : function(selector, returnDom){
  3212. return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);
  3213. },
  3214. prev : function(selector, returnDom){
  3215. return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);
  3216. },
  3217. first : function(selector, returnDom){
  3218. return this.matchNode('nextSibling', 'firstChild', selector, returnDom);
  3219. },
  3220. last : function(selector, returnDom){
  3221. return this.matchNode('previousSibling', 'lastChild', selector, returnDom);
  3222. },
  3223. matchNode : function(dir, start, selector, returnDom){
  3224. var n = this.dom[start];
  3225. while(n){
  3226. if(n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))){
  3227. return !returnDom ? Ext.get(n) : n;
  3228. }
  3229. n = n[dir];
  3230. }
  3231. return null;
  3232. },
  3233. appendChild: function(el){
  3234. el = Ext.get(el);
  3235. el.appendTo(this);
  3236. return this;
  3237. },
  3238. createChild: function(config, insertBefore, returnDom){
  3239. config = config || {tag:'div'};
  3240. if(insertBefore){
  3241. return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
  3242. }
  3243. return Ext.DomHelper[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
  3244. },
  3245. appendTo: function(el){
  3246. el = Ext.getDom(el);
  3247. el.appendChild(this.dom);
  3248. return this;
  3249. },
  3250. insertBefore: function(el){
  3251. el = Ext.getDom(el);
  3252. el.parentNode.insertBefore(this.dom, el);
  3253. return this;
  3254. },
  3255. insertAfter: function(el){
  3256. el = Ext.getDom(el);
  3257. el.parentNode.insertBefore(this.dom, el.nextSibling);
  3258. return this;
  3259. },
  3260. insertFirst: function(el, returnDom){
  3261. el = el || {};
  3262. if(typeof el == 'object' && !el.nodeType && !el.dom){ // dh config
  3263. return this.createChild(el, this.dom.firstChild, returnDom);
  3264. }else{
  3265. el = Ext.getDom(el);
  3266. this.dom.insertBefore(el, this.dom.firstChild);
  3267. return !returnDom ? Ext.get(el) : el;
  3268. }
  3269. },
  3270. insertSibling: function(el, where, returnDom){
  3271. var rt;
  3272. if(Ext.isArray(el)){
  3273. for(var i = 0, len = el.length; i < len; i++){
  3274. rt = this.insertSibling(el[i], where, returnDom);
  3275. }
  3276. return rt;
  3277. }
  3278. where = where ? where.toLowerCase() : 'before';
  3279. el = el || {};
  3280. var refNode = where == 'before' ? this.dom : this.dom.nextSibling;
  3281. if(typeof el == 'object' && !el.nodeType && !el.dom){ // dh config
  3282. if(where == 'after' && !this.dom.nextSibling){
  3283. rt = Ext.DomHelper.append(this.dom.parentNode, el, !returnDom);
  3284. }else{
  3285. rt = Ext.DomHelper[where == 'after' ? 'insertAfter' : 'insertBefore'](this.dom, el, !returnDom);
  3286. }
  3287. }else{
  3288. rt = this.dom.parentNode.insertBefore(Ext.getDom(el), refNode);
  3289. if(!returnDom){
  3290. rt = Ext.get(rt);
  3291. }
  3292. }
  3293. return rt;
  3294. },
  3295. wrap: function(config, returnDom){
  3296. if(!config){
  3297. config = {tag: "div"};
  3298. }
  3299. var newEl = Ext.DomHelper.insertBefore(this.dom, config, !returnDom);
  3300. newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
  3301. return newEl;
  3302. },
  3303. replace: function(el){
  3304. el = Ext.get(el);
  3305. this.insertBefore(el);
  3306. el.remove();
  3307. return this;
  3308. },
  3309. replaceWith: function(el){
  3310. if(typeof el == 'object' && !el.nodeType && !el.dom){ // dh config
  3311. el = this.insertSibling(el, 'before');
  3312. }else{
  3313. el = Ext.getDom(el);
  3314. this.dom.parentNode.insertBefore(el, this.dom);
  3315. }
  3316. El.uncache(this.id);
  3317. Ext.removeNode(this.dom);
  3318. this.dom = el;
  3319. this.id = Ext.id(el);
  3320. El.cache[this.id] = this;
  3321. return this;
  3322. },
  3323. insertHtml : function(where, html, returnEl){
  3324. var el = Ext.DomHelper.insertHtml(where, this.dom, html);
  3325. return returnEl ? Ext.get(el) : el;
  3326. },
  3327. set : function(o, useSet){
  3328. var el = this.dom;
  3329. useSet = typeof useSet == 'undefined' ? (el.setAttribute ? true : false) : useSet;
  3330. for(var attr in o){
  3331. if(attr == "style" || typeof o[attr] == "function") continue;
  3332. if(attr=="cls"){
  3333. el.className = o["cls"];
  3334. }else if(o.hasOwnProperty(attr)){
  3335. if(useSet) el.setAttribute(attr, o[attr]);
  3336. else el[attr] = o[attr];
  3337. }
  3338. }
  3339. if(o.style){
  3340. Ext.DomHelper.applyStyles(el, o.style);
  3341. }
  3342. return this;
  3343. },
  3344. addKeyListener : function(key, fn, scope){
  3345. var config;
  3346. if(typeof key != "object" || Ext.isArray(key)){
  3347. config = {
  3348. key: key,
  3349. fn: fn,
  3350. scope: scope
  3351. };
  3352. }else{
  3353. config = {
  3354. key : key.key,
  3355. shift : key.shift,
  3356. ctrl : key.ctrl,
  3357. alt : key.alt,
  3358. fn: fn,
  3359. scope: scope
  3360. };
  3361. }
  3362. return new Ext.KeyMap(this, config);
  3363. },
  3364. addKeyMap : function(config){
  3365. return new Ext.KeyMap(this, config);
  3366. },
  3367. isScrollable : function(){
  3368. var dom = this.dom;
  3369. return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
  3370. },
  3371. scrollTo : function(side, value, animate){
  3372. var prop = side.toLowerCase() == "left" ? "scrollLeft" : "scrollTop";
  3373. if(!animate || !A){
  3374. this.dom[prop] = value;
  3375. }else{
  3376. var to = prop == "scrollLeft" ? [value, this.dom.scrollTop] : [this.dom.scrollLeft, value];
  3377. this.anim({scroll: {"to": to}}, this.preanim(arguments, 2), 'scroll');
  3378. }
  3379. return this;
  3380. },
  3381. scroll : function(direction, distance, animate){
  3382. if(!this.isScrollable()){
  3383. return;
  3384. }
  3385. var el = this.dom;
  3386. var l = el.scrollLeft, t = el.scrollTop;
  3387. var w = el.scrollWidth, h = el.scrollHeight;
  3388. var cw = el.clientWidth, ch = el.clientHeight;
  3389. direction = direction.toLowerCase();
  3390. var scrolled = false;
  3391. var a = this.preanim(arguments, 2);
  3392. switch(direction){
  3393. case "l":
  3394. case "left":
  3395. if(w - l > cw){
  3396. var v = Math.min(l + distance, w-cw);
  3397. this.scrollTo("left", v, a);
  3398. scrolled = true;
  3399. }
  3400. break;
  3401. case "r":
  3402. case "right":
  3403. if(l > 0){
  3404. var v = Math.max(l - distance, 0);
  3405. this.scrollTo("left", v, a);
  3406. scrolled = true;
  3407. }
  3408. break;
  3409. case "t":
  3410. case "top":
  3411. case "up":
  3412. if(t > 0){
  3413. var v = Math.max(t - distance, 0);
  3414. this.scrollTo("top", v, a);
  3415. scrolled = true;
  3416. }
  3417. break;
  3418. case "b":
  3419. case "bottom":
  3420. case "down":
  3421. if(h - t > ch){
  3422. var v = Math.min(t + distance, h-ch);
  3423. this.scrollTo("top", v, a);
  3424. scrolled = true;
  3425. }
  3426. break;
  3427. }
  3428. return scrolled;
  3429. },
  3430. translatePoints : function(x, y){
  3431. if(typeof x == 'object' || Ext.isArray(x)){
  3432. y = x[1]; x = x[0];
  3433. }
  3434. var p = this.getStyle('position');
  3435. var o = this.getXY();
  3436. var l = parseInt(this.getStyle('left'), 10);
  3437. var t = parseInt(this.getStyle('top'), 10);
  3438. if(isNaN(l)){
  3439. l = (p == "relative") ? 0 : this.dom.offsetLeft;
  3440. }
  3441. if(isNaN(t)){
  3442. t = (p == "relative") ? 0 : this.dom.offsetTop;
  3443. }
  3444. return {left: (x - o[0] + l), top: (y - o[1] + t)};
  3445. },
  3446. getScroll : function(){
  3447. var d = this.dom, doc = document;
  3448. if(d == doc || d == doc.body){
  3449. var l, t;
  3450. if(Ext.isIE && Ext.isStrict){
  3451. l = doc.documentElement.scrollLeft || (doc.body.scrollLeft || 0);
  3452. t = doc.documentElement.scrollTop || (doc.body.scrollTop || 0);
  3453. }else{
  3454. l = window.pageXOffset || (doc.body.scrollLeft || 0);
  3455. t = window.pageYOffset || (doc.body.scrollTop || 0);
  3456. }
  3457. return {left: l, top: t};
  3458. }else{
  3459. return {left: d.scrollLeft, top: d.scrollTop};
  3460. }
  3461. },
  3462. getColor : function(attr, defaultValue, prefix){
  3463. var v = this.getStyle(attr);
  3464. if(!v || v == "transparent" || v == "inherit") {
  3465. return defaultValue;
  3466. }
  3467. var color = typeof prefix == "undefined" ? "#" : prefix;
  3468. if(v.substr(0, 4) == "rgb("){
  3469. var rvs = v.slice(4, v.length -1).split(",");
  3470. for(var i = 0; i < 3; i++){
  3471. var h = parseInt(rvs[i]);
  3472. var s = h.toString(16);
  3473. if(h < 16){
  3474. s = "0" + s;
  3475. }
  3476. color += s;
  3477. }
  3478. } else {
  3479. if(v.substr(0, 1) == "#"){
  3480. if(v.length == 4) {
  3481. for(var i = 1; i < 4; i++){
  3482. var c = v.charAt(i);
  3483. color += c + c;
  3484. }
  3485. }else if(v.length == 7){
  3486. color += v.substr(1);
  3487. }
  3488. }
  3489. }
  3490. return(color.length > 5 ? color.toLowerCase() : defaultValue);
  3491. },
  3492. boxWrap : function(cls){
  3493. cls = cls || 'x-box';
  3494. var el = Ext.get(this.insertHtml('beforeBegin', String.format('<div class="{0}">'+El.boxMarkup+'</div>', cls)));
  3495. el.child('.'+cls+'-mc').dom.appendChild(this.dom);
  3496. return el;
  3497. },
  3498. getAttributeNS : Ext.isIE ? function(ns, name){
  3499. var d = this.dom;
  3500. var type = typeof d[ns+":"+name];
  3501. if(type != 'undefined' && type != 'unknown'){
  3502. return d[ns+":"+name];
  3503. }
  3504. return d[name];
  3505. } : function(ns, name){
  3506. var d = this.dom;
  3507. return d.getAttributeNS(ns, name) || d.getAttribute(ns+":"+name) || d.getAttribute(name) || d[name];
  3508. },
  3509. getTextWidth : function(text, min, max){
  3510. return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
  3511. }
  3512. };
  3513. var ep = El.prototype;
  3514. ep.on = ep.addListener;
  3515. // backwards compat
  3516. ep.mon = ep.addListener;
  3517. ep.getUpdateManager = ep.getUpdater;
  3518. ep.un = ep.removeListener;
  3519. ep.autoBoxAdjust = true;
  3520. // private
  3521. El.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
  3522. // private
  3523. El.addUnits = function(v, defaultUnit){
  3524. if(v === "" || v == "auto"){
  3525. return v;
  3526. }
  3527. if(v === undefined){
  3528. return '';
  3529. }
  3530. if(typeof v == "number" || !El.unitPattern.test(v)){
  3531. return v + (defaultUnit || 'px');
  3532. }
  3533. return v;
  3534. };
  3535. // special markup used throughout Ext when box wrapping elements
  3536. El.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
  3537. El.VISIBILITY = 1;
  3538. El.DISPLAY = 2;
  3539. El.borders = {l: "border-left-width", r: "border-right-width", t: "border-top-width", b: "border-bottom-width"};
  3540. El.paddings = {l: "padding-left", r: "padding-right", t: "padding-top", b: "padding-bottom"};
  3541. El.margins = {l: "margin-left", r: "margin-right", t: "margin-top", b: "margin-bottom"};
  3542. El.cache = {};
  3543. var docEl;
  3544. El.get = function(el){
  3545. var ex, elm, id;
  3546. if(!el){ return null; }
  3547. if(typeof el == "string"){ // element id
  3548. if(!(elm = document.getElementById(el))){
  3549. return null;
  3550. }
  3551. if(ex = El.cache[el]){
  3552. ex.dom = elm;
  3553. }else{
  3554. ex = El.cache[el] = new El(elm);
  3555. }
  3556. return ex;
  3557. }else if(el.tagName){ // dom element
  3558. if(!(id = el.id)){
  3559. id = Ext.id(el);
  3560. }
  3561. if(ex = El.cache[id]){
  3562. ex.dom = el;
  3563. }else{
  3564. ex = El.cache[id] = new El(el);
  3565. }
  3566. return ex;
  3567. }else if(el instanceof El){
  3568. if(el != docEl){
  3569. el.dom = document.getElementById(el.id) || el.dom; // refresh dom element in case no longer valid,
  3570. // catch case where it hasn't been appended
  3571. El.cache[el.id] = el; // in case it was created directly with Element(), let's cache it
  3572. }
  3573. return el;
  3574. }else if(el.isComposite){
  3575. return el;
  3576. }else if(Ext.isArray(el)){
  3577. return El.select(el);
  3578. }else if(el == document){
  3579. // create a bogus element object representing the document object
  3580. if(!docEl){
  3581. var f = function(){};
  3582. f.prototype = El.prototype;
  3583. docEl = new f();
  3584. docEl.dom = document;
  3585. }
  3586. return docEl;
  3587. }
  3588. return null;
  3589. };
  3590. // private
  3591. El.uncache = function(el){
  3592. for(var i = 0, a = arguments, len = a.length; i < len; i++) {
  3593. if(a[i]){
  3594. delete El.cache[a[i].id || a[i]];
  3595. }
  3596. }
  3597. };
  3598. // private
  3599. // Garbage collection - uncache elements/purge listeners on orphaned elements
  3600. // so we don't hold a reference and cause the browser to retain them
  3601. El.garbageCollect = function(){
  3602. if(!Ext.enableGarbageCollector){
  3603. clearInterval(El.collectorThread);
  3604. return;
  3605. }
  3606. for(var eid in El.cache){
  3607. var el = El.cache[eid], d = el.dom;
  3608. // -------------------------------------------------------
  3609. // Determining what is garbage:
  3610. // -------------------------------------------------------
  3611. // !d
  3612. // dom node is null, definitely garbage
  3613. // -------------------------------------------------------
  3614. // !d.parentNode
  3615. // no parentNode == direct orphan, definitely garbage
  3616. // -------------------------------------------------------
  3617. // !d.offsetParent && !document.getElementById(eid)
  3618. // display none elements have no offsetParent so we will
  3619. // also try to look it up by it's id. However, check
  3620. // offsetParent first so we don't do unneeded lookups.
  3621. // This enables collection of elements that are not orphans
  3622. // directly, but somewhere up the line they have an orphan
  3623. // parent.
  3624. // -------------------------------------------------------
  3625. if(!d || !d.parentNode || (!d.offsetParent && !document.getElementById(eid))){
  3626. delete El.cache[eid];
  3627. if(d && Ext.enableListenerCollection){
  3628. Ext.EventManager.removeAll(d);
  3629. }
  3630. }
  3631. }
  3632. }
  3633. El.collectorThreadId = setInterval(El.garbageCollect, 30000);
  3634. var flyFn = function(){};
  3635. flyFn.prototype = El.prototype;
  3636. var _cls = new flyFn();
  3637. // dom is optional
  3638. El.Flyweight = function(dom){
  3639. this.dom = dom;
  3640. };
  3641. El.Flyweight.prototype = _cls;
  3642. El.Flyweight.prototype.isFlyweight = true;
  3643. El._flyweights = {};
  3644. El.fly = function(el, named){
  3645. named = named || '_global';
  3646. el = Ext.getDom(el);
  3647. if(!el){
  3648. return null;
  3649. }
  3650. if(!El._flyweights[named]){
  3651. El._flyweights[named] = new El.Flyweight();
  3652. }
  3653. El._flyweights[named].dom = el;
  3654. return El._flyweights[named];
  3655. };
  3656. Ext.get = El.get;
  3657. Ext.fly = El.fly;
  3658. // speedy lookup for elements never to box adjust
  3659. var noBoxAdjust = Ext.isStrict ? {
  3660. select:1
  3661. } : {
  3662. input:1, select:1, textarea:1
  3663. };
  3664. if(Ext.isIE || Ext.isGecko){
  3665. noBoxAdjust['button'] = 1;
  3666. }
  3667. Ext.EventManager.on(window, 'unload', function(){
  3668. delete El.cache;
  3669. delete El._flyweights;
  3670. });
  3671. })();
  3672. //Notifies Element that fx methods are available
  3673. Ext.enableFx = true;
  3674. Ext.Fx = {
  3675. slideIn : function(anchor, o){
  3676. var el = this.getFxEl();
  3677. o = o || {};
  3678. el.queueFx(o, function(){
  3679. anchor = anchor || "t";
  3680. // fix display to visibility
  3681. this.fixDisplay();
  3682. // restore values after effect
  3683. var r = this.getFxRestore();
  3684. var b = this.getBox();
  3685. // fixed size for slide
  3686. this.setSize(b);
  3687. // wrap if needed
  3688. var wrap = this.fxWrap(r.pos, o, "hidden");
  3689. var st = this.dom.style;
  3690. st.visibility = "visible";
  3691. st.position = "absolute";
  3692. // clear out temp styles after slide and unwrap
  3693. var after = function(){
  3694. el.fxUnwrap(wrap, r.pos, o);
  3695. st.width = r.width;
  3696. st.height = r.height;
  3697. el.afterFx(o);
  3698. };
  3699. // time to calc the positions
  3700. var a, pt = {to: [b.x, b.y]}, bw = {to: b.width}, bh = {to: b.height};
  3701. switch(anchor.toLowerCase()){
  3702. case "t":
  3703. wrap.setSize(b.width, 0);
  3704. st.left = st.bottom = "0";
  3705. a = {height: bh};
  3706. break;
  3707. case "l":
  3708. wrap.setSize(0, b.height);
  3709. st.right = st.top = "0";
  3710. a = {width: bw};
  3711. break;
  3712. case "r":
  3713. wrap.setSize(0, b.height);
  3714. wrap.setX(b.right);
  3715. st.left = st.top = "0";
  3716. a = {width: bw, points: pt};
  3717. break;
  3718. case "b":
  3719. wrap.setSize(b.width, 0);
  3720. wrap.setY(b.bottom);
  3721. st.left = st.top = "0";
  3722. a = {height: bh, points: pt};
  3723. break;
  3724. case "tl":
  3725. wrap.setSize(0, 0);
  3726. st.right = st.bottom = "0";
  3727. a = {width: bw, height: bh};
  3728. break;
  3729. case "bl":
  3730. wrap.setSize(0, 0);
  3731. wrap.setY(b.y+b.height);
  3732. st.right = st.top = "0";
  3733. a = {width: bw, height: bh, points: pt};
  3734. break;
  3735. case "br":
  3736. wrap.setSize(0, 0);
  3737. wrap.setXY([b.right, b.bottom]);
  3738. st.left = st.top = "0";
  3739. a = {width: bw, height: bh, points: pt};
  3740. break;
  3741. case "tr":
  3742. wrap.setSize(0, 0);
  3743. wrap.setX(b.x+b.width);
  3744. st.left = st.bottom = "0";
  3745. a = {width: bw, height: bh, points: pt};
  3746. break;
  3747. }
  3748. this.dom.style.visibility = "visible";
  3749. wrap.show();
  3750. arguments.callee.anim = wrap.fxanim(a,
  3751. o,
  3752. 'motion',
  3753. .5,
  3754. 'easeOut', after);
  3755. });
  3756. return this;
  3757. },
  3758. slideOut : function(anchor, o){
  3759. var el = this.getFxEl();
  3760. o = o || {};
  3761. el.queueFx(o, function(){
  3762. anchor = anchor || "t";
  3763. // restore values after effect
  3764. var r = this.getFxRestore();
  3765. var b = this.getBox();
  3766. // fixed size for slide
  3767. this.setSize(b);
  3768. // wrap if needed
  3769. var wrap = this.fxWrap(r.pos, o, "visible");
  3770. var st = this.dom.style;
  3771. st.visibility = "visible";
  3772. st.position = "absolute";
  3773. wrap.setSize(b);
  3774. var after = function(){
  3775. if(o.useDisplay){
  3776. el.setDisplayed(false);
  3777. }else{
  3778. el.hide();
  3779. }
  3780. el.fxUnwrap(wrap, r.pos, o);
  3781. st.width = r.width;
  3782. st.height = r.height;
  3783. el.afterFx(o);
  3784. };
  3785. var a, zero = {to: 0};
  3786. switch(anchor.toLowerCase()){
  3787. case "t":
  3788. st.left = st.bottom = "0";
  3789. a = {height: zero};
  3790. break;
  3791. case "l":
  3792. st.right = st.top = "0";
  3793. a = {width: zero};
  3794. break;
  3795. case "r":
  3796. st.left = st.top = "0";
  3797. a = {width: zero, points: {to:[b.right, b.y]}};
  3798. break;
  3799. case "b":
  3800. st.left = st.top = "0";
  3801. a = {height: zero, points: {to:[b.x, b.bottom]}};
  3802. break;
  3803. case "tl":
  3804. st.right = st.bottom = "0";
  3805. a = {width: zero, height: zero};
  3806. break;
  3807. case "bl":
  3808. st.right = st.top = "0";
  3809. a = {width: zero, height: zero, points: {to:[b.x, b.bottom]}};
  3810. break;
  3811. case "br":
  3812. st.left = st.top = "0";
  3813. a = {width: zero, height: zero, points: {to:[b.x+b.width, b.bottom]}};
  3814. break;
  3815. case "tr":
  3816. st.left = st.bottom = "0";
  3817. a = {width: zero, height: zero, points: {to:[b.right, b.y]}};
  3818. break;
  3819. }
  3820. arguments.callee.anim = wrap.fxanim(a,
  3821. o,
  3822. 'motion',
  3823. .5,
  3824. "easeOut", after);
  3825. });
  3826. return this;
  3827. },
  3828. puff : function(o){
  3829. var el = this.getFxEl();
  3830. o = o || {};
  3831. el.queueFx(o, function(){
  3832. this.clearOpacity();
  3833. this.show();
  3834. // restore values after effect
  3835. var r = this.getFxRestore();
  3836. var st = this.dom.style;
  3837. var after = function(){
  3838. if(o.useDisplay){
  3839. el.setDisplayed(false);
  3840. }else{
  3841. el.hide();
  3842. }
  3843. el.clearOpacity();
  3844. el.setPositioning(r.pos);
  3845. st.width = r.width;
  3846. st.height = r.height;
  3847. st.fontSize = '';
  3848. el.afterFx(o);
  3849. };
  3850. var width = this.getWidth();
  3851. var height = this.getHeight();
  3852. arguments.callee.anim = this.fxanim({
  3853. width : {to: this.adjustWidth(width * 2)},
  3854. height : {to: this.adjustHeight(height * 2)},
  3855. points : {by: [-(width * .5), -(height * .5)]},
  3856. opacity : {to: 0},
  3857. fontSize: {to:200, unit: "%"}
  3858. },
  3859. o,
  3860. 'motion',
  3861. .5,
  3862. "easeOut", after);
  3863. });
  3864. return this;
  3865. },
  3866. switchOff : function(o){
  3867. var el = this.getFxEl();
  3868. o = o || {};
  3869. el.queueFx(o, function(){
  3870. this.clearOpacity();
  3871. this.clip();
  3872. // restore values after effect
  3873. var r = this.getFxRestore();
  3874. var st = this.dom.style;
  3875. var after = function(){
  3876. if(o.useDisplay){
  3877. el.setDisplayed(false);
  3878. }else{
  3879. el.hide();
  3880. }
  3881. el.clearOpacity();
  3882. el.setPositioning(r.pos);
  3883. st.width = r.width;
  3884. st.height = r.height;
  3885. el.afterFx(o);
  3886. };
  3887. this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
  3888. this.clearOpacity();
  3889. (function(){
  3890. this.fxanim({
  3891. height:{to:1},
  3892. points:{by:[0, this.getHeight() * .5]}
  3893. }, o, 'motion', 0.3, 'easeIn', after);
  3894. }).defer(100, this);
  3895. });
  3896. });
  3897. return this;
  3898. },
  3899. highlight : function(color, o){
  3900. var el = this.getFxEl();
  3901. o = o || {};
  3902. el.queueFx(o, function(){
  3903. color = color || "ffff9c";
  3904. var attr = o.attr || "backgroundColor";
  3905. this.clearOpacity();
  3906. this.show();
  3907. var origColor = this.getColor(attr);
  3908. var restoreColor = this.dom.style[attr];
  3909. var endColor = (o.endColor || origColor) || "ffffff";
  3910. var after = function(){
  3911. el.dom.style[attr] = restoreColor;
  3912. el.afterFx(o);
  3913. };
  3914. var a = {};
  3915. a[attr] = {from: color, to: endColor};
  3916. arguments.callee.anim = this.fxanim(a,
  3917. o,
  3918. 'color',
  3919. 1,
  3920. 'easeIn', after);
  3921. });
  3922. return this;
  3923. },
  3924. frame : function(color, count, o){
  3925. var el = this.getFxEl();
  3926. o = o || {};
  3927. el.queueFx(o, function(){
  3928. color = color || "#C3DAF9";
  3929. if(color.length == 6){
  3930. color = "#" + color;
  3931. }
  3932. count = count || 1;
  3933. var duration = o.duration || 1;
  3934. this.show();
  3935. var b = this.getBox();
  3936. var animFn = function(){
  3937. var proxy = Ext.getBody().createChild({
  3938. style:{
  3939. visbility:"hidden",
  3940. position:"absolute",
  3941. "z-index":"35000", // yee haw
  3942. border:"0px solid " + color
  3943. }
  3944. });
  3945. var scale = Ext.isBorderBox ? 2 : 1;
  3946. proxy.animate({
  3947. top:{from:b.y, to:b.y - 20},
  3948. left:{from:b.x, to:b.x - 20},
  3949. borderWidth:{from:0, to:10},
  3950. opacity:{from:1, to:0},
  3951. height:{from:b.height, to:(b.height + (20*scale))},
  3952. width:{from:b.width, to:(b.width + (20*scale))}
  3953. }, duration, function(){
  3954. proxy.remove();
  3955. if(--count > 0){
  3956. animFn();
  3957. }else{
  3958. el.afterFx(o);
  3959. }
  3960. });
  3961. };
  3962. animFn.call(this);
  3963. });
  3964. return this;
  3965. },
  3966. pause : function(seconds){
  3967. var el = this.getFxEl();
  3968. var o = {};
  3969. el.queueFx(o, function(){
  3970. setTimeout(function(){
  3971. el.afterFx(o);
  3972. }, seconds * 1000);
  3973. });
  3974. return this;
  3975. },
  3976. fadeIn : function(o){
  3977. var el = this.getFxEl();
  3978. o = o || {};
  3979. el.queueFx(o, function(){
  3980. this.setOpacity(0);
  3981. this.fixDisplay();
  3982. this.dom.style.visibility = 'visible';
  3983. var to = o.endOpacity || 1;
  3984. arguments.callee.anim = this.fxanim({opacity:{to:to}},
  3985. o, null, .5, "easeOut", function(){
  3986. if(to == 1){
  3987. this.clearOpacity();
  3988. }
  3989. el.afterFx(o);
  3990. });
  3991. });
  3992. return this;
  3993. },
  3994. fadeOut : function(o){
  3995. var el = this.getFxEl();
  3996. o = o || {};
  3997. el.queueFx(o, function(){
  3998. var to = o.endOpacity || 0;
  3999. arguments.callee.anim = this.fxanim({opacity:{to:to}},
  4000. o, null, .5, "easeOut", function(){
  4001. if(to === 0){
  4002. if(this.visibilityMode == Ext.Element.DISPLAY || o.useDisplay){
  4003. this.dom.style.display = "none";
  4004. }else{
  4005. this.dom.style.visibility = "hidden";
  4006. }
  4007. this.clearOpacity();
  4008. }
  4009. el.afterFx(o);
  4010. });
  4011. });
  4012. return this;
  4013. },
  4014. scale : function(w, h, o){
  4015. this.shift(Ext.apply({}, o, {
  4016. width: w,
  4017. height: h
  4018. }));
  4019. return this;
  4020. },
  4021. shift : function(o){
  4022. var el = this.getFxEl();
  4023. o = o || {};
  4024. el.queueFx(o, function(){
  4025. var a = {}, w = o.width, h = o.height, x = o.x, y = o.y, op = o.opacity;
  4026. if(w !== undefined){
  4027. a.width = {to: this.adjustWidth(w)};
  4028. }
  4029. if(h !== undefined){
  4030. a.height = {to: this.adjustHeight(h)};
  4031. }
  4032. if(o.left !== undefined){
  4033. a.left = {to: o.left};
  4034. }
  4035. if(o.top !== undefined){
  4036. a.top = {to: o.top};
  4037. }
  4038. if(o.right !== undefined){
  4039. a.right = {to: o.right};
  4040. }
  4041. if(o.bottom !== undefined){
  4042. a.bottom = {to: o.bottom};
  4043. }
  4044. if(x !== undefined || y !== undefined){
  4045. a.points = {to: [
  4046. x !== undefined ? x : this.getX(),
  4047. y !== undefined ? y : this.getY()
  4048. ]};
  4049. }
  4050. if(op !== undefined){
  4051. a.opacity = {to: op};
  4052. }
  4053. if(o.xy !== undefined){
  4054. a.points = {to: o.xy};
  4055. }
  4056. arguments.callee.anim = this.fxanim(a,
  4057. o, 'motion', .35, "easeOut", function(){
  4058. el.afterFx(o);
  4059. });
  4060. });
  4061. return this;
  4062. },
  4063. ghost : function(anchor, o){
  4064. var el = this.getFxEl();
  4065. o = o || {};
  4066. el.queueFx(o, function(){
  4067. anchor = anchor || "b";
  4068. // restore values after effect
  4069. var r = this.getFxRestore();
  4070. var w = this.getWidth(),
  4071. h = this.getHeight();
  4072. var st = this.dom.style;
  4073. var after = function(){
  4074. if(o.useDisplay){
  4075. el.setDisplayed(false);
  4076. }else{
  4077. el.hide();
  4078. }
  4079. el.clearOpacity();
  4080. el.setPositioning(r.pos);
  4081. st.width = r.width;
  4082. st.height = r.height;
  4083. el.afterFx(o);
  4084. };
  4085. var a = {opacity: {to: 0}, points: {}}, pt = a.points;
  4086. switch(anchor.toLowerCase()){
  4087. case "t":
  4088. pt.by = [0, -h];
  4089. break;
  4090. case "l":
  4091. pt.by = [-w, 0];
  4092. break;
  4093. case "r":
  4094. pt.by = [w, 0];
  4095. break;
  4096. case "b":
  4097. pt.by = [0, h];
  4098. break;
  4099. case "tl":
  4100. pt.by = [-w, -h];
  4101. break;
  4102. case "bl":
  4103. pt.by = [-w, h];
  4104. break;
  4105. case "br":
  4106. pt.by = [w, h];
  4107. break;
  4108. case "tr":
  4109. pt.by = [w, -h];
  4110. break;
  4111. }
  4112. arguments.callee.anim = this.fxanim(a,
  4113. o,
  4114. 'motion',
  4115. .5,
  4116. "easeOut", after);
  4117. });
  4118. return this;
  4119. },
  4120. syncFx : function(){
  4121. this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
  4122. block : false,
  4123. concurrent : true,
  4124. stopFx : false
  4125. });
  4126. return this;
  4127. },
  4128. sequenceFx : function(){
  4129. this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
  4130. block : false,
  4131. concurrent : false,
  4132. stopFx : false
  4133. });
  4134. return this;
  4135. },
  4136. nextFx : function(){
  4137. var ef = this.fxQueue[0];
  4138. if(ef){
  4139. ef.call(this);
  4140. }
  4141. },
  4142. hasActiveFx : function(){
  4143. return this.fxQueue && this.fxQueue[0];
  4144. },
  4145. stopFx : function(){
  4146. if(this.hasActiveFx()){
  4147. var cur = this.fxQueue[0];
  4148. if(cur && cur.anim && cur.anim.isAnimated()){
  4149. this.fxQueue = [cur]; // clear out others
  4150. cur.anim.stop(true);
  4151. }
  4152. }
  4153. return this;
  4154. },
  4155. beforeFx : function(o){
  4156. if(this.hasActiveFx() && !o.concurrent){
  4157. if(o.stopFx){
  4158. this.stopFx();
  4159. return true;
  4160. }
  4161. return false;
  4162. }
  4163. return true;
  4164. },
  4165. hasFxBlock : function(){
  4166. var q = this.fxQueue;
  4167. return q && q[0] && q[0].block;
  4168. },
  4169. queueFx : function(o, fn){
  4170. if(!this.fxQueue){
  4171. this.fxQueue = [];
  4172. }
  4173. if(!this.hasFxBlock()){
  4174. Ext.applyIf(o, this.fxDefaults);
  4175. if(!o.concurrent){
  4176. var run = this.beforeFx(o);
  4177. fn.block = o.block;
  4178. this.fxQueue.push(fn);
  4179. if(run){
  4180. this.nextFx();
  4181. }
  4182. }else{
  4183. fn.call(this);
  4184. }
  4185. }
  4186. return this;
  4187. },
  4188. fxWrap : function(pos, o, vis){
  4189. var wrap;
  4190. if(!o.wrap || !(wrap = Ext.get(o.wrap))){
  4191. var wrapXY;
  4192. if(o.fixPosition){
  4193. wrapXY = this.getXY();
  4194. }
  4195. var div = document.createElement("div");
  4196. div.style.visibility = vis;
  4197. wrap = Ext.get(this.dom.parentNode.insertBefore(div, this.dom));
  4198. wrap.setPositioning(pos);
  4199. if(wrap.getStyle("position") == "static"){
  4200. wrap.position("relative");
  4201. }
  4202. this.clearPositioning('auto');
  4203. wrap.clip();
  4204. wrap.dom.appendChild(this.dom);
  4205. if(wrapXY){
  4206. wrap.setXY(wrapXY);
  4207. }
  4208. }
  4209. return wrap;
  4210. },
  4211. fxUnwrap : function(wrap, pos, o){
  4212. this.clearPositioning();
  4213. this.setPositioning(pos);
  4214. if(!o.wrap){
  4215. wrap.dom.parentNode.insertBefore(this.dom, wrap.dom);
  4216. wrap.remove();
  4217. }
  4218. },
  4219. getFxRestore : function(){
  4220. var st = this.dom.style;
  4221. return {pos: this.getPositioning(), width: st.width, height : st.height};
  4222. },
  4223. afterFx : function(o){
  4224. if(o.afterStyle){
  4225. this.applyStyles(o.afterStyle);
  4226. }
  4227. if(o.afterCls){
  4228. this.addClass(o.afterCls);
  4229. }
  4230. if(o.remove === true){
  4231. this.remove();
  4232. }
  4233. Ext.callback(o.callback, o.scope, [this]);
  4234. if(!o.concurrent){
  4235. this.fxQueue.shift();
  4236. this.nextFx();
  4237. }
  4238. },
  4239. getFxEl : function(){ // support for composite element fx
  4240. return Ext.get(this.dom);
  4241. },
  4242. fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
  4243. animType = animType || 'run';
  4244. opt = opt || {};
  4245. var anim = Ext.lib.Anim[animType](
  4246. this.dom, args,
  4247. (opt.duration || defaultDur) || .35,
  4248. (opt.easing || defaultEase) || 'easeOut',
  4249. function(){
  4250. Ext.callback(cb, this);
  4251. },
  4252. this
  4253. );
  4254. opt.anim = anim;
  4255. return anim;
  4256. }
  4257. };
  4258. // backwords compat
  4259. Ext.Fx.resize = Ext.Fx.scale;
  4260. //When included, Ext.Fx is automatically applied to Element so that all basic
  4261. //effects are available directly via the Element API
  4262. Ext.apply(Ext.Element.prototype, Ext.Fx);
  4263. Ext.CompositeElement = function(els){
  4264. this.elements = [];
  4265. this.addElements(els);
  4266. };
  4267. Ext.CompositeElement.prototype = {
  4268. isComposite: true,
  4269. addElements : function(els){
  4270. if(!els) return this;
  4271. if(typeof els == "string"){
  4272. els = Ext.Element.selectorFunction(els);
  4273. }
  4274. var yels = this.elements;
  4275. var index = yels.length-1;
  4276. for(var i = 0, len = els.length; i < len; i++) {
  4277. yels[++index] = Ext.get(els[i]);
  4278. }
  4279. return this;
  4280. },
  4281. fill : function(els){
  4282. this.elements = [];
  4283. this.add(els);
  4284. return this;
  4285. },
  4286. filter : function(selector){
  4287. var els = [];
  4288. this.each(function(el){
  4289. if(el.is(selector)){
  4290. els[els.length] = el.dom;
  4291. }
  4292. });
  4293. this.fill(els);
  4294. return this;
  4295. },
  4296. invoke : function(fn, args){
  4297. var els = this.elements;
  4298. for(var i = 0, len = els.length; i < len; i++) {
  4299. Ext.Element.prototype[fn].apply(els[i], args);
  4300. }
  4301. return this;
  4302. },
  4303. add : function(els){
  4304. if(typeof els == "string"){
  4305. this.addElements(Ext.Element.selectorFunction(els));
  4306. }else if(els.length !== undefined){
  4307. this.addElements(els);
  4308. }else{
  4309. this.addElements([els]);
  4310. }
  4311. return this;
  4312. },
  4313. each : function(fn, scope){
  4314. var els = this.elements;
  4315. for(var i = 0, len = els.length; i < len; i++){
  4316. if(fn.call(scope || els[i], els[i], this, i) === false) {
  4317. break;
  4318. }
  4319. }
  4320. return this;
  4321. },
  4322. item : function(index){
  4323. return this.elements[index] || null;
  4324. },
  4325. first : function(){
  4326. return this.item(0);
  4327. },
  4328. last : function(){
  4329. return this.item(this.elements.length-1);
  4330. },
  4331. getCount : function(){
  4332. return this.elements.length;
  4333. },
  4334. contains : function(el){
  4335. return this.indexOf(el) !== -1;
  4336. },
  4337. indexOf : function(el){
  4338. return this.elements.indexOf(Ext.get(el));
  4339. },
  4340. removeElement : function(el, removeDom){
  4341. if(Ext.isArray(el)){
  4342. for(var i = 0, len = el.length; i < len; i++){
  4343. this.removeElement(el[i]);
  4344. }
  4345. return this;
  4346. }
  4347. var index = typeof el == 'number' ? el : this.indexOf(el);
  4348. if(index !== -1 && this.elements[index]){
  4349. if(removeDom){
  4350. var d = this.elements[index];
  4351. if(d.dom){
  4352. d.remove();
  4353. }else{
  4354. Ext.removeNode(d);
  4355. }
  4356. }
  4357. this.elements.splice(index, 1);
  4358. }
  4359. return this;
  4360. },
  4361. replaceElement : function(el, replacement, domReplace){
  4362. var index = typeof el == 'number' ? el : this.indexOf(el);
  4363. if(index !== -1){
  4364. if(domReplace){
  4365. this.elements[index].replaceWith(replacement);
  4366. }else{
  4367. this.elements.splice(index, 1, Ext.get(replacement))
  4368. }
  4369. }
  4370. return this;
  4371. },
  4372. clear : function(){
  4373. this.elements = [];
  4374. }
  4375. };
  4376. (function(){
  4377. Ext.CompositeElement.createCall = function(proto, fnName){
  4378. if(!proto[fnName]){
  4379. proto[fnName] = function(){
  4380. return this.invoke(fnName, arguments);
  4381. };
  4382. }
  4383. };
  4384. for(var fnName in Ext.Element.prototype){
  4385. if(typeof Ext.Element.prototype[fnName] == "function"){
  4386. Ext.CompositeElement.createCall(Ext.CompositeElement.prototype, fnName);
  4387. }
  4388. };
  4389. })();
  4390. Ext.CompositeElementLite = function(els){
  4391. Ext.CompositeElementLite.superclass.constructor.call(this, els);
  4392. this.el = new Ext.Element.Flyweight();
  4393. };
  4394. Ext.extend(Ext.CompositeElementLite, Ext.CompositeElement, {
  4395. addElements : function(els){
  4396. if(els){
  4397. if(Ext.isArray(els)){
  4398. this.elements = this.elements.concat(els);
  4399. }else{
  4400. var yels = this.elements;
  4401. var index = yels.length-1;
  4402. for(var i = 0, len = els.length; i < len; i++) {
  4403. yels[++index] = els[i];
  4404. }
  4405. }
  4406. }
  4407. return this;
  4408. },
  4409. invoke : function(fn, args){
  4410. var els = this.elements;
  4411. var el = this.el;
  4412. for(var i = 0, len = els.length; i < len; i++) {
  4413. el.dom = els[i];
  4414. Ext.Element.prototype[fn].apply(el, args);
  4415. }
  4416. return this;
  4417. },
  4418. item : function(index){
  4419. if(!this.elements[index]){
  4420. return null;
  4421. }
  4422. this.el.dom = this.elements[index];
  4423. return this.el;
  4424. },
  4425. // fixes scope with flyweight
  4426. addListener : function(eventName, handler, scope, opt){
  4427. var els = this.elements;
  4428. for(var i = 0, len = els.length; i < len; i++) {
  4429. Ext.EventManager.on(els[i], eventName, handler, scope || els[i], opt);
  4430. }
  4431. return this;
  4432. },
  4433. each : function(fn, scope){
  4434. var els = this.elements;
  4435. var el = this.el;
  4436. for(var i = 0, len = els.length; i < len; i++){
  4437. el.dom = els[i];
  4438. if(fn.call(scope || el, el, this, i) === false){
  4439. break;
  4440. }
  4441. }
  4442. return this;
  4443. },
  4444. indexOf : function(el){
  4445. return this.elements.indexOf(Ext.getDom(el));
  4446. },
  4447. replaceElement : function(el, replacement, domReplace){
  4448. var index = typeof el == 'number' ? el : this.indexOf(el);
  4449. if(index !== -1){
  4450. replacement = Ext.getDom(replacement);
  4451. if(domReplace){
  4452. var d = this.elements[index];
  4453. d.parentNode.insertBefore(replacement, d);
  4454. Ext.removeNode(d);
  4455. }
  4456. this.elements.splice(index, 1, replacement);
  4457. }
  4458. return this;
  4459. }
  4460. });
  4461. Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
  4462. if(Ext.DomQuery){
  4463. Ext.Element.selectorFunction = Ext.DomQuery.select;
  4464. }
  4465. Ext.Element.select = function(selector, unique, root){
  4466. var els;
  4467. if(typeof selector == "string"){
  4468. els = Ext.Element.selectorFunction(selector, root);
  4469. }else if(selector.length !== undefined){
  4470. els = selector;
  4471. }else{
  4472. throw "Invalid selector";
  4473. }
  4474. if(unique === true){
  4475. return new Ext.CompositeElement(els);
  4476. }else{
  4477. return new Ext.CompositeElementLite(els);
  4478. }
  4479. };
  4480. Ext.select = Ext.Element.select;
  4481. Ext.data.Connection = function(config){
  4482. Ext.apply(this, config);
  4483. this.addEvents(
  4484. "beforerequest",
  4485. "requestcomplete",
  4486. "requestexception"
  4487. );
  4488. Ext.data.Connection.superclass.constructor.call(this);
  4489. };
  4490. Ext.extend(Ext.data.Connection, Ext.util.Observable, {
  4491. timeout : 30000,
  4492. autoAbort:false,
  4493. disableCaching: true,
  4494. disableCachingParam: '_dc',
  4495. request : function(o){
  4496. if(this.fireEvent("beforerequest", this, o) !== false){
  4497. var p = o.params;
  4498. if(typeof p == "function"){
  4499. p = p.call(o.scope||window, o);
  4500. }
  4501. if(typeof p == "object"){
  4502. p = Ext.urlEncode(p);
  4503. }
  4504. if(this.extraParams){
  4505. var extras = Ext.urlEncode(this.extraParams);
  4506. p = p ? (p + '&' + extras) : extras;
  4507. }
  4508. var url = o.url || this.url;
  4509. if(typeof url == 'function'){
  4510. url = url.call(o.scope||window, o);
  4511. }
  4512. if(o.form){
  4513. var form = Ext.getDom(o.form);
  4514. url = url || form.action;
  4515. var enctype = form.getAttribute("enctype");
  4516. if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
  4517. return this.doFormUpload(o, p, url);
  4518. }
  4519. var f = Ext.lib.Ajax.serializeForm(form);
  4520. p = p ? (p + '&' + f) : f;
  4521. }
  4522. var hs = o.headers;
  4523. if(this.defaultHeaders){
  4524. hs = Ext.apply(hs || {}, this.defaultHeaders);
  4525. if(!o.headers){
  4526. o.headers = hs;
  4527. }
  4528. }
  4529. var cb = {
  4530. success: this.handleResponse,
  4531. failure: this.handleFailure,
  4532. scope: this,
  4533. argument: {options: o},
  4534. timeout : o.timeout || this.timeout
  4535. };
  4536. var method = o.method||this.method||((p || o.xmlData || o.jsonData) ? "POST" : "GET");
  4537. if(method == 'GET' && (this.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
  4538. var dcp = o.disableCachingParam || this.disableCachingParam;
  4539. url += (url.indexOf('?') != -1 ? '&' : '?') + dcp + '=' + (new Date().getTime());
  4540. }
  4541. if(typeof o.autoAbort == 'boolean'){ // options gets top priority
  4542. if(o.autoAbort){
  4543. this.abort();
  4544. }
  4545. }else if(this.autoAbort !== false){
  4546. this.abort();
  4547. }
  4548. if((method == 'GET' || o.xmlData || o.jsonData) && p){
  4549. url += (url.indexOf('?') != -1 ? '&' : '?') + p;
  4550. p = '';
  4551. }
  4552. this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
  4553. return this.transId;
  4554. }else{
  4555. Ext.callback(o.callback, o.scope, [o, null, null]);
  4556. return null;
  4557. }
  4558. },
  4559. isLoading : function(transId){
  4560. if(transId){
  4561. return Ext.lib.Ajax.isCallInProgress(transId);
  4562. }else{
  4563. return this.transId ? true : false;
  4564. }
  4565. },
  4566. abort : function(transId){
  4567. if(transId || this.isLoading()){
  4568. Ext.lib.Ajax.abort(transId || this.transId);
  4569. }
  4570. },
  4571. // private
  4572. handleResponse : function(response){
  4573. this.transId = false;
  4574. var options = response.argument.options;
  4575. response.argument = options ? options.argument : null;
  4576. this.fireEvent("requestcomplete", this, response, options);
  4577. Ext.callback(options.success, options.scope, [response, options]);
  4578. Ext.callback(options.callback, options.scope, [options, true, response]);
  4579. },
  4580. // private
  4581. handleFailure : function(response, e){
  4582. this.transId = false;
  4583. var options = response.argument.options;
  4584. response.argument = options ? options.argument : null;
  4585. this.fireEvent("requestexception", this, response, options, e);
  4586. Ext.callback(options.failure, options.scope, [response, options]);
  4587. Ext.callback(options.callback, options.scope, [options, false, response]);
  4588. },
  4589. // private
  4590. doFormUpload : function(o, ps, url){
  4591. var id = Ext.id();
  4592. var frame = document.createElement('iframe');
  4593. frame.id = id;
  4594. frame.name = id;
  4595. frame.className = 'x-hidden';
  4596. if(Ext.isIE){
  4597. frame.src = Ext.SSL_SECURE_URL;
  4598. }
  4599. document.body.appendChild(frame);
  4600. if(Ext.isIE){
  4601. document.frames[id].name = id;
  4602. }
  4603. var form = Ext.getDom(o.form);
  4604. form.target = id;
  4605. form.method = 'POST';
  4606. form.enctype = form.encoding = 'multipart/form-data';
  4607. if(url){
  4608. form.action = url;
  4609. }
  4610. var hiddens, hd;
  4611. if(ps){ // add dynamic params
  4612. hiddens = [];
  4613. ps = Ext.urlDecode(ps, false);
  4614. for(var k in ps){
  4615. if(ps.hasOwnProperty(k)){
  4616. hd = document.createElement('input');
  4617. hd.type = 'hidden';
  4618. hd.name = k;
  4619. hd.value = ps[k];
  4620. form.appendChild(hd);
  4621. hiddens.push(hd);
  4622. }
  4623. }
  4624. }
  4625. function cb(){
  4626. var r = { // bogus response object
  4627. responseText : '',
  4628. responseXML : null
  4629. };
  4630. r.argument = o ? o.argument : null;
  4631. try { //
  4632. var doc;
  4633. if(Ext.isIE){
  4634. doc = frame.contentWindow.document;
  4635. }else {
  4636. doc = (frame.contentDocument || window.frames[id].document);
  4637. }
  4638. if(doc && doc.body){
  4639. r.responseText = doc.body.innerHTML;
  4640. }
  4641. if(doc && doc.XMLDocument){
  4642. r.responseXML = doc.XMLDocument;
  4643. }else {
  4644. r.responseXML = doc;
  4645. }
  4646. }
  4647. catch(e) {
  4648. // ignore
  4649. }
  4650. Ext.EventManager.removeListener(frame, 'load', cb, this);
  4651. this.fireEvent("requestcomplete", this, r, o);
  4652. Ext.callback(o.success, o.scope, [r, o]);
  4653. Ext.callback(o.callback, o.scope, [o, true, r]);
  4654. setTimeout(function(){Ext.removeNode(frame);}, 100);
  4655. }
  4656. Ext.EventManager.on(frame, 'load', cb, this);
  4657. form.submit();
  4658. if(hiddens){ // remove dynamic params
  4659. for(var i = 0, len = hiddens.length; i < len; i++){
  4660. Ext.removeNode(hiddens[i]);
  4661. }
  4662. }
  4663. }
  4664. });
  4665. Ext.Ajax = new Ext.data.Connection({
  4666. autoAbort : false,
  4667. serializeForm : function(form){
  4668. return Ext.lib.Ajax.serializeForm(form);
  4669. }
  4670. });
  4671. Ext.Updater = Ext.extend(Ext.util.Observable, {
  4672. constructor: function(el, forceNew){
  4673. el = Ext.get(el);
  4674. if(!forceNew && el.updateManager){
  4675. return el.updateManager;
  4676. }
  4677. this.el = el;
  4678. this.defaultUrl = null;
  4679. this.addEvents(
  4680. "beforeupdate",
  4681. "update",
  4682. "failure"
  4683. );
  4684. var d = Ext.Updater.defaults;
  4685. this.sslBlankUrl = d.sslBlankUrl;
  4686. this.disableCaching = d.disableCaching;
  4687. this.indicatorText = d.indicatorText;
  4688. this.showLoadIndicator = d.showLoadIndicator;
  4689. this.timeout = d.timeout;
  4690. this.loadScripts = d.loadScripts;
  4691. this.transaction = null;
  4692. this.refreshDelegate = this.refresh.createDelegate(this);
  4693. this.updateDelegate = this.update.createDelegate(this);
  4694. this.formUpdateDelegate = this.formUpdate.createDelegate(this);
  4695. if(!this.renderer){
  4696. this.renderer = this.getDefaultRenderer();
  4697. }
  4698. Ext.Updater.superclass.constructor.call(this);
  4699. },
  4700. getDefaultRenderer: function() {
  4701. return new Ext.Updater.BasicRenderer();
  4702. },
  4703. getEl : function(){
  4704. return this.el;
  4705. },
  4706. update : function(url, params, callback, discardUrl){
  4707. if(this.fireEvent("beforeupdate", this.el, url, params) !== false){
  4708. var cfg, callerScope;
  4709. if(typeof url == "object"){ // must be config object
  4710. cfg = url;
  4711. url = cfg.url;
  4712. params = params || cfg.params;
  4713. callback = callback || cfg.callback;
  4714. discardUrl = discardUrl || cfg.discardUrl;
  4715. callerScope = cfg.scope;
  4716. if(typeof cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
  4717. if(typeof cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
  4718. if(typeof cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
  4719. if(typeof cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
  4720. }
  4721. this.showLoading();
  4722. if(!discardUrl){
  4723. this.defaultUrl = url;
  4724. }
  4725. if(typeof url == "function"){
  4726. url = url.call(this);
  4727. }
  4728. var o = Ext.apply({}, {
  4729. url : url,
  4730. params: (typeof params == "function" && callerScope) ? params.createDelegate(callerScope) : params,
  4731. success: this.processSuccess,
  4732. failure: this.processFailure,
  4733. scope: this,
  4734. callback: undefined,
  4735. timeout: (this.timeout*1000),
  4736. disableCaching: this.disableCaching,
  4737. argument: {
  4738. "options": cfg,
  4739. "url": url,
  4740. "form": null,
  4741. "callback": callback,
  4742. "scope": callerScope || window,
  4743. "params": params
  4744. }
  4745. }, cfg);
  4746. this.transaction = Ext.Ajax.request(o);
  4747. }
  4748. },
  4749. formUpdate : function(form, url, reset, callback){
  4750. if(this.fireEvent("beforeupdate", this.el, form, url) !== false){
  4751. if(typeof url == "function"){
  4752. url = url.call(this);
  4753. }
  4754. form = Ext.getDom(form)
  4755. this.transaction = Ext.Ajax.request({
  4756. form: form,
  4757. url:url,
  4758. success: this.processSuccess,
  4759. failure: this.processFailure,
  4760. scope: this,
  4761. timeout: (this.timeout*1000),
  4762. argument: {
  4763. "url": url,
  4764. "form": form,
  4765. "callback": callback,
  4766. "reset": reset
  4767. }
  4768. });
  4769. this.showLoading.defer(1, this);
  4770. }
  4771. },
  4772. refresh : function(callback){
  4773. if(this.defaultUrl == null){
  4774. return;
  4775. }
  4776. this.update(this.defaultUrl, null, callback, true);
  4777. },
  4778. startAutoRefresh : function(interval, url, params, callback, refreshNow){
  4779. if(refreshNow){
  4780. this.update(url || this.defaultUrl, params, callback, true);
  4781. }
  4782. if(this.autoRefreshProcId){
  4783. clearInterval(this.autoRefreshProcId);
  4784. }
  4785. this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [url || this.defaultUrl, params, callback, true]), interval*1000);
  4786. },
  4787. stopAutoRefresh : function(){
  4788. if(this.autoRefreshProcId){
  4789. clearInterval(this.autoRefreshProcId);
  4790. delete this.autoRefreshProcId;
  4791. }
  4792. },
  4793. isAutoRefreshing : function(){
  4794. return this.autoRefreshProcId ? true : false;
  4795. },
  4796. showLoading : function(){
  4797. if(this.showLoadIndicator){
  4798. this.el.update(this.indicatorText);
  4799. }
  4800. },
  4801. // private
  4802. processSuccess : function(response){
  4803. this.transaction = null;
  4804. if(response.argument.form && response.argument.reset){
  4805. try{ // put in try/catch since some older FF releases had problems with this
  4806. response.argument.form.reset();
  4807. }catch(e){}
  4808. }
  4809. if(this.loadScripts){
  4810. this.renderer.render(this.el, response, this,
  4811. this.updateComplete.createDelegate(this, [response]));
  4812. }else{
  4813. this.renderer.render(this.el, response, this);
  4814. this.updateComplete(response);
  4815. }
  4816. },
  4817. // private
  4818. updateComplete : function(response){
  4819. this.fireEvent("update", this.el, response);
  4820. if(typeof response.argument.callback == "function"){
  4821. response.argument.callback.call(response.argument.scope, this.el, true, response, response.argument.options);
  4822. }
  4823. },
  4824. // private
  4825. processFailure : function(response){
  4826. this.transaction = null;
  4827. this.fireEvent("failure", this.el, response);
  4828. if(typeof response.argument.callback == "function"){
  4829. response.argument.callback.call(response.argument.scope, this.el, false, response, response.argument.options);
  4830. }
  4831. },
  4832. setRenderer : function(renderer){
  4833. this.renderer = renderer;
  4834. },
  4835. getRenderer : function(){
  4836. return this.renderer;
  4837. },
  4838. setDefaultUrl : function(defaultUrl){
  4839. this.defaultUrl = defaultUrl;
  4840. },
  4841. abort : function(){
  4842. if(this.transaction){
  4843. Ext.Ajax.abort(this.transaction);
  4844. }
  4845. },
  4846. isUpdating : function(){
  4847. if(this.transaction){
  4848. return Ext.Ajax.isLoading(this.transaction);
  4849. }
  4850. return false;
  4851. }
  4852. });
  4853. Ext.Updater.defaults = {
  4854. timeout : 30,
  4855. loadScripts : false,
  4856. sslBlankUrl : (Ext.SSL_SECURE_URL || "javascript:false"),
  4857. disableCaching : false,
  4858. showLoadIndicator : true,
  4859. indicatorText : '<div class="loading-indicator">Loading...</div>'
  4860. };
  4861. Ext.Updater.updateElement = function(el, url, params, options){
  4862. var um = Ext.get(el).getUpdater();
  4863. Ext.apply(um, options);
  4864. um.update(url, params, options ? options.callback : null);
  4865. };
  4866. Ext.Updater.BasicRenderer = function(){};
  4867. Ext.Updater.BasicRenderer.prototype = {
  4868. render : function(el, response, updateManager, callback){
  4869. el.update(response.responseText, updateManager.loadScripts, callback);
  4870. }
  4871. };
  4872. Ext.UpdateManager = Ext.Updater;
  4873. Ext.util.DelayedTask = function(fn, scope, args){
  4874. var id = null, d, t;
  4875. var call = function(){
  4876. var now = new Date().getTime();
  4877. if(now - t >= d){
  4878. clearInterval(id);
  4879. id = null;
  4880. fn.apply(scope, args || []);
  4881. }
  4882. };
  4883. this.delay = function(delay, newFn, newScope, newArgs){
  4884. if(id && delay != d){
  4885. this.cancel();
  4886. }
  4887. d = delay;
  4888. t = new Date().getTime();
  4889. fn = newFn || fn;
  4890. scope = newScope || scope;
  4891. args = newArgs || args;
  4892. if(!id){
  4893. id = setInterval(call, d);
  4894. }
  4895. };
  4896. this.cancel = function(){
  4897. if(id){
  4898. clearInterval(id);
  4899. id = null;
  4900. }
  4901. };
  4902. };