2 * Ext JS Library 0.30
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * Ext JS Library 2.0.1
\r
11 * Copyright(c) 2006-2008, Ext JS, LLC.
\r
12 * licensing@extjs.com
\r
14 * http://extjs.com/license
\r
18 Ext = {version: '2.0.1'};
\r
21 window["undefined"] = window["undefined"];
\r
26 Ext.apply = function(o, c, defaults){
\r
29 Ext.apply(o, defaults);
\r
31 if(o && c && typeof c == 'object'){
\r
41 var ua = navigator.userAgent.toLowerCase();
\r
43 var isStrict = document.compatMode == "CSS1Compat",
\r
44 isOpera = ua.indexOf("opera") > -1,
\r
45 isSafari = (/webkit|khtml/).test(ua),
\r
46 isSafari3 = isSafari && ua.indexOf('webkit/5') != -1,
\r
47 isIE = !isOpera && ua.indexOf("msie") > -1,
\r
48 isIE7 = !isOpera && ua.indexOf("msie 7") > -1,
\r
49 isGecko = !isSafari && ua.indexOf("gecko") > -1,
\r
50 isBorderBox = isIE && !isStrict,
\r
51 isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
\r
52 isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
\r
53 isAir = (ua.indexOf("adobeair") != -1),
\r
54 isLinux = (ua.indexOf("linux") != -1),
\r
55 isSecure = window.location.href.toLowerCase().indexOf("https") === 0;
\r
60 document.execCommand("BackgroundImageCache", false, true);
\r
66 isStrict : isStrict,
\r
68 isSecure : isSecure,
\r
73 enableGarbageCollector : true,
\r
76 enableListenerCollection:false,
\r
80 SSL_SECURE_URL : "javascript:false",
\r
83 BLANK_IMAGE_URL : "http:/"+"/extjs.com/s.gif",
\r
86 emptyFn : function(){},
\r
89 applyIf : function(o, c){
\r
92 if(typeof o[p] == "undefined"){ o[p] = c[p]; }
\r
99 addBehaviors : function(o){
\r
101 Ext.onReady(function(){
\r
102 Ext.addBehaviors(o);
\r
108 var parts = b.split('@');
\r
112 cache[s] = Ext.select(s);
\r
114 cache[s].on(parts[1], o[b]);
\r
121 id : function(el, prefix){
\r
122 prefix = prefix || "ext-gen";
\r
123 el = Ext.getDom(el);
\r
124 var id = prefix + (++idSeed);
\r
125 return el ? (el.id ? el.id : (el.id = id)) : id;
\r
129 extend : function(){
\r
131 var io = function(o){
\r
136 var oc = Object.prototype.constructor;
\r
138 return function(sb, sp, overrides){
\r
139 if(typeof sp == 'object'){
\r
142 sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
\r
144 var F = function(){}, sbp, spp = sp.prototype;
\r
146 sbp = sb.prototype = new F();
\r
147 sbp.constructor=sb;
\r
149 if(spp.constructor == oc){
\r
150 spp.constructor=sp;
\r
152 sb.override = function(o){
\r
153 Ext.override(sb, o);
\r
156 Ext.override(sb, overrides);
\r
162 override : function(origclass, overrides){
\r
164 var p = origclass.prototype;
\r
165 for(var method in overrides){
\r
166 p[method] = overrides[method];
\r
172 namespace : function(){
\r
173 var a=arguments, o=null, i, j, d, rt;
\r
174 for (i=0; i<a.length; ++i) {
\r
177 eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
\r
178 for (j=1; j<d.length; ++j) {
\r
179 o[d[j]]=o[d[j]] || {};
\r
186 urlEncode : function(o){
\r
192 var ov = o[key], k = encodeURIComponent(key);
\r
193 var type = typeof ov;
\r
194 if(type == 'undefined'){
\r
196 }else if(type != "function" && type != "object"){
\r
197 buf.push(k, "=", encodeURIComponent(ov), "&");
\r
198 }else if(Ext.isArray(ov)){
\r
200 for(var i = 0, len = ov.length; i < len; i++) {
\r
201 buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
\r
209 return buf.join("");
\r
213 urlDecode : function(string, overwrite){
\r
214 if(!string || !string.length){
\r
218 var pairs = string.split('&');
\r
219 var pair, name, value;
\r
220 for(var i = 0, len = pairs.length; i < len; i++){
\r
221 pair = pairs[i].split('=');
\r
222 name = decodeURIComponent(pair[0]);
\r
223 value = decodeURIComponent(pair[1]);
\r
224 if(overwrite !== true){
\r
225 if(typeof obj[name] == "undefined"){
\r
227 }else if(typeof obj[name] == "string"){
\r
228 obj[name] = [obj[name]];
\r
229 obj[name].push(value);
\r
231 obj[name].push(value);
\r
241 each : function(array, fn, scope){
\r
242 if(typeof array.length == "undefined" || typeof array == "string"){
\r
245 for(var i = 0, len = array.length; i < len; i++){
\r
246 if(fn.call(scope || array[i], array[i], i, array) === false){ return i; };
\r
251 combine : function(){
\r
252 var as = arguments, l = as.length, r = [];
\r
253 for(var i = 0; i < l; i++){
\r
255 if(Ext.isArray(a)){
\r
257 }else if(a.length !== undefined && !a.substr){
\r
258 r = r.concat(Array.prototype.slice.call(a, 0));
\r
267 escapeRe : function(s) {
\r
268 return s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
\r
272 callback : function(cb, scope, args, delay){
\r
273 if(typeof cb == "function"){
\r
275 cb.defer(delay, scope, args || []);
\r
277 cb.apply(scope, args || []);
\r
283 getDom : function(el){
\r
284 if(!el || !document){
\r
287 return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
\r
291 getDoc : function(){
\r
292 return Ext.get(document);
\r
296 getBody : function(){
\r
297 return Ext.get(document.body || document.documentElement);
\r
301 getCmp : function(id){
\r
302 return Ext.ComponentMgr.get(id);
\r
306 num : function(v, defaultValue){
\r
307 if(typeof v != 'number'){
\r
308 return defaultValue;
\r
314 destroy : function(){
\r
315 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
\r
319 as.removeAllListeners();
\r
323 if(typeof as.destroy == 'function'){
\r
330 removeNode : isIE ? function(){
\r
332 return function(n){
\r
334 d = d || document.createElement('div');
\r
340 if(n && n.parentNode){
\r
341 n.parentNode.removeChild(n);
\r
347 type : function(o){
\r
348 if(o === undefined || o === null){
\r
355 if(t == 'object' && o.nodeName) {
\r
356 switch(o.nodeType) {
\r
357 case 1: return 'element';
\r
358 case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
\r
361 if(t == 'object' || t == 'function') {
\r
362 switch(o.constructor) {
\r
363 case Array: return 'array';
\r
364 case RegExp: return 'regexp';
\r
366 if(typeof o.length == 'number' && typeof o.item == 'function') {
\r
374 isEmpty : function(v, allowBlank){
\r
375 return v === null || v === undefined || (!allowBlank ? v === '' : false);
\r
378 value : function(v, defaultValue, allowBlank){
\r
379 return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
\r
382 isArray : function(v){
\r
383 return v && typeof v.pop == 'function';
\r
386 isDate : function(v){
\r
387 return v && typeof v.getFullYear == 'function';
\r
393 isSafari : isSafari,
\r
395 isSafari3 : isSafari3,
\r
397 isSafari2 : isSafari && !isSafari3,
\r
401 isIE6 : isIE && !isIE7,
\r
407 isBorderBox : isBorderBox,
\r
411 isWindows : isWindows,
\r
418 useShims : ((isIE && !isIE7) || (isGecko && isMac))
\r
422 Ext.ns = Ext.namespace;
\r
425 Ext.ns("Ext", "Ext.util", "Ext.grid", "Ext.dd", "Ext.tree", "Ext.data",
\r
426 "Ext.form", "Ext.menu", "Ext.state", "Ext.lib", "Ext.layout", "Ext.app", "Ext.ux");
\r
430 Ext.apply(Function.prototype, {
\r
432 createCallback : function(){
\r
434 var args = arguments;
\r
436 return function() {
\r
437 return method.apply(window, args);
\r
442 createDelegate : function(obj, args, appendArgs){
\r
444 return function() {
\r
445 var callArgs = args || arguments;
\r
446 if(appendArgs === true){
\r
447 callArgs = Array.prototype.slice.call(arguments, 0);
\r
448 callArgs = callArgs.concat(args);
\r
449 }else if(typeof appendArgs == "number"){
\r
450 callArgs = Array.prototype.slice.call(arguments, 0);
451 var applyArgs = [appendArgs, 0].concat(args);
452 Array.prototype.splice.apply(callArgs, applyArgs);
454 return method.apply(obj || window, callArgs);
\r
459 defer : function(millis, obj, args, appendArgs){
\r
460 var fn = this.createDelegate(obj, args, appendArgs);
\r
462 return setTimeout(fn, millis);
\r
468 createSequence : function(fcn, scope){
\r
469 if(typeof fcn != "function"){
\r
473 return function() {
\r
474 var retval = method.apply(this || window, arguments);
\r
475 fcn.apply(scope || this || window, arguments);
\r
481 createInterceptor : function(fcn, scope){
\r
482 if(typeof fcn != "function"){
\r
486 return function() {
\r
488 fcn.method = method;
\r
489 if(fcn.apply(scope || this || window, arguments) === false){
\r
492 return method.apply(this || window, arguments);
\r
498 Ext.applyIf(String, {
\r
501 escape : function(string) {
\r
502 return string.replace(/('|\\)/g, "\\$1");
\r
506 leftPad : function (val, size, ch) {
\r
507 var result = new String(val);
\r
511 while (result.length < size) {
\r
512 result = ch + result;
\r
514 return result.toString();
\r
518 format : function(format){
\r
519 var args = Array.prototype.slice.call(arguments, 1);
\r
520 return format.replace(/\{(\d+)\}/g, function(m, i){
\r
527 String.prototype.toggle = function(value, other){
\r
528 return this == value ? other : value;
\r
532 String.prototype.trim = function(){
\r
533 var re = /^\s+|\s+$/g;
\r
534 return function(){ return this.replace(re, ""); };
\r
537 Ext.applyIf(Number.prototype, {
\r
539 constrain : function(min, max){
\r
540 return Math.min(Math.max(this, min), max);
\r
544 Ext.applyIf(Array.prototype, {
\r
546 indexOf : function(o){
\r
547 for (var i = 0, len = this.length; i < len; i++){
\r
548 if(this[i] == o) return i;
\r
554 remove : function(o){
\r
555 var index = this.indexOf(o);
\r
557 this.splice(index, 1);
\r
564 Date.prototype.getElapsed = function(date) {
\r
565 return Math.abs((date || new Date()).getTime()-this.getTime());
\r
572 getViewWidth : function(full) {
\r
573 return full ? this.getDocumentWidth() : this.getViewportWidth();
\r
576 getViewHeight : function(full) {
\r
577 return full ? this.getDocumentHeight() : this.getViewportHeight();
\r
580 getDocumentHeight: function() {
\r
581 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
\r
582 return Math.max(scrollHeight, this.getViewportHeight());
\r
585 getDocumentWidth: function() {
\r
586 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
\r
587 return Math.max(scrollWidth, this.getViewportWidth());
\r
590 getViewportHeight: function(){
\r
592 return Ext.isStrict ? document.documentElement.clientHeight :
\r
593 document.body.clientHeight;
\r
595 return self.innerHeight;
\r
599 getViewportWidth: function() {
\r
601 return Ext.isStrict ? document.documentElement.clientWidth :
\r
602 document.body.clientWidth;
\r
604 return self.innerWidth;
\r
608 isAncestor : function(p, c) {
\r
615 if (p.contains && !Ext.isSafari) {
\r
616 return p.contains(c);
\r
617 } else if (p.compareDocumentPosition) {
\r
618 return !!(p.compareDocumentPosition(c) & 16);
\r
620 var parent = c.parentNode;
\r
625 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
\r
628 parent = parent.parentNode;
\r
634 getRegion : function(el) {
\r
635 return Ext.lib.Region.getRegion(el);
\r
638 getY : function(el) {
\r
639 return this.getXY(el)[1];
\r
642 getX : function(el) {
\r
643 return this.getXY(el)[0];
\r
647 getXY : function(el) {
\r
648 var p, pe, b, scroll, bd = (document.body || document.documentElement);
\r
649 el = Ext.getDom(el);
\r
655 if (el.getBoundingClientRect) {
\r
656 b = el.getBoundingClientRect();
\r
657 scroll = fly(document).getScroll();
\r
658 return [b.left + scroll.left, b.top + scroll.top];
\r
664 var hasAbsolute = fly(el).getStyle("position") == "absolute";
\r
671 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
\r
672 hasAbsolute = true;
\r
678 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
\r
679 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
\r
686 if (p != el && pe.getStyle('overflow') != 'visible') {
\r
691 p = p.offsetParent;
\r
694 if (Ext.isSafari && hasAbsolute) {
\r
695 x -= bd.offsetLeft;
\r
699 if (Ext.isGecko && !hasAbsolute) {
\r
701 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
\r
702 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
\r
706 while (p && p != bd) {
\r
707 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
\r
716 setXY : function(el, xy) {
\r
717 el = Ext.fly(el, '_setXY');
\r
719 var pts = el.translatePoints(xy);
\r
720 if (xy[0] !== false) {
\r
721 el.dom.style.left = pts.left + "px";
\r
723 if (xy[1] !== false) {
\r
724 el.dom.style.top = pts.top + "px";
\r
728 setX : function(el, x) {
\r
729 this.setXY(el, [x, false]);
\r
732 setY : function(el, y) {
\r
733 this.setXY(el, [false, y]);
\r
738 Ext.lib.Event = function() {
\r
739 var loadComplete = false;
\r
740 var listeners = [];
\r
741 var unloadListeners = [];
\r
742 var retryCount = 0;
\r
743 var onAvailStack = [];
\r
745 var lastError = null;
\r
758 startInterval: function() {
\r
759 if (!this._interval) {
\r
761 var callback = function() {
\r
762 self._tryPreloadAttach();
\r
764 this._interval = setInterval(callback, this.POLL_INTERVAL);
\r
769 onAvailable: function(p_id, p_fn, p_obj, p_override) {
\r
770 onAvailStack.push({ id: p_id,
\r
773 override: p_override,
\r
774 checkReady: false });
\r
776 retryCount = this.POLL_RETRYS;
\r
777 this.startInterval();
\r
781 addListener: function(el, eventName, fn) {
\r
782 el = Ext.getDom(el);
\r
787 if ("unload" == eventName) {
\r
788 unloadListeners[unloadListeners.length] =
\r
789 [el, eventName, fn];
\r
794 var wrappedFn = function(e) {
\r
795 return typeof Ext != 'undefined' ? fn(Ext.lib.Event.getEvent(e)) : false;
\r
798 var li = [el, eventName, fn, wrappedFn];
\r
800 var index = listeners.length;
\r
801 listeners[index] = li;
\r
803 this.doAdd(el, eventName, wrappedFn, false);
\r
809 removeListener: function(el, eventName, fn) {
\r
812 el = Ext.getDom(el);
\r
815 return this.purgeElement(el, false, eventName);
\r
819 if ("unload" == eventName) {
\r
821 for (i = 0,len = unloadListeners.length; i < len; i++) {
\r
822 var li = unloadListeners[i];
\r
825 li[1] == eventName &&
\r
827 unloadListeners.splice(i, 1);
\r
835 var cacheItem = null;
\r
838 var index = arguments[3];
\r
840 if ("undefined" == typeof index) {
\r
841 index = this._getCacheIndex(el, eventName, fn);
\r
845 cacheItem = listeners[index];
\r
848 if (!el || !cacheItem) {
\r
852 this.doRemove(el, eventName, cacheItem[this.WFN], false);
\r
854 delete listeners[index][this.WFN];
\r
855 delete listeners[index][this.FN];
\r
856 listeners.splice(index, 1);
\r
863 getTarget: function(ev, resolveTextNode) {
\r
864 ev = ev.browserEvent || ev;
\r
865 var t = ev.target || ev.srcElement;
\r
866 return this.resolveTextNode(t);
\r
870 resolveTextNode: function(node) {
\r
871 if (Ext.isSafari && node && 3 == node.nodeType) {
\r
872 return node.parentNode;
\r
879 getPageX: function(ev) {
\r
880 ev = ev.browserEvent || ev;
\r
882 if (!x && 0 !== x) {
\r
883 x = ev.clientX || 0;
\r
886 x += this.getScroll()[1];
\r
894 getPageY: function(ev) {
\r
895 ev = ev.browserEvent || ev;
\r
897 if (!y && 0 !== y) {
\r
898 y = ev.clientY || 0;
\r
901 y += this.getScroll()[0];
\r
910 getXY: function(ev) {
\r
911 ev = ev.browserEvent || ev;
\r
912 return [this.getPageX(ev), this.getPageY(ev)];
\r
916 getRelatedTarget: function(ev) {
\r
917 ev = ev.browserEvent || ev;
\r
918 var t = ev.relatedTarget;
\r
920 if (ev.type == "mouseout") {
\r
922 } else if (ev.type == "mouseover") {
\r
923 t = ev.fromElement;
\r
927 return this.resolveTextNode(t);
\r
931 getTime: function(ev) {
\r
932 ev = ev.browserEvent || ev;
\r
934 var t = new Date().getTime();
\r
938 this.lastError = ex;
\r
947 stopEvent: function(ev) {
\r
948 this.stopPropagation(ev);
\r
949 this.preventDefault(ev);
\r
953 stopPropagation: function(ev) {
\r
954 ev = ev.browserEvent || ev;
\r
955 if (ev.stopPropagation) {
\r
956 ev.stopPropagation();
\r
958 ev.cancelBubble = true;
\r
963 preventDefault: function(ev) {
\r
964 ev = ev.browserEvent || ev;
\r
965 if(ev.preventDefault) {
\r
966 ev.preventDefault();
\r
968 ev.returnValue = false;
\r
973 getEvent: function(e) {
\r
974 var ev = e || window.event;
\r
976 var c = this.getEvent.caller;
\r
978 ev = c.arguments[0];
\r
979 if (ev && Event == ev.constructor) {
\r
989 getCharCode: function(ev) {
\r
990 ev = ev.browserEvent || ev;
\r
991 return ev.charCode || ev.keyCode || 0;
\r
995 _getCacheIndex: function(el, eventName, fn) {
\r
996 for (var i = 0,len = listeners.length; i < len; ++i) {
\r
997 var li = listeners[i];
\r
999 li[this.FN] == fn &&
\r
1000 li[this.EL] == el &&
\r
1001 li[this.TYPE] == eventName) {
\r
1013 getEl: function(id) {
\r
1014 return document.getElementById(id);
\r
1018 clearCache: function() {
\r
1022 _load: function(e) {
\r
1023 loadComplete = true;
\r
1024 var EU = Ext.lib.Event;
\r
1028 EU.doRemove(window, "load", EU._load);
\r
1033 _tryPreloadAttach: function() {
\r
1035 if (this.locked) {
\r
1039 this.locked = true;
\r
1042 var tryAgain = !loadComplete;
\r
1044 tryAgain = (retryCount > 0);
\r
1048 var notAvail = [];
\r
1049 for (var i = 0,len = onAvailStack.length; i < len; ++i) {
\r
1050 var item = onAvailStack[i];
\r
1052 var el = this.getEl(item.id);
\r
1055 if (!item.checkReady ||
\r
1058 (document && document.body)) {
\r
1061 if (item.override) {
\r
1062 if (item.override === true) {
\r
1065 scope = item.override;
\r
1068 item.fn.call(scope, item.obj);
\r
1069 onAvailStack[i] = null;
\r
1072 notAvail.push(item);
\r
1077 retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
\r
1081 this.startInterval();
\r
1083 clearInterval(this._interval);
\r
1084 this._interval = null;
\r
1087 this.locked = false;
\r
1094 purgeElement: function(el, recurse, eventName) {
\r
1095 var elListeners = this.getListeners(el, eventName);
\r
1096 if (elListeners) {
\r
1097 for (var i = 0,len = elListeners.length; i < len; ++i) {
\r
1098 var l = elListeners[i];
\r
1099 this.removeListener(el, l.type, l.fn);
\r
1103 if (recurse && el && el.childNodes) {
\r
1104 for (i = 0,len = el.childNodes.length; i < len; ++i) {
\r
1105 this.purgeElement(el.childNodes[i], recurse, eventName);
\r
1111 getListeners: function(el, eventName) {
\r
1112 var results = [], searchLists;
\r
1114 searchLists = [listeners, unloadListeners];
\r
1115 } else if (eventName == "unload") {
\r
1116 searchLists = [unloadListeners];
\r
1118 searchLists = [listeners];
\r
1121 for (var j = 0; j < searchLists.length; ++j) {
\r
1122 var searchList = searchLists[j];
\r
1123 if (searchList && searchList.length > 0) {
\r
1124 for (var i = 0,len = searchList.length; i < len; ++i) {
\r
1125 var l = searchList[i];
\r
1126 if (l && l[this.EL] === el &&
\r
1127 (!eventName || eventName === l[this.TYPE])) {
\r
1129 type: l[this.TYPE],
\r
1132 adjust: l[this.ADJ_SCOPE],
\r
1140 return (results.length) ? results : null;
\r
1144 _unload: function(e) {
\r
1146 var EU = Ext.lib.Event, i, j, l, len, index;
\r
1148 for (i = 0,len = unloadListeners.length; i < len; ++i) {
\r
1149 l = unloadListeners[i];
\r
1151 var scope = window;
\r
1152 if (l[EU.ADJ_SCOPE]) {
\r
1153 if (l[EU.ADJ_SCOPE] === true) {
\r
1154 scope = l[EU.OBJ];
\r
1156 scope = l[EU.ADJ_SCOPE];
\r
1159 l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
\r
1160 unloadListeners[i] = null;
\r
1166 unloadListeners = null;
\r
1168 if (listeners && listeners.length > 0) {
\r
1169 j = listeners.length;
\r
1172 l = listeners[index];
\r
1174 EU.removeListener(l[EU.EL], l[EU.TYPE],
\r
1184 EU.doRemove(window, "unload", EU._unload);
\r
1189 getScroll: function() {
\r
1190 var dd = document.documentElement, db = document.body;
\r
1191 if (dd && (dd.scrollTop || dd.scrollLeft)) {
\r
1192 return [dd.scrollTop, dd.scrollLeft];
\r
1194 return [db.scrollTop, db.scrollLeft];
\r
1201 doAdd: function () {
\r
1202 if (window.addEventListener) {
\r
1203 return function(el, eventName, fn, capture) {
\r
1204 el.addEventListener(eventName, fn, (capture));
\r
1206 } else if (window.attachEvent) {
\r
1207 return function(el, eventName, fn, capture) {
\r
1208 el.attachEvent("on" + eventName, fn);
\r
1211 return function() {
\r
1217 doRemove: function() {
\r
1218 if (window.removeEventListener) {
\r
1219 return function (el, eventName, fn, capture) {
\r
1220 el.removeEventListener(eventName, fn, (capture));
\r
1222 } else if (window.detachEvent) {
\r
1223 return function (el, eventName, fn) {
\r
1224 el.detachEvent("on" + eventName, fn);
\r
1227 return function() {
\r
1235 var E = Ext.lib.Event;
\r
1236 E.on = E.addListener;
\r
1237 E.un = E.removeListener;
\r
1238 if (document && document.body) {
\r
1241 E.doAdd(window, "load", E._load);
\r
1243 E.doAdd(window, "unload", E._unload);
\r
1244 E._tryPreloadAttach();
\r
1247 request : function(method, uri, cb, data, options) {
\r
1249 var hs = options.headers;
\r
1252 if(hs.hasOwnProperty(h)){
\r
1253 this.initHeader(h, hs[h], false);
\r
1257 if(options.xmlData){
\r
1258 this.initHeader('Content-Type', 'text/xml', false);
\r
1260 data = options.xmlData;
\r
1261 }else if(options.jsonData){
\r
1262 this.initHeader('Content-Type', 'text/javascript', false);
\r
1264 data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
\r
1268 return this.asyncRequest(method, uri, cb, data);
\r
1271 serializeForm : function(form) {
\r
1272 if(typeof form == 'string') {
\r
1273 form = (document.getElementById(form) || document.forms[form]);
\r
1276 var el, name, val, disabled, data = '', hasSubmit = false;
\r
1277 for (var i = 0; i < form.elements.length; i++) {
\r
1278 el = form.elements[i];
\r
1279 disabled = form.elements[i].disabled;
\r
1280 name = form.elements[i].name;
\r
1281 val = form.elements[i].value;
\r
1283 if (!disabled && name){
\r
1286 case 'select-one':
\r
1287 case 'select-multiple':
\r
1288 for (var j = 0; j < el.options.length; j++) {
\r
1289 if (el.options[j].selected) {
\r
1291 data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
\r
1294 data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
\r
1302 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1315 if(hasSubmit == false) {
\r
1316 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1321 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1326 data = data.substr(0, data.length - 1);
\r
1334 useDefaultHeader:true,
\r
1336 defaultPostHeader:'application/x-www-form-urlencoded',
\r
1338 useDefaultXhrHeader:true,
\r
1340 defaultXhrHeader:'XMLHttpRequest',
\r
1342 hasDefaultHeaders:true,
\r
1344 defaultHeaders:{},
\r
1354 setProgId:function(id)
\r
1356 this.activeX.unshift(id);
\r
1359 setDefaultPostHeader:function(b)
\r
1361 this.useDefaultHeader = b;
\r
1364 setDefaultXhrHeader:function(b)
\r
1366 this.useDefaultXhrHeader = b;
\r
1369 setPollingInterval:function(i)
\r
1371 if (typeof i == 'number' && isFinite(i)) {
\r
1372 this.pollInterval = i;
\r
1376 createXhrObject:function(transactionId)
\r
1382 http = new XMLHttpRequest();
\r
1384 obj = { conn:http, tId:transactionId };
\r
1388 for (var i = 0; i < this.activeX.length; ++i) {
\r
1392 http = new ActiveXObject(this.activeX[i]);
\r
1394 obj = { conn:http, tId:transactionId };
\r
1407 getConnectionObject:function()
\r
1410 var tId = this.transactionId;
\r
1414 o = this.createXhrObject(tId);
\r
1416 this.transactionId++;
\r
1427 asyncRequest:function(method, uri, callback, postData)
\r
1429 var o = this.getConnectionObject();
\r
1435 o.conn.open(method, uri, true);
\r
1437 if (this.useDefaultXhrHeader) {
\r
1438 if (!this.defaultHeaders['X-Requested-With']) {
\r
1439 this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
\r
1443 if(postData && this.useDefaultHeader){
\r
1444 this.initHeader('Content-Type', this.defaultPostHeader);
\r
1447 if (this.hasDefaultHeaders || this.hasHeaders) {
\r
1448 this.setHeader(o);
\r
1451 this.handleReadyState(o, callback);
\r
1452 o.conn.send(postData || null);
\r
1458 handleReadyState:function(o, callback)
\r
1462 if (callback && callback.timeout) {
\r
1463 this.timeout[o.tId] = window.setTimeout(function() {
\r
1464 oConn.abort(o, callback, true);
\r
1465 }, callback.timeout);
\r
1468 this.poll[o.tId] = window.setInterval(
\r
1470 if (o.conn && o.conn.readyState == 4) {
\r
1471 window.clearInterval(oConn.poll[o.tId]);
\r
1472 delete oConn.poll[o.tId];
\r
1474 if (callback && callback.timeout) {
\r
1475 window.clearTimeout(oConn.timeout[o.tId]);
\r
1476 delete oConn.timeout[o.tId];
\r
1479 oConn.handleTransactionResponse(o, callback);
\r
1482 , this.pollInterval);
\r
1485 handleTransactionResponse:function(o, callback, isAbort)
\r
1489 this.releaseObject(o);
\r
1493 var httpStatus, responseObject;
\r
1497 if (o.conn.status !== undefined && o.conn.status != 0) {
\r
1498 httpStatus = o.conn.status;
\r
1501 httpStatus = 13030;
\r
1507 httpStatus = 13030;
\r
1510 if (httpStatus >= 200 && httpStatus < 300) {
\r
1511 responseObject = this.createResponseObject(o, callback.argument);
\r
1512 if (callback.success) {
\r
1513 if (!callback.scope) {
\r
1514 callback.success(responseObject);
\r
1519 callback.success.apply(callback.scope, [responseObject]);
\r
1524 switch (httpStatus) {
\r
1532 responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
\r
1533 if (callback.failure) {
\r
1534 if (!callback.scope) {
\r
1535 callback.failure(responseObject);
\r
1538 callback.failure.apply(callback.scope, [responseObject]);
\r
1543 responseObject = this.createResponseObject(o, callback.argument);
\r
1544 if (callback.failure) {
\r
1545 if (!callback.scope) {
\r
1546 callback.failure(responseObject);
\r
1549 callback.failure.apply(callback.scope, [responseObject]);
\r
1555 this.releaseObject(o);
\r
1556 responseObject = null;
\r
1559 createResponseObject:function(o, callbackArg)
\r
1562 var headerObj = {};
\r
1566 var headerStr = o.conn.getAllResponseHeaders();
\r
1567 var header = headerStr.split('\n');
\r
1568 for (var i = 0; i < header.length; i++) {
\r
1569 var delimitPos = header[i].indexOf(':');
\r
1570 if (delimitPos != -1) {
\r
1571 headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
\r
1579 obj.status = o.conn.status;
\r
1580 obj.statusText = o.conn.statusText;
\r
1581 obj.getResponseHeader = headerObj;
\r
1582 obj.getAllResponseHeaders = headerStr;
\r
1583 obj.responseText = o.conn.responseText;
\r
1584 obj.responseXML = o.conn.responseXML;
\r
1586 if (typeof callbackArg !== undefined) {
\r
1587 obj.argument = callbackArg;
\r
1593 createExceptionObject:function(tId, callbackArg, isAbort)
\r
1595 var COMM_CODE = 0;
\r
1596 var COMM_ERROR = 'communication failure';
\r
1597 var ABORT_CODE = -1;
\r
1598 var ABORT_ERROR = 'transaction aborted';
\r
1604 obj.status = ABORT_CODE;
\r
1605 obj.statusText = ABORT_ERROR;
\r
1608 obj.status = COMM_CODE;
\r
1609 obj.statusText = COMM_ERROR;
\r
1612 if (callbackArg) {
\r
1613 obj.argument = callbackArg;
\r
1619 initHeader:function(label, value, isDefault)
\r
1621 var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
\r
1623 if (headerObj[label] === undefined) {
\r
1624 headerObj[label] = value;
\r
1629 headerObj[label] = value + "," + headerObj[label];
\r
1633 this.hasDefaultHeaders = true;
\r
1636 this.hasHeaders = true;
\r
1641 setHeader:function(o)
\r
1643 if (this.hasDefaultHeaders) {
\r
1644 for (var prop in this.defaultHeaders) {
\r
1645 if (this.defaultHeaders.hasOwnProperty(prop)) {
\r
1646 o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
\r
1651 if (this.hasHeaders) {
\r
1652 for (var prop in this.headers) {
\r
1653 if (this.headers.hasOwnProperty(prop)) {
\r
1654 o.conn.setRequestHeader(prop, this.headers[prop]);
\r
1657 this.headers = {};
\r
1658 this.hasHeaders = false;
\r
1662 resetDefaultHeaders:function() {
\r
1663 delete this.defaultHeaders;
\r
1664 this.defaultHeaders = {};
\r
1665 this.hasDefaultHeaders = false;
\r
1668 abort:function(o, callback, isTimeout)
\r
1670 if (this.isCallInProgress(o)) {
\r
1672 window.clearInterval(this.poll[o.tId]);
\r
1673 delete this.poll[o.tId];
\r
1675 delete this.timeout[o.tId];
\r
1678 this.handleTransactionResponse(o, callback, true);
\r
1688 isCallInProgress:function(o)
\r
1693 return o.conn.readyState != 4 && o.conn.readyState != 0;
\r
1702 releaseObject:function(o)
\r
1711 'MSXML2.XMLHTTP.3.0',
\r
1713 'Microsoft.XMLHTTP'
\r
1720 Ext.lib.Region = function(t, r, b, l) {
\r
1729 Ext.lib.Region.prototype = {
\r
1730 contains : function(region) {
\r
1731 return ( region.left >= this.left &&
\r
1732 region.right <= this.right &&
\r
1733 region.top >= this.top &&
\r
1734 region.bottom <= this.bottom );
\r
1738 getArea : function() {
\r
1739 return ( (this.bottom - this.top) * (this.right - this.left) );
\r
1742 intersect : function(region) {
\r
1743 var t = Math.max(this.top, region.top);
\r
1744 var r = Math.min(this.right, region.right);
\r
1745 var b = Math.min(this.bottom, region.bottom);
\r
1746 var l = Math.max(this.left, region.left);
\r
1748 if (b >= t && r >= l) {
\r
1749 return new Ext.lib.Region(t, r, b, l);
\r
1754 union : function(region) {
\r
1755 var t = Math.min(this.top, region.top);
\r
1756 var r = Math.max(this.right, region.right);
\r
1757 var b = Math.max(this.bottom, region.bottom);
\r
1758 var l = Math.min(this.left, region.left);
\r
1760 return new Ext.lib.Region(t, r, b, l);
\r
1763 constrainTo : function(r) {
\r
1764 this.top = this.top.constrain(r.top, r.bottom);
\r
1765 this.bottom = this.bottom.constrain(r.top, r.bottom);
\r
1766 this.left = this.left.constrain(r.left, r.right);
\r
1767 this.right = this.right.constrain(r.left, r.right);
\r
1771 adjust : function(t, l, b, r) {
\r
1780 Ext.lib.Region.getRegion = function(el) {
\r
1781 var p = Ext.lib.Dom.getXY(el);
\r
1784 var r = p[0] + el.offsetWidth;
\r
1785 var b = p[1] + el.offsetHeight;
\r
1788 return new Ext.lib.Region(t, r, b, l);
\r
1791 Ext.lib.Point = function(x, y) {
\r
1792 if (Ext.isArray(x)) {
\r
1796 this.x = this.right = this.left = this[0] = x;
\r
1797 this.y = this.top = this.bottom = this[1] = y;
\r
1800 Ext.lib.Point.prototype = new Ext.lib.Region();
\r
1804 scroll : function(el, args, duration, easing, cb, scope) {
\r
1805 return this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
\r
1808 motion : function(el, args, duration, easing, cb, scope) {
\r
1809 return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
\r
1812 color : function(el, args, duration, easing, cb, scope) {
\r
1813 return this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
\r
1816 run : function(el, args, duration, easing, cb, scope, type) {
\r
1817 type = type || Ext.lib.AnimBase;
\r
1818 if (typeof easing == "string") {
\r
1819 easing = Ext.lib.Easing[easing];
\r
1821 var anim = new type(el, args, duration, easing);
\r
1822 anim.animateX(function() {
\r
1823 Ext.callback(cb, scope);
\r
1830 function fly(el) {
\r
1831 if (!libFlyweight) {
\r
1832 libFlyweight = new Ext.Element.Flyweight();
\r
1834 libFlyweight.dom = el;
\r
1835 return libFlyweight;
\r
1840 function fnCleanUp() {
\r
1841 var p = Function.prototype;
\r
1842 delete p.createSequence;
\r
1844 delete p.createDelegate;
\r
1845 delete p.createCallback;
\r
1846 delete p.createInterceptor;
\r
1848 window.detachEvent("onunload", fnCleanUp);
\r
1850 window.attachEvent("onunload", fnCleanUp);
\r
1853 Ext.lib.AnimBase = function(el, attributes, duration, method) {
\r
1855 this.init(el, attributes, duration, method);
\r
1859 Ext.lib.AnimBase.prototype = {
\r
1861 toString: function() {
\r
1862 var el = this.getEl();
\r
1863 var id = el.id || el.tagName;
\r
1864 return ("Anim " + id);
\r
1868 noNegatives: /width|height|opacity|padding/i,
\r
1869 offsetAttribute: /^((width|height)|(top|left))$/,
\r
1870 defaultUnit: /width|height|top$|bottom$|left$|right$/i,
\r
1871 offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
\r
1875 doMethod: function(attr, start, end) {
\r
1876 return this.method(this.currentFrame, start, end - start, this.totalFrames);
\r
1880 setAttribute: function(attr, val, unit) {
\r
1881 if (this.patterns.noNegatives.test(attr)) {
\r
1882 val = (val > 0) ? val : 0;
\r
1885 Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
\r
1889 getAttribute: function(attr) {
\r
1890 var el = this.getEl();
\r
1891 var val = fly(el).getStyle(attr);
\r
1893 if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
\r
1894 return parseFloat(val);
\r
1897 var a = this.patterns.offsetAttribute.exec(attr) || [];
\r
1898 var pos = !!( a[3] );
\r
1899 var box = !!( a[2] );
\r
1902 if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
\r
1903 val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
\r
1912 getDefaultUnit: function(attr) {
\r
1913 if (this.patterns.defaultUnit.test(attr)) {
\r
1920 animateX : function(callback, scope) {
\r
1921 var f = function() {
\r
1922 this.onComplete.removeListener(f);
\r
1923 if (typeof callback == "function") {
\r
1924 callback.call(scope || this, this);
\r
1927 this.onComplete.addListener(f, this);
\r
1932 setRuntimeAttribute: function(attr) {
\r
1935 var attributes = this.attributes;
\r
1937 this.runtimeAttributes[attr] = {};
\r
1939 var isset = function(prop) {
\r
1940 return (typeof prop !== 'undefined');
\r
1943 if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) {
\r
1947 start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
\r
1950 if (isset(attributes[attr]['to'])) {
\r
1951 end = attributes[attr]['to'];
\r
1952 } else if (isset(attributes[attr]['by'])) {
\r
1953 if (start.constructor == Array) {
\r
1955 for (var i = 0, len = start.length; i < len; ++i) {
\r
1956 end[i] = start[i] + attributes[attr]['by'][i];
\r
1959 end = start + attributes[attr]['by'];
\r
1963 this.runtimeAttributes[attr].start = start;
\r
1964 this.runtimeAttributes[attr].end = end;
\r
1967 this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
\r
1971 init: function(el, attributes, duration, method) {
\r
1973 var isAnimated = false;
\r
1976 var startTime = null;
\r
1979 var actualFrames = 0;
\r
1982 el = Ext.getDom(el);
\r
1985 this.attributes = attributes || {};
\r
1988 this.duration = duration || 1;
\r
1991 this.method = method || Ext.lib.Easing.easeNone;
\r
1994 this.useSeconds = true;
\r
1997 this.currentFrame = 0;
\r
2000 this.totalFrames = Ext.lib.AnimMgr.fps;
\r
2003 this.getEl = function() {
\r
2008 this.isAnimated = function() {
\r
2009 return isAnimated;
\r
2013 this.getStartTime = function() {
\r
2017 this.runtimeAttributes = {};
\r
2020 this.animate = function() {
\r
2021 if (this.isAnimated()) {
\r
2025 this.currentFrame = 0;
\r
2027 this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration;
\r
2029 Ext.lib.AnimMgr.registerElement(this);
\r
2033 this.stop = function(finish) {
\r
2035 this.currentFrame = this.totalFrames;
\r
2036 this._onTween.fire();
\r
2038 Ext.lib.AnimMgr.stop(this);
\r
2041 var onStart = function() {
\r
2042 this.onStart.fire();
\r
2044 this.runtimeAttributes = {};
\r
2045 for (var attr in this.attributes) {
\r
2046 this.setRuntimeAttribute(attr);
\r
2049 isAnimated = true;
\r
2051 startTime = new Date();
\r
2055 var onTween = function() {
\r
2057 duration: new Date() - this.getStartTime(),
\r
2058 currentFrame: this.currentFrame
\r
2061 data.toString = function() {
\r
2063 'duration: ' + data.duration +
\r
2064 ', currentFrame: ' + data.currentFrame
\r
2068 this.onTween.fire(data);
\r
2070 var runtimeAttributes = this.runtimeAttributes;
\r
2072 for (var attr in runtimeAttributes) {
\r
2073 this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
\r
2076 actualFrames += 1;
\r
2079 var onComplete = function() {
\r
2080 var actual_duration = (new Date() - startTime) / 1000 ;
\r
2083 duration: actual_duration,
\r
2084 frames: actualFrames,
\r
2085 fps: actualFrames / actual_duration
\r
2088 data.toString = function() {
\r
2090 'duration: ' + data.duration +
\r
2091 ', frames: ' + data.frames +
\r
2092 ', fps: ' + data.fps
\r
2096 isAnimated = false;
\r
2098 this.onComplete.fire(data);
\r
2102 this._onStart = new Ext.util.Event(this);
\r
2103 this.onStart = new Ext.util.Event(this);
\r
2104 this.onTween = new Ext.util.Event(this);
\r
2105 this._onTween = new Ext.util.Event(this);
\r
2106 this.onComplete = new Ext.util.Event(this);
\r
2107 this._onComplete = new Ext.util.Event(this);
\r
2108 this._onStart.addListener(onStart);
\r
2109 this._onTween.addListener(onTween);
\r
2110 this._onComplete.addListener(onComplete);
\r
2115 Ext.lib.AnimMgr = new function() {
\r
2117 var thread = null;
\r
2123 var tweenCount = 0;
\r
2132 this.registerElement = function(tween) {
\r
2133 queue[queue.length] = tween;
\r
2135 tween._onStart.fire();
\r
2140 this.unRegister = function(tween, index) {
\r
2141 tween._onComplete.fire();
\r
2142 index = index || getIndex(tween);
\r
2143 if (index != -1) {
\r
2144 queue.splice(index, 1);
\r
2148 if (tweenCount <= 0) {
\r
2154 this.start = function() {
\r
2155 if (thread === null) {
\r
2156 thread = setInterval(this.run, this.delay);
\r
2161 this.stop = function(tween) {
\r
2163 clearInterval(thread);
\r
2165 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2166 if (queue[0].isAnimated()) {
\r
2167 this.unRegister(queue[0], 0);
\r
2176 this.unRegister(tween);
\r
2181 this.run = function() {
\r
2182 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2183 var tween = queue[i];
\r
2184 if (!tween || !tween.isAnimated()) {
\r
2188 if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
\r
2190 tween.currentFrame += 1;
\r
2192 if (tween.useSeconds) {
\r
2193 correctFrame(tween);
\r
2195 tween._onTween.fire();
\r
2198 Ext.lib.AnimMgr.stop(tween, i);
\r
2203 var getIndex = function(anim) {
\r
2204 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2205 if (queue[i] == anim) {
\r
2213 var correctFrame = function(tween) {
\r
2214 var frames = tween.totalFrames;
\r
2215 var frame = tween.currentFrame;
\r
2216 var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
\r
2217 var elapsed = (new Date() - tween.getStartTime());
\r
2220 if (elapsed < tween.duration * 1000) {
\r
2221 tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
\r
2223 tweak = frames - (frame + 1);
\r
2225 if (tweak > 0 && isFinite(tweak)) {
\r
2226 if (tween.currentFrame + tweak >= frames) {
\r
2227 tweak = frames - (frame + 1);
\r
2230 tween.currentFrame += tweak;
\r
2235 Ext.lib.Bezier = new function() {
\r
2237 this.getPosition = function(points, t) {
\r
2238 var n = points.length;
\r
2241 for (var i = 0; i < n; ++i) {
\r
2242 tmp[i] = [points[i][0], points[i][1]];
\r
2245 for (var j = 1; j < n; ++j) {
\r
2246 for (i = 0; i < n - j; ++i) {
\r
2247 tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
\r
2248 tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
\r
2252 return [ tmp[0][0], tmp[0][1] ];
\r
2258 Ext.lib.ColorAnim = function(el, attributes, duration, method) {
\r
2259 Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
\r
2262 Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase);
\r
2266 var superclass = Y.ColorAnim.superclass;
\r
2267 var proto = Y.ColorAnim.prototype;
\r
2269 proto.toString = function() {
\r
2270 var el = this.getEl();
\r
2271 var id = el.id || el.tagName;
\r
2272 return ("ColorAnim " + id);
\r
2275 proto.patterns.color = /color$/i;
\r
2276 proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
\r
2277 proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
\r
2278 proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
\r
2279 proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
\r
2282 proto.parseColor = function(s) {
\r
2283 if (s.length == 3) {
\r
2287 var c = this.patterns.hex.exec(s);
\r
2288 if (c && c.length == 4) {
\r
2289 return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
\r
2292 c = this.patterns.rgb.exec(s);
\r
2293 if (c && c.length == 4) {
\r
2294 return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
\r
2297 c = this.patterns.hex3.exec(s);
\r
2298 if (c && c.length == 4) {
\r
2299 return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
\r
2305 proto.getAttribute = function(attr) {
\r
2306 var el = this.getEl();
\r
2307 if (this.patterns.color.test(attr)) {
\r
2308 var val = fly(el).getStyle(attr);
\r
2310 if (this.patterns.transparent.test(val)) {
\r
2311 var parent = el.parentNode;
\r
2312 val = fly(parent).getStyle(attr);
\r
2314 while (parent && this.patterns.transparent.test(val)) {
\r
2315 parent = parent.parentNode;
\r
2316 val = fly(parent).getStyle(attr);
\r
2317 if (parent.tagName.toUpperCase() == 'HTML') {
\r
2323 val = superclass.getAttribute.call(this, attr);
\r
2329 proto.doMethod = function(attr, start, end) {
\r
2332 if (this.patterns.color.test(attr)) {
\r
2334 for (var i = 0, len = start.length; i < len; ++i) {
\r
2335 val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
\r
2338 val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1]) + ',' + Math.floor(val[2]) + ')';
\r
2341 val = superclass.doMethod.call(this, attr, start, end);
\r
2347 proto.setRuntimeAttribute = function(attr) {
\r
2348 superclass.setRuntimeAttribute.call(this, attr);
\r
2350 if (this.patterns.color.test(attr)) {
\r
2351 var attributes = this.attributes;
\r
2352 var start = this.parseColor(this.runtimeAttributes[attr].start);
\r
2353 var end = this.parseColor(this.runtimeAttributes[attr].end);
\r
2355 if (typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined') {
\r
2356 end = this.parseColor(attributes[attr].by);
\r
2358 for (var i = 0, len = start.length; i < len; ++i) {
\r
2359 end[i] = start[i] + end[i];
\r
2363 this.runtimeAttributes[attr].start = start;
\r
2364 this.runtimeAttributes[attr].end = end;
\r
2370 Ext.lib.Easing = {
\r
2373 easeNone: function (t, b, c, d) {
\r
2374 return c * t / d + b;
\r
2378 easeIn: function (t, b, c, d) {
\r
2379 return c * (t /= d) * t + b;
\r
2383 easeOut: function (t, b, c, d) {
\r
2384 return -c * (t /= d) * (t - 2) + b;
\r
2388 easeBoth: function (t, b, c, d) {
\r
2389 if ((t /= d / 2) < 1) {
\r
2390 return c / 2 * t * t + b;
\r
2393 return -c / 2 * ((--t) * (t - 2) - 1) + b;
\r
2397 easeInStrong: function (t, b, c, d) {
\r
2398 return c * (t /= d) * t * t * t + b;
\r
2402 easeOutStrong: function (t, b, c, d) {
\r
2403 return -c * ((t = t / d - 1) * t * t * t - 1) + b;
\r
2407 easeBothStrong: function (t, b, c, d) {
\r
2408 if ((t /= d / 2) < 1) {
\r
2409 return c / 2 * t * t * t * t + b;
\r
2412 return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
\r
2417 elasticIn: function (t, b, c, d, a, p) {
\r
2421 if ((t /= d) == 1) {
\r
2428 if (!a || a < Math.abs(c)) {
\r
2433 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2436 return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
\r
2440 elasticOut: function (t, b, c, d, a, p) {
\r
2444 if ((t /= d) == 1) {
\r
2451 if (!a || a < Math.abs(c)) {
\r
2456 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2459 return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
\r
2463 elasticBoth: function (t, b, c, d, a, p) {
\r
2468 if ((t /= d / 2) == 2) {
\r
2473 p = d * (.3 * 1.5);
\r
2476 if (!a || a < Math.abs(c)) {
\r
2481 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2485 return -.5 * (a * Math.pow(2, 10 * (t -= 1)) *
\r
2486 Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
\r
2488 return a * Math.pow(2, -10 * (t -= 1)) *
\r
2489 Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
\r
2494 backIn: function (t, b, c, d, s) {
\r
2495 if (typeof s == 'undefined') {
\r
2498 return c * (t /= d) * t * ((s + 1) * t - s) + b;
\r
2502 backOut: function (t, b, c, d, s) {
\r
2503 if (typeof s == 'undefined') {
\r
2506 return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
\r
2510 backBoth: function (t, b, c, d, s) {
\r
2511 if (typeof s == 'undefined') {
\r
2515 if ((t /= d / 2 ) < 1) {
\r
2516 return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
\r
2518 return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
\r
2522 bounceIn: function (t, b, c, d) {
\r
2523 return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b;
\r
2527 bounceOut: function (t, b, c, d) {
\r
2528 if ((t /= d) < (1 / 2.75)) {
\r
2529 return c * (7.5625 * t * t) + b;
\r
2530 } else if (t < (2 / 2.75)) {
\r
2531 return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
\r
2532 } else if (t < (2.5 / 2.75)) {
\r
2533 return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
\r
2535 return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
\r
2539 bounceBoth: function (t, b, c, d) {
\r
2541 return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
\r
2543 return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
\r
2548 Ext.lib.Motion = function(el, attributes, duration, method) {
\r
2550 Ext.lib.Motion.superclass.constructor.call(this, el, attributes, duration, method);
\r
2554 Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim);
\r
2558 var superclass = Y.Motion.superclass;
\r
2559 var proto = Y.Motion.prototype;
\r
2561 proto.toString = function() {
\r
2562 var el = this.getEl();
\r
2563 var id = el.id || el.tagName;
\r
2564 return ("Motion " + id);
\r
2567 proto.patterns.points = /^points$/i;
\r
2569 proto.setAttribute = function(attr, val, unit) {
\r
2570 if (this.patterns.points.test(attr)) {
\r
2571 unit = unit || 'px';
\r
2572 superclass.setAttribute.call(this, 'left', val[0], unit);
\r
2573 superclass.setAttribute.call(this, 'top', val[1], unit);
\r
2575 superclass.setAttribute.call(this, attr, val, unit);
\r
2579 proto.getAttribute = function(attr) {
\r
2580 if (this.patterns.points.test(attr)) {
\r
2582 superclass.getAttribute.call(this, 'left'),
\r
2583 superclass.getAttribute.call(this, 'top')
\r
2586 val = superclass.getAttribute.call(this, attr);
\r
2592 proto.doMethod = function(attr, start, end) {
\r
2595 if (this.patterns.points.test(attr)) {
\r
2596 var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
\r
2597 val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
\r
2599 val = superclass.doMethod.call(this, attr, start, end);
\r
2604 proto.setRuntimeAttribute = function(attr) {
\r
2605 if (this.patterns.points.test(attr)) {
\r
2606 var el = this.getEl();
\r
2607 var attributes = this.attributes;
\r
2609 var control = attributes['points']['control'] || [];
\r
2613 if (control.length > 0 && !Ext.isArray(control[0])) {
\r
2614 control = [control];
\r
2617 for (i = 0,len = control.length; i < len; ++i) {
\r
2618 tmp[i] = control[i];
\r
2623 Ext.fly(el).position();
\r
2625 if (isset(attributes['points']['from'])) {
\r
2626 Ext.lib.Dom.setXY(el, attributes['points']['from']);
\r
2629 Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el));
\r
2632 start = this.getAttribute('points');
\r
2635 if (isset(attributes['points']['to'])) {
\r
2636 end = translateValues.call(this, attributes['points']['to'], start);
\r
2638 var pageXY = Ext.lib.Dom.getXY(this.getEl());
\r
2639 for (i = 0,len = control.length; i < len; ++i) {
\r
2640 control[i] = translateValues.call(this, control[i], start);
\r
2644 } else if (isset(attributes['points']['by'])) {
\r
2645 end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
\r
2647 for (i = 0,len = control.length; i < len; ++i) {
\r
2648 control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
\r
2652 this.runtimeAttributes[attr] = [start];
\r
2654 if (control.length > 0) {
\r
2655 this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
\r
2658 this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
\r
2661 superclass.setRuntimeAttribute.call(this, attr);
\r
2665 var translateValues = function(val, start) {
\r
2666 var pageXY = Ext.lib.Dom.getXY(this.getEl());
\r
2667 val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
\r
2672 var isset = function(prop) {
\r
2673 return (typeof prop !== 'undefined');
\r
2679 Ext.lib.Scroll = function(el, attributes, duration, method) {
\r
2681 Ext.lib.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
\r
2685 Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim);
\r
2689 var superclass = Y.Scroll.superclass;
\r
2690 var proto = Y.Scroll.prototype;
\r
2692 proto.toString = function() {
\r
2693 var el = this.getEl();
\r
2694 var id = el.id || el.tagName;
\r
2695 return ("Scroll " + id);
\r
2698 proto.doMethod = function(attr, start, end) {
\r
2701 if (attr == 'scroll') {
\r
2703 this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
\r
2704 this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
\r
2708 val = superclass.doMethod.call(this, attr, start, end);
\r
2713 proto.getAttribute = function(attr) {
\r
2715 var el = this.getEl();
\r
2717 if (attr == 'scroll') {
\r
2718 val = [ el.scrollLeft, el.scrollTop ];
\r
2720 val = superclass.getAttribute.call(this, attr);
\r
2726 proto.setAttribute = function(attr, val, unit) {
\r
2727 var el = this.getEl();
\r
2729 if (attr == 'scroll') {
\r
2730 el.scrollLeft = val[0];
\r
2731 el.scrollTop = val[1];
\r
2733 superclass.setAttribute.call(this, attr, val, unit);
\r