3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/*
\r
9 * Ext JS Library 2.0.1
\r
10 * Copyright(c) 2006-2008, Ext JS, LLC.
\r
11 * licensing@extjs.com
\r
13 * http://extjs.com/license
\r
17 Ext = {version: '2.0.1'};
\r
20 window["undefined"] = window["undefined"];
\r
25 Ext.apply = function(o, c, defaults){
\r
28 Ext.apply(o, defaults);
\r
30 if(o && c && typeof c == 'object'){
\r
40 var ua = navigator.userAgent.toLowerCase();
\r
42 var isStrict = document.compatMode == "CSS1Compat",
\r
43 isOpera = ua.indexOf("opera") > -1,
\r
44 isSafari = (/webkit|khtml/).test(ua),
\r
45 isSafari3 = isSafari && ua.indexOf('webkit/5') != -1,
\r
46 isIE = !isOpera && ua.indexOf("msie") > -1,
\r
47 isIE7 = !isOpera && ua.indexOf("msie 7") > -1,
\r
48 isGecko = !isSafari && ua.indexOf("gecko") > -1,
\r
49 isBorderBox = isIE && !isStrict,
\r
50 isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
\r
51 isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
\r
52 isAir = (ua.indexOf("adobeair") != -1),
\r
53 isLinux = (ua.indexOf("linux") != -1),
\r
54 isSecure = window.location.href.toLowerCase().indexOf("https") === 0;
\r
59 document.execCommand("BackgroundImageCache", false, true);
\r
65 isStrict : isStrict,
\r
67 isSecure : isSecure,
\r
72 enableGarbageCollector : true,
\r
75 enableListenerCollection:false,
\r
79 SSL_SECURE_URL : "javascript:false",
\r
82 BLANK_IMAGE_URL : "http:/"+"/extjs.com/s.gif",
\r
85 emptyFn : function(){},
\r
88 applyIf : function(o, c){
\r
91 if(typeof o[p] == "undefined"){ o[p] = c[p]; }
\r
98 addBehaviors : function(o){
\r
100 Ext.onReady(function(){
\r
101 Ext.addBehaviors(o);
\r
107 var parts = b.split('@');
\r
111 cache[s] = Ext.select(s);
\r
113 cache[s].on(parts[1], o[b]);
\r
120 id : function(el, prefix){
\r
121 prefix = prefix || "ext-gen";
\r
122 el = Ext.getDom(el);
\r
123 var id = prefix + (++idSeed);
\r
124 return el ? (el.id ? el.id : (el.id = id)) : id;
\r
128 extend : function(){
\r
130 var io = function(o){
\r
135 var oc = Object.prototype.constructor;
\r
137 return function(sb, sp, overrides){
\r
138 if(typeof sp == 'object'){
\r
141 sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
\r
143 var F = function(){}, sbp, spp = sp.prototype;
\r
145 sbp = sb.prototype = new F();
\r
146 sbp.constructor=sb;
\r
148 if(spp.constructor == oc){
\r
149 spp.constructor=sp;
\r
151 sb.override = function(o){
\r
152 Ext.override(sb, o);
\r
155 Ext.override(sb, overrides);
\r
161 override : function(origclass, overrides){
\r
163 var p = origclass.prototype;
\r
164 for(var method in overrides){
\r
165 p[method] = overrides[method];
\r
171 namespace : function(){
\r
172 var a=arguments, o=null, i, j, d, rt;
\r
173 for (i=0; i<a.length; ++i) {
\r
176 eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
\r
177 for (j=1; j<d.length; ++j) {
\r
178 o[d[j]]=o[d[j]] || {};
\r
185 urlEncode : function(o){
\r
191 var ov = o[key], k = encodeURIComponent(key);
\r
192 var type = typeof ov;
\r
193 if(type == 'undefined'){
\r
195 }else if(type != "function" && type != "object"){
\r
196 buf.push(k, "=", encodeURIComponent(ov), "&");
\r
197 }else if(Ext.isArray(ov)){
\r
199 for(var i = 0, len = ov.length; i < len; i++) {
\r
200 buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
\r
208 return buf.join("");
\r
212 urlDecode : function(string, overwrite){
\r
213 if(!string || !string.length){
\r
217 var pairs = string.split('&');
\r
218 var pair, name, value;
\r
219 for(var i = 0, len = pairs.length; i < len; i++){
\r
220 pair = pairs[i].split('=');
\r
221 name = decodeURIComponent(pair[0]);
\r
222 value = decodeURIComponent(pair[1]);
\r
223 if(overwrite !== true){
\r
224 if(typeof obj[name] == "undefined"){
\r
226 }else if(typeof obj[name] == "string"){
\r
227 obj[name] = [obj[name]];
\r
228 obj[name].push(value);
\r
230 obj[name].push(value);
\r
240 each : function(array, fn, scope){
\r
241 if(typeof array.length == "undefined" || typeof array == "string"){
\r
244 for(var i = 0, len = array.length; i < len; i++){
\r
245 if(fn.call(scope || array[i], array[i], i, array) === false){ return i; };
\r
250 combine : function(){
\r
251 var as = arguments, l = as.length, r = [];
\r
252 for(var i = 0; i < l; i++){
\r
254 if(Ext.isArray(a)){
\r
256 }else if(a.length !== undefined && !a.substr){
\r
257 r = r.concat(Array.prototype.slice.call(a, 0));
\r
266 escapeRe : function(s) {
\r
267 return s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
\r
271 callback : function(cb, scope, args, delay){
\r
272 if(typeof cb == "function"){
\r
274 cb.defer(delay, scope, args || []);
\r
276 cb.apply(scope, args || []);
\r
282 getDom : function(el){
\r
283 if(!el || !document){
\r
286 return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
\r
290 getDoc : function(){
\r
291 return Ext.get(document);
\r
295 getBody : function(){
\r
296 return Ext.get(document.body || document.documentElement);
\r
300 getCmp : function(id){
\r
301 return Ext.ComponentMgr.get(id);
\r
305 num : function(v, defaultValue){
\r
306 if(typeof v != 'number'){
\r
307 return defaultValue;
\r
313 destroy : function(){
\r
314 for(var i = 0, a = arguments, len = a.length; i < len; i++) {
\r
318 as.removeAllListeners();
\r
322 if(typeof as.destroy == 'function'){
\r
329 removeNode : isIE ? function(){
\r
331 return function(n){
\r
333 d = d || document.createElement('div');
\r
339 if(n && n.parentNode){
\r
340 n.parentNode.removeChild(n);
\r
346 type : function(o){
\r
347 if(o === undefined || o === null){
\r
354 if(t == 'object' && o.nodeName) {
\r
355 switch(o.nodeType) {
\r
356 case 1: return 'element';
\r
357 case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
\r
360 if(t == 'object' || t == 'function') {
\r
361 switch(o.constructor) {
\r
362 case Array: return 'array';
\r
363 case RegExp: return 'regexp';
\r
365 if(typeof o.length == 'number' && typeof o.item == 'function') {
\r
373 isEmpty : function(v, allowBlank){
\r
374 return v === null || v === undefined || (!allowBlank ? v === '' : false);
\r
377 value : function(v, defaultValue, allowBlank){
\r
378 return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
\r
381 isArray : function(v){
\r
382 return v && typeof v.pop == 'function';
\r
385 isDate : function(v){
\r
386 return v && typeof v.getFullYear == 'function';
\r
392 isSafari : isSafari,
\r
394 isSafari3 : isSafari3,
\r
396 isSafari2 : isSafari && !isSafari3,
\r
400 isIE6 : isIE && !isIE7,
\r
406 isBorderBox : isBorderBox,
\r
410 isWindows : isWindows,
\r
417 useShims : ((isIE && !isIE7) || (isGecko && isMac))
\r
421 Ext.ns = Ext.namespace;
\r
424 Ext.ns("Ext", "Ext.util", "Ext.grid", "Ext.dd", "Ext.tree", "Ext.data",
\r
425 "Ext.form", "Ext.menu", "Ext.state", "Ext.lib", "Ext.layout", "Ext.app", "Ext.ux");
\r
429 Ext.apply(Function.prototype, {
\r
431 createCallback : function(){
\r
433 var args = arguments;
\r
435 return function() {
\r
436 return method.apply(window, args);
\r
441 createDelegate : function(obj, args, appendArgs){
\r
443 return function() {
\r
444 var callArgs = args || arguments;
\r
445 if(appendArgs === true){
\r
446 callArgs = Array.prototype.slice.call(arguments, 0);
\r
447 callArgs = callArgs.concat(args);
\r
448 }else if(typeof appendArgs == "number"){
\r
449 callArgs = Array.prototype.slice.call(arguments, 0);
450 var applyArgs = [appendArgs, 0].concat(args);
451 Array.prototype.splice.apply(callArgs, applyArgs);
453 return method.apply(obj || window, callArgs);
\r
458 defer : function(millis, obj, args, appendArgs){
\r
459 var fn = this.createDelegate(obj, args, appendArgs);
\r
461 return setTimeout(fn, millis);
\r
467 createSequence : function(fcn, scope){
\r
468 if(typeof fcn != "function"){
\r
472 return function() {
\r
473 var retval = method.apply(this || window, arguments);
\r
474 fcn.apply(scope || this || window, arguments);
\r
480 createInterceptor : function(fcn, scope){
\r
481 if(typeof fcn != "function"){
\r
485 return function() {
\r
487 fcn.method = method;
\r
488 if(fcn.apply(scope || this || window, arguments) === false){
\r
491 return method.apply(this || window, arguments);
\r
497 Ext.applyIf(String, {
\r
500 escape : function(string) {
\r
501 return string.replace(/('|\\)/g, "\\$1");
\r
505 leftPad : function (val, size, ch) {
\r
506 var result = new String(val);
\r
510 while (result.length < size) {
\r
511 result = ch + result;
\r
513 return result.toString();
\r
517 format : function(format){
\r
518 var args = Array.prototype.slice.call(arguments, 1);
\r
519 return format.replace(/\{(\d+)\}/g, function(m, i){
\r
526 String.prototype.toggle = function(value, other){
\r
527 return this == value ? other : value;
\r
531 String.prototype.trim = function(){
\r
532 var re = /^\s+|\s+$/g;
\r
533 return function(){ return this.replace(re, ""); };
\r
536 Ext.applyIf(Number.prototype, {
\r
538 constrain : function(min, max){
\r
539 return Math.min(Math.max(this, min), max);
\r
543 Ext.applyIf(Array.prototype, {
\r
545 indexOf : function(o){
\r
546 for (var i = 0, len = this.length; i < len; i++){
\r
547 if(this[i] == o) return i;
\r
553 remove : function(o){
\r
554 var index = this.indexOf(o);
\r
556 this.splice(index, 1);
\r
563 Date.prototype.getElapsed = function(date) {
\r
564 return Math.abs((date || new Date()).getTime()-this.getTime());
\r
571 getViewWidth : function(full) {
\r
572 return full ? this.getDocumentWidth() : this.getViewportWidth();
\r
575 getViewHeight : function(full) {
\r
576 return full ? this.getDocumentHeight() : this.getViewportHeight();
\r
579 getDocumentHeight: function() {
\r
580 var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
\r
581 return Math.max(scrollHeight, this.getViewportHeight());
\r
584 getDocumentWidth: function() {
\r
585 var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
\r
586 return Math.max(scrollWidth, this.getViewportWidth());
\r
589 getViewportHeight: function(){
\r
591 return Ext.isStrict ? document.documentElement.clientHeight :
\r
592 document.body.clientHeight;
\r
594 return self.innerHeight;
\r
598 getViewportWidth: function() {
\r
600 return Ext.isStrict ? document.documentElement.clientWidth :
\r
601 document.body.clientWidth;
\r
603 return self.innerWidth;
\r
607 isAncestor : function(p, c) {
\r
614 if (p.contains && !Ext.isSafari) {
\r
615 return p.contains(c);
\r
616 } else if (p.compareDocumentPosition) {
\r
617 return !!(p.compareDocumentPosition(c) & 16);
\r
619 var parent = c.parentNode;
\r
624 else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
\r
627 parent = parent.parentNode;
\r
633 getRegion : function(el) {
\r
634 return Ext.lib.Region.getRegion(el);
\r
637 getY : function(el) {
\r
638 return this.getXY(el)[1];
\r
641 getX : function(el) {
\r
642 return this.getXY(el)[0];
\r
646 getXY : function(el) {
\r
647 var p, pe, b, scroll, bd = (document.body || document.documentElement);
\r
648 el = Ext.getDom(el);
\r
654 if (el.getBoundingClientRect) {
\r
655 b = el.getBoundingClientRect();
\r
656 scroll = fly(document).getScroll();
\r
657 return [b.left + scroll.left, b.top + scroll.top];
\r
663 var hasAbsolute = fly(el).getStyle("position") == "absolute";
\r
670 if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
\r
671 hasAbsolute = true;
\r
677 var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
\r
678 var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
\r
685 if (p != el && pe.getStyle('overflow') != 'visible') {
\r
690 p = p.offsetParent;
\r
693 if (Ext.isSafari && hasAbsolute) {
\r
694 x -= bd.offsetLeft;
\r
698 if (Ext.isGecko && !hasAbsolute) {
\r
700 x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
\r
701 y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
\r
705 while (p && p != bd) {
\r
706 if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
\r
715 setXY : function(el, xy) {
\r
716 el = Ext.fly(el, '_setXY');
\r
718 var pts = el.translatePoints(xy);
\r
719 if (xy[0] !== false) {
\r
720 el.dom.style.left = pts.left + "px";
\r
722 if (xy[1] !== false) {
\r
723 el.dom.style.top = pts.top + "px";
\r
727 setX : function(el, x) {
\r
728 this.setXY(el, [x, false]);
\r
731 setY : function(el, y) {
\r
732 this.setXY(el, [false, y]);
\r
737 Ext.lib.Event = function() {
\r
738 var loadComplete = false;
\r
739 var listeners = [];
\r
740 var unloadListeners = [];
\r
741 var retryCount = 0;
\r
742 var onAvailStack = [];
\r
744 var lastError = null;
\r
757 startInterval: function() {
\r
758 if (!this._interval) {
\r
760 var callback = function() {
\r
761 self._tryPreloadAttach();
\r
763 this._interval = setInterval(callback, this.POLL_INTERVAL);
\r
768 onAvailable: function(p_id, p_fn, p_obj, p_override) {
\r
769 onAvailStack.push({ id: p_id,
\r
772 override: p_override,
\r
773 checkReady: false });
\r
775 retryCount = this.POLL_RETRYS;
\r
776 this.startInterval();
\r
780 addListener: function(el, eventName, fn) {
\r
781 el = Ext.getDom(el);
\r
786 if ("unload" == eventName) {
\r
787 unloadListeners[unloadListeners.length] =
\r
788 [el, eventName, fn];
\r
793 var wrappedFn = function(e) {
\r
794 return typeof Ext != 'undefined' ? fn(Ext.lib.Event.getEvent(e)) : false;
\r
797 var li = [el, eventName, fn, wrappedFn];
\r
799 var index = listeners.length;
\r
800 listeners[index] = li;
\r
802 this.doAdd(el, eventName, wrappedFn, false);
\r
808 removeListener: function(el, eventName, fn) {
\r
811 el = Ext.getDom(el);
\r
814 return this.purgeElement(el, false, eventName);
\r
818 if ("unload" == eventName) {
\r
820 for (i = 0,len = unloadListeners.length; i < len; i++) {
\r
821 var li = unloadListeners[i];
\r
824 li[1] == eventName &&
\r
826 unloadListeners.splice(i, 1);
\r
834 var cacheItem = null;
\r
837 var index = arguments[3];
\r
839 if ("undefined" == typeof index) {
\r
840 index = this._getCacheIndex(el, eventName, fn);
\r
844 cacheItem = listeners[index];
\r
847 if (!el || !cacheItem) {
\r
851 this.doRemove(el, eventName, cacheItem[this.WFN], false);
\r
853 delete listeners[index][this.WFN];
\r
854 delete listeners[index][this.FN];
\r
855 listeners.splice(index, 1);
\r
862 getTarget: function(ev, resolveTextNode) {
\r
863 ev = ev.browserEvent || ev;
\r
864 var t = ev.target || ev.srcElement;
\r
865 return this.resolveTextNode(t);
\r
869 resolveTextNode: function(node) {
\r
870 if (Ext.isSafari && node && 3 == node.nodeType) {
\r
871 return node.parentNode;
\r
878 getPageX: function(ev) {
\r
879 ev = ev.browserEvent || ev;
\r
881 if (!x && 0 !== x) {
\r
882 x = ev.clientX || 0;
\r
885 x += this.getScroll()[1];
\r
893 getPageY: function(ev) {
\r
894 ev = ev.browserEvent || ev;
\r
896 if (!y && 0 !== y) {
\r
897 y = ev.clientY || 0;
\r
900 y += this.getScroll()[0];
\r
909 getXY: function(ev) {
\r
910 ev = ev.browserEvent || ev;
\r
911 return [this.getPageX(ev), this.getPageY(ev)];
\r
915 getRelatedTarget: function(ev) {
\r
916 ev = ev.browserEvent || ev;
\r
917 var t = ev.relatedTarget;
\r
919 if (ev.type == "mouseout") {
\r
921 } else if (ev.type == "mouseover") {
\r
922 t = ev.fromElement;
\r
926 return this.resolveTextNode(t);
\r
930 getTime: function(ev) {
\r
931 ev = ev.browserEvent || ev;
\r
933 var t = new Date().getTime();
\r
937 this.lastError = ex;
\r
946 stopEvent: function(ev) {
\r
947 this.stopPropagation(ev);
\r
948 this.preventDefault(ev);
\r
952 stopPropagation: function(ev) {
\r
953 ev = ev.browserEvent || ev;
\r
954 if (ev.stopPropagation) {
\r
955 ev.stopPropagation();
\r
957 ev.cancelBubble = true;
\r
962 preventDefault: function(ev) {
\r
963 ev = ev.browserEvent || ev;
\r
964 if(ev.preventDefault) {
\r
965 ev.preventDefault();
\r
967 ev.returnValue = false;
\r
972 getEvent: function(e) {
\r
973 var ev = e || window.event;
\r
975 var c = this.getEvent.caller;
\r
977 ev = c.arguments[0];
\r
978 if (ev && Event == ev.constructor) {
\r
988 getCharCode: function(ev) {
\r
989 ev = ev.browserEvent || ev;
\r
990 return ev.charCode || ev.keyCode || 0;
\r
994 _getCacheIndex: function(el, eventName, fn) {
\r
995 for (var i = 0,len = listeners.length; i < len; ++i) {
\r
996 var li = listeners[i];
\r
998 li[this.FN] == fn &&
\r
999 li[this.EL] == el &&
\r
1000 li[this.TYPE] == eventName) {
\r
1012 getEl: function(id) {
\r
1013 return document.getElementById(id);
\r
1017 clearCache: function() {
\r
1021 _load: function(e) {
\r
1022 loadComplete = true;
\r
1023 var EU = Ext.lib.Event;
\r
1027 EU.doRemove(window, "load", EU._load);
\r
1032 _tryPreloadAttach: function() {
\r
1034 if (this.locked) {
\r
1038 this.locked = true;
\r
1041 var tryAgain = !loadComplete;
\r
1043 tryAgain = (retryCount > 0);
\r
1047 var notAvail = [];
\r
1048 for (var i = 0,len = onAvailStack.length; i < len; ++i) {
\r
1049 var item = onAvailStack[i];
\r
1051 var el = this.getEl(item.id);
\r
1054 if (!item.checkReady ||
\r
1057 (document && document.body)) {
\r
1060 if (item.override) {
\r
1061 if (item.override === true) {
\r
1064 scope = item.override;
\r
1067 item.fn.call(scope, item.obj);
\r
1068 onAvailStack[i] = null;
\r
1071 notAvail.push(item);
\r
1076 retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
\r
1080 this.startInterval();
\r
1082 clearInterval(this._interval);
\r
1083 this._interval = null;
\r
1086 this.locked = false;
\r
1093 purgeElement: function(el, recurse, eventName) {
\r
1094 var elListeners = this.getListeners(el, eventName);
\r
1095 if (elListeners) {
\r
1096 for (var i = 0,len = elListeners.length; i < len; ++i) {
\r
1097 var l = elListeners[i];
\r
1098 this.removeListener(el, l.type, l.fn);
\r
1102 if (recurse && el && el.childNodes) {
\r
1103 for (i = 0,len = el.childNodes.length; i < len; ++i) {
\r
1104 this.purgeElement(el.childNodes[i], recurse, eventName);
\r
1110 getListeners: function(el, eventName) {
\r
1111 var results = [], searchLists;
\r
1113 searchLists = [listeners, unloadListeners];
\r
1114 } else if (eventName == "unload") {
\r
1115 searchLists = [unloadListeners];
\r
1117 searchLists = [listeners];
\r
1120 for (var j = 0; j < searchLists.length; ++j) {
\r
1121 var searchList = searchLists[j];
\r
1122 if (searchList && searchList.length > 0) {
\r
1123 for (var i = 0,len = searchList.length; i < len; ++i) {
\r
1124 var l = searchList[i];
\r
1125 if (l && l[this.EL] === el &&
\r
1126 (!eventName || eventName === l[this.TYPE])) {
\r
1128 type: l[this.TYPE],
\r
1131 adjust: l[this.ADJ_SCOPE],
\r
1139 return (results.length) ? results : null;
\r
1143 _unload: function(e) {
\r
1145 var EU = Ext.lib.Event, i, j, l, len, index;
\r
1147 for (i = 0,len = unloadListeners.length; i < len; ++i) {
\r
1148 l = unloadListeners[i];
\r
1150 var scope = window;
\r
1151 if (l[EU.ADJ_SCOPE]) {
\r
1152 if (l[EU.ADJ_SCOPE] === true) {
\r
1153 scope = l[EU.OBJ];
\r
1155 scope = l[EU.ADJ_SCOPE];
\r
1158 l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
\r
1159 unloadListeners[i] = null;
\r
1165 unloadListeners = null;
\r
1167 if (listeners && listeners.length > 0) {
\r
1168 j = listeners.length;
\r
1171 l = listeners[index];
\r
1173 EU.removeListener(l[EU.EL], l[EU.TYPE],
\r
1183 EU.doRemove(window, "unload", EU._unload);
\r
1188 getScroll: function() {
\r
1189 var dd = document.documentElement, db = document.body;
\r
1190 if (dd && (dd.scrollTop || dd.scrollLeft)) {
\r
1191 return [dd.scrollTop, dd.scrollLeft];
\r
1193 return [db.scrollTop, db.scrollLeft];
\r
1200 doAdd: function () {
\r
1201 if (window.addEventListener) {
\r
1202 return function(el, eventName, fn, capture) {
\r
1203 el.addEventListener(eventName, fn, (capture));
\r
1205 } else if (window.attachEvent) {
\r
1206 return function(el, eventName, fn, capture) {
\r
1207 el.attachEvent("on" + eventName, fn);
\r
1210 return function() {
\r
1216 doRemove: function() {
\r
1217 if (window.removeEventListener) {
\r
1218 return function (el, eventName, fn, capture) {
\r
1219 el.removeEventListener(eventName, fn, (capture));
\r
1221 } else if (window.detachEvent) {
\r
1222 return function (el, eventName, fn) {
\r
1223 el.detachEvent("on" + eventName, fn);
\r
1226 return function() {
\r
1234 var E = Ext.lib.Event;
\r
1235 E.on = E.addListener;
\r
1236 E.un = E.removeListener;
\r
1237 if (document && document.body) {
\r
1240 E.doAdd(window, "load", E._load);
\r
1242 E.doAdd(window, "unload", E._unload);
\r
1243 E._tryPreloadAttach();
\r
1246 request : function(method, uri, cb, data, options) {
\r
1248 var hs = options.headers;
\r
1251 if(hs.hasOwnProperty(h)){
\r
1252 this.initHeader(h, hs[h], false);
\r
1256 if(options.xmlData){
\r
1257 this.initHeader('Content-Type', 'text/xml', false);
\r
1259 data = options.xmlData;
\r
1260 }else if(options.jsonData){
\r
1261 this.initHeader('Content-Type', 'text/javascript', false);
\r
1263 data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
\r
1267 return this.asyncRequest(method, uri, cb, data);
\r
1270 serializeForm : function(form) {
\r
1271 if(typeof form == 'string') {
\r
1272 form = (document.getElementById(form) || document.forms[form]);
\r
1275 var el, name, val, disabled, data = '', hasSubmit = false;
\r
1276 for (var i = 0; i < form.elements.length; i++) {
\r
1277 el = form.elements[i];
\r
1278 disabled = form.elements[i].disabled;
\r
1279 name = form.elements[i].name;
\r
1280 val = form.elements[i].value;
\r
1282 if (!disabled && name){
\r
1285 case 'select-one':
\r
1286 case 'select-multiple':
\r
1287 for (var j = 0; j < el.options.length; j++) {
\r
1288 if (el.options[j].selected) {
\r
1290 data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
\r
1293 data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
\r
1301 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1314 if(hasSubmit == false) {
\r
1315 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1320 data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
\r
1325 data = data.substr(0, data.length - 1);
\r
1333 useDefaultHeader:true,
\r
1335 defaultPostHeader:'application/x-www-form-urlencoded',
\r
1337 useDefaultXhrHeader:true,
\r
1339 defaultXhrHeader:'XMLHttpRequest',
\r
1341 hasDefaultHeaders:true,
\r
1343 defaultHeaders:{},
\r
1353 setProgId:function(id)
\r
1355 this.activeX.unshift(id);
\r
1358 setDefaultPostHeader:function(b)
\r
1360 this.useDefaultHeader = b;
\r
1363 setDefaultXhrHeader:function(b)
\r
1365 this.useDefaultXhrHeader = b;
\r
1368 setPollingInterval:function(i)
\r
1370 if (typeof i == 'number' && isFinite(i)) {
\r
1371 this.pollInterval = i;
\r
1375 createXhrObject:function(transactionId)
\r
1381 http = new XMLHttpRequest();
\r
1383 obj = { conn:http, tId:transactionId };
\r
1387 for (var i = 0; i < this.activeX.length; ++i) {
\r
1391 http = new ActiveXObject(this.activeX[i]);
\r
1393 obj = { conn:http, tId:transactionId };
\r
1406 getConnectionObject:function()
\r
1409 var tId = this.transactionId;
\r
1413 o = this.createXhrObject(tId);
\r
1415 this.transactionId++;
\r
1426 asyncRequest:function(method, uri, callback, postData)
\r
1428 var o = this.getConnectionObject();
\r
1434 o.conn.open(method, uri, true);
\r
1436 if (this.useDefaultXhrHeader) {
\r
1437 if (!this.defaultHeaders['X-Requested-With']) {
\r
1438 this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
\r
1442 if(postData && this.useDefaultHeader){
\r
1443 this.initHeader('Content-Type', this.defaultPostHeader);
\r
1446 if (this.hasDefaultHeaders || this.hasHeaders) {
\r
1447 this.setHeader(o);
\r
1450 this.handleReadyState(o, callback);
\r
1451 o.conn.send(postData || null);
\r
1457 handleReadyState:function(o, callback)
\r
1461 if (callback && callback.timeout) {
\r
1462 this.timeout[o.tId] = window.setTimeout(function() {
\r
1463 oConn.abort(o, callback, true);
\r
1464 }, callback.timeout);
\r
1467 this.poll[o.tId] = window.setInterval(
\r
1469 if (o.conn && o.conn.readyState == 4) {
\r
1470 window.clearInterval(oConn.poll[o.tId]);
\r
1471 delete oConn.poll[o.tId];
\r
1473 if (callback && callback.timeout) {
\r
1474 window.clearTimeout(oConn.timeout[o.tId]);
\r
1475 delete oConn.timeout[o.tId];
\r
1478 oConn.handleTransactionResponse(o, callback);
\r
1481 , this.pollInterval);
\r
1484 handleTransactionResponse:function(o, callback, isAbort)
\r
1488 this.releaseObject(o);
\r
1492 var httpStatus, responseObject;
\r
1496 if (o.conn.status !== undefined && o.conn.status != 0) {
\r
1497 httpStatus = o.conn.status;
\r
1500 httpStatus = 13030;
\r
1506 httpStatus = 13030;
\r
1509 if (httpStatus >= 200 && httpStatus < 300) {
\r
1510 responseObject = this.createResponseObject(o, callback.argument);
\r
1511 if (callback.success) {
\r
1512 if (!callback.scope) {
\r
1513 callback.success(responseObject);
\r
1518 callback.success.apply(callback.scope, [responseObject]);
\r
1523 switch (httpStatus) {
\r
1531 responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
\r
1532 if (callback.failure) {
\r
1533 if (!callback.scope) {
\r
1534 callback.failure(responseObject);
\r
1537 callback.failure.apply(callback.scope, [responseObject]);
\r
1542 responseObject = this.createResponseObject(o, callback.argument);
\r
1543 if (callback.failure) {
\r
1544 if (!callback.scope) {
\r
1545 callback.failure(responseObject);
\r
1548 callback.failure.apply(callback.scope, [responseObject]);
\r
1554 this.releaseObject(o);
\r
1555 responseObject = null;
\r
1558 createResponseObject:function(o, callbackArg)
\r
1561 var headerObj = {};
\r
1565 var headerStr = o.conn.getAllResponseHeaders();
\r
1566 var header = headerStr.split('\n');
\r
1567 for (var i = 0; i < header.length; i++) {
\r
1568 var delimitPos = header[i].indexOf(':');
\r
1569 if (delimitPos != -1) {
\r
1570 headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
\r
1578 obj.status = o.conn.status;
\r
1579 obj.statusText = o.conn.statusText;
\r
1580 obj.getResponseHeader = headerObj;
\r
1581 obj.getAllResponseHeaders = headerStr;
\r
1582 obj.responseText = o.conn.responseText;
\r
1583 obj.responseXML = o.conn.responseXML;
\r
1585 if (typeof callbackArg !== undefined) {
\r
1586 obj.argument = callbackArg;
\r
1592 createExceptionObject:function(tId, callbackArg, isAbort)
\r
1594 var COMM_CODE = 0;
\r
1595 var COMM_ERROR = 'communication failure';
\r
1596 var ABORT_CODE = -1;
\r
1597 var ABORT_ERROR = 'transaction aborted';
\r
1603 obj.status = ABORT_CODE;
\r
1604 obj.statusText = ABORT_ERROR;
\r
1607 obj.status = COMM_CODE;
\r
1608 obj.statusText = COMM_ERROR;
\r
1611 if (callbackArg) {
\r
1612 obj.argument = callbackArg;
\r
1618 initHeader:function(label, value, isDefault)
\r
1620 var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
\r
1622 if (headerObj[label] === undefined) {
\r
1623 headerObj[label] = value;
\r
1628 headerObj[label] = value + "," + headerObj[label];
\r
1632 this.hasDefaultHeaders = true;
\r
1635 this.hasHeaders = true;
\r
1640 setHeader:function(o)
\r
1642 if (this.hasDefaultHeaders) {
\r
1643 for (var prop in this.defaultHeaders) {
\r
1644 if (this.defaultHeaders.hasOwnProperty(prop)) {
\r
1645 o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
\r
1650 if (this.hasHeaders) {
\r
1651 for (var prop in this.headers) {
\r
1652 if (this.headers.hasOwnProperty(prop)) {
\r
1653 o.conn.setRequestHeader(prop, this.headers[prop]);
\r
1656 this.headers = {};
\r
1657 this.hasHeaders = false;
\r
1661 resetDefaultHeaders:function() {
\r
1662 delete this.defaultHeaders;
\r
1663 this.defaultHeaders = {};
\r
1664 this.hasDefaultHeaders = false;
\r
1667 abort:function(o, callback, isTimeout)
\r
1669 if (this.isCallInProgress(o)) {
\r
1671 window.clearInterval(this.poll[o.tId]);
\r
1672 delete this.poll[o.tId];
\r
1674 delete this.timeout[o.tId];
\r
1677 this.handleTransactionResponse(o, callback, true);
\r
1687 isCallInProgress:function(o)
\r
1692 return o.conn.readyState != 4 && o.conn.readyState != 0;
\r
1701 releaseObject:function(o)
\r
1710 'MSXML2.XMLHTTP.3.0',
\r
1712 'Microsoft.XMLHTTP'
\r
1719 Ext.lib.Region = function(t, r, b, l) {
\r
1728 Ext.lib.Region.prototype = {
\r
1729 contains : function(region) {
\r
1730 return ( region.left >= this.left &&
\r
1731 region.right <= this.right &&
\r
1732 region.top >= this.top &&
\r
1733 region.bottom <= this.bottom );
\r
1737 getArea : function() {
\r
1738 return ( (this.bottom - this.top) * (this.right - this.left) );
\r
1741 intersect : function(region) {
\r
1742 var t = Math.max(this.top, region.top);
\r
1743 var r = Math.min(this.right, region.right);
\r
1744 var b = Math.min(this.bottom, region.bottom);
\r
1745 var l = Math.max(this.left, region.left);
\r
1747 if (b >= t && r >= l) {
\r
1748 return new Ext.lib.Region(t, r, b, l);
\r
1753 union : function(region) {
\r
1754 var t = Math.min(this.top, region.top);
\r
1755 var r = Math.max(this.right, region.right);
\r
1756 var b = Math.max(this.bottom, region.bottom);
\r
1757 var l = Math.min(this.left, region.left);
\r
1759 return new Ext.lib.Region(t, r, b, l);
\r
1762 constrainTo : function(r) {
\r
1763 this.top = this.top.constrain(r.top, r.bottom);
\r
1764 this.bottom = this.bottom.constrain(r.top, r.bottom);
\r
1765 this.left = this.left.constrain(r.left, r.right);
\r
1766 this.right = this.right.constrain(r.left, r.right);
\r
1770 adjust : function(t, l, b, r) {
\r
1779 Ext.lib.Region.getRegion = function(el) {
\r
1780 var p = Ext.lib.Dom.getXY(el);
\r
1783 var r = p[0] + el.offsetWidth;
\r
1784 var b = p[1] + el.offsetHeight;
\r
1787 return new Ext.lib.Region(t, r, b, l);
\r
1790 Ext.lib.Point = function(x, y) {
\r
1791 if (Ext.isArray(x)) {
\r
1795 this.x = this.right = this.left = this[0] = x;
\r
1796 this.y = this.top = this.bottom = this[1] = y;
\r
1799 Ext.lib.Point.prototype = new Ext.lib.Region();
\r
1803 scroll : function(el, args, duration, easing, cb, scope) {
\r
1804 return this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
\r
1807 motion : function(el, args, duration, easing, cb, scope) {
\r
1808 return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
\r
1811 color : function(el, args, duration, easing, cb, scope) {
\r
1812 return this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
\r
1815 run : function(el, args, duration, easing, cb, scope, type) {
\r
1816 type = type || Ext.lib.AnimBase;
\r
1817 if (typeof easing == "string") {
\r
1818 easing = Ext.lib.Easing[easing];
\r
1820 var anim = new type(el, args, duration, easing);
\r
1821 anim.animateX(function() {
\r
1822 Ext.callback(cb, scope);
\r
1829 function fly(el) {
\r
1830 if (!libFlyweight) {
\r
1831 libFlyweight = new Ext.Element.Flyweight();
\r
1833 libFlyweight.dom = el;
\r
1834 return libFlyweight;
\r
1839 function fnCleanUp() {
\r
1840 var p = Function.prototype;
\r
1841 delete p.createSequence;
\r
1843 delete p.createDelegate;
\r
1844 delete p.createCallback;
\r
1845 delete p.createInterceptor;
\r
1847 window.detachEvent("onunload", fnCleanUp);
\r
1849 window.attachEvent("onunload", fnCleanUp);
\r
1852 Ext.lib.AnimBase = function(el, attributes, duration, method) {
\r
1854 this.init(el, attributes, duration, method);
\r
1858 Ext.lib.AnimBase.prototype = {
\r
1860 toString: function() {
\r
1861 var el = this.getEl();
\r
1862 var id = el.id || el.tagName;
\r
1863 return ("Anim " + id);
\r
1867 noNegatives: /width|height|opacity|padding/i,
\r
1868 offsetAttribute: /^((width|height)|(top|left))$/,
\r
1869 defaultUnit: /width|height|top$|bottom$|left$|right$/i,
\r
1870 offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
\r
1874 doMethod: function(attr, start, end) {
\r
1875 return this.method(this.currentFrame, start, end - start, this.totalFrames);
\r
1879 setAttribute: function(attr, val, unit) {
\r
1880 if (this.patterns.noNegatives.test(attr)) {
\r
1881 val = (val > 0) ? val : 0;
\r
1884 Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
\r
1888 getAttribute: function(attr) {
\r
1889 var el = this.getEl();
\r
1890 var val = fly(el).getStyle(attr);
\r
1892 if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
\r
1893 return parseFloat(val);
\r
1896 var a = this.patterns.offsetAttribute.exec(attr) || [];
\r
1897 var pos = !!( a[3] );
\r
1898 var box = !!( a[2] );
\r
1901 if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
\r
1902 val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
\r
1911 getDefaultUnit: function(attr) {
\r
1912 if (this.patterns.defaultUnit.test(attr)) {
\r
1919 animateX : function(callback, scope) {
\r
1920 var f = function() {
\r
1921 this.onComplete.removeListener(f);
\r
1922 if (typeof callback == "function") {
\r
1923 callback.call(scope || this, this);
\r
1926 this.onComplete.addListener(f, this);
\r
1931 setRuntimeAttribute: function(attr) {
\r
1934 var attributes = this.attributes;
\r
1936 this.runtimeAttributes[attr] = {};
\r
1938 var isset = function(prop) {
\r
1939 return (typeof prop !== 'undefined');
\r
1942 if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) {
\r
1946 start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
\r
1949 if (isset(attributes[attr]['to'])) {
\r
1950 end = attributes[attr]['to'];
\r
1951 } else if (isset(attributes[attr]['by'])) {
\r
1952 if (start.constructor == Array) {
\r
1954 for (var i = 0, len = start.length; i < len; ++i) {
\r
1955 end[i] = start[i] + attributes[attr]['by'][i];
\r
1958 end = start + attributes[attr]['by'];
\r
1962 this.runtimeAttributes[attr].start = start;
\r
1963 this.runtimeAttributes[attr].end = end;
\r
1966 this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
\r
1970 init: function(el, attributes, duration, method) {
\r
1972 var isAnimated = false;
\r
1975 var startTime = null;
\r
1978 var actualFrames = 0;
\r
1981 el = Ext.getDom(el);
\r
1984 this.attributes = attributes || {};
\r
1987 this.duration = duration || 1;
\r
1990 this.method = method || Ext.lib.Easing.easeNone;
\r
1993 this.useSeconds = true;
\r
1996 this.currentFrame = 0;
\r
1999 this.totalFrames = Ext.lib.AnimMgr.fps;
\r
2002 this.getEl = function() {
\r
2007 this.isAnimated = function() {
\r
2008 return isAnimated;
\r
2012 this.getStartTime = function() {
\r
2016 this.runtimeAttributes = {};
\r
2019 this.animate = function() {
\r
2020 if (this.isAnimated()) {
\r
2024 this.currentFrame = 0;
\r
2026 this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration;
\r
2028 Ext.lib.AnimMgr.registerElement(this);
\r
2032 this.stop = function(finish) {
\r
2034 this.currentFrame = this.totalFrames;
\r
2035 this._onTween.fire();
\r
2037 Ext.lib.AnimMgr.stop(this);
\r
2040 var onStart = function() {
\r
2041 this.onStart.fire();
\r
2043 this.runtimeAttributes = {};
\r
2044 for (var attr in this.attributes) {
\r
2045 this.setRuntimeAttribute(attr);
\r
2048 isAnimated = true;
\r
2050 startTime = new Date();
\r
2054 var onTween = function() {
\r
2056 duration: new Date() - this.getStartTime(),
\r
2057 currentFrame: this.currentFrame
\r
2060 data.toString = function() {
\r
2062 'duration: ' + data.duration +
\r
2063 ', currentFrame: ' + data.currentFrame
\r
2067 this.onTween.fire(data);
\r
2069 var runtimeAttributes = this.runtimeAttributes;
\r
2071 for (var attr in runtimeAttributes) {
\r
2072 this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
\r
2075 actualFrames += 1;
\r
2078 var onComplete = function() {
\r
2079 var actual_duration = (new Date() - startTime) / 1000 ;
\r
2082 duration: actual_duration,
\r
2083 frames: actualFrames,
\r
2084 fps: actualFrames / actual_duration
\r
2087 data.toString = function() {
\r
2089 'duration: ' + data.duration +
\r
2090 ', frames: ' + data.frames +
\r
2091 ', fps: ' + data.fps
\r
2095 isAnimated = false;
\r
2097 this.onComplete.fire(data);
\r
2101 this._onStart = new Ext.util.Event(this);
\r
2102 this.onStart = new Ext.util.Event(this);
\r
2103 this.onTween = new Ext.util.Event(this);
\r
2104 this._onTween = new Ext.util.Event(this);
\r
2105 this.onComplete = new Ext.util.Event(this);
\r
2106 this._onComplete = new Ext.util.Event(this);
\r
2107 this._onStart.addListener(onStart);
\r
2108 this._onTween.addListener(onTween);
\r
2109 this._onComplete.addListener(onComplete);
\r
2114 Ext.lib.AnimMgr = new function() {
\r
2116 var thread = null;
\r
2122 var tweenCount = 0;
\r
2131 this.registerElement = function(tween) {
\r
2132 queue[queue.length] = tween;
\r
2134 tween._onStart.fire();
\r
2139 this.unRegister = function(tween, index) {
\r
2140 tween._onComplete.fire();
\r
2141 index = index || getIndex(tween);
\r
2142 if (index != -1) {
\r
2143 queue.splice(index, 1);
\r
2147 if (tweenCount <= 0) {
\r
2153 this.start = function() {
\r
2154 if (thread === null) {
\r
2155 thread = setInterval(this.run, this.delay);
\r
2160 this.stop = function(tween) {
\r
2162 clearInterval(thread);
\r
2164 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2165 if (queue[0].isAnimated()) {
\r
2166 this.unRegister(queue[0], 0);
\r
2175 this.unRegister(tween);
\r
2180 this.run = function() {
\r
2181 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2182 var tween = queue[i];
\r
2183 if (!tween || !tween.isAnimated()) {
\r
2187 if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
\r
2189 tween.currentFrame += 1;
\r
2191 if (tween.useSeconds) {
\r
2192 correctFrame(tween);
\r
2194 tween._onTween.fire();
\r
2197 Ext.lib.AnimMgr.stop(tween, i);
\r
2202 var getIndex = function(anim) {
\r
2203 for (var i = 0, len = queue.length; i < len; ++i) {
\r
2204 if (queue[i] == anim) {
\r
2212 var correctFrame = function(tween) {
\r
2213 var frames = tween.totalFrames;
\r
2214 var frame = tween.currentFrame;
\r
2215 var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
\r
2216 var elapsed = (new Date() - tween.getStartTime());
\r
2219 if (elapsed < tween.duration * 1000) {
\r
2220 tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
\r
2222 tweak = frames - (frame + 1);
\r
2224 if (tweak > 0 && isFinite(tweak)) {
\r
2225 if (tween.currentFrame + tweak >= frames) {
\r
2226 tweak = frames - (frame + 1);
\r
2229 tween.currentFrame += tweak;
\r
2234 Ext.lib.Bezier = new function() {
\r
2236 this.getPosition = function(points, t) {
\r
2237 var n = points.length;
\r
2240 for (var i = 0; i < n; ++i) {
\r
2241 tmp[i] = [points[i][0], points[i][1]];
\r
2244 for (var j = 1; j < n; ++j) {
\r
2245 for (i = 0; i < n - j; ++i) {
\r
2246 tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
\r
2247 tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
\r
2251 return [ tmp[0][0], tmp[0][1] ];
\r
2257 Ext.lib.ColorAnim = function(el, attributes, duration, method) {
\r
2258 Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
\r
2261 Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase);
\r
2265 var superclass = Y.ColorAnim.superclass;
\r
2266 var proto = Y.ColorAnim.prototype;
\r
2268 proto.toString = function() {
\r
2269 var el = this.getEl();
\r
2270 var id = el.id || el.tagName;
\r
2271 return ("ColorAnim " + id);
\r
2274 proto.patterns.color = /color$/i;
\r
2275 proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
\r
2276 proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
\r
2277 proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
\r
2278 proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
\r
2281 proto.parseColor = function(s) {
\r
2282 if (s.length == 3) {
\r
2286 var c = this.patterns.hex.exec(s);
\r
2287 if (c && c.length == 4) {
\r
2288 return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
\r
2291 c = this.patterns.rgb.exec(s);
\r
2292 if (c && c.length == 4) {
\r
2293 return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
\r
2296 c = this.patterns.hex3.exec(s);
\r
2297 if (c && c.length == 4) {
\r
2298 return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
\r
2304 proto.getAttribute = function(attr) {
\r
2305 var el = this.getEl();
\r
2306 if (this.patterns.color.test(attr)) {
\r
2307 var val = fly(el).getStyle(attr);
\r
2309 if (this.patterns.transparent.test(val)) {
\r
2310 var parent = el.parentNode;
\r
2311 val = fly(parent).getStyle(attr);
\r
2313 while (parent && this.patterns.transparent.test(val)) {
\r
2314 parent = parent.parentNode;
\r
2315 val = fly(parent).getStyle(attr);
\r
2316 if (parent.tagName.toUpperCase() == 'HTML') {
\r
2322 val = superclass.getAttribute.call(this, attr);
\r
2328 proto.doMethod = function(attr, start, end) {
\r
2331 if (this.patterns.color.test(attr)) {
\r
2333 for (var i = 0, len = start.length; i < len; ++i) {
\r
2334 val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
\r
2337 val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1]) + ',' + Math.floor(val[2]) + ')';
\r
2340 val = superclass.doMethod.call(this, attr, start, end);
\r
2346 proto.setRuntimeAttribute = function(attr) {
\r
2347 superclass.setRuntimeAttribute.call(this, attr);
\r
2349 if (this.patterns.color.test(attr)) {
\r
2350 var attributes = this.attributes;
\r
2351 var start = this.parseColor(this.runtimeAttributes[attr].start);
\r
2352 var end = this.parseColor(this.runtimeAttributes[attr].end);
\r
2354 if (typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined') {
\r
2355 end = this.parseColor(attributes[attr].by);
\r
2357 for (var i = 0, len = start.length; i < len; ++i) {
\r
2358 end[i] = start[i] + end[i];
\r
2362 this.runtimeAttributes[attr].start = start;
\r
2363 this.runtimeAttributes[attr].end = end;
\r
2369 Ext.lib.Easing = {
\r
2372 easeNone: function (t, b, c, d) {
\r
2373 return c * t / d + b;
\r
2377 easeIn: function (t, b, c, d) {
\r
2378 return c * (t /= d) * t + b;
\r
2382 easeOut: function (t, b, c, d) {
\r
2383 return -c * (t /= d) * (t - 2) + b;
\r
2387 easeBoth: function (t, b, c, d) {
\r
2388 if ((t /= d / 2) < 1) {
\r
2389 return c / 2 * t * t + b;
\r
2392 return -c / 2 * ((--t) * (t - 2) - 1) + b;
\r
2396 easeInStrong: function (t, b, c, d) {
\r
2397 return c * (t /= d) * t * t * t + b;
\r
2401 easeOutStrong: function (t, b, c, d) {
\r
2402 return -c * ((t = t / d - 1) * t * t * t - 1) + b;
\r
2406 easeBothStrong: function (t, b, c, d) {
\r
2407 if ((t /= d / 2) < 1) {
\r
2408 return c / 2 * t * t * t * t + b;
\r
2411 return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
\r
2416 elasticIn: function (t, b, c, d, a, p) {
\r
2420 if ((t /= d) == 1) {
\r
2427 if (!a || a < Math.abs(c)) {
\r
2432 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2435 return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
\r
2439 elasticOut: function (t, b, c, d, a, p) {
\r
2443 if ((t /= d) == 1) {
\r
2450 if (!a || a < Math.abs(c)) {
\r
2455 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2458 return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
\r
2462 elasticBoth: function (t, b, c, d, a, p) {
\r
2467 if ((t /= d / 2) == 2) {
\r
2472 p = d * (.3 * 1.5);
\r
2475 if (!a || a < Math.abs(c)) {
\r
2480 var s = p / (2 * Math.PI) * Math.asin(c / a);
\r
2484 return -.5 * (a * Math.pow(2, 10 * (t -= 1)) *
\r
2485 Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
\r
2487 return a * Math.pow(2, -10 * (t -= 1)) *
\r
2488 Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
\r
2493 backIn: function (t, b, c, d, s) {
\r
2494 if (typeof s == 'undefined') {
\r
2497 return c * (t /= d) * t * ((s + 1) * t - s) + b;
\r
2501 backOut: function (t, b, c, d, s) {
\r
2502 if (typeof s == 'undefined') {
\r
2505 return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
\r
2509 backBoth: function (t, b, c, d, s) {
\r
2510 if (typeof s == 'undefined') {
\r
2514 if ((t /= d / 2 ) < 1) {
\r
2515 return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
\r
2517 return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
\r
2521 bounceIn: function (t, b, c, d) {
\r
2522 return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b;
\r
2526 bounceOut: function (t, b, c, d) {
\r
2527 if ((t /= d) < (1 / 2.75)) {
\r
2528 return c * (7.5625 * t * t) + b;
\r
2529 } else if (t < (2 / 2.75)) {
\r
2530 return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
\r
2531 } else if (t < (2.5 / 2.75)) {
\r
2532 return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
\r
2534 return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
\r
2538 bounceBoth: function (t, b, c, d) {
\r
2540 return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
\r
2542 return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
\r
2547 Ext.lib.Motion = function(el, attributes, duration, method) {
\r
2549 Ext.lib.Motion.superclass.constructor.call(this, el, attributes, duration, method);
\r
2553 Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim);
\r
2557 var superclass = Y.Motion.superclass;
\r
2558 var proto = Y.Motion.prototype;
\r
2560 proto.toString = function() {
\r
2561 var el = this.getEl();
\r
2562 var id = el.id || el.tagName;
\r
2563 return ("Motion " + id);
\r
2566 proto.patterns.points = /^points$/i;
\r
2568 proto.setAttribute = function(attr, val, unit) {
\r
2569 if (this.patterns.points.test(attr)) {
\r
2570 unit = unit || 'px';
\r
2571 superclass.setAttribute.call(this, 'left', val[0], unit);
\r
2572 superclass.setAttribute.call(this, 'top', val[1], unit);
\r
2574 superclass.setAttribute.call(this, attr, val, unit);
\r
2578 proto.getAttribute = function(attr) {
\r
2579 if (this.patterns.points.test(attr)) {
\r
2581 superclass.getAttribute.call(this, 'left'),
\r
2582 superclass.getAttribute.call(this, 'top')
\r
2585 val = superclass.getAttribute.call(this, attr);
\r
2591 proto.doMethod = function(attr, start, end) {
\r
2594 if (this.patterns.points.test(attr)) {
\r
2595 var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
\r
2596 val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
\r
2598 val = superclass.doMethod.call(this, attr, start, end);
\r
2603 proto.setRuntimeAttribute = function(attr) {
\r
2604 if (this.patterns.points.test(attr)) {
\r
2605 var el = this.getEl();
\r
2606 var attributes = this.attributes;
\r
2608 var control = attributes['points']['control'] || [];
\r
2612 if (control.length > 0 && !Ext.isArray(control[0])) {
\r
2613 control = [control];
\r
2616 for (i = 0,len = control.length; i < len; ++i) {
\r
2617 tmp[i] = control[i];
\r
2622 Ext.fly(el).position();
\r
2624 if (isset(attributes['points']['from'])) {
\r
2625 Ext.lib.Dom.setXY(el, attributes['points']['from']);
\r
2628 Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el));
\r
2631 start = this.getAttribute('points');
\r
2634 if (isset(attributes['points']['to'])) {
\r
2635 end = translateValues.call(this, attributes['points']['to'], start);
\r
2637 var pageXY = Ext.lib.Dom.getXY(this.getEl());
\r
2638 for (i = 0,len = control.length; i < len; ++i) {
\r
2639 control[i] = translateValues.call(this, control[i], start);
\r
2643 } else if (isset(attributes['points']['by'])) {
\r
2644 end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
\r
2646 for (i = 0,len = control.length; i < len; ++i) {
\r
2647 control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
\r
2651 this.runtimeAttributes[attr] = [start];
\r
2653 if (control.length > 0) {
\r
2654 this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
\r
2657 this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
\r
2660 superclass.setRuntimeAttribute.call(this, attr);
\r
2664 var translateValues = function(val, start) {
\r
2665 var pageXY = Ext.lib.Dom.getXY(this.getEl());
\r
2666 val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
\r
2671 var isset = function(prop) {
\r
2672 return (typeof prop !== 'undefined');
\r
2678 Ext.lib.Scroll = function(el, attributes, duration, method) {
\r
2680 Ext.lib.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
\r
2684 Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim);
\r
2688 var superclass = Y.Scroll.superclass;
\r
2689 var proto = Y.Scroll.prototype;
\r
2691 proto.toString = function() {
\r
2692 var el = this.getEl();
\r
2693 var id = el.id || el.tagName;
\r
2694 return ("Scroll " + id);
\r
2697 proto.doMethod = function(attr, start, end) {
\r
2700 if (attr == 'scroll') {
\r
2702 this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
\r
2703 this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
\r
2707 val = superclass.doMethod.call(this, attr, start, end);
\r
2712 proto.getAttribute = function(attr) {
\r
2714 var el = this.getEl();
\r
2716 if (attr == 'scroll') {
\r
2717 val = [ el.scrollLeft, el.scrollTop ];
\r
2719 val = superclass.getAttribute.call(this, attr);
\r
2725 proto.setAttribute = function(attr, val, unit) {
\r
2726 var el = this.getEl();
\r
2728 if (attr == 'scroll') {
\r
2729 el.scrollLeft = val[0];
\r
2730 el.scrollTop = val[1];
\r
2732 superclass.setAttribute.call(this, attr, val, unit);
\r