PageRenderTime 68ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/samples/build-ext-using-maven/src/main/javascript/adapter/ext-base.js

https://github.com/harlanji/javascript-maven-tools
JavaScript | 2178 lines | 1663 code | 502 blank | 13 comment | 427 complexity | 05bebce6fe0d5581de4abce18482d34d MD5 | raw file

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

  1. /*
  2. * Ext JS Library 1.1.1
  3. * Copyright(c) 2006-2007, Ext JS, LLC.
  4. * licensing@extjs.com
  5. *
  6. * http://www.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. var height = self.innerHeight;
  27. var mode = document.compatMode;
  28. if ((mode || Ext.isIE) && !Ext.isOpera) {
  29. height = (mode == "CSS1Compat") ?
  30. document.documentElement.clientHeight :
  31. document.body.clientHeight;
  32. }
  33. return height;
  34. },
  35. getViewportWidth: function() {
  36. var width = self.innerWidth;
  37. var mode = document.compatMode;
  38. if (mode || Ext.isIE) {
  39. width = (mode == "CSS1Compat") ?
  40. document.documentElement.clientWidth :
  41. document.body.clientWidth;
  42. }
  43. return width;
  44. },
  45. isAncestor : function(p, c) {
  46. p = Ext.getDom(p);
  47. c = Ext.getDom(c);
  48. if (!p || !c) {
  49. return false;
  50. }
  51. if (p.contains && !Ext.isSafari) {
  52. return p.contains(c);
  53. } else if (p.compareDocumentPosition) {
  54. return !!(p.compareDocumentPosition(c) & 16);
  55. } else {
  56. var parent = c.parentNode;
  57. while (parent) {
  58. if (parent == p) {
  59. return true;
  60. }
  61. else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
  62. return false;
  63. }
  64. parent = parent.parentNode;
  65. }
  66. return false;
  67. }
  68. },
  69. getRegion : function(el) {
  70. return Ext.lib.Region.getRegion(el);
  71. },
  72. getY : function(el) {
  73. return this.getXY(el)[1];
  74. },
  75. getX : function(el) {
  76. return this.getXY(el)[0];
  77. },
  78. getXY : function(el) {
  79. var p, pe, b, scroll, bd = document.body;
  80. el = Ext.getDom(el);
  81. if (el.getBoundingClientRect) {
  82. b = el.getBoundingClientRect();
  83. scroll = fly(document).getScroll();
  84. return [b.left + scroll.left, b.top + scroll.top];
  85. }
  86. var x = 0, y = 0;
  87. p = el;
  88. var hasAbsolute = fly(el).getStyle("position") == "absolute";
  89. while (p) {
  90. x += p.offsetLeft;
  91. y += p.offsetTop;
  92. if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
  93. hasAbsolute = true;
  94. }
  95. if (Ext.isGecko) {
  96. pe = fly(p);
  97. var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
  98. var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
  99. x += bl;
  100. y += bt;
  101. if (p != el && pe.getStyle('overflow') != 'visible') {
  102. x += bl;
  103. y += bt;
  104. }
  105. }
  106. p = p.offsetParent;
  107. }
  108. if (Ext.isSafari && hasAbsolute) {
  109. x -= bd.offsetLeft;
  110. y -= bd.offsetTop;
  111. }
  112. if (Ext.isGecko && !hasAbsolute) {
  113. var dbd = fly(bd);
  114. x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
  115. y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
  116. }
  117. p = el.parentNode;
  118. while (p && p != bd) {
  119. if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
  120. x -= p.scrollLeft;
  121. y -= p.scrollTop;
  122. }
  123. p = p.parentNode;
  124. }
  125. return [x, y];
  126. },
  127. setXY : function(el, xy) {
  128. el = Ext.fly(el, '_setXY');
  129. el.position();
  130. var pts = el.translatePoints(xy);
  131. if (xy[0] !== false) {
  132. el.dom.style.left = pts.left + "px";
  133. }
  134. if (xy[1] !== false) {
  135. el.dom.style.top = pts.top + "px";
  136. }
  137. },
  138. setX : function(el, x) {
  139. this.setXY(el, [x, false]);
  140. },
  141. setY : function(el, y) {
  142. this.setXY(el, [false, y]);
  143. }
  144. };
  145. /*
  146. * Portions of this file are based on pieces of Yahoo User Interface Library
  147. * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
  148. * YUI licensed under the BSD License:
  149. * http://developer.yahoo.net/yui/license.txt
  150. */
  151. Ext.lib.Event = function() {
  152. var loadComplete = false;
  153. var listeners = [];
  154. var unloadListeners = [];
  155. var retryCount = 0;
  156. var onAvailStack = [];
  157. var counter = 0;
  158. var lastError = null;
  159. return {
  160. POLL_RETRYS: 200,
  161. POLL_INTERVAL: 20,
  162. EL: 0,
  163. TYPE: 1,
  164. FN: 2,
  165. WFN: 3,
  166. OBJ: 3,
  167. ADJ_SCOPE: 4,
  168. _interval: null,
  169. startInterval: function() {
  170. if (!this._interval) {
  171. var self = this;
  172. var callback = function() {
  173. self._tryPreloadAttach();
  174. };
  175. this._interval = setInterval(callback, this.POLL_INTERVAL);
  176. }
  177. },
  178. onAvailable: function(p_id, p_fn, p_obj, p_override) {
  179. onAvailStack.push({ id: p_id,
  180. fn: p_fn,
  181. obj: p_obj,
  182. override: p_override,
  183. checkReady: false });
  184. retryCount = this.POLL_RETRYS;
  185. this.startInterval();
  186. },
  187. addListener: function(el, eventName, fn) {
  188. el = Ext.getDom(el);
  189. if (!el || !fn) {
  190. return false;
  191. }
  192. if ("unload" == eventName) {
  193. unloadListeners[unloadListeners.length] =
  194. [el, eventName, fn];
  195. return true;
  196. }
  197. var wrappedFn = function(e) {
  198. return fn(Ext.lib.Event.getEvent(e));
  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. }
  558. }
  559. return this.asyncRequest(method, uri, cb, data);
  560. },
  561. serializeForm : function(form) {
  562. if(typeof form == 'string') {
  563. form = (document.getElementById(form) || document.forms[form]);
  564. }
  565. var el, name, val, disabled, data = '', hasSubmit = false;
  566. for (var i = 0; i < form.elements.length; i++) {
  567. el = form.elements[i];
  568. disabled = form.elements[i].disabled;
  569. name = form.elements[i].name;
  570. val = form.elements[i].value;
  571. if (!disabled && name){
  572. switch (el.type)
  573. {
  574. case 'select-one':
  575. case 'select-multiple':
  576. for (var j = 0; j < el.options.length; j++) {
  577. if (el.options[j].selected) {
  578. if (Ext.isIE) {
  579. data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
  580. }
  581. else {
  582. data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
  583. }
  584. }
  585. }
  586. break;
  587. case 'radio':
  588. case 'checkbox':
  589. if (el.checked) {
  590. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  591. }
  592. break;
  593. case 'file':
  594. case undefined:
  595. case 'reset':
  596. case 'button':
  597. break;
  598. case 'submit':
  599. if(hasSubmit == false) {
  600. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  601. hasSubmit = true;
  602. }
  603. break;
  604. default:
  605. data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
  606. break;
  607. }
  608. }
  609. }
  610. data = data.substr(0, data.length - 1);
  611. return data;
  612. },
  613. headers:{},
  614. hasHeaders:false,
  615. useDefaultHeader:true,
  616. defaultPostHeader:'application/x-www-form-urlencoded',
  617. useDefaultXhrHeader:true,
  618. defaultXhrHeader:'XMLHttpRequest',
  619. hasDefaultHeaders:true,
  620. defaultHeaders:{},
  621. poll:{},
  622. timeout:{},
  623. pollInterval:50,
  624. transactionId:0,
  625. setProgId:function(id)
  626. {
  627. this.activeX.unshift(id);
  628. },
  629. setDefaultPostHeader:function(b)
  630. {
  631. this.useDefaultHeader = b;
  632. },
  633. setDefaultXhrHeader:function(b)
  634. {
  635. this.useDefaultXhrHeader = b;
  636. },
  637. setPollingInterval:function(i)
  638. {
  639. if (typeof i == 'number' && isFinite(i)) {
  640. this.pollInterval = i;
  641. }
  642. },
  643. createXhrObject:function(transactionId)
  644. {
  645. var obj,http;
  646. try
  647. {
  648. http = new XMLHttpRequest();
  649. obj = { conn:http, tId:transactionId };
  650. }
  651. catch(e)
  652. {
  653. for (var i = 0; i < this.activeX.length; ++i) {
  654. try
  655. {
  656. http = new ActiveXObject(this.activeX[i]);
  657. obj = { conn:http, tId:transactionId };
  658. break;
  659. }
  660. catch(e) {
  661. }
  662. }
  663. }
  664. finally
  665. {
  666. return obj;
  667. }
  668. },
  669. getConnectionObject:function()
  670. {
  671. var o;
  672. var tId = this.transactionId;
  673. try
  674. {
  675. o = this.createXhrObject(tId);
  676. if (o) {
  677. this.transactionId++;
  678. }
  679. }
  680. catch(e) {
  681. }
  682. finally
  683. {
  684. return o;
  685. }
  686. },
  687. asyncRequest:function(method, uri, callback, postData)
  688. {
  689. var o = this.getConnectionObject();
  690. if (!o) {
  691. return null;
  692. }
  693. else {
  694. o.conn.open(method, uri, true);
  695. if (this.useDefaultXhrHeader) {
  696. if (!this.defaultHeaders['X-Requested-With']) {
  697. this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
  698. }
  699. }
  700. if(postData && this.useDefaultHeader){
  701. this.initHeader('Content-Type', this.defaultPostHeader);
  702. }
  703. if (this.hasDefaultHeaders || this.hasHeaders) {
  704. this.setHeader(o);
  705. }
  706. this.handleReadyState(o, callback);
  707. o.conn.send(postData || null);
  708. return o;
  709. }
  710. },
  711. handleReadyState:function(o, callback)
  712. {
  713. var oConn = this;
  714. if (callback && callback.timeout) {
  715. this.timeout[o.tId] = window.setTimeout(function() {
  716. oConn.abort(o, callback, true);
  717. }, callback.timeout);
  718. }
  719. this.poll[o.tId] = window.setInterval(
  720. function() {
  721. if (o.conn && o.conn.readyState == 4) {
  722. window.clearInterval(oConn.poll[o.tId]);
  723. delete oConn.poll[o.tId];
  724. if(callback && callback.timeout) {
  725. window.clearTimeout(oConn.timeout[o.tId]);
  726. delete oConn.timeout[o.tId];
  727. }
  728. oConn.handleTransactionResponse(o, callback);
  729. }
  730. }
  731. , this.pollInterval);
  732. },
  733. handleTransactionResponse:function(o, callback, isAbort)
  734. {
  735. if (!callback) {
  736. this.releaseObject(o);
  737. return;
  738. }
  739. var httpStatus, responseObject;
  740. try
  741. {
  742. if (o.conn.status !== undefined && o.conn.status != 0) {
  743. httpStatus = o.conn.status;
  744. }
  745. else {
  746. httpStatus = 13030;
  747. }
  748. }
  749. catch(e) {
  750. httpStatus = 13030;
  751. }
  752. if (httpStatus >= 200 && httpStatus < 300) {
  753. responseObject = this.createResponseObject(o, callback.argument);
  754. if (callback.success) {
  755. if (!callback.scope) {
  756. callback.success(responseObject);
  757. }
  758. else {
  759. callback.success.apply(callback.scope, [responseObject]);
  760. }
  761. }
  762. }
  763. else {
  764. switch (httpStatus) {
  765. case 12002:
  766. case 12029:
  767. case 12030:
  768. case 12031:
  769. case 12152:
  770. case 13030:
  771. responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
  772. if (callback.failure) {
  773. if (!callback.scope) {
  774. callback.failure(responseObject);
  775. }
  776. else {
  777. callback.failure.apply(callback.scope, [responseObject]);
  778. }
  779. }
  780. break;
  781. default:
  782. responseObject = this.createResponseObject(o, callback.argument);
  783. if (callback.failure) {
  784. if (!callback.scope) {
  785. callback.failure(responseObject);
  786. }
  787. else {
  788. callback.failure.apply(callback.scope, [responseObject]);
  789. }
  790. }
  791. }
  792. }
  793. this.releaseObject(o);
  794. responseObject = null;
  795. },
  796. createResponseObject:function(o, callbackArg)
  797. {
  798. var obj = {};
  799. var headerObj = {};
  800. try
  801. {
  802. var headerStr = o.conn.getAllResponseHeaders();
  803. var header = headerStr.split('\n');
  804. for (var i = 0; i < header.length; i++) {
  805. var delimitPos = header[i].indexOf(':');
  806. if (delimitPos != -1) {
  807. headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
  808. }
  809. }
  810. }
  811. catch(e) {
  812. }
  813. obj.tId = o.tId;
  814. obj.status = o.conn.status;
  815. obj.statusText = o.conn.statusText;
  816. obj.getResponseHeader = headerObj;
  817. obj.getAllResponseHeaders = headerStr;
  818. obj.responseText = o.conn.responseText;
  819. obj.responseXML = o.conn.responseXML;
  820. if (typeof callbackArg !== undefined) {
  821. obj.argument = callbackArg;
  822. }
  823. return obj;
  824. },
  825. createExceptionObject:function(tId, callbackArg, isAbort)
  826. {
  827. var COMM_CODE = 0;
  828. var COMM_ERROR = 'communication failure';
  829. var ABORT_CODE = -1;
  830. var ABORT_ERROR = 'transaction aborted';
  831. var obj = {};
  832. obj.tId = tId;
  833. if (isAbort) {
  834. obj.status = ABORT_CODE;
  835. obj.statusText = ABORT_ERROR;
  836. }
  837. else {
  838. obj.status = COMM_CODE;
  839. obj.statusText = COMM_ERROR;
  840. }
  841. if (callbackArg) {
  842. obj.argument = callbackArg;
  843. }
  844. return obj;
  845. },
  846. initHeader:function(label, value, isDefault)
  847. {
  848. var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
  849. if (headerObj[label] === undefined) {
  850. headerObj[label] = value;
  851. }
  852. else {
  853. headerObj[label] = value + "," + headerObj[label];
  854. }
  855. if (isDefault) {
  856. this.hasDefaultHeaders = true;
  857. }
  858. else {
  859. this.hasHeaders = true;
  860. }
  861. },
  862. setHeader:function(o)
  863. {
  864. if (this.hasDefaultHeaders) {
  865. for (var prop in this.defaultHeaders) {
  866. if (this.defaultHeaders.hasOwnProperty(prop)) {
  867. o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
  868. }
  869. }
  870. }
  871. if (this.hasHeaders) {
  872. for (var prop in this.headers) {
  873. if (this.headers.hasOwnProperty(prop)) {
  874. o.conn.setRequestHeader(prop, this.headers[prop]);
  875. }
  876. }
  877. this.headers = {};
  878. this.hasHeaders = false;
  879. }
  880. },
  881. resetDefaultHeaders:function() {
  882. delete this.defaultHeaders;
  883. this.defaultHeaders = {};
  884. this.hasDefaultHeaders = false;
  885. },
  886. abort:function(o, callback, isTimeout)
  887. {
  888. if(this.isCallInProgress(o)) {
  889. o.conn.abort();
  890. window.clearInterval(this.poll[o.tId]);
  891. delete this.poll[o.tId];
  892. if (isTimeout) {
  893. delete this.timeout[o.tId];
  894. }
  895. this.handleTransactionResponse(o, callback, true);
  896. return true;
  897. }
  898. else {
  899. return false;
  900. }
  901. },
  902. isCallInProgress:function(o)
  903. {
  904. if (o && o.conn) {
  905. return o.conn.readyState != 4 && o.conn.readyState != 0;
  906. }
  907. else {
  908. return false;
  909. }
  910. },
  911. releaseObject:function(o)
  912. {
  913. o.conn = null;
  914. o = null;
  915. },
  916. activeX:[
  917. 'MSXML2.XMLHTTP.3.0',
  918. 'MSXML2.XMLHTTP',
  919. 'Microsoft.XMLHTTP'
  920. ]
  921. };
  922. Ext.lib.Region = function(t, r, b, l) {
  923. this.top = t;
  924. this[1] = t;
  925. this.right = r;
  926. this.bottom = b;
  927. this.left = l;
  928. this[0] = l;
  929. };
  930. Ext.lib.Region.prototype = {
  931. contains : function(region) {
  932. return ( region.left >= this.left &&
  933. region.right <= this.right &&
  934. region.top >= this.top &&
  935. region.bottom <= this.bottom );
  936. },
  937. getArea : function() {
  938. return ( (this.bottom - this.top) * (this.right - this.left) );
  939. },
  940. intersect : function(region) {
  941. var t = Math.max(this.top, region.top);
  942. var r = Math.min(this.right, region.right);
  943. var b = Math.min(this.bottom, region.bottom);
  944. var l = Math.max(this.left, region.left);
  945. if (b >= t && r >= l) {
  946. return new Ext.lib.Region(t, r, b, l);
  947. } else {
  948. return null;
  949. }
  950. },
  951. union : function(region) {
  952. var t = Math.min(this.top, region.top);
  953. var r = Math.max(this.right, region.right);
  954. var b = Math.max(this.bottom, region.bottom);
  955. var l = Math.min(this.left, region.left);
  956. return new Ext.lib.Region(t, r, b, l);
  957. },
  958. adjust : function(t, l, b, r) {
  959. this.top += t;
  960. this.left += l;
  961. this.right += r;
  962. this.bottom += b;
  963. return this;
  964. }
  965. };
  966. Ext.lib.Region.getRegion = function(el) {
  967. var p = Ext.lib.Dom.getXY(el);
  968. var t = p[1];
  969. var r = p[0] + el.offsetWidth;
  970. var b = p[1] + el.offsetHeight;
  971. var l = p[0];
  972. return new Ext.lib.Region(t, r, b, l);
  973. };
  974. Ext.lib.Point = function(x, y) {
  975. if (x instanceof Array) {
  976. y = x[1];
  977. x = x[0];
  978. }
  979. this.x = this.right = this.left = this[0] = x;
  980. this.y = this.top = this.bottom = this[1] = y;
  981. };
  982. Ext.lib.Point.prototype = new Ext.lib.Region();
  983. Ext.lib.Anim = {
  984. scroll : function(el, args, duration, easing, cb, scope) {
  985. this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
  986. },
  987. motion : function(el, args, duration, easing, cb, scope) {
  988. this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  989. },
  990. color : function(el, args, duration, easing, cb, scope) {
  991. this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
  992. },
  993. run : function(el, args, duration, easing, cb, scope, type) {
  994. type = type || Ext.lib.AnimBase;
  995. if (typeof easing == "string") {
  996. easing = Ext.lib.Easing[easing];
  997. }
  998. var anim = new type(el, args, duration, easing);
  999. anim.animateX(function() {
  1000. Ext.callback(cb, scope);
  1001. });
  1002. return anim;
  1003. }
  1004. };
  1005. function fly(el) {
  1006. if (!libFlyweight) {
  1007. libFlyweight = new Ext.Element.Flyweight();
  1008. }
  1009. libFlyweight.dom = el;
  1010. return libFlyweight;
  1011. }
  1012. if(Ext.isIE) {
  1013. function fnCleanUp() {
  1014. var p = Function.prototype;
  1015. delete p.createSequence;
  1016. delete p.defer;
  1017. delete p.createDelegate;
  1018. delete p.createCallback;
  1019. delete p.createInterceptor;
  1020. window.detachEvent("onunload", fnCleanUp);
  1021. }
  1022. window.attachEvent("onunload", fnCleanUp);
  1023. }
  1024. Ext.lib.AnimBase = function(el, attributes, duration, method) {
  1025. if (el) {
  1026. this.init(el, attributes, duration, method);
  1027. }
  1028. };
  1029. Ext.lib.AnimBase.prototype = {
  1030. toString: function() {
  1031. var el = this.getEl();
  1032. var id = el.id || el.tagName;
  1033. return ("Anim " + id);
  1034. },
  1035. patterns: {
  1036. noNegatives: /width|height|opacity|padding/i,
  1037. offsetAttribute: /^((width|height)|(top|left))$/,
  1038. defaultUnit: /width|height|top$|bottom$|left$|right$/i,
  1039. offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
  1040. },
  1041. doMethod: function(attr, start, end) {
  1042. return this.method(this.currentFrame, start, end - start, this.totalFrames);
  1043. },
  1044. setAttribute: function(attr, val, unit) {
  1045. if (this.patterns.noNegatives.test(attr)) {
  1046. val = (val > 0) ? val : 0;
  1047. }
  1048. Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
  1049. },
  1050. getAttribute: function(attr) {
  1051. var el = this.getEl();
  1052. var val = fly(el).getStyle(attr);
  1053. if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
  1054. return parseFloat(val);
  1055. }
  1056. var a = this.patterns.offsetAttribute.exec(attr) || [];
  1057. var pos = !!( a[3] );
  1058. var box = !!( a[2] );
  1059. if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
  1060. val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
  1061. } else {
  1062. val = 0;
  1063. }
  1064. return val;
  1065. },
  1066. getDefaultUnit: function(attr) {
  1067. if (this.patterns.defaultUnit.test(attr)) {
  1068. return 'px';
  1069. }
  1070. return '';
  1071. },
  1072. animateX : function(callback, scope) {
  1073. var f = function() {
  1074. this.onComplete.removeListener(f);
  1075. if (typeof callback == "function") {
  1076. callback.call(scope || this, this);
  1077. }
  1078. };
  1079. this.onComplete.addListener(f, this);
  1080. this.animate();
  1081. },
  1082. setRuntimeAttribute: function(attr) {
  1083. var start;
  1084. var end;
  1085. var attributes = this.attributes;
  1086. this.runtimeAttributes[attr] = {};
  1087. var isset = function(prop) {
  1088. return (typeof prop !== 'undefined');
  1089. };
  1090. if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) {
  1091. return false;
  1092. }
  1093. start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
  1094. if (isset(attributes[attr]['to'])) {
  1095. end = attributes[attr]['to'];
  1096. } else if (isset(attributes[attr]['by'])) {
  1097. if (start.constructor == Array) {
  1098. end = [];
  1099. for (var i = 0, len = start.length; i < len; ++i) {
  1100. end[i] = start[i] + attributes[attr]['by'][i];
  1101. }
  1102. } else {
  1103. end = start + attributes[attr]['by'];
  1104. }
  1105. }
  1106. this.runtimeAttributes[attr].start = start;
  1107. this.runtimeAttributes[attr].end = end;
  1108. this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
  1109. },
  1110. init: function(el, attributes, duration, method) {
  1111. var isAnimated = false;
  1112. var startTime = null;
  1113. var actualFrames = 0;
  1114. el = Ext.getDom(el);
  1115. this.attributes = attributes || {};
  1116. this.duration = duration || 1;
  1117. this.method = method || Ext.lib.Easing.easeNone;
  1118. this.useSeconds = true;
  1119. this.currentFrame = 0;
  1120. this.totalFrames = Ext.lib.AnimMgr.fps;
  1121. this.getEl = function() {
  1122. return el;
  1123. };
  1124. this.isAnimated = function() {
  1125. return isAnimated;
  1126. };
  1127. this.getStartTime = function() {
  1128. return startTime;
  1129. };
  1130. this.runtimeAttributes = {};
  1131. this.animate = function() {
  1132. if (this.isAnimated()) {
  1133. return false;
  1134. }
  1135. this.currentFrame = 0;
  1136. this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration;
  1137. Ext.lib.AnimMgr.registerElement(this);
  1138. };
  1139. this.stop = function(finish) {
  1140. if (finish) {
  1141. this.currentFrame = this.totalFrames;
  1142. this._onTween.fire();
  1143. }
  1144. Ext.lib.AnimMgr.stop(this);
  1145. };
  1146. var onStart = function() {
  1147. this.onStart.fire();
  1148. this.runtimeAttributes = {};
  1149. for (var attr in this.attributes) {
  1150. this.setRuntimeAttribute(attr);
  1151. }
  1152. isAnimated = true;
  1153. actualFrames = 0;
  1154. startTime = new Date();
  1155. };
  1156. var onTween = function() {
  1157. var data = {
  1158. duration: new Date() - this.getStartTime(),
  1159. currentFrame: this.currentFrame
  1160. };
  1161. data.toString = function() {
  1162. return (
  1163. 'duration: ' + data.duration +
  1164. ', currentFrame: ' + data.currentFrame
  1165. );
  1166. };
  1167. this.onTween.fire(data);
  1168. var runtimeAttributes = this.runtimeAttributes;
  1169. for (var attr in runtimeAttributes) {
  1170. this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
  1171. }
  1172. actualFrames += 1;
  1173. };
  1174. var onComplete = function() {
  1175. var actual_duration = (new Date() - startTime) / 1000 ;
  1176. var data = {
  1177. duration: actual_duration,
  1178. frames: actualFrames,
  1179. fps: actualFrames / actual_duration
  1180. };
  1181. data.toString = function() {
  1182. return (
  1183. 'duration: ' + data.duration +
  1184. ', frames: ' + data.frames +
  1185. ', fps: ' + data.fps
  1186. );
  1187. };
  1188. isAnimated = false;
  1189. actualFrames = 0;
  1190. this.onComplete.fire(data);
  1191. };
  1192. this._onStart = new Ext.util.Event(this);
  1193. this.onStart = new Ext.util.Event(this);
  1194. this.onTween = new Ext.util.Event(this);
  1195. this._onTween = new Ext.util.Event(this);
  1196. this.onComplete = new Ext.util.Event(this);
  1197. this._onComplete = new Ext.util.Event(this);
  1198. this._onStart.addListener(onStart);
  1199. this._onTween.addListener(onTween);
  1200. this._onComplete.addListener(onComplete);
  1201. }
  1202. };
  1203. Ext.lib.AnimMgr = new function() {
  1204. var thread = null;
  1205. var queue = [];
  1206. var tweenCount = 0;
  1207. this.fps = 1000;
  1208. this.delay = 1;
  1209. this.registerElement = function(tween) {
  1210. queue[queue.length] = tween;
  1211. tweenCount += 1;
  1212. tween._onStart.fire();
  1213. this.start();
  1214. };
  1215. this.unRegister = function(tween, index) {
  1216. tween._onComplete.fire();
  1217. index = index || getIndex(tween);
  1218. if (index != -1) {
  1219. queue.splice(index, 1);
  1220. }
  1221. tweenCount -= 1;
  1222. if (tweenCount <= 0) {
  1223. this.stop();
  1224. }
  1225. };
  1226. this.start = function() {
  1227. if (thread === null) {
  1228. thread = setInterval(this.run, this.delay);
  1229. }
  1230. };
  1231. this.stop = function(tween) {
  1232. if (!tween) {
  1233. clearInterval(thread);
  1234. for (var i = 0, len = queue.length; i < len; ++i) {
  1235. if (queue[0].isAnimated()) {
  1236. this.unRegister(queue[0], 0);
  1237. }
  1238. }
  1239. queue = [];
  1240. thread = null;
  1241. tweenCount = 0;
  1242. }
  1243. else {
  1244. this.unRegister(tween);
  1245. }
  1246. };
  1247. this.run = function() {
  1248. for (var i = 0, len = queue.length; i < len; ++i) {
  1249. var tween = queue[i];
  1250. if (!tween || !tween.isAnimated()) {
  1251. continue;
  1252. }
  1253. if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
  1254. {
  1255. tween.currentFrame += 1;
  1256. if (tween.useSeconds) {
  1257. correctFrame(tween);
  1258. }
  1259. tween._onTween.fire();
  1260. }
  1261. else {
  1262. Ext.lib.AnimMgr.stop(tween, i);
  1263. }
  1264. }
  1265. };
  1266. var getIndex = function(anim) {
  1267. for (var i = 0, len = queue.length; i < len; ++i) {
  1268. if (queue[i] == anim) {
  1269. return i;
  1270. }
  1271. }
  1272. return -1;
  1273. };
  1274. var correctFrame = function(tween) {
  1275. var frames = tween.totalFrames;
  1276. var frame = tween.currentFrame;
  1277. var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
  1278. var elapsed = (new Date() - tween.getStartTime());
  1279. var tweak = 0;
  1280. if (elapsed < tween.duration * 1000) {
  1281. tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
  1282. } else {
  1283. tweak = frames - (frame + 1);
  1284. }
  1285. if (tweak > 0 && isFinite(tweak)) {
  1286. if (tween.currentFrame + tweak >= frames) {
  1287. tweak = frames - (frame + 1);
  1288. }
  1289. tween.currentFrame += t

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