PageRenderTime 57ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/WebContent/js/ext-2.0/source/adapter/ext-base.js

http://groovywebchat.googlecode.com/
JavaScript | 2145 lines | 1641 code | 490 blank | 14 comment | 418 complexity | aa3a2d0991f7133ea6ebd0bee944d999 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Ext JS Library 2.0.2
  3. * Copyright(c) 2006-2008, Ext JS, LLC.
  4. * licensing@extjs.com
  5. *
  6. * http://extjs.com/license
  7. */
  8. (function() {
  9. var libFlyweight;
  10. Ext.lib.Dom = {
  11. getViewWidth : function(full) {
  12. return full ? this.getDocumentWidth() : this.getViewportWidth();
  13. },
  14. getViewHeight : function(full) {
  15. return full ? this.getDocumentHeight() : this.getViewportHeight();
  16. },
  17. getDocumentHeight: function() {
  18. var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
  19. return Math.max(scrollHeight, this.getViewportHeight());
  20. },
  21. getDocumentWidth: function() {
  22. var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
  23. return Math.max(scrollWidth, this.getViewportWidth());
  24. },
  25. getViewportHeight: function(){
  26. if(Ext.isIE){
  27. return Ext.isStrict ? document.documentElement.clientHeight :
  28. document.body.clientHeight;
  29. }else{
  30. return self.innerHeight;
  31. }
  32. },
  33. getViewportWidth: function() {
  34. if(Ext.isIE){
  35. return Ext.isStrict ? document.documentElement.clientWidth :
  36. document.body.clientWidth;
  37. }else{
  38. return self.innerWidth;
  39. }
  40. },
  41. isAncestor : function(p, c) {
  42. p = Ext.getDom(p);
  43. c = Ext.getDom(c);
  44. if (!p || !c) {
  45. return false;
  46. }
  47. if (p.contains && !Ext.isSafari) {
  48. return p.contains(c);
  49. } else if (p.compareDocumentPosition) {
  50. return !!(p.compareDocumentPosition(c) & 16);
  51. } else {
  52. var parent = c.parentNode;
  53. while (parent) {
  54. if (parent == p) {
  55. return true;
  56. }
  57. else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
  58. return false;
  59. }
  60. parent = parent.parentNode;
  61. }
  62. return false;
  63. }
  64. },
  65. getRegion : function(el) {
  66. return Ext.lib.Region.getRegion(el);
  67. },
  68. getY : function(el) {
  69. return this.getXY(el)[1];
  70. },
  71. getX : function(el) {
  72. return this.getXY(el)[0];
  73. },
  74. getXY : function(el) {
  75. var p, pe, b, scroll, bd = (document.body || document.documentElement);
  76. el = Ext.getDom(el);
  77. if(el == bd){
  78. return [0, 0];
  79. }
  80. if (el.getBoundingClientRect) {
  81. b = el.getBoundingClientRect();
  82. scroll = fly(document).getScroll();
  83. return [b.left + scroll.left, b.top + scroll.top];
  84. }
  85. var x = 0, y = 0;
  86. p = el;
  87. var hasAbsolute = fly(el).getStyle("position") == "absolute";
  88. while (p) {
  89. x += p.offsetLeft;
  90. y += p.offsetTop;
  91. if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
  92. hasAbsolute = true;
  93. }
  94. if (Ext.isGecko) {
  95. pe = fly(p);
  96. var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
  97. var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
  98. x += bl;
  99. y += bt;
  100. if (p != el && pe.getStyle('overflow') != 'visible') {
  101. x += bl;
  102. y += bt;
  103. }
  104. }
  105. p = p.offsetParent;
  106. }
  107. if (Ext.isSafari && hasAbsolute) {
  108. x -= bd.offsetLeft;
  109. y -= bd.offsetTop;
  110. }
  111. if (Ext.isGecko && !hasAbsolute) {
  112. var dbd = fly(bd);
  113. x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
  114. y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
  115. }
  116. p = el.parentNode;
  117. while (p && p != bd) {
  118. if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
  119. x -= p.scrollLeft;
  120. y -= p.scrollTop;
  121. }
  122. p = p.parentNode;
  123. }
  124. return [x, y];
  125. },
  126. setXY : function(el, xy) {
  127. el = Ext.fly(el, '_setXY');
  128. el.position();
  129. var pts = el.translatePoints(xy);
  130. if (xy[0] !== false) {
  131. el.dom.style.left = pts.left + "px";
  132. }
  133. if (xy[1] !== false) {
  134. el.dom.style.top = pts.top + "px";
  135. }
  136. },
  137. setX : function(el, x) {
  138. this.setXY(el, [x, false]);
  139. },
  140. setY : function(el, y) {
  141. this.setXY(el, [false, y]);
  142. }
  143. };
  144. /*
  145. * Portions of this file are based on pieces of Yahoo User Interface Library
  146. * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
  147. * YUI licensed under the BSD License:
  148. * http://developer.yahoo.net/yui/license.txt
  149. */
  150. Ext.lib.Event = function() {
  151. var loadComplete = false;
  152. var listeners = [];
  153. var unloadListeners = [];
  154. var retryCount = 0;
  155. var onAvailStack = [];
  156. var counter = 0;
  157. var lastError = null;
  158. return {
  159. POLL_RETRYS: 200,
  160. POLL_INTERVAL: 20,
  161. EL: 0,
  162. TYPE: 1,
  163. FN: 2,
  164. WFN: 3,
  165. OBJ: 3,
  166. ADJ_SCOPE: 4,
  167. _interval: null,
  168. startInterval: function() {
  169. if (!this._interval) {
  170. var self = this;
  171. var callback = function() {
  172. self._tryPreloadAttach();
  173. };
  174. this._interval = setInterval(callback, this.POLL_INTERVAL);
  175. }
  176. },
  177. onAvailable: function(p_id, p_fn, p_obj, p_override) {
  178. onAvailStack.push({ id: p_id,
  179. fn: p_fn,
  180. obj: p_obj,
  181. override: p_override,
  182. checkReady: false });
  183. retryCount = this.POLL_RETRYS;
  184. this.startInterval();
  185. },
  186. addListener: function(el, eventName, fn) {
  187. el = Ext.getDom(el);
  188. if (!el || !fn) {
  189. return false;
  190. }
  191. if ("unload" == eventName) {
  192. unloadListeners[unloadListeners.length] =
  193. [el, eventName, fn];
  194. return true;
  195. }
  196. // prevent unload errors with simple check
  197. var wrappedFn = function(e) {
  198. return typeof Ext != 'undefined' ? fn(Ext.lib.Event.getEvent(e)) : false;
  199. };
  200. var li = [el, eventName, fn, wrappedFn];
  201. var index = listeners.length;
  202. listeners[index] = li;
  203. this.doAdd(el, eventName, wrappedFn, false);
  204. return true;
  205. },
  206. removeListener: function(el, eventName, fn) {
  207. var i, len;
  208. el = Ext.getDom(el);
  209. if(!fn) {
  210. return this.purgeElement(el, false, eventName);
  211. }
  212. if ("unload" == eventName) {
  213. for (i = 0,len = unloadListeners.length; i < len; i++) {
  214. var li = unloadListeners[i];
  215. if (li &&
  216. li[0] == el &&
  217. li[1] == eventName &&
  218. li[2] == fn) {
  219. unloadListeners.splice(i, 1);
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. var cacheItem = null;
  226. var index = arguments[3];
  227. if ("undefined" == typeof index) {
  228. index = this._getCacheIndex(el, eventName, fn);
  229. }
  230. if (index >= 0) {
  231. cacheItem = listeners[index];
  232. }
  233. if (!el || !cacheItem) {
  234. return false;
  235. }
  236. this.doRemove(el, eventName, cacheItem[this.WFN], false);
  237. delete listeners[index][this.WFN];
  238. delete listeners[index][this.FN];
  239. listeners.splice(index, 1);
  240. return true;
  241. },
  242. getTarget: function(ev, resolveTextNode) {
  243. ev = ev.browserEvent || ev;
  244. var t = ev.target || ev.srcElement;
  245. return this.resolveTextNode(t);
  246. },
  247. resolveTextNode: function(node) {
  248. if (Ext.isSafari && node && 3 == node.nodeType) {
  249. return node.parentNode;
  250. } else {
  251. return node;
  252. }
  253. },
  254. getPageX: function(ev) {
  255. ev = ev.browserEvent || ev;
  256. var x = ev.pageX;
  257. if (!x && 0 !== x) {
  258. x = ev.clientX || 0;
  259. if (Ext.isIE) {
  260. x += this.getScroll()[1];
  261. }
  262. }
  263. return x;
  264. },
  265. getPageY: function(ev) {
  266. ev = ev.browserEvent || ev;
  267. var y = ev.pageY;
  268. if (!y && 0 !== y) {
  269. y = ev.clientY || 0;
  270. if (Ext.isIE) {
  271. y += this.getScroll()[0];
  272. }
  273. }
  274. return y;
  275. },
  276. getXY: function(ev) {
  277. ev = ev.browserEvent || ev;
  278. return [this.getPageX(ev), this.getPageY(ev)];
  279. },
  280. getRelatedTarget: function(ev) {
  281. ev = ev.browserEvent || ev;
  282. var t = ev.relatedTarget;
  283. if (!t) {
  284. if (ev.type == "mouseout") {
  285. t = ev.toElement;
  286. } else if (ev.type == "mouseover") {
  287. t = ev.fromElement;
  288. }
  289. }
  290. return this.resolveTextNode(t);
  291. },
  292. getTime: function(ev) {
  293. ev = ev.browserEvent || ev;
  294. if (!ev.time) {
  295. var t = new Date().getTime();
  296. try {
  297. ev.time = t;
  298. } catch(ex) {
  299. this.lastError = ex;
  300. return t;
  301. }
  302. }
  303. return ev.time;
  304. },
  305. stopEvent: function(ev) {
  306. this.stopPropagation(ev);
  307. this.preventDefault(ev);
  308. },
  309. stopPropagation: function(ev) {
  310. ev = ev.browserEvent || ev;
  311. if (ev.stopPropagation) {
  312. ev.stopPropagation();
  313. } else {
  314. ev.cancelBubble = true;
  315. }
  316. },
  317. preventDefault: function(ev) {
  318. ev = ev.browserEvent || ev;
  319. if(ev.preventDefault) {
  320. ev.preventDefault();
  321. } else {
  322. ev.returnValue = false;
  323. }
  324. },
  325. getEvent: function(e) {
  326. var ev = e || window.event;
  327. if (!ev) {
  328. var c = this.getEvent.caller;
  329. while (c) {
  330. ev = c.arguments[0];
  331. if (ev && Event == ev.constructor) {
  332. break;
  333. }
  334. c = c.caller;
  335. }
  336. }
  337. return ev;
  338. },
  339. getCharCode: function(ev) {
  340. ev = ev.browserEvent || ev;
  341. return ev.charCode || ev.keyCode || 0;
  342. },
  343. _getCacheIndex: function(el, eventName, fn) {
  344. for (var i = 0,len = listeners.length; i < len; ++i) {
  345. var li = listeners[i];
  346. if (li &&
  347. li[this.FN] == fn &&
  348. li[this.EL] == el &&
  349. li[this.TYPE] == eventName) {
  350. return i;
  351. }
  352. }
  353. return -1;
  354. },
  355. elCache: {},
  356. getEl: function(id) {
  357. return document.getElementById(id);
  358. },
  359. clearCache: function() {
  360. },
  361. _load: function(e) {
  362. loadComplete = true;
  363. var EU = Ext.lib.Event;
  364. if (Ext.isIE) {
  365. EU.doRemove(window, "load", EU._load);
  366. }
  367. },
  368. _tryPreloadAttach: function() {
  369. if (this.locked) {
  370. return false;
  371. }
  372. this.locked = true;
  373. var tryAgain = !loadComplete;
  374. if (!tryAgain) {
  375. tryAgain = (retryCount > 0);
  376. }
  377. var notAvail = [];
  378. for (var i = 0,len = onAvailStack.length; i < len; ++i) {
  379. var item = onAvailStack[i];
  380. if (item) {
  381. var el = this.getEl(item.id);
  382. if (el) {
  383. if (!item.checkReady ||
  384. loadComplete ||
  385. el.nextSibling ||
  386. (document && document.body)) {
  387. var scope = el;
  388. if (item.override) {
  389. if (item.override === true) {
  390. scope = item.obj;
  391. } else {
  392. scope = item.override;
  393. }
  394. }
  395. item.fn.call(scope, item.obj);
  396. onAvailStack[i] = null;
  397. }
  398. } else {
  399. notAvail.push(item);
  400. }
  401. }
  402. }
  403. retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
  404. if (tryAgain) {
  405. this.startInterval();
  406. } else {
  407. clearInterval(this._interval);
  408. this._interval = null;
  409. }
  410. this.locked = false;
  411. return true;
  412. },
  413. purgeElement: function(el, recurse, eventName) {
  414. var elListeners = this.getListeners(el, eventName);
  415. if (elListeners) {
  416. for (var i = 0,len = elListeners.length; i < len; ++i) {
  417. var l = elListeners[i];
  418. this.removeListener(el, l.type, l.fn);
  419. }
  420. }
  421. if (recurse && el && el.childNodes) {
  422. for (i = 0,len = el.childNodes.length; i < len; ++i) {
  423. this.purgeElement(el.childNodes[i], recurse, eventName);
  424. }
  425. }
  426. },
  427. getListeners: function(el, eventName) {
  428. var results = [], searchLists;
  429. if (!eventName) {
  430. searchLists = [listeners, unloadListeners];
  431. } else if (eventName == "unload") {
  432. searchLists = [unloadListeners];
  433. } else {
  434. searchLists = [listeners];
  435. }
  436. for (var j = 0; j < searchLists.length; ++j) {
  437. var searchList = searchLists[j];
  438. if (searchList && searchList.length > 0) {
  439. for (var i = 0,len = searchList.length; i < len; ++i) {
  440. var l = searchList[i];
  441. if (l && l[this.EL] === el &&
  442. (!eventName || eventName === l[this.TYPE])) {
  443. results.push({
  444. type: l[this.TYPE],
  445. fn: l[this.FN],
  446. obj: l[this.OBJ],
  447. adjust: l[this.ADJ_SCOPE],
  448. index: i
  449. });
  450. }
  451. }
  452. }
  453. }
  454. return (results.length) ? results : null;
  455. },
  456. _unload: function(e) {
  457. var EU = Ext.lib.Event, i, j, l, len, index;
  458. for (i = 0,len = unloadListeners.length; i < len; ++i) {
  459. l = unloadListeners[i];
  460. if (l) {
  461. var scope = window;
  462. if (l[EU.ADJ_SCOPE]) {
  463. if (l[EU.ADJ_SCOPE] === true) {
  464. scope = l[EU.OBJ];
  465. } else {
  466. scope = l[EU.ADJ_SCOPE];
  467. }
  468. }
  469. l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
  470. unloadListeners[i] = null;
  471. l = null;
  472. scope = null;
  473. }
  474. }
  475. unloadListeners = null;
  476. if (listeners && listeners.length > 0) {
  477. j = listeners.length;
  478. while (j) {
  479. index = j - 1;
  480. l = listeners[index];
  481. if (l) {
  482. EU.removeListener(l[EU.EL], l[EU.TYPE],
  483. l[EU.FN], index);
  484. }
  485. j = j - 1;
  486. }
  487. l = null;
  488. EU.clearCache();
  489. }
  490. EU.doRemove(window, "unload", EU._unload);
  491. },
  492. getScroll: function() {
  493. var dd = document.documentElement, db = document.body;
  494. if (dd && (dd.scrollTop || dd.scrollLeft)) {
  495. return [dd.scrollTop, dd.scrollLeft];
  496. } else if (db) {
  497. return [db.scrollTop, db.scrollLeft];
  498. } else {
  499. return [0, 0];
  500. }
  501. },
  502. doAdd: function () {
  503. if (window.addEventListener) {
  504. return function(el, eventName, fn, capture) {
  505. el.addEventListener(eventName, fn, (capture));
  506. };
  507. } else if (window.attachEvent) {
  508. return function(el, eventName, fn, capture) {
  509. el.attachEvent("on" + eventName, fn);
  510. };
  511. } else {
  512. return function() {
  513. };
  514. }
  515. }(),
  516. doRemove: function() {
  517. if (window.removeEventListener) {
  518. return function (el, eventName, fn, capture) {
  519. el.removeEventListener(eventName, fn, (capture));
  520. };
  521. } else if (window.detachEvent) {
  522. return function (el, eventName, fn) {
  523. el.detachEvent("on" + eventName, fn);
  524. };
  525. } else {
  526. return function() {
  527. };
  528. }
  529. }()
  530. };
  531. }();
  532. var E = Ext.lib.Event;
  533. E.on = E.addListener;
  534. E.un = E.removeListener;
  535. if (document && document.body) {
  536. E._load();
  537. } else {
  538. E.doAdd(window, "load", E._load);
  539. }
  540. E.doAdd(window, "unload", E._unload);
  541. E._tryPreloadAttach();
  542. Ext.lib.Ajax = {
  543. request : function(method, uri, cb, data, options) {
  544. if(options){
  545. var hs = options.headers;
  546. if(hs){
  547. for(var h in hs){
  548. if(hs.hasOwnProperty(h)){
  549. this.initHeader(h, hs[h], false);
  550. }
  551. }
  552. }
  553. if(options.xmlData){
  554. this.initHeader('Content-Type', 'text/xml', false);
  555. method = 'POST';
  556. data = options.xmlData;
  557. }else if(options.jsonData){
  558. this.initHeader('Content-Type', 'text/javascript', false);
  559. method = 'POST';
  560. data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
  561. }
  562. }
  563. return this.asyncRequest(method, uri, cb, data);
  564. },
  565. serializeForm : function(form) {
  566. if(typeof form == 'string') {
  567. form = (document.getElementById(form) || document.forms[form]);
  568. }
  569. var el, name, val, disabled, data = '', hasSubmit = false;
  570. for (var i = 0; i < form.elements.length; i++) {
  571. el = form.elements[i];
  572. disabled = form.elements[i].disabled;
  573. name = form.elements[i].name;
  574. val = form.elements[i].value;
  575. if (!disabled && name){
  576. switch (el.type)
  577. {
  578. case 'select-one':
  579. case 'select-multiple':
  580. for (var j = 0; j < el.options.length; j++) {
  581. if (el.options[j].selected) {
  582. if (Ext.isIE) {
  583. data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
  584. }
  585. else {
  586. data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
  587. }
  588. }
  589. }
  590. break;
  591. case 'radio':
  592. case 'checkbox':
  593. if (el.checked) {
  594. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  595. }
  596. break;
  597. case 'file':
  598. case undefined:
  599. case 'reset':
  600. case 'button':
  601. break;
  602. case 'submit':
  603. if(hasSubmit == false) {
  604. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  605. hasSubmit = true;
  606. }
  607. break;
  608. default:
  609. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  610. break;
  611. }
  612. }
  613. }
  614. data = data.substr(0, data.length - 1);
  615. return data;
  616. },
  617. headers:{},
  618. hasHeaders:false,
  619. useDefaultHeader:true,
  620. defaultPostHeader:'application/x-www-form-urlencoded',
  621. useDefaultXhrHeader:true,
  622. defaultXhrHeader:'XMLHttpRequest',
  623. hasDefaultHeaders:true,
  624. defaultHeaders:{},
  625. poll:{},
  626. timeout:{},
  627. pollInterval:50,
  628. transactionId:0,
  629. setProgId:function(id)
  630. {
  631. this.activeX.unshift(id);
  632. },
  633. setDefaultPostHeader:function(b)
  634. {
  635. this.useDefaultHeader = b;
  636. },
  637. setDefaultXhrHeader:function(b)
  638. {
  639. this.useDefaultXhrHeader = b;
  640. },
  641. setPollingInterval:function(i)
  642. {
  643. if (typeof i == 'number' && isFinite(i)) {
  644. this.pollInterval = i;
  645. }
  646. },
  647. createXhrObject:function(transactionId)
  648. {
  649. var obj,http;
  650. try
  651. {
  652. http = new XMLHttpRequest();
  653. obj = { conn:http, tId:transactionId };
  654. }
  655. catch(e)
  656. {
  657. for (var i = 0; i < this.activeX.length; ++i) {
  658. try
  659. {
  660. http = new ActiveXObject(this.activeX[i]);
  661. obj = { conn:http, tId:transactionId };
  662. break;
  663. }
  664. catch(e) {
  665. }
  666. }
  667. }
  668. finally
  669. {
  670. return obj;
  671. }
  672. },
  673. getConnectionObject:function()
  674. {
  675. var o;
  676. var tId = this.transactionId;
  677. try
  678. {
  679. o = this.createXhrObject(tId);
  680. if (o) {
  681. this.transactionId++;
  682. }
  683. }
  684. catch(e) {
  685. }
  686. finally
  687. {
  688. return o;
  689. }
  690. },
  691. asyncRequest:function(method, uri, callback, postData)
  692. {
  693. var o = this.getConnectionObject();
  694. if (!o) {
  695. return null;
  696. }
  697. else {
  698. o.conn.open(method, uri, true);
  699. if (this.useDefaultXhrHeader) {
  700. if (!this.defaultHeaders['X-Requested-With']) {
  701. this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
  702. }
  703. }
  704. if(postData && this.useDefaultHeader){
  705. this.initHeader('Content-Type', this.defaultPostHeader);
  706. }
  707. if (this.hasDefaultHeaders || this.hasHeaders) {
  708. this.setHeader(o);
  709. }
  710. this.handleReadyState(o, callback);
  711. o.conn.send(postData || null);
  712. return o;
  713. }
  714. },
  715. handleReadyState:function(o, callback)
  716. {
  717. var oConn = this;
  718. if (callback && callback.timeout) {
  719. this.timeout[o.tId] = window.setTimeout(function() {
  720. oConn.abort(o, callback, true);
  721. }, callback.timeout);
  722. }
  723. this.poll[o.tId] = window.setInterval(
  724. function() {
  725. if (o.conn && o.conn.readyState == 4) {
  726. window.clearInterval(oConn.poll[o.tId]);
  727. delete oConn.poll[o.tId];
  728. if (callback && callback.timeout) {
  729. window.clearTimeout(oConn.timeout[o.tId]);
  730. delete oConn.timeout[o.tId];
  731. }
  732. oConn.handleTransactionResponse(o, callback);
  733. }
  734. }
  735. , this.pollInterval);
  736. },
  737. handleTransactionResponse:function(o, callback, isAbort)
  738. {
  739. if (!callback) {
  740. this.releaseObject(o);
  741. return;
  742. }
  743. var httpStatus, responseObject;
  744. try
  745. {
  746. if (o.conn.status !== undefined && o.conn.status != 0) {
  747. httpStatus = o.conn.status;
  748. }
  749. else {
  750. httpStatus = 13030;
  751. }
  752. }
  753. catch(e) {
  754. httpStatus = 13030;
  755. }
  756. if (httpStatus >= 200 && httpStatus < 300) {
  757. responseObject = this.createResponseObject(o, callback.argument);
  758. if (callback.success) {
  759. if (!callback.scope) {
  760. callback.success(responseObject);
  761. }
  762. else {
  763. callback.success.apply(callback.scope, [responseObject]);
  764. }
  765. }
  766. }
  767. else {
  768. switch (httpStatus) {
  769. case 12002:
  770. case 12029:
  771. case 12030:
  772. case 12031:
  773. case 12152:
  774. case 13030:
  775. responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
  776. if (callback.failure) {
  777. if (!callback.scope) {
  778. callback.failure(responseObject);
  779. }
  780. else {
  781. callback.failure.apply(callback.scope, [responseObject]);
  782. }
  783. }
  784. break;
  785. default:
  786. responseObject = this.createResponseObject(o, callback.argument);
  787. if (callback.failure) {
  788. if (!callback.scope) {
  789. callback.failure(responseObject);
  790. }
  791. else {
  792. callback.failure.apply(callback.scope, [responseObject]);
  793. }
  794. }
  795. }
  796. }
  797. this.releaseObject(o);
  798. responseObject = null;
  799. },
  800. createResponseObject:function(o, callbackArg)
  801. {
  802. var obj = {};
  803. var headerObj = {};
  804. try
  805. {
  806. var headerStr = o.conn.getAllResponseHeaders();
  807. var header = headerStr.split('\n');
  808. for (var i = 0; i < header.length; i++) {
  809. var delimitPos = header[i].indexOf(':');
  810. if (delimitPos != -1) {
  811. headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
  812. }
  813. }
  814. }
  815. catch(e) {
  816. }
  817. obj.tId = o.tId;
  818. obj.status = o.conn.status;
  819. obj.statusText = o.conn.statusText;
  820. obj.getResponseHeader = headerObj;
  821. obj.getAllResponseHeaders = headerStr;
  822. obj.responseText = o.conn.responseText;
  823. obj.responseXML = o.conn.responseXML;
  824. if (typeof callbackArg !== undefined) {
  825. obj.argument = callbackArg;
  826. }
  827. return obj;
  828. },
  829. createExceptionObject:function(tId, callbackArg, isAbort)
  830. {
  831. var COMM_CODE = 0;
  832. var COMM_ERROR = 'communication failure';
  833. var ABORT_CODE = -1;
  834. var ABORT_ERROR = 'transaction aborted';
  835. var obj = {};
  836. obj.tId = tId;
  837. if (isAbort) {
  838. obj.status = ABORT_CODE;
  839. obj.statusText = ABORT_ERROR;
  840. }
  841. else {
  842. obj.status = COMM_CODE;
  843. obj.statusText = COMM_ERROR;
  844. }
  845. if (callbackArg) {
  846. obj.argument = callbackArg;
  847. }
  848. return obj;
  849. },
  850. initHeader:function(label, value, isDefault)
  851. {
  852. var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
  853. if (headerObj[label] === undefined) {
  854. headerObj[label] = value;
  855. }
  856. else {
  857. headerObj[label] = value + "," + headerObj[label];
  858. }
  859. if (isDefault) {
  860. this.hasDefaultHeaders = true;
  861. }
  862. else {
  863. this.hasHeaders = true;
  864. }
  865. },
  866. setHeader:function(o)
  867. {
  868. if (this.hasDefaultHeaders) {
  869. for (var prop in this.defaultHeaders) {
  870. if (this.defaultHeaders.hasOwnProperty(prop)) {
  871. o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
  872. }
  873. }
  874. }
  875. if (this.hasHeaders) {
  876. for (var prop in this.headers) {
  877. if (this.headers.hasOwnProperty(prop)) {
  878. o.conn.setRequestHeader(prop, this.headers[prop]);
  879. }
  880. }
  881. this.headers = {};
  882. this.hasHeaders = false;
  883. }
  884. },
  885. resetDefaultHeaders:function() {
  886. delete this.defaultHeaders;
  887. this.defaultHeaders = {};
  888. this.hasDefaultHeaders = false;
  889. },
  890. abort:function(o, callback, isTimeout)
  891. {
  892. if (this.isCallInProgress(o)) {
  893. o.conn.abort();
  894. window.clearInterval(this.poll[o.tId]);
  895. delete this.poll[o.tId];
  896. if (isTimeout) {
  897. delete this.timeout[o.tId];
  898. }
  899. this.handleTransactionResponse(o, callback, true);
  900. return true;
  901. }
  902. else {
  903. return false;
  904. }
  905. },
  906. isCallInProgress:function(o)
  907. {
  908. if (o.conn) {
  909. return o.conn.readyState != 4 && o.conn.readyState != 0;
  910. }
  911. else {
  912. return false;
  913. }
  914. },
  915. releaseObject:function(o)
  916. {
  917. o.conn = null;
  918. o = null;
  919. },
  920. activeX:[
  921. 'MSXML2.XMLHTTP.3.0',
  922. 'MSXML2.XMLHTTP',
  923. 'Microsoft.XMLHTTP'
  924. ]
  925. };
  926. Ext.lib.Region = function(t, r, b, l) {
  927. this.top = t;
  928. this[1] = t;
  929. this.right = r;
  930. this.bottom = b;
  931. this.left = l;
  932. this[0] = l;
  933. };
  934. Ext.lib.Region.prototype = {
  935. contains : function(region) {
  936. return ( region.left >= this.left &&
  937. region.right <= this.right &&
  938. region.top >= this.top &&
  939. region.bottom <= this.bottom );
  940. },
  941. getArea : function() {
  942. return ( (this.bottom - this.top) * (this.right - this.left) );
  943. },
  944. intersect : function(region) {
  945. var t = Math.max(this.top, region.top);
  946. var r = Math.min(this.right, region.right);
  947. var b = Math.min(this.bottom, region.bottom);
  948. var l = Math.max(this.left, region.left);
  949. if (b >= t && r >= l) {
  950. return new Ext.lib.Region(t, r, b, l);
  951. } else {
  952. return null;
  953. }
  954. },
  955. union : function(region) {
  956. var t = Math.min(this.top, region.top);
  957. var r = Math.max(this.right, region.right);
  958. var b = Math.max(this.bottom, region.bottom);
  959. var l = Math.min(this.left, region.left);
  960. return new Ext.lib.Region(t, r, b, l);
  961. },
  962. constrainTo : function(r) {
  963. this.top = this.top.constrain(r.top, r.bottom);
  964. this.bottom = this.bottom.constrain(r.top, r.bottom);
  965. this.left = this.left.constrain(r.left, r.right);
  966. this.right = this.right.constrain(r.left, r.right);
  967. return this;
  968. },
  969. adjust : function(t, l, b, r) {
  970. this.top += t;
  971. this.left += l;
  972. this.right += r;
  973. this.bottom += b;
  974. return this;
  975. }
  976. };
  977. Ext.lib.Region.getRegion = function(el) {
  978. var p = Ext.lib.Dom.getXY(el);
  979. var t = p[1];
  980. var r = p[0] + el.offsetWidth;
  981. var b = p[1] + el.offsetHeight;
  982. var l = p[0];
  983. return new Ext.lib.Region(t, r, b, l);
  984. };
  985. Ext.lib.Point = function(x, y) {
  986. if (Ext.isArray(x)) {
  987. y = x[1];
  988. x = x[0];
  989. }
  990. this.x = this.right = this.left = this[0] = x;
  991. this.y = this.top = this.bottom = this[1] = y;
  992. };
  993. Ext.lib.Point.prototype = new Ext.lib.Region();
  994. Ext.lib.Anim = {
  995. scroll : function(el, args, duration, easing, cb, scope) {
  996. return this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
  997. },
  998. motion : function(el, args, duration, easing, cb, scope) {
  999. return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  1000. },
  1001. color : function(el, args, duration, easing, cb, scope) {
  1002. return this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
  1003. },
  1004. run : function(el, args, duration, easing, cb, scope, type) {
  1005. type = type || Ext.lib.AnimBase;
  1006. if (typeof easing == "string") {
  1007. easing = Ext.lib.Easing[easing];
  1008. }
  1009. var anim = new type(el, args, duration, easing);
  1010. anim.animateX(function() {
  1011. Ext.callback(cb, scope);
  1012. });
  1013. return anim;
  1014. }
  1015. };
  1016. function fly(el) {
  1017. if (!libFlyweight) {
  1018. libFlyweight = new Ext.Element.Flyweight();
  1019. }
  1020. libFlyweight.dom = el;
  1021. return libFlyweight;
  1022. }
  1023. if(Ext.isIE) {
  1024. function fnCleanUp() {
  1025. var p = Function.prototype;
  1026. delete p.createSequence;
  1027. delete p.defer;
  1028. delete p.createDelegate;
  1029. delete p.createCallback;
  1030. delete p.createInterceptor;
  1031. window.detachEvent("onunload", fnCleanUp);
  1032. }
  1033. window.attachEvent("onunload", fnCleanUp);
  1034. }
  1035. Ext.lib.AnimBase = function(el, attributes, duration, method) {
  1036. if (el) {
  1037. this.init(el, attributes, duration, method);
  1038. }
  1039. };
  1040. Ext.lib.AnimBase.prototype = {
  1041. toString: function() {
  1042. var el = this.getEl();
  1043. var id = el.id || el.tagName;
  1044. return ("Anim " + id);
  1045. },
  1046. patterns: {
  1047. noNegatives: /width|height|opacity|padding/i,
  1048. offsetAttribute: /^((width|height)|(top|left))$/,
  1049. defaultUnit: /width|height|top$|bottom$|left$|right$/i,
  1050. offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
  1051. },
  1052. doMethod: function(attr, start, end) {
  1053. return this.method(this.currentFrame, start, end - start, this.totalFrames);
  1054. },
  1055. setAttribute: function(attr, val, unit) {
  1056. if (this.patterns.noNegatives.test(attr)) {
  1057. val = (val > 0) ? val : 0;
  1058. }
  1059. Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
  1060. },
  1061. getAttribute: function(attr) {
  1062. var el = this.getEl();
  1063. var val = fly(el).getStyle(attr);
  1064. if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
  1065. return parseFloat(val);
  1066. }
  1067. var a = this.patterns.offsetAttribute.exec(attr) || [];
  1068. var pos = !!( a[3] );
  1069. var box = !!( a[2] );
  1070. if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
  1071. val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
  1072. } else {
  1073. val = 0;
  1074. }
  1075. return val;
  1076. },
  1077. getDefaultUnit: function(attr) {
  1078. if (this.patterns.defaultUnit.test(attr)) {
  1079. return 'px';
  1080. }
  1081. return '';
  1082. },
  1083. animateX : function(callback, scope) {
  1084. var f = function() {
  1085. this.onComplete.removeListener(f);
  1086. if (typeof callback == "function") {
  1087. callback.call(scope || this, this);
  1088. }
  1089. };
  1090. this.onComplete.addListener(f, this);
  1091. this.animate();
  1092. },
  1093. setRuntimeAttribute: function(attr) {
  1094. var start;
  1095. var end;
  1096. var attributes = this.attributes;
  1097. this.runtimeAttributes[attr] = {};
  1098. var isset = function(prop) {
  1099. return (typeof prop !== 'undefined');
  1100. };
  1101. if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) {
  1102. return false;
  1103. }
  1104. start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
  1105. if (isset(attributes[attr]['to'])) {
  1106. end = attributes[attr]['to'];
  1107. } else if (isset(attributes[attr]['by'])) {
  1108. if (start.constructor == Array) {
  1109. end = [];
  1110. for (var i = 0, len = start.length; i < len; ++i) {
  1111. end[i] = start[i] + attributes[attr]['by'][i];
  1112. }
  1113. } else {
  1114. end = start + attributes[attr]['by'];
  1115. }
  1116. }
  1117. this.runtimeAttributes[attr].start = start;
  1118. this.runtimeAttributes[attr].end = end;
  1119. this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
  1120. },
  1121. init: function(el, attributes, duration, method) {
  1122. var isAnimated = false;
  1123. var startTime = null;
  1124. var actualFrames = 0;
  1125. el = Ext.getDom(el);
  1126. this.attributes = attributes || {};
  1127. this.duration = duration || 1;
  1128. this.method = method || Ext.lib.Easing.easeNone;
  1129. this.useSeconds = true;
  1130. this.currentFrame = 0;
  1131. this.totalFrames = Ext.lib.AnimMgr.fps;
  1132. this.getEl = function() {
  1133. return el;
  1134. };
  1135. this.isAnimated = function() {
  1136. return isAnimated;
  1137. };
  1138. this.getStartTime = function() {
  1139. return startTime;
  1140. };
  1141. this.runtimeAttributes = {};
  1142. this.animate = function() {
  1143. if (this.isAnimated()) {
  1144. return false;
  1145. }
  1146. this.currentFrame = 0;
  1147. this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration;
  1148. Ext.lib.AnimMgr.registerElement(this);
  1149. };
  1150. this.stop = function(finish) {
  1151. if (finish) {
  1152. this.currentFrame = this.totalFrames;
  1153. this._onTween.fire();
  1154. }
  1155. Ext.lib.AnimMgr.stop(this);
  1156. };
  1157. var onStart = function() {
  1158. this.onStart.fire();
  1159. this.runtimeAttributes = {};
  1160. for (var attr in this.attributes) {
  1161. this.setRuntimeAttribute(attr);
  1162. }
  1163. isAnimated = true;
  1164. actualFrames = 0;
  1165. startTime = new Date();
  1166. };
  1167. var onTween = function() {
  1168. var data = {
  1169. duration: new Date() - this.getStartTime(),
  1170. currentFrame: this.currentFrame
  1171. };
  1172. data.toString = function() {
  1173. return (
  1174. 'duration: ' + data.duration +
  1175. ', currentFrame: ' + data.currentFrame
  1176. );
  1177. };
  1178. this.onTween.fire(data);
  1179. var runtimeAttributes = this.runtimeAttributes;
  1180. for (var attr in runtimeAttributes) {
  1181. this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
  1182. }
  1183. actualFrames += 1;
  1184. };
  1185. var onComplete = function() {
  1186. var actual_duration = (new Date() - startTime) / 1000 ;
  1187. var data = {
  1188. duration: actual_duration,
  1189. frames: actualFrames,
  1190. fps: actualFrames / actual_duration
  1191. };
  1192. data.toString = function() {
  1193. return (
  1194. 'duration: ' + data.duration +
  1195. ', frames: ' + data.frames +
  1196. ', fps: ' + data.fps
  1197. );
  1198. };
  1199. isAnimated = false;
  1200. actualFrames = 0;
  1201. this.onComplete.fire(data);
  1202. };
  1203. this._onStart = new Ext.util.Event(this);
  1204. this.onStart = new Ext.util.Event(this);
  1205. this.onTween = new Ext.util.Event(this);
  1206. this._onTween = new Ext.util.Event(this);
  1207. this.onComplete = new Ext.util.Event(this);
  1208. this._onComplete = new Ext.util.Event(this);
  1209. this._onStart.addListener(onStart);
  1210. this._onTween.addListener(onTween);
  1211. this._onComplete.addListener(onComplete);
  1212. }
  1213. };
  1214. Ext.lib.AnimMgr = new function() {
  1215. var thread = null;
  1216. var queue = [];
  1217. var tweenCount = 0;
  1218. this.fps = 1000;
  1219. this.delay = 1;
  1220. this.registerElement = function(tween) {
  1221. queue[queue.length] = tween;
  1222. tweenCount += 1;
  1223. tween._onStart.fire();
  1224. this.start();
  1225. };
  1226. this.unRegister = function(tween, index) {
  1227. tween._onComplete.fire();
  1228. index = index || getIndex(tween);
  1229. if (index != -1) {
  1230. queue.splice(index, 1);
  1231. }
  1232. tweenCount -= 1;
  1233. if (tweenCount <= 0) {
  1234. this.stop();
  1235. }
  1236. };
  1237. this.start = function() {
  1238. if (thread === null) {
  1239. thread = setInterval(this.run, this.delay);
  1240. }
  1241. };
  1242. this.stop = function(tween) {
  1243. if (!tween) {
  1244. clearInterval(thread);
  1245. for (var i = 0, len = queue.length; i < len; ++i) {
  1246. if (queue[0].isAnimated()) {
  1247. this.unRegister(queue[0], 0);
  1248. }
  1249. }
  1250. queue = [];
  1251. thread = null;
  1252. tweenCount = 0;
  1253. }
  1254. else {
  1255. this.unRegister(tween);
  1256. }
  1257. };
  1258. this.run = function() {
  1259. for (var i = 0, len = queue.length; i < len; ++i) {
  1260. var tween = queue[i];
  1261. if (!tween || !tween.isAnimated()) {
  1262. continue;
  1263. }
  1264. if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
  1265. {
  1266. tween.currentFrame += 1;
  1267. if (tween.useSeconds) {
  1268. correctFrame(tween);
  1269. }
  1270. tween._onTween.fire();
  1271. }
  1272. else {
  1273. Ext.lib.AnimMgr.stop(tween, i);
  1274. }
  1275. }
  1276. };
  1277. var getIndex = function(anim) {
  1278. for (var i = 0, len = queue.length; i < len; ++i) {
  1279. if (queue[i] == anim) {
  1280. return i;
  1281. }
  1282. }

Large files files are truncated, but you can click here to view the full file