123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079 |
- /*
- * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
- *
- * http://extjs.com/license
- */
- (function() {
- var libFlyweight;
- Ext.lib.Dom = {
- getViewWidth : function(full) {
- return full ? this.getDocumentWidth() : this.getViewportWidth();
- },
- getViewHeight : function(full) {
- return full ? this.getDocumentHeight() : this.getViewportHeight();
- },
- getDocumentHeight : function() {
- var scrollHeight = (document.compatMode != "CSS1Compat")
- ? document.body.scrollHeight
- : document.documentElement.scrollHeight;
- return Math.max(scrollHeight, this.getViewportHeight());
- },
- getDocumentWidth : function() {
- var scrollWidth = (document.compatMode != "CSS1Compat")
- ? document.body.scrollWidth
- : document.documentElement.scrollWidth;
- return Math.max(scrollWidth, this.getViewportWidth());
- },
- getViewportHeight : function() {
- if (Ext.isIE) {
- return Ext.isStrict
- ? document.documentElement.clientHeight
- : document.body.clientHeight;
- } else {
- return self.innerHeight;
- }
- },
- getViewportWidth : function() {
- if (Ext.isIE) {
- return Ext.isStrict
- ? document.documentElement.clientWidth
- : document.body.clientWidth;
- } else {
- return self.innerWidth;
- }
- },
- isAncestor : function(p, c) {
- p = Ext.getDom(p);
- c = Ext.getDom(c);
- if (!p || !c) {
- return false;
- }
- if (p.contains && !Ext.isSafari) {
- return p.contains(c);
- } else if (p.compareDocumentPosition) {
- return !!(p.compareDocumentPosition(c) & 16);
- } else {
- var parent = c.parentNode;
- while (parent) {
- if (parent == p) {
- return true;
- } else if (!parent.tagName
- || parent.tagName.toUpperCase() == "HTML") {
- return false;
- }
- parent = parent.parentNode;
- }
- return false;
- }
- },
- getRegion : function(el) {
- return Ext.lib.Region.getRegion(el);
- },
- getY : function(el) {
- return this.getXY(el)[1];
- },
- getX : function(el) {
- return this.getXY(el)[0];
- },
- getXY : function(el) {
- var p, pe, b, scroll, bd = (document.body || document.documentElement);
- el = Ext.getDom(el);
- if (el == bd) {
- return [0, 0];
- }
- if (el.getBoundingClientRect) {
- b = el.getBoundingClientRect();
- scroll = fly(document).getScroll();
- return [b.left + scroll.left, b.top + scroll.top];
- }
- var x = 0, y = 0;
- p = el;
- var hasAbsolute = fly(el).getStyle("position") == "absolute";
- while (p) {
- x += p.offsetLeft;
- y += p.offsetTop;
- if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
- hasAbsolute = true;
- }
- if (Ext.isGecko) {
- pe = fly(p);
- var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
- var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
- x += bl;
- y += bt;
- if (p != el && pe.getStyle('overflow') != 'visible') {
- x += bl;
- y += bt;
- }
- }
- p = p.offsetParent;
- }
- if (Ext.isSafari && hasAbsolute) {
- x -= bd.offsetLeft;
- y -= bd.offsetTop;
- }
- if (Ext.isGecko && !hasAbsolute) {
- var dbd = fly(bd);
- x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
- y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
- }
- p = el.parentNode;
- while (p && p != bd) {
- if (!Ext.isOpera
- || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
- x -= p.scrollLeft;
- y -= p.scrollTop;
- }
- p = p.parentNode;
- }
- return [x, y];
- },
- setXY : function(el, xy) {
- el = Ext.fly(el, '_setXY');
- el.position();
- var pts = el.translatePoints(xy);
- if (xy[0] !== false) {
- el.dom.style.left = pts.left + "px";
- }
- if (xy[1] !== false) {
- el.dom.style.top = pts.top + "px";
- }
- },
- setX : function(el, x) {
- this.setXY(el, [x, false]);
- },
- setY : function(el, y) {
- this.setXY(el, [false, y]);
- }
- };
- /*
- * Portions of this file are based on pieces of Yahoo User Interface Library
- * Copyright (c) 2007, Yahoo! Inc. All rights reserved. YUI licensed under
- * the BSD License: http://developer.yahoo.net/yui/license.txt
- */
- Ext.lib.Event = function() {
- var loadComplete = false;
- var listeners = [];
- var unloadListeners = [];
- var retryCount = 0;
- var onAvailStack = [];
- var counter = 0;
- var lastError = null;
- return {
- POLL_RETRYS : 200,
- POLL_INTERVAL : 20,
- EL : 0,
- TYPE : 1,
- FN : 2,
- WFN : 3,
- OBJ : 3,
- ADJ_SCOPE : 4,
- _interval : null,
- startInterval : function() {
- if (!this._interval) {
- var self = this;
- var callback = function() {
- self._tryPreloadAttach();
- };
- this._interval = setInterval(callback, this.POLL_INTERVAL);
- }
- },
- onAvailable : function(p_id, p_fn, p_obj, p_override) {
- onAvailStack.push({
- id : p_id,
- fn : p_fn,
- obj : p_obj,
- override : p_override,
- checkReady : false
- });
- retryCount = this.POLL_RETRYS;
- this.startInterval();
- },
- addListener : function(el, eventName, fn) {
- el = Ext.getDom(el);
- if (!el || !fn) {
- return false;
- }
- if ("unload" == eventName) {
- unloadListeners[unloadListeners.length] = [el, eventName,
- fn];
- return true;
- }
- // prevent unload errors with simple check
- var wrappedFn = function(e) {
- return typeof Ext != 'undefined' ? fn(Ext.lib.Event
- .getEvent(e)) : false;
- };
- var li = [el, eventName, fn, wrappedFn];
- var index = listeners.length;
- listeners[index] = li;
- this.doAdd(el, eventName, wrappedFn, false);
- return true;
- },
- removeListener : function(el, eventName, fn) {
- var i, len;
- el = Ext.getDom(el);
- if (!fn) {
- return this.purgeElement(el, false, eventName);
- }
- if ("unload" == eventName) {
- for (i = 0, len = unloadListeners.length; i < len; i++) {
- var li = unloadListeners[i];
- if (li && li[0] == el && li[1] == eventName
- && li[2] == fn) {
- unloadListeners.splice(i, 1);
- return true;
- }
- }
- return false;
- }
- var cacheItem = null;
- var index = arguments[3];
- if ("undefined" == typeof index) {
- index = this._getCacheIndex(el, eventName, fn);
- }
- if (index >= 0) {
- cacheItem = listeners[index];
- }
- if (!el || !cacheItem) {
- return false;
- }
- this.doRemove(el, eventName, cacheItem[this.WFN], false);
- delete listeners[index][this.WFN];
- delete listeners[index][this.FN];
- listeners.splice(index, 1);
- return true;
- },
- getTarget : function(ev, resolveTextNode) {
- ev = ev.browserEvent || ev;
- var t = ev.target || ev.srcElement;
- return this.resolveTextNode(t);
- },
- resolveTextNode : function(node) {
- if (Ext.isSafari && node && 3 == node.nodeType) {
- return node.parentNode;
- } else {
- return node;
- }
- },
- getPageX : function(ev) {
- ev = ev.browserEvent || ev;
- var x = ev.pageX;
- if (!x && 0 !== x) {
- x = ev.clientX || 0;
- if (Ext.isIE) {
- x += this.getScroll()[1];
- }
- }
- return x;
- },
- getPageY : function(ev) {
- ev = ev.browserEvent || ev;
- var y = ev.pageY;
- if (!y && 0 !== y) {
- y = ev.clientY || 0;
- if (Ext.isIE) {
- y += this.getScroll()[0];
- }
- }
- return y;
- },
- getXY : function(ev) {
- ev = ev.browserEvent || ev;
- return [this.getPageX(ev), this.getPageY(ev)];
- },
- getRelatedTarget : function(ev) {
- ev = ev.browserEvent || ev;
- var t = ev.relatedTarget;
- if (!t) {
- if (ev.type == "mouseout") {
- t = ev.toElement;
- } else if (ev.type == "mouseover") {
- t = ev.fromElement;
- }
- }
- return this.resolveTextNode(t);
- },
- getTime : function(ev) {
- ev = ev.browserEvent || ev;
- if (!ev.time) {
- var t = allGetServerTime().getTime();
- try {
- ev.time = t;
- } catch (ex) {
- this.lastError = ex;
- return t;
- }
- }
- return ev.time;
- },
- stopEvent : function(ev) {
- this.stopPropagation(ev);
- this.preventDefault(ev);
- },
- stopPropagation : function(ev) {
- ev = ev.browserEvent || ev;
- if (ev.stopPropagation) {
- ev.stopPropagation();
- } else {
- ev.cancelBubble = true;
- }
- },
- preventDefault : function(ev) {
- ev = ev.browserEvent || ev;
- if (ev.preventDefault) {
- ev.preventDefault();
- } else {
- ev.returnValue = false;
- }
- },
- getEvent : function(e) {
- var ev = e || window.event;
- if (!ev) {
- var c = this.getEvent.caller;
- while (c) {
- ev = c.arguments[0];
- if (ev && Event == ev.constructor) {
- break;
- }
- c = c.caller;
- }
- }
- return ev;
- },
- getCharCode : function(ev) {
- ev = ev.browserEvent || ev;
- return ev.charCode || ev.keyCode || 0;
- },
- _getCacheIndex : function(el, eventName, fn) {
- for (var i = 0, len = listeners.length; i < len; ++i) {
- var li = listeners[i];
- if (li && li[this.FN] == fn && li[this.EL] == el
- && li[this.TYPE] == eventName) {
- return i;
- }
- }
- return -1;
- },
- elCache : {},
- getEl : function(id) {
- return document.getElementById(id);
- },
- clearCache : function() {
- },
- _load : function(e) {
- loadComplete = true;
- var EU = Ext.lib.Event;
- if (Ext.isIE) {
- EU.doRemove(window, "load", EU._load);
- }
- },
- _tryPreloadAttach : function() {
- if (this.locked) {
- return false;
- }
- this.locked = true;
- var tryAgain = !loadComplete;
- if (!tryAgain) {
- tryAgain = (retryCount > 0);
- }
- var notAvail = [];
- for (var i = 0, len = onAvailStack.length; i < len; ++i) {
- var item = onAvailStack[i];
- if (item) {
- var el = this.getEl(item.id);
- if (el) {
- if (!item.checkReady || loadComplete
- || el.nextSibling
- || (document && document.body)) {
- var scope = el;
- if (item.override) {
- if (item.override === true) {
- scope = item.obj;
- } else {
- scope = item.override;
- }
- }
- item.fn.call(scope, item.obj);
- onAvailStack[i] = null;
- }
- } else {
- notAvail.push(item);
- }
- }
- }
- retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
- if (tryAgain) {
- this.startInterval();
- } else {
- clearInterval(this._interval);
- this._interval = null;
- }
- this.locked = false;
- return true;
- },
- purgeElement : function(el, recurse, eventName) {
- var elListeners = this.getListeners(el, eventName);
- if (elListeners) {
- for (var i = 0, len = elListeners.length; i < len; ++i) {
- var l = elListeners[i];
- this.removeListener(el, l.type, l.fn);
- }
- }
- if (recurse && el && el.childNodes) {
- for (i = 0, len = el.childNodes.length; i < len; ++i) {
- this.purgeElement(el.childNodes[i], recurse, eventName);
- }
- }
- },
- getListeners : function(el, eventName) {
- var results = [], searchLists;
- if (!eventName) {
- searchLists = [listeners, unloadListeners];
- } else if (eventName == "unload") {
- searchLists = [unloadListeners];
- } else {
- searchLists = [listeners];
- }
- for (var j = 0; j < searchLists.length; ++j) {
- var searchList = searchLists[j];
- if (searchList && searchList.length > 0) {
- for (var i = 0, len = searchList.length; i < len; ++i) {
- var l = searchList[i];
- if (l
- && l[this.EL] === el
- && (!eventName || eventName === l[this.TYPE])) {
- results.push({
- type : l[this.TYPE],
- fn : l[this.FN],
- obj : l[this.OBJ],
- adjust : l[this.ADJ_SCOPE],
- index : i
- });
- }
- }
- }
- }
- return (results.length) ? results : null;
- },
- _unload : function(e) {
- var EU = Ext.lib.Event, i, j, l, len, index;
- for (i = 0, len = unloadListeners.length; i < len; ++i) {
- l = unloadListeners[i];
- if (l) {
- var scope = window;
- if (l[EU.ADJ_SCOPE]) {
- if (l[EU.ADJ_SCOPE] === true) {
- scope = l[EU.OBJ];
- } else {
- scope = l[EU.ADJ_SCOPE];
- }
- }
- l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
- unloadListeners[i] = null;
- l = null;
- scope = null;
- }
- }
- unloadListeners = null;
- if (listeners && listeners.length > 0) {
- j = listeners.length;
- while (j) {
- index = j - 1;
- l = listeners[index];
- if (l) {
- EU.removeListener(l[EU.EL], l[EU.TYPE], l[EU.FN],
- index);
- }
- j = j - 1;
- }
- l = null;
- EU.clearCache();
- }
- EU.doRemove(window, "unload", EU._unload);
- },
- getScroll : function() {
- var dd = document.documentElement, db = document.body;
- if (dd && (dd.scrollTop || dd.scrollLeft)) {
- return [dd.scrollTop, dd.scrollLeft];
- } else if (db) {
- return [db.scrollTop, db.scrollLeft];
- } else {
- return [0, 0];
- }
- },
- doAdd : function() {
- if (window.addEventListener) {
- return function(el, eventName, fn, capture) {
- el.addEventListener(eventName, fn, (capture));
- };
- } else if (window.attachEvent) {
- return function(el, eventName, fn, capture) {
- el.attachEvent("on" + eventName, fn);
- };
- } else {
- return function() {
- };
- }
- }(),
- doRemove : function() {
- if (window.removeEventListener) {
- return function(el, eventName, fn, capture) {
- el.removeEventListener(eventName, fn, (capture));
- };
- } else if (window.detachEvent) {
- return function(el, eventName, fn) {
- el.detachEvent("on" + eventName, fn);
- };
- } else {
- return function() {
- };
- }
- }()
- };
- }();
- var E = Ext.lib.Event;
- E.on = E.addListener;
- E.un = E.removeListener;
- if (document && document.body) {
- E._load();
- } else {
- E.doAdd(window, "load", E._load);
- }
- E.doAdd(window, "unload", E._unload);
- E._tryPreloadAttach();
- Ext.lib.Ajax = {
- request : function(method, uri, cb, data, options) {
- if (options) {
- var hs = options.headers;
- if (hs) {
- for (var h in hs) {
- if (hs.hasOwnProperty(h)) {
- this.initHeader(h, hs[h], false);
- }
- }
- }
- if (options.xmlData) {
- this.initHeader('Content-Type', 'text/xml', false);
- method = 'POST';
- data = options.xmlData;
- } else if (options.jsonData) {
- this.initHeader('Content-Type', 'text/javascript', false);
- method = 'POST';
- data = typeof options.jsonData == 'object' ? Ext
- .encode(options.jsonData) : options.jsonData;
- }
- }
- return this.asyncRequest(method, uri, cb, data);
- },
- serializeForm : function(form) {
- if (typeof form == 'string') {
- form = (document.getElementById(form) || document.forms[form]);
- }
- var el, name, val, disabled, data = '', hasSubmit = false;
- for (var i = 0; i < form.elements.length; i++) {
- el = form.elements[i];
- disabled = form.elements[i].disabled;
- name = form.elements[i].name;
- val = form.elements[i].value;
- if (!disabled && name) {
- switch (el.type) {
- case 'select-one' :
- case 'select-multiple' :
- for (var j = 0; j < el.options.length; j++) {
- if (el.options[j].selected) {
- if (Ext.isIE) {
- data += encodeURIComponent(name)
- + '='
- + encodeURIComponent(el.options[j].attributes['value'].specified
- ? el.options[j].value
- : el.options[j].text)
- + '&';
- } else {
- data += encodeURIComponent(name)
- + '='
- + encodeURIComponent(el.options[j]
- .hasAttribute('value')
- ? el.options[j].value
- : el.options[j].text)
- + '&';
- }
- }
- }
- break;
- case 'radio' :
- case 'checkbox' :
- if (el.checked) {
- data += encodeURIComponent(name) + '='
- + encodeURIComponent(val) + '&';
- }
- break;
- case 'file' :
- case undefined :
- case 'reset' :
- case 'button' :
- break;
- case 'submit' :
- if (hasSubmit == false) {
- data += encodeURIComponent(name) + '='
- + encodeURIComponent(val) + '&';
- hasSubmit = true;
- }
- break;
- default :
- data += encodeURIComponent(name) + '='
- + encodeURIComponent(val) + '&';
- break;
- }
- }
- }
- data = data.substr(0, data.length - 1);
- return data;
- },
- headers : {},
- hasHeaders : false,
- useDefaultHeader : true,
- defaultPostHeader : 'application/x-www-form-urlencoded',
- useDefaultXhrHeader : true,
- defaultXhrHeader : 'XMLHttpRequest',
- hasDefaultHeaders : true,
- defaultHeaders : {},
- poll : {},
- timeout : {},
- pollInterval : 50,
- transactionId : 0,
- setProgId : function(id) {
- this.activeX.unshift(id);
- },
- setDefaultPostHeader : function(b) {
- this.useDefaultHeader = b;
- },
- setDefaultXhrHeader : function(b) {
- this.useDefaultXhrHeader = b;
- },
- setPollingInterval : function(i) {
- if (typeof i == 'number' && isFinite(i)) {
- this.pollInterval = i;
- }
- },
- createXhrObject : function(transactionId) {
- var obj, http;
- try {
- http = new XMLHttpRequest();
- obj = {
- conn : http,
- tId : transactionId
- };
- } catch (e) {
- for (var i = 0; i < this.activeX.length; ++i) {
- try {
- http = new ActiveXObject(this.activeX[i]);
- obj = {
- conn : http,
- tId : transactionId
- };
- break;
- } catch (e) {
- }
- }
- } finally {
- return obj;
- }
- },
- getConnectionObject : function() {
- var o;
- var tId = this.transactionId;
- try {
- o = this.createXhrObject(tId);
- if (o) {
- this.transactionId++;
- }
- } catch (e) {
- } finally {
- return o;
- }
- },
- asyncRequest : function(method, uri, callback, postData) {
- var o = this.getConnectionObject();
- if (!o) {
- return null;
- } else {
- o.conn.open(method, uri, true);
- if (this.useDefaultXhrHeader) {
- if (!this.defaultHeaders['X-Requested-With']) {
- this.initHeader('X-Requested-With',
- this.defaultXhrHeader, true);
- }
- }
- if (postData && this.useDefaultHeader) {
- this.initHeader('Content-Type', this.defaultPostHeader);
- }
- if (this.hasDefaultHeaders || this.hasHeaders) {
- this.setHeader(o);
- }
- this.handleReadyState(o, callback);
- o.conn.send(postData || null);
- return o;
- }
- },
- handleReadyState : function(o, callback) {
- var oConn = this;
- if (callback && callback.timeout) {
- this.timeout[o.tId] = window.setTimeout(function() {
- oConn.abort(o, callback, true);
- }, callback.timeout);
- }
- this.poll[o.tId] = window.setInterval(function() {
- if (o.conn && o.conn.readyState == 4) {
- window.clearInterval(oConn.poll[o.tId]);
- delete oConn.poll[o.tId];
- if (callback && callback.timeout) {
- window.clearTimeout(oConn.timeout[o.tId]);
- delete oConn.timeout[o.tId];
- }
- oConn.handleTransactionResponse(o, callback);
- }
- }, this.pollInterval);
- },
- handleTransactionResponse : function(o, callback, isAbort) {
- if (!callback) {
- this.releaseObject(o);
- return;
- }
- var httpStatus, responseObject;
- try {
- if (o.conn.status !== undefined && o.conn.status != 0) {
- httpStatus = o.conn.status;
- } else {
- httpStatus = 13030;
- }
- } catch (e) {
- httpStatus = 13030;
- }
- if (httpStatus >= 200 && httpStatus < 300) {
- responseObject = this
- .createResponseObject(o, callback.argument);
- if (callback.success) {
- if (!callback.scope) {
- callback.success(responseObject);
- } else {
- callback.success
- .apply(callback.scope, [responseObject]);
- }
- }
- } else {
- switch (httpStatus) {
- case 12002 :
- case 12029 :
- case 12030 :
- case 12031 :
- case 12152 :
- case 13030 :
- responseObject = this.createExceptionObject(o.tId,
- callback.argument, (isAbort ? isAbort : false));
- if (callback.failure) {
- if (!callback.scope) {
- callback.failure(responseObject);
- } else {
- callback.failure.apply(callback.scope,
- [responseObject]);
- }
- }
- break;
- default :
- responseObject = this.createResponseObject(o,
- callback.argument);
- if (callback.failure) {
- if (!callback.scope) {
- callback.failure(responseObject);
- } else {
- callback.failure.apply(callback.scope,
- [responseObject]);
- }
- }
- }
- }
- this.releaseObject(o);
- responseObject = null;
- },
- createResponseObject : function(o, callbackArg) {
- var obj = {};
- var headerObj = {};
- try {
- var headerStr = o.conn.getAllResponseHeaders();
- var header = headerStr.split('\n');
- for (var i = 0; i < header.length; i++) {
- var delimitPos = header[i].indexOf(':');
- if (delimitPos != -1) {
- headerObj[header[i].substring(0, delimitPos)] = header[i]
- .substring(delimitPos + 2);
- }
- }
- } catch (e) {
- }
- obj.tId = o.tId;
- obj.status = o.conn.status;
- obj.statusText = o.conn.statusText;
- obj.getResponseHeader = headerObj;
- obj.getAllResponseHeaders = headerStr;
- obj.responseText = o.conn.responseText;
- obj.responseXML = o.conn.responseXML;
- if (typeof callbackArg !== undefined) {
- obj.argument = callbackArg;
- }
- return obj;
- },
- createExceptionObject : function(tId, callbackArg, isAbort) {
- var COMM_CODE = 0;
- var COMM_ERROR = 'communication failure';
- var ABORT_CODE = -1;
- var ABORT_ERROR = 'transaction aborted';
- var obj = {};
- obj.tId = tId;
- if (isAbort) {
- obj.status = ABORT_CODE;
- obj.statusText = ABORT_ERROR;
- } else {
- obj.status = COMM_CODE;
- obj.statusText = COMM_ERROR;
- }
- if (callbackArg) {
- obj.argument = callbackArg;
- }
- return obj;
- },
- initHeader : function(label, value, isDefault) {
- var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
- if (headerObj[label] === undefined) {
- headerObj[label] = value;
- } else {
- headerObj[label] = value + "," + headerObj[label];
- }
- if (isDefault) {
- this.hasDefaultHeaders = true;
- } else {
- this.hasHeaders = true;
- }
- },
- setHeader : function(o) {
- if (this.hasDefaultHeaders) {
- for (var prop in this.defaultHeaders) {
- if (this.defaultHeaders.hasOwnProperty(prop)) {
- o.conn
- .setRequestHeader(prop,
- this.defaultHeaders[prop]);
- }
- }
- }
- if (this.hasHeaders) {
- for (var prop in this.headers) {
- if (this.headers.hasOwnProperty(prop)) {
- o.conn.setRequestHeader(prop, this.headers[prop]);
- }
- }
- this.headers = {};
- this.hasHeaders = false;
- }
- },
- resetDefaultHeaders : function() {
- delete this.defaultHeaders;
- this.defaultHeaders = {};
- this.hasDefaultHeaders = false;
- },
- abort : function(o, callback, isTimeout) {
- if (this.isCallInProgress(o)) {
- o.conn.abort();
- window.clearInterval(this.poll[o.tId]);
- delete this.poll[o.tId];
- if (isTimeout) {
- delete this.timeout[o.tId];
- }
- this.handleTransactionResponse(o, callback, true);
- return true;
- } else {
- return false;
- }
- },
- isCallInProgress : function(o) {
- if (o.conn) {
- return o.conn.readyState != 4 && o.conn.readyState != 0;
- } else {
- return false;
- }
- },
- releaseObject : function(o) {
- o.conn = null;
- o = null;
- },
- activeX : ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP']
- };
- Ext.lib.Region = function(t, r, b, l) {
- this.top = t;
- this[1] = t;
- this.right = r;
- this.bottom = b;
- this.left = l;
- this[0] = l;
- };
- Ext.lib.Region.prototype = {
- contains : function(region) {
- return (region.left >= this.left && region.right <= this.right
- && region.top >= this.top && region.bottom <= this.bottom);
- },
- getArea : function() {
- return ((this.bottom - this.top) * (this.right - this.left));
- },
- intersect : function(region) {
- var t = Math.max(this.top, region.top);
- var r = Math.min(this.right, region.right);
- var b = Math.min(this.bottom, region.bottom);
- var l = Math.max(this.left, region.left);
- if (b >= t && r >= l) {
- return new Ext.lib.Region(t, r, b, l);
- } else {
- return null;
- }
- },
- union : function(region) {
- var t = Math.min(this.top, region.top);
- var r = Math.max(this.right, region.right);
- var b = Math.max(this.bottom, region.bottom);
- var l = Math.min(this.left, region.left);
- return new Ext.lib.Region(t, r, b, l);
- },
- constrainTo : function(r) {
- this.top = this.top.constrain(r.top, r.bottom);
- this.bottom = this.bottom.constrain(r.top, r.bottom);
- this.left = this.left.constrain(r.left, r.right);
- this.right = this.right.constrain(r.left, r.right);
- return this;
- },
- adjust : function(t, l, b, r) {
- this.top += t;
- this.left += l;
- this.right += r;
- this.bottom += b;
- return this;
- }
- };
- Ext.lib.Region.getRegion = function(el) {
- var p = Ext.lib.Dom.getXY(el);
- var t = p[1];
- var r = p[0] + el.offsetWidth;
- var b = p[1] + el.offsetHeight;
- var l = p[0];
- return new Ext.lib.Region(t, r, b, l);
- };
- Ext.lib.Point = function(x, y) {
- if (x instanceof Array) {
- y = x[1];
- x = x[0];
- }
- this.x = this.right = this.left = this[0] = x;
- this.y = this.top = this.bottom = this[1] = y;
- };
- Ext.lib.Point.prototype = new Ext.lib.Region();
- Ext.lib.Anim = {
- scroll : function(el, args, duration, easing, cb, scope) {
- this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
- },
- motion : function(el, args, duration, easing, cb, scope) {
- this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
- },
- color : function(el, args, duration, easing, cb, scope) {
- this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
- },
- run : function(el, args, duration, easing, cb, scope, type) {
- type = type || Ext.lib.AnimBase;
- if (typeof easing == "string") {
- easing = Ext.lib.Easing[easing];
- }
- var anim = new type(el, args, duration, easing);
- anim.animateX(function() {
- Ext.callback(cb, scope);
- });
- return anim;
- }
- };
- function fly(el) {
- if (!libFlyweight) {
- libFlyweight = new Ext.Element.Flyweight();
- }
- libFlyweight.dom = el;
- return libFlyweight;
- }
- if (Ext.isIE) {
- function fnCleanUp() {
- var p = Function.prototype;
- delete p.createSequence;
- delete p.defer;
- delete p.createDelegate;
- delete p.createCallback;
- delete p.createInterceptor;
- window.detachEvent("onunload", fnCleanUp);
- }
- window.attachEvent("onunload", fnCleanUp);
- }
- Ext.lib.AnimBase = function(el, attributes, duration, method) {
- if (el) {
- this.init(el, attributes, duration, method);
- }
- };
- Ext.lib.AnimBase.prototype = {
- toString : function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Anim " + id);
- },
- patterns : {
- noNegatives : /width|height|opacity|padding/i,
- offsetAttribute : /^((width|height)|(top|left))$/,
- defaultUnit : /width|height|top$|bottom$|left$|right$/i,
- offsetUnit : /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
- },
- doMethod : function(attr, start, end) {
- return this.method(this.currentFrame, start, end - start,
- this.totalFrames);
- },
- setAttribute : function(attr, val, unit) {
- if (this.patterns.noNegatives.test(attr)) {
- val = (val > 0) ? val : 0;
- }
- Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
- },
- getAttribute : function(attr) {
- var el = this.getEl();
- var val = fly(el).getStyle(attr);
- if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
- return parseFloat(val);
- }
- var a = this.patterns.offsetAttribute.exec(attr) || [];
- var pos = !!(a[3]);
- var box = !!(a[2]);
- if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
- val = el['offset' + a[0].charAt(0).toUpperCase()
- + a[0].substr(1)];
- } else {
- val = 0;
- }
- return val;
- },
- getDefaultUnit : function(attr) {
- if (this.patterns.defaultUnit.test(attr)) {
- return 'px';
- }
- return '';
- },
- animateX : function(callback, scope) {
- var f = function() {
- this.onComplete.removeListener(f);
- if (typeof callback == "function") {
- callback.call(scope || this, this);
- }
- };
- this.onComplete.addListener(f, this);
- this.animate();
- },
- setRuntimeAttribute : function(attr) {
- var start;
- var end;
- var attributes = this.attributes;
- this.runtimeAttributes[attr] = {};
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
- if (!isset(attributes[attr]['to'])
- && !isset(attributes[attr]['by'])) {
- return false;
- }
- start = (isset(attributes[attr]['from']))
- ? attributes[attr]['from']
- : this.getAttribute(attr);
- if (isset(attributes[attr]['to'])) {
- end = attributes[attr]['to'];
- } else if (isset(attributes[attr]['by'])) {
- if (start.constructor == Array) {
- end = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + attributes[attr]['by'][i];
- }
- } else {
- end = start + attributes[attr]['by'];
- }
- }
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
- this.runtimeAttributes[attr].unit = (isset(attributes[attr].unit))
- ? attributes[attr]['unit']
- : this.getDefaultUnit(attr);
- },
- init : function(el, attributes, duration, method) {
- var isAnimated = false;
- var startTime = null;
- var actualFrames = 0;
- el = Ext.getDom(el);
- this.attributes = attributes || {};
- this.duration = duration || 1;
- this.method = method || Ext.lib.Easing.easeNone;
- this.useSeconds = true;
- this.currentFrame = 0;
- this.totalFrames = Ext.lib.AnimMgr.fps;
- this.getEl = function() {
- return el;
- };
- this.isAnimated = function() {
- return isAnimated;
- };
- this.getStartTime = function() {
- return startTime;
- };
- this.runtimeAttributes = {};
- this.animate = function() {
- if (this.isAnimated()) {
- return false;
- }
- this.currentFrame = 0;
- this.totalFrames = (this.useSeconds)
- ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration)
- : this.duration;
- Ext.lib.AnimMgr.registerElement(this);
- };
- this.stop = function(finish) {
- if (finish) {
- this.currentFrame = this.totalFrames;
- this._onTween.fire();
- }
- Ext.lib.AnimMgr.stop(this);
- };
- var onStart = function() {
- this.onStart.fire();
- this.runtimeAttributes = {};
- for (var attr in this.attributes) {
- this.setRuntimeAttribute(attr);
- }
- isAnimated = true;
- actualFrames = 0;
- startTime = allGetServerTime();
- };
- var onTween = function() {
- var data = {
- duration : allGetServerTime() - this.getStartTime(),
- currentFrame : this.currentFrame
- };
- data.toString = function() {
- return ('duration: ' + data.duration + ', currentFrame: ' + data.currentFrame);
- };
- this.onTween.fire(data);
- var runtimeAttributes = this.runtimeAttributes;
- for (var attr in runtimeAttributes) {
- this.setAttribute(attr, this.doMethod(attr,
- runtimeAttributes[attr].start,
- runtimeAttributes[attr].end),
- runtimeAttributes[attr].unit);
- }
- actualFrames += 1;
- };
- var onComplete = function() {
- var actual_duration = (allGetServerTime() - startTime) / 1000;
- var data = {
- duration : actual_duration,
- frames : actualFrames,
- fps : actualFrames / actual_duration
- };
- data.toString = function() {
- return ('duration: ' + data.duration + ', frames: '
- + data.frames + ', fps: ' + data.fps);
- };
- isAnimated = false;
- actualFrames = 0;
- this.onComplete.fire(data);
- };
- this._onStart = new Ext.util.Event(this);
- this.onStart = new Ext.util.Event(this);
- this.onTween = new Ext.util.Event(this);
- this._onTween = new Ext.util.Event(this);
- this.onComplete = new Ext.util.Event(this);
- this._onComplete = new Ext.util.Event(this);
- this._onStart.addListener(onStart);
- this._onTween.addListener(onTween);
- this._onComplete.addListener(onComplete);
- }
- };
- Ext.lib.AnimMgr = new function() {
- var thread = null;
- var queue = [];
- var tweenCount = 0;
- this.fps = 1000;
- this.delay = 1;
- this.registerElement = function(tween) {
- queue[queue.length] = tween;
- tweenCount += 1;
- tween._onStart.fire();
- this.start();
- };
- this.unRegister = function(tween, index) {
- tween._onComplete.fire();
- index = index || getIndex(tween);
- if (index != -1) {
- queue.splice(index, 1);
- }
- tweenCount -= 1;
- if (tweenCount <= 0) {
- this.stop();
- }
- };
- this.start = function() {
- if (thread === null) {
- thread = setInterval(this.run, this.delay);
- }
- };
- this.stop = function(tween) {
- if (!tween) {
- clearInterval(thread);
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[0].isAnimated()) {
- this.unRegister(queue[0], 0);
- }
- }
- queue = [];
- thread = null;
- tweenCount = 0;
- } else {
- this.unRegister(tween);
- }
- };
- this.run = function() {
- for (var i = 0, len = queue.length; i < len; ++i) {
- var tween = queue[i];
- if (!tween || !tween.isAnimated()) {
- continue;
- }
- if (tween.currentFrame < tween.totalFrames
- || tween.totalFrames === null) {
- tween.currentFrame += 1;
- if (tween.useSeconds) {
- correctFrame(tween);
- }
- tween._onTween.fire();
- } else {
- Ext.lib.AnimMgr.stop(tween, i);
- }
- }
- };
- var getIndex = function(anim) {
- for (var i = 0, len = queue.length; i < len; ++i) {
- if (queue[i] == anim) {
- return i;
- }
- }
- return -1;
- };
- var correctFrame = function(tween) {
- var frames = tween.totalFrames;
- var frame = tween.currentFrame;
- var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
- var elapsed = (allGetServerTime() - tween.getStartTime());
- var tweak = 0;
- if (elapsed < tween.duration * 1000) {
- tweak = Math.round((elapsed / expected - 1)
- * tween.currentFrame);
- } else {
- tweak = frames - (frame + 1);
- }
- if (tweak > 0 && isFinite(tweak)) {
- if (tween.currentFrame + tweak >= frames) {
- tweak = frames - (frame + 1);
- }
- tween.currentFrame += tweak;
- }
- };
- };
- Ext.lib.Bezier = new function() {
- this.getPosition = function(points, t) {
- var n = points.length;
- var tmp = [];
- for (var i = 0; i < n; ++i) {
- tmp[i] = [points[i][0], points[i][1]];
- }
- for (var j = 1; j < n; ++j) {
- for (i = 0; i < n - j; ++i) {
- tmp[i][0] = (1 - t) * tmp[i][0] + t
- * tmp[parseInt(i + 1, 10)][0];
- tmp[i][1] = (1 - t) * tmp[i][1] + t
- * tmp[parseInt(i + 1, 10)][1];
- }
- }
- return [tmp[0][0], tmp[0][1]];
- };
- };
- (function() {
- Ext.lib.ColorAnim = function(el, attributes, duration, method) {
- Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes,
- duration, method);
- };
- Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase);
- var Y = Ext.lib;
- var superclass = Y.ColorAnim.superclass;
- var proto = Y.ColorAnim.prototype;
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("ColorAnim " + id);
- };
- proto.patterns.color = /color$/i;
- proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
- proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
- proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
- proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
- proto.parseColor = function(s) {
- if (s.length == 3) {
- return s;
- }
- var c = this.patterns.hex.exec(s);
- if (c && c.length == 4) {
- return [parseInt(c[1], 16), parseInt(c[2], 16),
- parseInt(c[3], 16)];
- }
- c = this.patterns.rgb.exec(s);
- if (c && c.length == 4) {
- return [parseInt(c[1], 10), parseInt(c[2], 10),
- parseInt(c[3], 10)];
- }
- c = this.patterns.hex3.exec(s);
- if (c && c.length == 4) {
- return [parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16),
- parseInt(c[3] + c[3], 16)];
- }
- return null;
- };
- proto.getAttribute = function(attr) {
- var el = this.getEl();
- if (this.patterns.color.test(attr)) {
- var val = fly(el).getStyle(attr);
- if (this.patterns.transparent.test(val)) {
- var parent = el.parentNode;
- val = fly(parent).getStyle(attr);
- while (parent && this.patterns.transparent.test(val)) {
- parent = parent.parentNode;
- val = fly(parent).getStyle(attr);
- if (parent.tagName.toUpperCase() == 'HTML') {
- val = '#fff';
- }
- }
- }
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
- return val;
- };
- proto.doMethod = function(attr, start, end) {
- var val;
- if (this.patterns.color.test(attr)) {
- val = [];
- for (var i = 0, len = start.length; i < len; ++i) {
- val[i] = superclass.doMethod.call(this, attr, start[i],
- end[i]);
- }
- val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1])
- + ',' + Math.floor(val[2]) + ')';
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
- proto.setRuntimeAttribute = function(attr) {
- superclass.setRuntimeAttribute.call(this, attr);
- if (this.patterns.color.test(attr)) {
- var attributes = this.attributes;
- var start = this.parseColor(this.runtimeAttributes[attr].start);
- var end = this.parseColor(this.runtimeAttributes[attr].end);
- if (typeof attributes[attr]['to'] === 'undefined'
- && typeof attributes[attr]['by'] !== 'undefined') {
- end = this.parseColor(attributes[attr].by);
- for (var i = 0, len = start.length; i < len; ++i) {
- end[i] = start[i] + end[i];
- }
- }
- this.runtimeAttributes[attr].start = start;
- this.runtimeAttributes[attr].end = end;
- }
- };
- })();
- Ext.lib.Easing = {
- easeNone : function(t, b, c, d) {
- return c * t / d + b;
- },
- easeIn : function(t, b, c, d) {
- return c * (t /= d) * t + b;
- },
- easeOut : function(t, b, c, d) {
- return -c * (t /= d) * (t - 2) + b;
- },
- easeBoth : function(t, b, c, d) {
- if ((t /= d / 2) < 1) {
- return c / 2 * t * t + b;
- }
- return -c / 2 * ((--t) * (t - 2) - 1) + b;
- },
- easeInStrong : function(t, b, c, d) {
- return c * (t /= d) * t * t * t + b;
- },
- easeOutStrong : function(t, b, c, d) {
- return -c * ((t = t / d - 1) * t * t * t - 1) + b;
- },
- easeBothStrong : function(t, b, c, d) {
- if ((t /= d / 2) < 1) {
- return c / 2 * t * t * t * t + b;
- }
- return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
- },
- elasticIn : function(t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
- if ((t /= d) == 1) {
- return b + c;
- }
- if (!p) {
- p = d * .3;
- }
- if (!a || a < Math.abs(c)) {
- a = c;
- var s = p / 4;
- } else {
- var s = p / (2 * Math.PI) * Math.asin(c / a);
- }
- return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s)
- * (2 * Math.PI) / p))
- + b;
- },
- elasticOut : function(t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
- if ((t /= d) == 1) {
- return b + c;
- }
- if (!p) {
- p = d * .3;
- }
- if (!a || a < Math.abs(c)) {
- a = c;
- var s = p / 4;
- } else {
- var s = p / (2 * Math.PI) * Math.asin(c / a);
- }
- return a * Math.pow(2, -10 * t)
- * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
- },
- elasticBoth : function(t, b, c, d, a, p) {
- if (t == 0) {
- return b;
- }
- if ((t /= d / 2) == 2) {
- return b + c;
- }
- if (!p) {
- p = d * (.3 * 1.5);
- }
- if (!a || a < Math.abs(c)) {
- a = c;
- var s = p / 4;
- } else {
- var s = p / (2 * Math.PI) * Math.asin(c / a);
- }
- if (t < 1) {
- return -.5
- * (a * Math.pow(2, 10 * (t -= 1)) * Math
- .sin((t * d - s) * (2 * Math.PI) / p)) + b;
- }
- return a * Math.pow(2, -10 * (t -= 1))
- * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
- },
- backIn : function(t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
- return c * (t /= d) * t * ((s + 1) * t - s) + b;
- },
- backOut : function(t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
- return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
- },
- backBoth : function(t, b, c, d, s) {
- if (typeof s == 'undefined') {
- s = 1.70158;
- }
- if ((t /= d / 2) < 1) {
- return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
- }
- return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2)
- + b;
- },
- bounceIn : function(t, b, c, d) {
- return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b;
- },
- bounceOut : function(t, b, c, d) {
- if ((t /= d) < (1 / 2.75)) {
- return c * (7.5625 * t * t) + b;
- } else if (t < (2 / 2.75)) {
- return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
- } else if (t < (2.5 / 2.75)) {
- return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
- }
- return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
- },
- bounceBoth : function(t, b, c, d) {
- if (t < d / 2) {
- return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
- }
- return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5
- + b;
- }
- };
- (function() {
- Ext.lib.Motion = function(el, attributes, duration, method) {
- if (el) {
- Ext.lib.Motion.superclass.constructor.call(this, el,
- attributes, duration, method);
- }
- };
- Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim);
- var Y = Ext.lib;
- var superclass = Y.Motion.superclass;
- var proto = Y.Motion.prototype;
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Motion " + id);
- };
- proto.patterns.points = /^points$/i;
- proto.setAttribute = function(attr, val, unit) {
- if (this.patterns.points.test(attr)) {
- unit = unit || 'px';
- superclass.setAttribute.call(this, 'left', val[0], unit);
- superclass.setAttribute.call(this, 'top', val[1], unit);
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
- proto.getAttribute = function(attr) {
- if (this.patterns.points.test(attr)) {
- var val = [superclass.getAttribute.call(this, 'left'),
- superclass.getAttribute.call(this, 'top')];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
- return val;
- };
- proto.doMethod = function(attr, start, end) {
- var val = null;
- if (this.patterns.points.test(attr)) {
- var t = this
- .method(this.currentFrame, 0, 100, this.totalFrames)
- / 100;
- val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
- proto.setRuntimeAttribute = function(attr) {
- if (this.patterns.points.test(attr)) {
- var el = this.getEl();
- var attributes = this.attributes;
- var start;
- var control = attributes['points']['control'] || [];
- var end;
- var i, len;
- if (control.length > 0 && !(control[0] instanceof Array)) {
- control = [control];
- } else {
- var tmp = [];
- for (i = 0, len = control.length; i < len; ++i) {
- tmp[i] = control[i];
- }
- control = tmp;
- }
- Ext.fly(el).position();
- if (isset(attributes['points']['from'])) {
- Ext.lib.Dom.setXY(el, attributes['points']['from']);
- } else {
- Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el));
- }
- start = this.getAttribute('points');
- if (isset(attributes['points']['to'])) {
- end = translateValues.call(this,
- attributes['points']['to'], start);
- var pageXY = Ext.lib.Dom.getXY(this.getEl());
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = translateValues.call(this, control[i],
- start);
- }
- } else if (isset(attributes['points']['by'])) {
- end = [start[0] + attributes['points']['by'][0],
- start[1] + attributes['points']['by'][1]];
- for (i = 0, len = control.length; i < len; ++i) {
- control[i] = [start[0] + control[i][0],
- start[1] + control[i][1]];
- }
- }
- this.runtimeAttributes[attr] = [start];
- if (control.length > 0) {
- this.runtimeAttributes[attr] = this.runtimeAttributes[attr]
- .concat(control);
- }
- this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
- } else {
- superclass.setRuntimeAttribute.call(this, attr);
- }
- };
- var translateValues = function(val, start) {
- var pageXY = Ext.lib.Dom.getXY(this.getEl());
- val = [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
- return val;
- };
- var isset = function(prop) {
- return (typeof prop !== 'undefined');
- };
- })();
- (function() {
- Ext.lib.Scroll = function(el, attributes, duration, method) {
- if (el) {
- Ext.lib.Scroll.superclass.constructor.call(this, el,
- attributes, duration, method);
- }
- };
- Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim);
- var Y = Ext.lib;
- var superclass = Y.Scroll.superclass;
- var proto = Y.Scroll.prototype;
- proto.toString = function() {
- var el = this.getEl();
- var id = el.id || el.tagName;
- return ("Scroll " + id);
- };
- proto.doMethod = function(attr, start, end) {
- var val = null;
- if (attr == 'scroll') {
- val = [
- this.method(this.currentFrame, start[0], end[0]
- - start[0], this.totalFrames),
- this.method(this.currentFrame, start[1], end[1]
- - start[1], this.totalFrames)];
- } else {
- val = superclass.doMethod.call(this, attr, start, end);
- }
- return val;
- };
- proto.getAttribute = function(attr) {
- var val = null;
- var el = this.getEl();
- if (attr == 'scroll') {
- val = [el.scrollLeft, el.scrollTop];
- } else {
- val = superclass.getAttribute.call(this, attr);
- }
- return val;
- };
- proto.setAttribute = function(attr, val, unit) {
- var el = this.getEl();
- if (attr == 'scroll') {
- el.scrollLeft = val[0];
- el.scrollTop = val[1];
- } else {
- superclass.setAttribute.call(this, attr, val, unit);
- }
- };
- })();
- })();
|