ext-base.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. (function() {
  7. var libFlyweight;
  8. Ext.lib.Dom = {
  9. getViewWidth : function(full) {
  10. return full ? this.getDocumentWidth() : this.getViewportWidth();
  11. },
  12. getViewHeight : function(full) {
  13. return full ? this.getDocumentHeight() : this.getViewportHeight();
  14. },
  15. getDocumentHeight : function() {
  16. var scrollHeight = (document.compatMode != "CSS1Compat")
  17. ? document.body.scrollHeight
  18. : document.documentElement.scrollHeight;
  19. return Math.max(scrollHeight, this.getViewportHeight());
  20. },
  21. getDocumentWidth : function() {
  22. var scrollWidth = (document.compatMode != "CSS1Compat")
  23. ? document.body.scrollWidth
  24. : document.documentElement.scrollWidth;
  25. return Math.max(scrollWidth, this.getViewportWidth());
  26. },
  27. getViewportHeight : function() {
  28. if (Ext.isIE) {
  29. return Ext.isStrict
  30. ? document.documentElement.clientHeight
  31. : document.body.clientHeight;
  32. } else {
  33. return self.innerHeight;
  34. }
  35. },
  36. getViewportWidth : function() {
  37. if (Ext.isIE) {
  38. return Ext.isStrict
  39. ? document.documentElement.clientWidth
  40. : document.body.clientWidth;
  41. } else {
  42. return self.innerWidth;
  43. }
  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. } else if (!parent.tagName
  61. || 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 || document.documentElement);
  80. el = Ext.getDom(el);
  81. if (el == bd) {
  82. return [0, 0];
  83. }
  84. if (el.getBoundingClientRect) {
  85. b = el.getBoundingClientRect();
  86. scroll = fly(document).getScroll();
  87. return [b.left + scroll.left, b.top + scroll.top];
  88. }
  89. var x = 0, y = 0;
  90. p = el;
  91. var hasAbsolute = fly(el).getStyle("position") == "absolute";
  92. while (p) {
  93. x += p.offsetLeft;
  94. y += p.offsetTop;
  95. if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
  96. hasAbsolute = true;
  97. }
  98. if (Ext.isGecko) {
  99. pe = fly(p);
  100. var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
  101. var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
  102. x += bl;
  103. y += bt;
  104. if (p != el && pe.getStyle('overflow') != 'visible') {
  105. x += bl;
  106. y += bt;
  107. }
  108. }
  109. p = p.offsetParent;
  110. }
  111. if (Ext.isSafari && hasAbsolute) {
  112. x -= bd.offsetLeft;
  113. y -= bd.offsetTop;
  114. }
  115. if (Ext.isGecko && !hasAbsolute) {
  116. var dbd = fly(bd);
  117. x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
  118. y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
  119. }
  120. p = el.parentNode;
  121. while (p && p != bd) {
  122. if (!Ext.isOpera
  123. || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
  124. x -= p.scrollLeft;
  125. y -= p.scrollTop;
  126. }
  127. p = p.parentNode;
  128. }
  129. return [x, y];
  130. },
  131. setXY : function(el, xy) {
  132. el = Ext.fly(el, '_setXY');
  133. el.position();
  134. var pts = el.translatePoints(xy);
  135. if (xy[0] !== false) {
  136. el.dom.style.left = pts.left + "px";
  137. }
  138. if (xy[1] !== false) {
  139. el.dom.style.top = pts.top + "px";
  140. }
  141. },
  142. setX : function(el, x) {
  143. this.setXY(el, [x, false]);
  144. },
  145. setY : function(el, y) {
  146. this.setXY(el, [false, y]);
  147. }
  148. };
  149. /*
  150. * Portions of this file are based on pieces of Yahoo User Interface Library
  151. * Copyright (c) 2007, Yahoo! Inc. All rights reserved. YUI licensed under
  152. * the BSD License: http://developer.yahoo.net/yui/license.txt
  153. */
  154. Ext.lib.Event = function() {
  155. var loadComplete = false;
  156. var listeners = [];
  157. var unloadListeners = [];
  158. var retryCount = 0;
  159. var onAvailStack = [];
  160. var counter = 0;
  161. var lastError = null;
  162. return {
  163. POLL_RETRYS : 200,
  164. POLL_INTERVAL : 20,
  165. EL : 0,
  166. TYPE : 1,
  167. FN : 2,
  168. WFN : 3,
  169. OBJ : 3,
  170. ADJ_SCOPE : 4,
  171. _interval : null,
  172. startInterval : function() {
  173. if (!this._interval) {
  174. var self = this;
  175. var callback = function() {
  176. self._tryPreloadAttach();
  177. };
  178. this._interval = setInterval(callback, this.POLL_INTERVAL);
  179. }
  180. },
  181. onAvailable : function(p_id, p_fn, p_obj, p_override) {
  182. onAvailStack.push({
  183. id : p_id,
  184. fn : p_fn,
  185. obj : p_obj,
  186. override : p_override,
  187. checkReady : false
  188. });
  189. retryCount = this.POLL_RETRYS;
  190. this.startInterval();
  191. },
  192. addListener : function(el, eventName, fn) {
  193. el = Ext.getDom(el);
  194. if (!el || !fn) {
  195. return false;
  196. }
  197. if ("unload" == eventName) {
  198. unloadListeners[unloadListeners.length] = [el, eventName,
  199. fn];
  200. return true;
  201. }
  202. // prevent unload errors with simple check
  203. var wrappedFn = function(e) {
  204. return typeof Ext != 'undefined' ? fn(Ext.lib.Event
  205. .getEvent(e)) : false;
  206. };
  207. var li = [el, eventName, fn, wrappedFn];
  208. var index = listeners.length;
  209. listeners[index] = li;
  210. this.doAdd(el, eventName, wrappedFn, false);
  211. return true;
  212. },
  213. removeListener : function(el, eventName, fn) {
  214. var i, len;
  215. el = Ext.getDom(el);
  216. if (!fn) {
  217. return this.purgeElement(el, false, eventName);
  218. }
  219. if ("unload" == eventName) {
  220. for (i = 0, len = unloadListeners.length; i < len; i++) {
  221. var li = unloadListeners[i];
  222. if (li && li[0] == el && li[1] == eventName
  223. && li[2] == fn) {
  224. unloadListeners.splice(i, 1);
  225. return true;
  226. }
  227. }
  228. return false;
  229. }
  230. var cacheItem = null;
  231. var index = arguments[3];
  232. if ("undefined" == typeof index) {
  233. index = this._getCacheIndex(el, eventName, fn);
  234. }
  235. if (index >= 0) {
  236. cacheItem = listeners[index];
  237. }
  238. if (!el || !cacheItem) {
  239. return false;
  240. }
  241. this.doRemove(el, eventName, cacheItem[this.WFN], false);
  242. delete listeners[index][this.WFN];
  243. delete listeners[index][this.FN];
  244. listeners.splice(index, 1);
  245. return true;
  246. },
  247. getTarget : function(ev, resolveTextNode) {
  248. ev = ev.browserEvent || ev;
  249. var t = ev.target || ev.srcElement;
  250. return this.resolveTextNode(t);
  251. },
  252. resolveTextNode : function(node) {
  253. if (Ext.isSafari && node && 3 == node.nodeType) {
  254. return node.parentNode;
  255. } else {
  256. return node;
  257. }
  258. },
  259. getPageX : function(ev) {
  260. ev = ev.browserEvent || ev;
  261. var x = ev.pageX;
  262. if (!x && 0 !== x) {
  263. x = ev.clientX || 0;
  264. if (Ext.isIE) {
  265. x += this.getScroll()[1];
  266. }
  267. }
  268. return x;
  269. },
  270. getPageY : function(ev) {
  271. ev = ev.browserEvent || ev;
  272. var y = ev.pageY;
  273. if (!y && 0 !== y) {
  274. y = ev.clientY || 0;
  275. if (Ext.isIE) {
  276. y += this.getScroll()[0];
  277. }
  278. }
  279. return y;
  280. },
  281. getXY : function(ev) {
  282. ev = ev.browserEvent || ev;
  283. return [this.getPageX(ev), this.getPageY(ev)];
  284. },
  285. getRelatedTarget : function(ev) {
  286. ev = ev.browserEvent || ev;
  287. var t = ev.relatedTarget;
  288. if (!t) {
  289. if (ev.type == "mouseout") {
  290. t = ev.toElement;
  291. } else if (ev.type == "mouseover") {
  292. t = ev.fromElement;
  293. }
  294. }
  295. return this.resolveTextNode(t);
  296. },
  297. getTime : function(ev) {
  298. ev = ev.browserEvent || ev;
  299. if (!ev.time) {
  300. var t = allGetServerTime().getTime();
  301. try {
  302. ev.time = t;
  303. } catch (ex) {
  304. this.lastError = ex;
  305. return t;
  306. }
  307. }
  308. return ev.time;
  309. },
  310. stopEvent : function(ev) {
  311. this.stopPropagation(ev);
  312. this.preventDefault(ev);
  313. },
  314. stopPropagation : function(ev) {
  315. ev = ev.browserEvent || ev;
  316. if (ev.stopPropagation) {
  317. ev.stopPropagation();
  318. } else {
  319. ev.cancelBubble = true;
  320. }
  321. },
  322. preventDefault : function(ev) {
  323. ev = ev.browserEvent || ev;
  324. if (ev.preventDefault) {
  325. ev.preventDefault();
  326. } else {
  327. ev.returnValue = false;
  328. }
  329. },
  330. getEvent : function(e) {
  331. var ev = e || window.event;
  332. if (!ev) {
  333. var c = this.getEvent.caller;
  334. while (c) {
  335. ev = c.arguments[0];
  336. if (ev && Event == ev.constructor) {
  337. break;
  338. }
  339. c = c.caller;
  340. }
  341. }
  342. return ev;
  343. },
  344. getCharCode : function(ev) {
  345. ev = ev.browserEvent || ev;
  346. return ev.charCode || ev.keyCode || 0;
  347. },
  348. _getCacheIndex : function(el, eventName, fn) {
  349. for (var i = 0, len = listeners.length; i < len; ++i) {
  350. var li = listeners[i];
  351. if (li && li[this.FN] == fn && li[this.EL] == el
  352. && li[this.TYPE] == eventName) {
  353. return i;
  354. }
  355. }
  356. return -1;
  357. },
  358. elCache : {},
  359. getEl : function(id) {
  360. return document.getElementById(id);
  361. },
  362. clearCache : function() {
  363. },
  364. _load : function(e) {
  365. loadComplete = true;
  366. var EU = Ext.lib.Event;
  367. if (Ext.isIE) {
  368. EU.doRemove(window, "load", EU._load);
  369. }
  370. },
  371. _tryPreloadAttach : function() {
  372. if (this.locked) {
  373. return false;
  374. }
  375. this.locked = true;
  376. var tryAgain = !loadComplete;
  377. if (!tryAgain) {
  378. tryAgain = (retryCount > 0);
  379. }
  380. var notAvail = [];
  381. for (var i = 0, len = onAvailStack.length; i < len; ++i) {
  382. var item = onAvailStack[i];
  383. if (item) {
  384. var el = this.getEl(item.id);
  385. if (el) {
  386. if (!item.checkReady || loadComplete
  387. || el.nextSibling
  388. || (document && document.body)) {
  389. var scope = el;
  390. if (item.override) {
  391. if (item.override === true) {
  392. scope = item.obj;
  393. } else {
  394. scope = item.override;
  395. }
  396. }
  397. item.fn.call(scope, item.obj);
  398. onAvailStack[i] = null;
  399. }
  400. } else {
  401. notAvail.push(item);
  402. }
  403. }
  404. }
  405. retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
  406. if (tryAgain) {
  407. this.startInterval();
  408. } else {
  409. clearInterval(this._interval);
  410. this._interval = null;
  411. }
  412. this.locked = false;
  413. return true;
  414. },
  415. purgeElement : function(el, recurse, eventName) {
  416. var elListeners = this.getListeners(el, eventName);
  417. if (elListeners) {
  418. for (var i = 0, len = elListeners.length; i < len; ++i) {
  419. var l = elListeners[i];
  420. this.removeListener(el, l.type, l.fn);
  421. }
  422. }
  423. if (recurse && el && el.childNodes) {
  424. for (i = 0, len = el.childNodes.length; i < len; ++i) {
  425. this.purgeElement(el.childNodes[i], recurse, eventName);
  426. }
  427. }
  428. },
  429. getListeners : function(el, eventName) {
  430. var results = [], searchLists;
  431. if (!eventName) {
  432. searchLists = [listeners, unloadListeners];
  433. } else if (eventName == "unload") {
  434. searchLists = [unloadListeners];
  435. } else {
  436. searchLists = [listeners];
  437. }
  438. for (var j = 0; j < searchLists.length; ++j) {
  439. var searchList = searchLists[j];
  440. if (searchList && searchList.length > 0) {
  441. for (var i = 0, len = searchList.length; i < len; ++i) {
  442. var l = searchList[i];
  443. if (l
  444. && l[this.EL] === el
  445. && (!eventName || eventName === l[this.TYPE])) {
  446. results.push({
  447. type : l[this.TYPE],
  448. fn : l[this.FN],
  449. obj : l[this.OBJ],
  450. adjust : l[this.ADJ_SCOPE],
  451. index : i
  452. });
  453. }
  454. }
  455. }
  456. }
  457. return (results.length) ? results : null;
  458. },
  459. _unload : function(e) {
  460. var EU = Ext.lib.Event, i, j, l, len, index;
  461. for (i = 0, len = unloadListeners.length; i < len; ++i) {
  462. l = unloadListeners[i];
  463. if (l) {
  464. var scope = window;
  465. if (l[EU.ADJ_SCOPE]) {
  466. if (l[EU.ADJ_SCOPE] === true) {
  467. scope = l[EU.OBJ];
  468. } else {
  469. scope = l[EU.ADJ_SCOPE];
  470. }
  471. }
  472. l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
  473. unloadListeners[i] = null;
  474. l = null;
  475. scope = null;
  476. }
  477. }
  478. unloadListeners = null;
  479. if (listeners && listeners.length > 0) {
  480. j = listeners.length;
  481. while (j) {
  482. index = j - 1;
  483. l = listeners[index];
  484. if (l) {
  485. EU.removeListener(l[EU.EL], l[EU.TYPE], l[EU.FN],
  486. index);
  487. }
  488. j = j - 1;
  489. }
  490. l = null;
  491. EU.clearCache();
  492. }
  493. EU.doRemove(window, "unload", EU._unload);
  494. },
  495. getScroll : function() {
  496. var dd = document.documentElement, db = document.body;
  497. if (dd && (dd.scrollTop || dd.scrollLeft)) {
  498. return [dd.scrollTop, dd.scrollLeft];
  499. } else if (db) {
  500. return [db.scrollTop, db.scrollLeft];
  501. } else {
  502. return [0, 0];
  503. }
  504. },
  505. doAdd : function() {
  506. if (window.addEventListener) {
  507. return function(el, eventName, fn, capture) {
  508. el.addEventListener(eventName, fn, (capture));
  509. };
  510. } else if (window.attachEvent) {
  511. return function(el, eventName, fn, capture) {
  512. el.attachEvent("on" + eventName, fn);
  513. };
  514. } else {
  515. return function() {
  516. };
  517. }
  518. }(),
  519. doRemove : function() {
  520. if (window.removeEventListener) {
  521. return function(el, eventName, fn, capture) {
  522. el.removeEventListener(eventName, fn, (capture));
  523. };
  524. } else if (window.detachEvent) {
  525. return function(el, eventName, fn) {
  526. el.detachEvent("on" + eventName, fn);
  527. };
  528. } else {
  529. return function() {
  530. };
  531. }
  532. }()
  533. };
  534. }();
  535. var E = Ext.lib.Event;
  536. E.on = E.addListener;
  537. E.un = E.removeListener;
  538. if (document && document.body) {
  539. E._load();
  540. } else {
  541. E.doAdd(window, "load", E._load);
  542. }
  543. E.doAdd(window, "unload", E._unload);
  544. E._tryPreloadAttach();
  545. Ext.lib.Ajax = {
  546. request : function(method, uri, cb, data, options) {
  547. if (options) {
  548. var hs = options.headers;
  549. if (hs) {
  550. for (var h in hs) {
  551. if (hs.hasOwnProperty(h)) {
  552. this.initHeader(h, hs[h], false);
  553. }
  554. }
  555. }
  556. if (options.xmlData) {
  557. this.initHeader('Content-Type', 'text/xml', false);
  558. method = 'POST';
  559. data = options.xmlData;
  560. } else if (options.jsonData) {
  561. this.initHeader('Content-Type', 'text/javascript', false);
  562. method = 'POST';
  563. data = typeof options.jsonData == 'object' ? Ext
  564. .encode(options.jsonData) : options.jsonData;
  565. }
  566. }
  567. return this.asyncRequest(method, uri, cb, data);
  568. },
  569. serializeForm : function(form) {
  570. if (typeof form == 'string') {
  571. form = (document.getElementById(form) || document.forms[form]);
  572. }
  573. var el, name, val, disabled, data = '', hasSubmit = false;
  574. for (var i = 0; i < form.elements.length; i++) {
  575. el = form.elements[i];
  576. disabled = form.elements[i].disabled;
  577. name = form.elements[i].name;
  578. val = form.elements[i].value;
  579. if (!disabled && name) {
  580. switch (el.type) {
  581. case 'select-one' :
  582. case 'select-multiple' :
  583. for (var j = 0; j < el.options.length; j++) {
  584. if (el.options[j].selected) {
  585. if (Ext.isIE) {
  586. data += encodeURIComponent(name)
  587. + '='
  588. + encodeURIComponent(el.options[j].attributes['value'].specified
  589. ? el.options[j].value
  590. : el.options[j].text)
  591. + '&';
  592. } else {
  593. data += encodeURIComponent(name)
  594. + '='
  595. + encodeURIComponent(el.options[j]
  596. .hasAttribute('value')
  597. ? el.options[j].value
  598. : el.options[j].text)
  599. + '&';
  600. }
  601. }
  602. }
  603. break;
  604. case 'radio' :
  605. case 'checkbox' :
  606. if (el.checked) {
  607. data += encodeURIComponent(name) + '='
  608. + encodeURIComponent(val) + '&';
  609. }
  610. break;
  611. case 'file' :
  612. case undefined :
  613. case 'reset' :
  614. case 'button' :
  615. break;
  616. case 'submit' :
  617. if (hasSubmit == false) {
  618. data += encodeURIComponent(name) + '='
  619. + encodeURIComponent(val) + '&';
  620. hasSubmit = true;
  621. }
  622. break;
  623. default :
  624. data += encodeURIComponent(name) + '='
  625. + encodeURIComponent(val) + '&';
  626. break;
  627. }
  628. }
  629. }
  630. data = data.substr(0, data.length - 1);
  631. return data;
  632. },
  633. headers : {},
  634. hasHeaders : false,
  635. useDefaultHeader : true,
  636. defaultPostHeader : 'application/x-www-form-urlencoded',
  637. useDefaultXhrHeader : true,
  638. defaultXhrHeader : 'XMLHttpRequest',
  639. hasDefaultHeaders : true,
  640. defaultHeaders : {},
  641. poll : {},
  642. timeout : {},
  643. pollInterval : 50,
  644. transactionId : 0,
  645. setProgId : function(id) {
  646. this.activeX.unshift(id);
  647. },
  648. setDefaultPostHeader : function(b) {
  649. this.useDefaultHeader = b;
  650. },
  651. setDefaultXhrHeader : function(b) {
  652. this.useDefaultXhrHeader = b;
  653. },
  654. setPollingInterval : function(i) {
  655. if (typeof i == 'number' && isFinite(i)) {
  656. this.pollInterval = i;
  657. }
  658. },
  659. createXhrObject : function(transactionId) {
  660. var obj, http;
  661. try {
  662. http = new XMLHttpRequest();
  663. obj = {
  664. conn : http,
  665. tId : transactionId
  666. };
  667. } catch (e) {
  668. for (var i = 0; i < this.activeX.length; ++i) {
  669. try {
  670. http = new ActiveXObject(this.activeX[i]);
  671. obj = {
  672. conn : http,
  673. tId : transactionId
  674. };
  675. break;
  676. } catch (e) {
  677. }
  678. }
  679. } finally {
  680. return obj;
  681. }
  682. },
  683. getConnectionObject : function() {
  684. var o;
  685. var tId = this.transactionId;
  686. try {
  687. o = this.createXhrObject(tId);
  688. if (o) {
  689. this.transactionId++;
  690. }
  691. } catch (e) {
  692. } finally {
  693. return o;
  694. }
  695. },
  696. asyncRequest : function(method, uri, callback, postData) {
  697. var o = this.getConnectionObject();
  698. if (!o) {
  699. return null;
  700. } else {
  701. o.conn.open(method, uri, true);
  702. if (this.useDefaultXhrHeader) {
  703. if (!this.defaultHeaders['X-Requested-With']) {
  704. this.initHeader('X-Requested-With',
  705. this.defaultXhrHeader, true);
  706. }
  707. }
  708. if (postData && this.useDefaultHeader) {
  709. this.initHeader('Content-Type', this.defaultPostHeader);
  710. }
  711. if (this.hasDefaultHeaders || this.hasHeaders) {
  712. this.setHeader(o);
  713. }
  714. this.handleReadyState(o, callback);
  715. o.conn.send(postData || null);
  716. return o;
  717. }
  718. },
  719. handleReadyState : function(o, callback) {
  720. var oConn = this;
  721. if (callback && callback.timeout) {
  722. this.timeout[o.tId] = window.setTimeout(function() {
  723. oConn.abort(o, callback, true);
  724. }, callback.timeout);
  725. }
  726. this.poll[o.tId] = window.setInterval(function() {
  727. if (o.conn && o.conn.readyState == 4) {
  728. window.clearInterval(oConn.poll[o.tId]);
  729. delete oConn.poll[o.tId];
  730. if (callback && callback.timeout) {
  731. window.clearTimeout(oConn.timeout[o.tId]);
  732. delete oConn.timeout[o.tId];
  733. }
  734. oConn.handleTransactionResponse(o, callback);
  735. }
  736. }, this.pollInterval);
  737. },
  738. handleTransactionResponse : function(o, callback, isAbort) {
  739. if (!callback) {
  740. this.releaseObject(o);
  741. return;
  742. }
  743. var httpStatus, responseObject;
  744. try {
  745. if (o.conn.status !== undefined && o.conn.status != 0) {
  746. httpStatus = o.conn.status;
  747. } else {
  748. httpStatus = 13030;
  749. }
  750. } catch (e) {
  751. httpStatus = 13030;
  752. }
  753. if (httpStatus >= 200 && httpStatus < 300) {
  754. responseObject = this
  755. .createResponseObject(o, callback.argument);
  756. if (callback.success) {
  757. if (!callback.scope) {
  758. callback.success(responseObject);
  759. } else {
  760. callback.success
  761. .apply(callback.scope, [responseObject]);
  762. }
  763. }
  764. } else {
  765. switch (httpStatus) {
  766. case 12002 :
  767. case 12029 :
  768. case 12030 :
  769. case 12031 :
  770. case 12152 :
  771. case 13030 :
  772. responseObject = this.createExceptionObject(o.tId,
  773. callback.argument, (isAbort ? isAbort : false));
  774. if (callback.failure) {
  775. if (!callback.scope) {
  776. callback.failure(responseObject);
  777. } else {
  778. callback.failure.apply(callback.scope,
  779. [responseObject]);
  780. }
  781. }
  782. break;
  783. default :
  784. responseObject = this.createResponseObject(o,
  785. callback.argument);
  786. if (callback.failure) {
  787. if (!callback.scope) {
  788. callback.failure(responseObject);
  789. } else {
  790. callback.failure.apply(callback.scope,
  791. [responseObject]);
  792. }
  793. }
  794. }
  795. }
  796. this.releaseObject(o);
  797. responseObject = null;
  798. },
  799. createResponseObject : function(o, callbackArg) {
  800. var obj = {};
  801. var headerObj = {};
  802. try {
  803. var headerStr = o.conn.getAllResponseHeaders();
  804. var header = headerStr.split('\n');
  805. for (var i = 0; i < header.length; i++) {
  806. var delimitPos = header[i].indexOf(':');
  807. if (delimitPos != -1) {
  808. headerObj[header[i].substring(0, delimitPos)] = header[i]
  809. .substring(delimitPos + 2);
  810. }
  811. }
  812. } catch (e) {
  813. }
  814. obj.tId = o.tId;
  815. obj.status = o.conn.status;
  816. obj.statusText = o.conn.statusText;
  817. obj.getResponseHeader = headerObj;
  818. obj.getAllResponseHeaders = headerStr;
  819. obj.responseText = o.conn.responseText;
  820. obj.responseXML = o.conn.responseXML;
  821. if (typeof callbackArg !== undefined) {
  822. obj.argument = callbackArg;
  823. }
  824. return obj;
  825. },
  826. createExceptionObject : function(tId, callbackArg, isAbort) {
  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. } else {
  837. obj.status = COMM_CODE;
  838. obj.statusText = COMM_ERROR;
  839. }
  840. if (callbackArg) {
  841. obj.argument = callbackArg;
  842. }
  843. return obj;
  844. },
  845. initHeader : function(label, value, isDefault) {
  846. var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
  847. if (headerObj[label] === undefined) {
  848. headerObj[label] = value;
  849. } else {
  850. headerObj[label] = value + "," + headerObj[label];
  851. }
  852. if (isDefault) {
  853. this.hasDefaultHeaders = true;
  854. } else {
  855. this.hasHeaders = true;
  856. }
  857. },
  858. setHeader : function(o) {
  859. if (this.hasDefaultHeaders) {
  860. for (var prop in this.defaultHeaders) {
  861. if (this.defaultHeaders.hasOwnProperty(prop)) {
  862. o.conn
  863. .setRequestHeader(prop,
  864. this.defaultHeaders[prop]);
  865. }
  866. }
  867. }
  868. if (this.hasHeaders) {
  869. for (var prop in this.headers) {
  870. if (this.headers.hasOwnProperty(prop)) {
  871. o.conn.setRequestHeader(prop, this.headers[prop]);
  872. }
  873. }
  874. this.headers = {};
  875. this.hasHeaders = false;
  876. }
  877. },
  878. resetDefaultHeaders : function() {
  879. delete this.defaultHeaders;
  880. this.defaultHeaders = {};
  881. this.hasDefaultHeaders = false;
  882. },
  883. abort : function(o, callback, isTimeout) {
  884. if (this.isCallInProgress(o)) {
  885. o.conn.abort();
  886. window.clearInterval(this.poll[o.tId]);
  887. delete this.poll[o.tId];
  888. if (isTimeout) {
  889. delete this.timeout[o.tId];
  890. }
  891. this.handleTransactionResponse(o, callback, true);
  892. return true;
  893. } else {
  894. return false;
  895. }
  896. },
  897. isCallInProgress : function(o) {
  898. if (o.conn) {
  899. return o.conn.readyState != 4 && o.conn.readyState != 0;
  900. } else {
  901. return false;
  902. }
  903. },
  904. releaseObject : function(o) {
  905. o.conn = null;
  906. o = null;
  907. },
  908. activeX : ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']
  909. };
  910. Ext.lib.Region = function(t, r, b, l) {
  911. this.top = t;
  912. this[1] = t;
  913. this.right = r;
  914. this.bottom = b;
  915. this.left = l;
  916. this[0] = l;
  917. };
  918. Ext.lib.Region.prototype = {
  919. contains : function(region) {
  920. return (region.left >= this.left && region.right <= this.right
  921. && region.top >= this.top && region.bottom <= this.bottom);
  922. },
  923. getArea : function() {
  924. return ((this.bottom - this.top) * (this.right - this.left));
  925. },
  926. intersect : function(region) {
  927. var t = Math.max(this.top, region.top);
  928. var r = Math.min(this.right, region.right);
  929. var b = Math.min(this.bottom, region.bottom);
  930. var l = Math.max(this.left, region.left);
  931. if (b >= t && r >= l) {
  932. return new Ext.lib.Region(t, r, b, l);
  933. } else {
  934. return null;
  935. }
  936. },
  937. union : function(region) {
  938. var t = Math.min(this.top, region.top);
  939. var r = Math.max(this.right, region.right);
  940. var b = Math.max(this.bottom, region.bottom);
  941. var l = Math.min(this.left, region.left);
  942. return new Ext.lib.Region(t, r, b, l);
  943. },
  944. constrainTo : function(r) {
  945. this.top = this.top.constrain(r.top, r.bottom);
  946. this.bottom = this.bottom.constrain(r.top, r.bottom);
  947. this.left = this.left.constrain(r.left, r.right);
  948. this.right = this.right.constrain(r.left, r.right);
  949. return this;
  950. },
  951. adjust : function(t, l, b, r) {
  952. this.top += t;
  953. this.left += l;
  954. this.right += r;
  955. this.bottom += b;
  956. return this;
  957. }
  958. };
  959. Ext.lib.Region.getRegion = function(el) {
  960. var p = Ext.lib.Dom.getXY(el);
  961. var t = p[1];
  962. var r = p[0] + el.offsetWidth;
  963. var b = p[1] + el.offsetHeight;
  964. var l = p[0];
  965. return new Ext.lib.Region(t, r, b, l);
  966. };
  967. Ext.lib.Point = function(x, y) {
  968. if (x instanceof Array) {
  969. y = x[1];
  970. x = x[0];
  971. }
  972. this.x = this.right = this.left = this[0] = x;
  973. this.y = this.top = this.bottom = this[1] = y;
  974. };
  975. Ext.lib.Point.prototype = new Ext.lib.Region();
  976. Ext.lib.Anim = {
  977. scroll : function(el, args, duration, easing, cb, scope) {
  978. this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
  979. },
  980. motion : function(el, args, duration, easing, cb, scope) {
  981. this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
  982. },
  983. color : function(el, args, duration, easing, cb, scope) {
  984. this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
  985. },
  986. run : function(el, args, duration, easing, cb, scope, type) {
  987. type = type || Ext.lib.AnimBase;
  988. if (typeof easing == "string") {
  989. easing = Ext.lib.Easing[easing];
  990. }
  991. var anim = new type(el, args, duration, easing);
  992. anim.animateX(function() {
  993. Ext.callback(cb, scope);
  994. });
  995. return anim;
  996. }
  997. };
  998. function fly(el) {
  999. if (!libFlyweight) {
  1000. libFlyweight = new Ext.Element.Flyweight();
  1001. }
  1002. libFlyweight.dom = el;
  1003. return libFlyweight;
  1004. }
  1005. if (Ext.isIE) {
  1006. function fnCleanUp() {
  1007. var p = Function.prototype;
  1008. delete p.createSequence;
  1009. delete p.defer;
  1010. delete p.createDelegate;
  1011. delete p.createCallback;
  1012. delete p.createInterceptor;
  1013. window.detachEvent("onunload", fnCleanUp);
  1014. }
  1015. window.attachEvent("onunload", fnCleanUp);
  1016. }
  1017. Ext.lib.AnimBase = function(el, attributes, duration, method) {
  1018. if (el) {
  1019. this.init(el, attributes, duration, method);
  1020. }
  1021. };
  1022. Ext.lib.AnimBase.prototype = {
  1023. toString : function() {
  1024. var el = this.getEl();
  1025. var id = el.id || el.tagName;
  1026. return ("Anim " + id);
  1027. },
  1028. patterns : {
  1029. noNegatives : /width|height|opacity|padding/i,
  1030. offsetAttribute : /^((width|height)|(top|left))$/,
  1031. defaultUnit : /width|height|top$|bottom$|left$|right$/i,
  1032. offsetUnit : /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
  1033. },
  1034. doMethod : function(attr, start, end) {
  1035. return this.method(this.currentFrame, start, end - start,
  1036. this.totalFrames);
  1037. },
  1038. setAttribute : function(attr, val, unit) {
  1039. if (this.patterns.noNegatives.test(attr)) {
  1040. val = (val > 0) ? val : 0;
  1041. }
  1042. Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
  1043. },
  1044. getAttribute : function(attr) {
  1045. var el = this.getEl();
  1046. var val = fly(el).getStyle(attr);
  1047. if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
  1048. return parseFloat(val);
  1049. }
  1050. var a = this.patterns.offsetAttribute.exec(attr) || [];
  1051. var pos = !!(a[3]);
  1052. var box = !!(a[2]);
  1053. if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
  1054. val = el['offset' + a[0].charAt(0).toUpperCase()
  1055. + a[0].substr(1)];
  1056. } else {
  1057. val = 0;
  1058. }
  1059. return val;
  1060. },
  1061. getDefaultUnit : function(attr) {
  1062. if (this.patterns.defaultUnit.test(attr)) {
  1063. return 'px';
  1064. }
  1065. return '';
  1066. },
  1067. animateX : function(callback, scope) {
  1068. var f = function() {
  1069. this.onComplete.removeListener(f);
  1070. if (typeof callback == "function") {
  1071. callback.call(scope || this, this);
  1072. }
  1073. };
  1074. this.onComplete.addListener(f, this);
  1075. this.animate();
  1076. },
  1077. setRuntimeAttribute : function(attr) {
  1078. var start;
  1079. var end;
  1080. var attributes = this.attributes;
  1081. this.runtimeAttributes[attr] = {};
  1082. var isset = function(prop) {
  1083. return (typeof prop !== 'undefined');
  1084. };
  1085. if (!isset(attributes[attr]['to'])
  1086. && !isset(attributes[attr]['by'])) {
  1087. return false;
  1088. }
  1089. start = (isset(attributes[attr]['from']))
  1090. ? attributes[attr]['from']
  1091. : this.getAttribute(attr);
  1092. if (isset(attributes[attr]['to'])) {
  1093. end = attributes[attr]['to'];
  1094. } else if (isset(attributes[attr]['by'])) {
  1095. if (start.constructor == Array) {
  1096. end = [];
  1097. for (var i = 0, len = start.length; i < len; ++i) {
  1098. end[i] = start[i] + attributes[attr]['by'][i];
  1099. }
  1100. } else {
  1101. end = start + attributes[attr]['by'];
  1102. }
  1103. }
  1104. this.runtimeAttributes[attr].start = start;
  1105. this.runtimeAttributes[attr].end = end;
  1106. this.runtimeAttributes[attr].unit = (isset(attributes[attr].unit))
  1107. ? attributes[attr]['unit']
  1108. : 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)
  1137. ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration)
  1138. : this.duration;
  1139. Ext.lib.AnimMgr.registerElement(this);
  1140. };
  1141. this.stop = function(finish) {
  1142. if (finish) {
  1143. this.currentFrame = this.totalFrames;
  1144. this._onTween.fire();
  1145. }
  1146. Ext.lib.AnimMgr.stop(this);
  1147. };
  1148. var onStart = function() {
  1149. this.onStart.fire();
  1150. this.runtimeAttributes = {};
  1151. for (var attr in this.attributes) {
  1152. this.setRuntimeAttribute(attr);
  1153. }
  1154. isAnimated = true;
  1155. actualFrames = 0;
  1156. startTime = allGetServerTime();
  1157. };
  1158. var onTween = function() {
  1159. var data = {
  1160. duration : allGetServerTime() - this.getStartTime(),
  1161. currentFrame : this.currentFrame
  1162. };
  1163. data.toString = function() {
  1164. return ('duration: ' + data.duration + ', currentFrame: ' + data.currentFrame);
  1165. };
  1166. this.onTween.fire(data);
  1167. var runtimeAttributes = this.runtimeAttributes;
  1168. for (var attr in runtimeAttributes) {
  1169. this.setAttribute(attr, this.doMethod(attr,
  1170. runtimeAttributes[attr].start,
  1171. runtimeAttributes[attr].end),
  1172. runtimeAttributes[attr].unit);
  1173. }
  1174. actualFrames += 1;
  1175. };
  1176. var onComplete = function() {
  1177. var actual_duration = (allGetServerTime() - startTime) / 1000;
  1178. var data = {
  1179. duration : actual_duration,
  1180. frames : actualFrames,
  1181. fps : actualFrames / actual_duration
  1182. };
  1183. data.toString = function() {
  1184. return ('duration: ' + data.duration + ', frames: '
  1185. + data.frames + ', fps: ' + data.fps);
  1186. };
  1187. isAnimated = false;
  1188. actualFrames = 0;
  1189. this.onComplete.fire(data);
  1190. };
  1191. this._onStart = new Ext.util.Event(this);
  1192. this.onStart = new Ext.util.Event(this);
  1193. this.onTween = new Ext.util.Event(this);
  1194. this._onTween = new Ext.util.Event(this);
  1195. this.onComplete = new Ext.util.Event(this);
  1196. this._onComplete = new Ext.util.Event(this);
  1197. this._onStart.addListener(onStart);
  1198. this._onTween.addListener(onTween);
  1199. this._onComplete.addListener(onComplete);
  1200. }
  1201. };
  1202. Ext.lib.AnimMgr = new function() {
  1203. var thread = null;
  1204. var queue = [];
  1205. var tweenCount = 0;
  1206. this.fps = 1000;
  1207. this.delay = 1;
  1208. this.registerElement = function(tween) {
  1209. queue[queue.length] = tween;
  1210. tweenCount += 1;
  1211. tween._onStart.fire();
  1212. this.start();
  1213. };
  1214. this.unRegister = function(tween, index) {
  1215. tween._onComplete.fire();
  1216. index = index || getIndex(tween);
  1217. if (index != -1) {
  1218. queue.splice(index, 1);
  1219. }
  1220. tweenCount -= 1;
  1221. if (tweenCount <= 0) {
  1222. this.stop();
  1223. }
  1224. };
  1225. this.start = function() {
  1226. if (thread === null) {
  1227. thread = setInterval(this.run, this.delay);
  1228. }
  1229. };
  1230. this.stop = function(tween) {
  1231. if (!tween) {
  1232. clearInterval(thread);
  1233. for (var i = 0, len = queue.length; i < len; ++i) {
  1234. if (queue[0].isAnimated()) {
  1235. this.unRegister(queue[0], 0);
  1236. }
  1237. }
  1238. queue = [];
  1239. thread = null;
  1240. tweenCount = 0;
  1241. } else {
  1242. this.unRegister(tween);
  1243. }
  1244. };
  1245. this.run = function() {
  1246. for (var i = 0, len = queue.length; i < len; ++i) {
  1247. var tween = queue[i];
  1248. if (!tween || !tween.isAnimated()) {
  1249. continue;
  1250. }
  1251. if (tween.currentFrame < tween.totalFrames
  1252. || tween.totalFrames === null) {
  1253. tween.currentFrame += 1;
  1254. if (tween.useSeconds) {
  1255. correctFrame(tween);
  1256. }
  1257. tween._onTween.fire();
  1258. } else {
  1259. Ext.lib.AnimMgr.stop(tween, i);
  1260. }
  1261. }
  1262. };
  1263. var getIndex = function(anim) {
  1264. for (var i = 0, len = queue.length; i < len; ++i) {
  1265. if (queue[i] == anim) {
  1266. return i;
  1267. }
  1268. }
  1269. return -1;
  1270. };
  1271. var correctFrame = function(tween) {
  1272. var frames = tween.totalFrames;
  1273. var frame = tween.currentFrame;
  1274. var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
  1275. var elapsed = (allGetServerTime() - tween.getStartTime());
  1276. var tweak = 0;
  1277. if (elapsed < tween.duration * 1000) {
  1278. tweak = Math.round((elapsed / expected - 1)
  1279. * tween.currentFrame);
  1280. } else {
  1281. tweak = frames - (frame + 1);
  1282. }
  1283. if (tweak > 0 && isFinite(tweak)) {
  1284. if (tween.currentFrame + tweak >= frames) {
  1285. tweak = frames - (frame + 1);
  1286. }
  1287. tween.currentFrame += tweak;
  1288. }
  1289. };
  1290. };
  1291. Ext.lib.Bezier = new function() {
  1292. this.getPosition = function(points, t) {
  1293. var n = points.length;
  1294. var tmp = [];
  1295. for (var i = 0; i < n; ++i) {
  1296. tmp[i] = [points[i][0], points[i][1]];
  1297. }
  1298. for (var j = 1; j < n; ++j) {
  1299. for (i = 0; i < n - j; ++i) {
  1300. tmp[i][0] = (1 - t) * tmp[i][0] + t
  1301. * tmp[parseInt(i + 1, 10)][0];
  1302. tmp[i][1] = (1 - t) * tmp[i][1] + t
  1303. * tmp[parseInt(i + 1, 10)][1];
  1304. }
  1305. }
  1306. return [tmp[0][0], tmp[0][1]];
  1307. };
  1308. };
  1309. (function() {
  1310. Ext.lib.ColorAnim = function(el, attributes, duration, method) {
  1311. Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes,
  1312. duration, method);
  1313. };
  1314. Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase);
  1315. var Y = Ext.lib;
  1316. var superclass = Y.ColorAnim.superclass;
  1317. var proto = Y.ColorAnim.prototype;
  1318. proto.toString = function() {
  1319. var el = this.getEl();
  1320. var id = el.id || el.tagName;
  1321. return ("ColorAnim " + id);
  1322. };
  1323. proto.patterns.color = /color$/i;
  1324. proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
  1325. proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
  1326. proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
  1327. proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
  1328. proto.parseColor = function(s) {
  1329. if (s.length == 3) {
  1330. return s;
  1331. }
  1332. var c = this.patterns.hex.exec(s);
  1333. if (c && c.length == 4) {
  1334. return [parseInt(c[1], 16), parseInt(c[2], 16),
  1335. parseInt(c[3], 16)];
  1336. }
  1337. c = this.patterns.rgb.exec(s);
  1338. if (c && c.length == 4) {
  1339. return [parseInt(c[1], 10), parseInt(c[2], 10),
  1340. parseInt(c[3], 10)];
  1341. }
  1342. c = this.patterns.hex3.exec(s);
  1343. if (c && c.length == 4) {
  1344. return [parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16),
  1345. parseInt(c[3] + c[3], 16)];
  1346. }
  1347. return null;
  1348. };
  1349. proto.getAttribute = function(attr) {
  1350. var el = this.getEl();
  1351. if (this.patterns.color.test(attr)) {
  1352. var val = fly(el).getStyle(attr);
  1353. if (this.patterns.transparent.test(val)) {
  1354. var parent = el.parentNode;
  1355. val = fly(parent).getStyle(attr);
  1356. while (parent && this.patterns.transparent.test(val)) {
  1357. parent = parent.parentNode;
  1358. val = fly(parent).getStyle(attr);
  1359. if (parent.tagName.toUpperCase() == 'HTML') {
  1360. val = '#fff';
  1361. }
  1362. }
  1363. }
  1364. } else {
  1365. val = superclass.getAttribute.call(this, attr);
  1366. }
  1367. return val;
  1368. };
  1369. proto.doMethod = function(attr, start, end) {
  1370. var val;
  1371. if (this.patterns.color.test(attr)) {
  1372. val = [];
  1373. for (var i = 0, len = start.length; i < len; ++i) {
  1374. val[i] = superclass.doMethod.call(this, attr, start[i],
  1375. end[i]);
  1376. }
  1377. val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1])
  1378. + ',' + Math.floor(val[2]) + ')';
  1379. } else {
  1380. val = superclass.doMethod.call(this, attr, start, end);
  1381. }
  1382. return val;
  1383. };
  1384. proto.setRuntimeAttribute = function(attr) {
  1385. superclass.setRuntimeAttribute.call(this, attr);
  1386. if (this.patterns.color.test(attr)) {
  1387. var attributes = this.attributes;
  1388. var start = this.parseColor(this.runtimeAttributes[attr].start);
  1389. var end = this.parseColor(this.runtimeAttributes[attr].end);
  1390. if (typeof attributes[attr]['to'] === 'undefined'
  1391. && typeof attributes[attr]['by'] !== 'undefined') {
  1392. end = this.parseColor(attributes[attr].by);
  1393. for (var i = 0, len = start.length; i < len; ++i) {
  1394. end[i] = start[i] + end[i];
  1395. }
  1396. }
  1397. this.runtimeAttributes[attr].start = start;
  1398. this.runtimeAttributes[attr].end = end;
  1399. }
  1400. };
  1401. })();
  1402. Ext.lib.Easing = {
  1403. easeNone : function(t, b, c, d) {
  1404. return c * t / d + b;
  1405. },
  1406. easeIn : function(t, b, c, d) {
  1407. return c * (t /= d) * t + b;
  1408. },
  1409. easeOut : function(t, b, c, d) {
  1410. return -c * (t /= d) * (t - 2) + b;
  1411. },
  1412. easeBoth : function(t, b, c, d) {
  1413. if ((t /= d / 2) < 1) {
  1414. return c / 2 * t * t + b;
  1415. }
  1416. return -c / 2 * ((--t) * (t - 2) - 1) + b;
  1417. },
  1418. easeInStrong : function(t, b, c, d) {
  1419. return c * (t /= d) * t * t * t + b;
  1420. },
  1421. easeOutStrong : function(t, b, c, d) {
  1422. return -c * ((t = t / d - 1) * t * t * t - 1) + b;
  1423. },
  1424. easeBothStrong : function(t, b, c, d) {
  1425. if ((t /= d / 2) < 1) {
  1426. return c / 2 * t * t * t * t + b;
  1427. }
  1428. return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
  1429. },
  1430. elasticIn : function(t, b, c, d, a, p) {
  1431. if (t == 0) {
  1432. return b;
  1433. }
  1434. if ((t /= d) == 1) {
  1435. return b + c;
  1436. }
  1437. if (!p) {
  1438. p = d * .3;
  1439. }
  1440. if (!a || a < Math.abs(c)) {
  1441. a = c;
  1442. var s = p / 4;
  1443. } else {
  1444. var s = p / (2 * Math.PI) * Math.asin(c / a);
  1445. }
  1446. return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s)
  1447. * (2 * Math.PI) / p))
  1448. + b;
  1449. },
  1450. elasticOut : function(t, b, c, d, a, p) {
  1451. if (t == 0) {
  1452. return b;
  1453. }
  1454. if ((t /= d) == 1) {
  1455. return b + c;
  1456. }
  1457. if (!p) {
  1458. p = d * .3;
  1459. }
  1460. if (!a || a < Math.abs(c)) {
  1461. a = c;
  1462. var s = p / 4;
  1463. } else {
  1464. var s = p / (2 * Math.PI) * Math.asin(c / a);
  1465. }
  1466. return a * Math.pow(2, -10 * t)
  1467. * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
  1468. },
  1469. elasticBoth : function(t, b, c, d, a, p) {
  1470. if (t == 0) {
  1471. return b;
  1472. }
  1473. if ((t /= d / 2) == 2) {
  1474. return b + c;
  1475. }
  1476. if (!p) {
  1477. p = d * (.3 * 1.5);
  1478. }
  1479. if (!a || a < Math.abs(c)) {
  1480. a = c;
  1481. var s = p / 4;
  1482. } else {
  1483. var s = p / (2 * Math.PI) * Math.asin(c / a);
  1484. }
  1485. if (t < 1) {
  1486. return -.5
  1487. * (a * Math.pow(2, 10 * (t -= 1)) * Math
  1488. .sin((t * d - s) * (2 * Math.PI) / p)) + b;
  1489. }
  1490. return a * Math.pow(2, -10 * (t -= 1))
  1491. * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
  1492. },
  1493. backIn : function(t, b, c, d, s) {
  1494. if (typeof s == 'undefined') {
  1495. s = 1.70158;
  1496. }
  1497. return c * (t /= d) * t * ((s + 1) * t - s) + b;
  1498. },
  1499. backOut : function(t, b, c, d, s) {
  1500. if (typeof s == 'undefined') {
  1501. s = 1.70158;
  1502. }
  1503. return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
  1504. },
  1505. backBoth : function(t, b, c, d, s) {
  1506. if (typeof s == 'undefined') {
  1507. s = 1.70158;
  1508. }
  1509. if ((t /= d / 2) < 1) {
  1510. return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
  1511. }
  1512. return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2)
  1513. + b;
  1514. },
  1515. bounceIn : function(t, b, c, d) {
  1516. return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b;
  1517. },
  1518. bounceOut : function(t, b, c, d) {
  1519. if ((t /= d) < (1 / 2.75)) {
  1520. return c * (7.5625 * t * t) + b;
  1521. } else if (t < (2 / 2.75)) {
  1522. return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
  1523. } else if (t < (2.5 / 2.75)) {
  1524. return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
  1525. }
  1526. return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
  1527. },
  1528. bounceBoth : function(t, b, c, d) {
  1529. if (t < d / 2) {
  1530. return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
  1531. }
  1532. return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5
  1533. + b;
  1534. }
  1535. };
  1536. (function() {
  1537. Ext.lib.Motion = function(el, attributes, duration, method) {
  1538. if (el) {
  1539. Ext.lib.Motion.superclass.constructor.call(this, el,
  1540. attributes, duration, method);
  1541. }
  1542. };
  1543. Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim);
  1544. var Y = Ext.lib;
  1545. var superclass = Y.Motion.superclass;
  1546. var proto = Y.Motion.prototype;
  1547. proto.toString = function() {
  1548. var el = this.getEl();
  1549. var id = el.id || el.tagName;
  1550. return ("Motion " + id);
  1551. };
  1552. proto.patterns.points = /^points$/i;
  1553. proto.setAttribute = function(attr, val, unit) {
  1554. if (this.patterns.points.test(attr)) {
  1555. unit = unit || 'px';
  1556. superclass.setAttribute.call(this, 'left', val[0], unit);
  1557. superclass.setAttribute.call(this, 'top', val[1], unit);
  1558. } else {
  1559. superclass.setAttribute.call(this, attr, val, unit);
  1560. }
  1561. };
  1562. proto.getAttribute = function(attr) {
  1563. if (this.patterns.points.test(attr)) {
  1564. var val = [superclass.getAttribute.call(this, 'left'),
  1565. superclass.getAttribute.call(this, 'top')];
  1566. } else {
  1567. val = superclass.getAttribute.call(this, attr);
  1568. }
  1569. return val;
  1570. };
  1571. proto.doMethod = function(attr, start, end) {
  1572. var val = null;
  1573. if (this.patterns.points.test(attr)) {
  1574. var t = this
  1575. .method(this.currentFrame, 0, 100, this.totalFrames)
  1576. / 100;
  1577. val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
  1578. } else {
  1579. val = superclass.doMethod.call(this, attr, start, end);
  1580. }
  1581. return val;
  1582. };
  1583. proto.setRuntimeAttribute = function(attr) {
  1584. if (this.patterns.points.test(attr)) {
  1585. var el = this.getEl();
  1586. var attributes = this.attributes;
  1587. var start;
  1588. var control = attributes['points']['control'] || [];
  1589. var end;
  1590. var i, len;
  1591. if (control.length > 0 && !(control[0] instanceof Array)) {
  1592. control = [control];
  1593. } else {
  1594. var tmp = [];
  1595. for (i = 0, len = control.length; i < len; ++i) {
  1596. tmp[i] = control[i];
  1597. }
  1598. control = tmp;
  1599. }
  1600. Ext.fly(el).position();
  1601. if (isset(attributes['points']['from'])) {
  1602. Ext.lib.Dom.setXY(el, attributes['points']['from']);
  1603. } else {
  1604. Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el));
  1605. }
  1606. start = this.getAttribute('points');
  1607. if (isset(attributes['points']['to'])) {
  1608. end = translateValues.call(this,
  1609. attributes['points']['to'], start);
  1610. var pageXY = Ext.lib.Dom.getXY(this.getEl());
  1611. for (i = 0, len = control.length; i < len; ++i) {
  1612. control[i] = translateValues.call(this, control[i],
  1613. start);
  1614. }
  1615. } else if (isset(attributes['points']['by'])) {
  1616. end = [start[0] + attributes['points']['by'][0],
  1617. start[1] + attributes['points']['by'][1]];
  1618. for (i = 0, len = control.length; i < len; ++i) {
  1619. control[i] = [start[0] + control[i][0],
  1620. start[1] + control[i][1]];
  1621. }
  1622. }
  1623. this.runtimeAttributes[attr] = [start];
  1624. if (control.length > 0) {
  1625. this.runtimeAttributes[attr] = this.runtimeAttributes[attr]
  1626. .concat(control);
  1627. }
  1628. this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
  1629. } else {
  1630. superclass.setRuntimeAttribute.call(this, attr);
  1631. }
  1632. };
  1633. var translateValues = function(val, start) {
  1634. var pageXY = Ext.lib.Dom.getXY(this.getEl());
  1635. val = [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
  1636. return val;
  1637. };
  1638. var isset = function(prop) {
  1639. return (typeof prop !== 'undefined');
  1640. };
  1641. })();
  1642. (function() {
  1643. Ext.lib.Scroll = function(el, attributes, duration, method) {
  1644. if (el) {
  1645. Ext.lib.Scroll.superclass.constructor.call(this, el,
  1646. attributes, duration, method);
  1647. }
  1648. };
  1649. Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim);
  1650. var Y = Ext.lib;
  1651. var superclass = Y.Scroll.superclass;
  1652. var proto = Y.Scroll.prototype;
  1653. proto.toString = function() {
  1654. var el = this.getEl();
  1655. var id = el.id || el.tagName;
  1656. return ("Scroll " + id);
  1657. };
  1658. proto.doMethod = function(attr, start, end) {
  1659. var val = null;
  1660. if (attr == 'scroll') {
  1661. val = [
  1662. this.method(this.currentFrame, start[0], end[0]
  1663. - start[0], this.totalFrames),
  1664. this.method(this.currentFrame, start[1], end[1]
  1665. - start[1], this.totalFrames)];
  1666. } else {
  1667. val = superclass.doMethod.call(this, attr, start, end);
  1668. }
  1669. return val;
  1670. };
  1671. proto.getAttribute = function(attr) {
  1672. var val = null;
  1673. var el = this.getEl();
  1674. if (attr == 'scroll') {
  1675. val = [el.scrollLeft, el.scrollTop];
  1676. } else {
  1677. val = superclass.getAttribute.call(this, attr);
  1678. }
  1679. return val;
  1680. };
  1681. proto.setAttribute = function(attr, val, unit) {
  1682. var el = this.getEl();
  1683. if (attr == 'scroll') {
  1684. el.scrollLeft = val[0];
  1685. el.scrollTop = val[1];
  1686. } else {
  1687. superclass.setAttribute.call(this, attr, val, unit);
  1688. }
  1689. };
  1690. })();
  1691. })();