ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- var me = this;
- return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0;
- },
- getTop : function(local) {
- return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0;
- },
- getBottom : function(local){
- var me = this;
- return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0;
- },
- position : function(pos, zIndex, x, y){
- var me = this;
- if(!pos && me.isStyle(POSITION, STATIC)){
- me.setStyle(POSITION, RELATIVE);
- } else if(pos) {
- me.setStyle(POSITION, pos);
- }
- if(zIndex){
- me.setStyle(ZINDEX, zIndex);
- }
- if(x || y) me.setXY([x || false, y || false]);
- },
- clearPositioning : function(value){
- value = value || '';
- this.setStyle({
- left : value,
- right : value,
- top : value,
- bottom : value,
- "z-index" : "",
- position : STATIC
- });
- return this;
- },
- getPositioning : function(){
- var l = this.getStyle(LEFT);
- var t = this.getStyle(TOP);
- return {
- "position" : this.getStyle(POSITION),
- "left" : l,
- "right" : l ? "" : this.getStyle(RIGHT),
- "top" : t,
- "bottom" : t ? "" : this.getStyle(BOTTOM),
- "z-index" : this.getStyle(ZINDEX)
- };
- },
- setPositioning : function(pc){
- var me = this,
- style = me.dom.style;
- me.setStyle(pc);
- if(pc.right == AUTO){
- style.right = "";
- }
- if(pc.bottom == AUTO){
- style.bottom = "";
- }
- return me;
- },
- translatePoints : function(x, y){
- y = isNaN(x[1]) ? y : x[1];
- x = isNaN(x[0]) ? x : x[0];
- var me = this,
- relative = me.isStyle(POSITION, RELATIVE),
- o = me.getXY(),
- l = parseInt(me.getStyle(LEFT), 10),
- t = parseInt(me.getStyle(TOP), 10);
- l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
- t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
- return {left: (x - o[0] + l), top: (y - o[1] + t)};
- },
- animTest : function(args, animate, i) {
- return !!animate && this.preanim ? this.preanim(args, i) : false;
- }
- });
- })();
- Ext.Element.addMethods({
- setBox : function(box, adjust, animate){
- var me = this,
- w = box.width,
- h = box.height;
- if((adjust && !me.autoBoxAdjust) && !me.isBorderBox()){
- w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
- h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
- }
- me.setBounds(box.x, box.y, w, h, me.animTest.call(me, arguments, animate, 2));
- return me;
- },
- getBox : function(contentBox, local) {
- var me = this,
- xy,
- left,
- top,
- getBorderWidth = me.getBorderWidth,
- getPadding = me.getPadding,
- l,
- r,
- t,
- b;
- if(!local){
- xy = me.getXY();
- }else{
- left = parseInt(me.getStyle("left"), 10) || 0;
- top = parseInt(me.getStyle("top"), 10) || 0;
- xy = [left, top];
- }
- var el = me.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
- if(!contentBox){
- bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
- }else{
- l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
- r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
- t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
- b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
- bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
- }
- bx.right = bx.x + bx.width;
- bx.bottom = bx.y + bx.height;
- return bx;
- },
- move : function(direction, distance, animate){
- var me = this,
- xy = me.getXY(),
- x = xy[0],
- y = xy[1],
- left = [x - distance, y],
- right = [x + distance, y],
- top = [x, y - distance],
- bottom = [x, y + distance],
- hash = {
- l : left,
- left : left,
- r : right,
- right : right,
- t : top,
- top : top,
- up : top,
- b : bottom,
- bottom : bottom,
- down : bottom
- };
- direction = direction.toLowerCase();
- me.moveTo(hash[direction][0], hash[direction][1], me.animTest.call(me, arguments, animate, 2));
- },
- setLeftTop : function(left, top){
- var me = this,
- style = me.dom.style;
- style.left = me.addUnits(left);
- style.top = me.addUnits(top);
- return me;
- },
- getRegion : function(){
- return Ext.lib.Dom.getRegion(this.dom);
- },
- setBounds : function(x, y, width, height, animate){
- var me = this;
- if (!animate || !me.anim) {
- me.setSize(width, height);
- me.setLocation(x, y);
- } else {
- me.anim({points: {to: [x, y]},
- width: {to: me.adjustWidth(width)},
- height: {to: me.adjustHeight(height)}},
- me.preanim(arguments, 4),
- 'motion');
- }
- return me;
- },
- setRegion : function(region, animate) {
- return this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.animTest.call(this, arguments, animate, 1));
- }
- });
- Ext.Element.addMethods({
- isScrollable : function(){
- var dom = this.dom;
- return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
- },
- scrollTo : function(side, value){
- this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value;
- return this;
- },
- getScroll : function(){
- var d = this.dom,
- doc = document,
- body = doc.body,
- docElement = doc.documentElement,
- l,
- t,
- ret;
- if(d == doc || d == body){
- if(Ext.isIE && Ext.isStrict){
- l = docElement.scrollLeft;
- t = docElement.scrollTop;
- }else{
- l = window.pageXOffset;
- t = window.pageYOffset;
- }
- ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)};
- }else{
- ret = {left: d.scrollLeft, top: d.scrollTop};
- }
- return ret;
- }
- });
- Ext.Element.addMethods({
- scrollTo : function(side, value, animate){
- var top = /top/i.test(side),
- me = this,
- dom = me.dom,
- prop;
- if (!animate || !me.anim) {
- prop = 'scroll' + (top ? 'Top' : 'Left'),
- dom[prop] = value;
- }else{
- prop = 'scroll' + (top ? 'Left' : 'Top'),
- me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}},
- me.preanim(arguments, 2), 'scroll');
- }
- return me;
- },
- scrollIntoView : function(container, hscroll){
- var c = Ext.getDom(container) || Ext.getBody().dom,
- el = this.dom,
- o = this.getOffsetsTo(c),
- l = o[0] + c.scrollLeft,
- t = o[1] + c.scrollTop,
- b = t + el.offsetHeight,
- r = l + el.offsetWidth,
- ch = c.clientHeight,
- ct = parseInt(c.scrollTop, 10),
- cl = parseInt(c.scrollLeft, 10),
- cb = ct + ch,
- cr = cl + c.clientWidth;
- if (el.offsetHeight > ch || t < ct) {
- c.scrollTop = t;
- } else if (b > cb){
- c.scrollTop = b-ch;
- }
- c.scrollTop = c.scrollTop;
- if(hscroll !== false){
- if(el.offsetWidth > c.clientWidth || l < cl){
- c.scrollLeft = l;
- }else if(r > cr){
- c.scrollLeft = r - c.clientWidth;
- }
- c.scrollLeft = c.scrollLeft;
- }
- return this;
- },
- scrollChildIntoView : function(child, hscroll){
- Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
- },
- scroll : function(direction, distance, animate){
- if(!this.isScrollable()){
- return;
- }
- var el = this.dom,
- l = el.scrollLeft, t = el.scrollTop,
- w = el.scrollWidth, h = el.scrollHeight,
- cw = el.clientWidth, ch = el.clientHeight,
- scrolled = false, v,
- hash = {
- l: Math.min(l + distance, w-cw),
- r: v = Math.max(l - distance, 0),
- t: Math.max(t - distance, 0),
- b: Math.min(t + distance, h-ch)
- };
- hash.d = hash.b;
- hash.u = hash.t;
- direction = direction.substr(0, 1);
- if((v = hash[direction]) > -1){
- scrolled = true;
- this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));
- }
- return scrolled;
- }
- });
- Ext.Element.VISIBILITY = 1;
- Ext.Element.DISPLAY = 2;
- Ext.Element.addMethods(function(){
- var VISIBILITY = "visibility",
- DISPLAY = "display",
- HIDDEN = "hidden",
- NONE = "none",
- ORIGINALDISPLAY = 'originalDisplay',
- VISMODE = 'visibilityMode',
- ELDISPLAY = Ext.Element.DISPLAY,
- data = Ext.Element.data,
- getDisplay = function(dom){
- var d = data(dom, ORIGINALDISPLAY);
- if(d === undefined){
- data(dom, ORIGINALDISPLAY, d = '');
- }
- return d;
- },
- getVisMode = function(dom){
- var m = data(dom, VISMODE);
- if(m === undefined){
- data(dom, VISMODE, m = 1)
- }
- return m;
- };
- return {
- originalDisplay : "",
- visibilityMode : 1,
- setVisibilityMode : function(visMode){
- data(this.dom, VISMODE, visMode);
- return this;
- },
- animate : function(args, duration, onComplete, easing, animType){
- this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
- return this;
- },
- anim : function(args, opt, animType, defaultDur, defaultEase, cb){
- animType = animType || 'run';
- opt = opt || {};
- var me = this,
- anim = Ext.lib.Anim[animType](
- me.dom,
- args,
- (opt.duration || defaultDur) || .35,
- (opt.easing || defaultEase) || 'easeOut',
- function(){
- if(cb) cb.call(me);
- if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
- },
- me
- );
- opt.anim = anim;
- return anim;
- },
- preanim : function(a, i){
- return !a[i] ? false : (Ext.isObject(a[i]) ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
- },
- isVisible : function() {
- return !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE);
- },
- setVisible : function(visible, animate){
- var me = this,
- dom = me.dom,
- isDisplay = getVisMode(this.dom) == ELDISPLAY;
- if (!animate || !me.anim) {
- if(isDisplay){
- me.setDisplayed(visible);
- }else{
- me.fixDisplay();
- dom.style.visibility = visible ? "visible" : HIDDEN;
- }
- }else{
- if(visible){
- me.setOpacity(.01);
- me.setVisible(true);
- }
- me.anim({opacity: { to: (visible?1:0) }},
- me.preanim(arguments, 1),
- null,
- .35,
- 'easeIn',
- function(){
- if(!visible){
- dom.style[isDisplay ? DISPLAY : VISIBILITY] = (isDisplay) ? NONE : HIDDEN;
- Ext.fly(dom).setOpacity(1);
- }
- });
- }
- return me;
- },
- toggle : function(animate){
- var me = this;
- me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
- return me;
- },
- setDisplayed : function(value) {
- if(typeof value == "boolean"){
- value = value ? getDisplay(this.dom) : NONE;
- }
- this.setStyle(DISPLAY, value);
- return this;
- },
- fixDisplay : function(){
- var me = this;
- if(me.isStyle(DISPLAY, NONE)){
- me.setStyle(VISIBILITY, HIDDEN);
- me.setStyle(DISPLAY, getDisplay(this.dom));
- if(me.isStyle(DISPLAY, NONE)){
- me.setStyle(DISPLAY, "block");
- }
- }
- },
- hide : function(animate){
- this.setVisible(false, this.preanim(arguments, 0));
- return this;
- },
- show : function(animate){
- this.setVisible(true, this.preanim(arguments, 0));
- return this;
- }
- }
- }());
- Ext.Element.addMethods(
- function(){
- var VISIBILITY = "visibility",
- DISPLAY = "display",
- HIDDEN = "hidden",
- NONE = "none",
- XMASKED = "x-masked",
- XMASKEDRELATIVE = "x-masked-relative",
- data = Ext.Element.data;
- return {
- isVisible : function(deep) {
- var vis = !this.isStyle(VISIBILITY,HIDDEN) && !this.isStyle(DISPLAY,NONE),
- p = this.dom.parentNode;
- if(deep !== true || !vis){
- return vis;
- }
- while(p && !/body/i.test(p.tagName)){
- if(!Ext.fly(p, '_isVisible').isVisible()){
- return false;
- }
- p = p.parentNode;
- }
- return true;
- },
- isDisplayed : function() {
- return !this.isStyle(DISPLAY, NONE);
- },
- enableDisplayMode : function(display){
- this.setVisibilityMode(Ext.Element.DISPLAY);
- if(!Ext.isEmpty(display)){
- data(this.dom, 'originalDisplay', display);
- }
- return this;
- },
- mask : function(msg, msgCls){
- var me = this,
- dom = me.dom,
- dh = Ext.DomHelper,
- EXTELMASKMSG = "ext-el-mask-msg",
- el,
- mask;
- if(me.getStyle("position") == "static"){
- me.addClass(XMASKEDRELATIVE);
- }
- if((el = data(dom, 'maskMsg'))){
- el.remove();
- }
- if((el = data(dom, 'mask'))){
- el.remove();
- }
- mask = dh.append(dom, {cls : "ext-el-mask"}, true);
- data(dom, 'mask', mask);
- me.addClass(XMASKED);
- mask.setDisplayed(true);
- if(typeof msg == 'string'){
- var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
- data(dom, 'maskMsg', mm);
- mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
- mm.dom.firstChild.innerHTML = msg;
- mm.setDisplayed(true);
- mm.center(me);
- }
- if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto'){
- mask.setSize(undefined, me.getHeight());
- }
- return mask;
- },
- unmask : function(){
- var me = this,
- dom = me.dom,
- mask = data(dom, 'mask'),
- maskMsg = data(dom, 'maskMsg');
- if(mask){
- if(maskMsg){
- maskMsg.remove();
- data(dom, 'maskMsg', undefined);
- }
- mask.remove();
- data(dom, 'mask', undefined);
- }
- me.removeClass([XMASKED, XMASKEDRELATIVE]);
- },
- isMasked : function(){
- var m = data(this.dom, 'mask');
- return m && m.isVisible();
- },
- createShim : function(){
- var el = document.createElement('iframe'),
- shim;
- el.frameBorder = '0';
- el.className = 'ext-shim';
- el.src = Ext.SSL_SECURE_URL;
- shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
- shim.autoBoxAdjust = false;
- return shim;
- }
- };
- }());
- Ext.Element.addMethods({
- addKeyListener : function(key, fn, scope){
- var config;
- if(!Ext.isObject(key) || Ext.isArray(key)){
- config = {
- key: key,
- fn: fn,
- scope: scope
- };
- }else{
- config = {
- key : key.key,
- shift : key.shift,
- ctrl : key.ctrl,
- alt : key.alt,
- fn: fn,
- scope: scope
- };
- }
- return new Ext.KeyMap(this, config);
- },
- addKeyMap : function(config){
- return new Ext.KeyMap(this, config);
- }
- });(function(){
- var NULL = null,
- UNDEFINED = undefined,
- TRUE = true,
- FALSE = false,
- SETX = "setX",
- SETY = "setY",
- SETXY = "setXY",
- LEFT = "left",
- BOTTOM = "bottom",
- TOP = "top",
- RIGHT = "right",
- HEIGHT = "height",
- WIDTH = "width",
- POINTS = "points",
- HIDDEN = "hidden",
- ABSOLUTE = "absolute",
- VISIBLE = "visible",
- MOTION = "motion",
- POSITION = "position",
- EASEOUT = "easeOut",
- flyEl = new Ext.Element.Flyweight(),
- queues = {},
- getObject = function(o){
- return o || {};
- },
- fly = function(dom){
- flyEl.dom = dom;
- flyEl.id = Ext.id(dom);
- return flyEl;
- },
- getQueue = function(id){
- if(!queues[id]){
- queues[id] = [];
- }
- return queues[id];
- },
- setQueue = function(id, value){
- queues[id] = value;
- };
- Ext.enableFx = TRUE;
- Ext.Fx = {
- switchStatements : function(key, fn, argHash){
- return fn.apply(this, argHash[key]);
- },
- slideIn : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- xy,
- r,
- b,
- wrap,
- after,
- st,
- args,
- pt,
- bw,
- bh;
- anchor = anchor || "t";
- me.queueFx(o, function(){
- xy = fly(dom).getXY();
- fly(dom).fixDisplay();
- r = fly(dom).getFxRestore();
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
- b.right = b.x + b.width;
- b.bottom = b.y + b.height;
- fly(dom).setWidth(b.width).setHeight(b.height);
- wrap = fly(dom).fxWrap(r.pos, o, HIDDEN);
- st.visibility = VISIBLE;
- st.position = ABSOLUTE;
- function after(){
- fly(dom).fxUnwrap(wrap, r.pos, o);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- }
- pt = {to: [b.x, b.y]};
- bw = {to: b.width};
- bh = {to: b.height};
- function argCalc(wrap, style, ww, wh, sXY, sXYval, s1, s2, w, h, p){
- var ret = {};
- fly(wrap).setWidth(ww).setHeight(wh);
- if(fly(wrap)[sXY]){
- fly(wrap)[sXY](sXYval);
- }
- style[s1] = style[s2] = "0";
- if(w){
- ret.width = w
- };
- if(h){
- ret.height = h;
- }
- if(p){
- ret.points = p;
- }
- return ret;
- };
- args = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
- t : [wrap, st, b.width, 0, NULL, NULL, LEFT, BOTTOM, NULL, bh, NULL],
- l : [wrap, st, 0, b.height, NULL, NULL, RIGHT, TOP, bw, NULL, NULL],
- r : [wrap, st, b.width, b.height, SETX, b.right, LEFT, TOP, NULL, NULL, pt],
- b : [wrap, st, b.width, b.height, SETY, b.bottom, LEFT, TOP, NULL, bh, pt],
- tl : [wrap, st, 0, 0, NULL, NULL, RIGHT, BOTTOM, bw, bh, pt],
- bl : [wrap, st, 0, 0, SETY, b.y + b.height, RIGHT, TOP, bw, bh, pt],
- br : [wrap, st, 0, 0, SETXY, [b.right, b.bottom], LEFT, TOP, bw, bh, pt],
- tr : [wrap, st, 0, 0, SETX, b.x + b.width, LEFT, BOTTOM, bw, bh, pt]
- });
- st.visibility = VISIBLE;
- fly(wrap).show();
- arguments.callee.anim = fly(wrap).fxanim(args,
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
- slideOut : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- xy = me.getXY(),
- wrap,
- r,
- b,
- a,
- zero = {to: 0};
- anchor = anchor || "t";
- me.queueFx(o, function(){
- r = fly(dom).getFxRestore();
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight};
- b.right = b.x + b.width;
- b.bottom = b.y + b.height;
- fly(dom).setWidth(b.width).setHeight(b.height);
- wrap = fly(dom).fxWrap(r.pos, o, VISIBLE);
- st.visibility = VISIBLE;
- st.position = ABSOLUTE;
- fly(wrap).setWidth(b.width).setHeight(b.height);
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).fxUnwrap(wrap, r.pos, o);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- }
- function argCalc(style, s1, s2, p1, v1, p2, v2, p3, v3){
- var ret = {};
- style[s1] = style[s2] = "0";
- ret[p1] = v1;
- if(p2){
- ret[p2] = v2;
- }
- if(p3){
- ret[p3] = v3;
- }
- return ret;
- };
- a = fly(dom).switchStatements(anchor.toLowerCase(), argCalc, {
- t : [st, LEFT, BOTTOM, HEIGHT, zero],
- l : [st, RIGHT, TOP, WIDTH, zero],
- r : [st, LEFT, TOP, WIDTH, zero, POINTS, {to : [b.right, b.y]}],
- b : [st, LEFT, TOP, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
- tl : [st, RIGHT, BOTTOM, WIDTH, zero, HEIGHT, zero],
- bl : [st, RIGHT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x, b.bottom]}],
- br : [st, LEFT, TOP, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.x + b.width, b.bottom]}],
- tr : [st, LEFT, BOTTOM, WIDTH, zero, HEIGHT, zero, POINTS, {to : [b.right, b.y]}]
- });
- arguments.callee.anim = fly(wrap).fxanim(a,
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
- puff : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- width,
- height,
- r;
- me.queueFx(o, function(){
- width = fly(dom).getWidth();
- height = fly(dom).getHeight();
- fly(dom).clearOpacity();
- fly(dom).show();
- r = fly(dom).getFxRestore();
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- st.fontSize = '';
- fly(dom).afterFx(o);
- }
- arguments.callee.anim = fly(dom).fxanim({
- width : {to : fly(dom).adjustWidth(width * 2)},
- height : {to : fly(dom).adjustHeight(height * 2)},
- points : {by : [-width * .5, -height * .5]},
- opacity : {to : 0},
- fontSize: {to : 200, unit: "%"}
- },
- o,
- MOTION,
- .5,
- EASEOUT,
- after);
- });
- return me;
- },
- switchOff : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- r;
- me.queueFx(o, function(){
- fly(dom).clearOpacity();
- fly(dom).clip();
- r = fly(dom).getFxRestore();
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- };
- fly(dom).fxanim({opacity : {to : 0.3}},
- NULL,
- NULL,
- .1,
- NULL,
- function(){
- fly(dom).clearOpacity();
- (function(){
- fly(dom).fxanim({
- height : {to : 1},
- points : {by : [0, fly(dom).getHeight() * .5]}
- },
- o,
- MOTION,
- 0.3,
- 'easeIn',
- after);
- }).defer(100);
- });
- });
- return me;
- },
- highlight : function(color, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- attr = o.attr || "backgroundColor",
- a = {},
- restore;
- me.queueFx(o, function(){
- fly(dom).clearOpacity();
- fly(dom).show();
- function after(){
- dom.style[attr] = restore;
- fly(dom).afterFx(o);
- }
- restore = dom.style[attr];
- a[attr] = {from: color || "ffff9c", to: o.endColor || fly(dom).getColor(attr) || "ffffff"};
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- 'color',
- 1,
- 'easeIn',
- after);
- });
- return me;
- },
- frame : function(color, count, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- proxy,
- active;
- me.queueFx(o, function(){
- color = color || '#C3DAF9';
- if(color.length == 6){
- color = '#' + color;
- }
- count = count || 1;
- fly(dom).show();
- var xy = fly(dom).getXY(),
- b = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: dom.offsetWidth, height: dom.offsetHeight},
- queue = function(){
- proxy = fly(document.body || document.documentElement).createChild({
- style:{
- position : ABSOLUTE,
- 'z-index': 35000,
- border : '0px solid ' + color
- }
- });
- return proxy.queueFx({}, animFn);
- };
- arguments.callee.anim = {
- isAnimated: true,
- stop: function() {
- count = 0;
- proxy.stopFx();
- }
- };
- function animFn(){
- var scale = Ext.isBorderBox ? 2 : 1;
- active = proxy.anim({
- top : {from : b.y, to : b.y - 20},
- left : {from : b.x, to : b.x - 20},
- borderWidth : {from : 0, to : 10},
- opacity : {from : 1, to : 0},
- height : {from : b.height, to : b.height + 20 * scale},
- width : {from : b.width, to : b.width + 20 * scale}
- },{
- duration: o.duration || 1,
- callback: function() {
- proxy.remove();
- --count > 0 ? queue() : fly(dom).afterFx(o);
- }
- });
- arguments.callee.anim = {
- isAnimated: true,
- stop: function(){
- active.stop();
- }
- };
- };
- queue();
- });
- return me;
- },
- pause : function(seconds){
- var dom = this.dom,
- t;
- this.queueFx({}, function(){
- t = setTimeout(function(){
- fly(dom).afterFx({});
- }, seconds * 1000);
- arguments.callee.anim = {
- isAnimated: true,
- stop: function(){
- clearTimeout(t);
- fly(dom).afterFx({});
- }
- };
- });
- return this;
- },
- fadeIn : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- to = o.endOpacity || 1;
- me.queueFx(o, function(){
- fly(dom).setOpacity(0);
- fly(dom).fixDisplay();
- dom.style.visibility = VISIBLE;
- arguments.callee.anim = fly(dom).fxanim({opacity:{to:to}},
- o, NULL, .5, EASEOUT, function(){
- if(to == 1){
- fly(dom).clearOpacity();
- }
- fly(dom).afterFx(o);
- });
- });
- return me;
- },
- fadeOut : function(o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- style = dom.style,
- to = o.endOpacity || 0;
- me.queueFx(o, function(){
- arguments.callee.anim = fly(dom).fxanim({
- opacity : {to : to}},
- o,
- NULL,
- .5,
- EASEOUT,
- function(){
- if(to == 0){
- Ext.Element.data(dom, 'visibilityMode') == Ext.Element.DISPLAY || o.useDisplay ?
- style.display = "none" :
- style.visibility = HIDDEN;
- fly(dom).clearOpacity();
- }
- fly(dom).afterFx(o);
- });
- });
- return me;
- },
- scale : function(w, h, o){
- this.shift(Ext.apply({}, o, {
- width: w,
- height: h
- }));
- return this;
- },
- shift : function(o){
- o = getObject(o);
- var dom = this.dom,
- a = {};
- this.queueFx(o, function(){
- for (var prop in o) {
- if (o[prop] != UNDEFINED) {
- a[prop] = {to : o[prop]};
- }
- }
- a.width ? a.width.to = fly(dom).adjustWidth(o.width) : a;
- a.height ? a.height.to = fly(dom).adjustWidth(o.height) : a;
- if (a.x || a.y || a.xy) {
- a.points = a.xy ||
- {to : [ a.x ? a.x.to : fly(dom).getX(),
- a.y ? a.y.to : fly(dom).getY()]};
- }
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- MOTION,
- .35,
- EASEOUT,
- function(){
- fly(dom).afterFx(o);
- });
- });
- return this;
- },
- ghost : function(anchor, o){
- o = getObject(o);
- var me = this,
- dom = me.dom,
- st = dom.style,
- a = {opacity: {to: 0}, points: {}},
- pt = a.points,
- r,
- w,
- h;
- anchor = anchor || "b";
- me.queueFx(o, function(){
- r = fly(dom).getFxRestore();
- w = fly(dom).getWidth();
- h = fly(dom).getHeight();
- function after(){
- o.useDisplay ? fly(dom).setDisplayed(FALSE) : fly(dom).hide();
- fly(dom).clearOpacity();
- fly(dom).setPositioning(r.pos);
- st.width = r.width;
- st.height = r.height;
- fly(dom).afterFx(o);
- }
- pt.by = fly(dom).switchStatements(anchor.toLowerCase(), function(v1,v2){ return [v1, v2];}, {
- t : [0, -h],
- l : [-w, 0],
- r : [w, 0],
- b : [0, h],
- tl : [-w, -h],
- bl : [-w, h],
- br : [w, h],
- tr : [w, -h]
- });
- arguments.callee.anim = fly(dom).fxanim(a,
- o,
- MOTION,
- .5,
- EASEOUT, after);
- });
- return me;
- },
- syncFx : function(){
- var me = this;
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
- block : FALSE,
- concurrent : TRUE,
- stopFx : FALSE
- });
- return me;
- },
- sequenceFx : function(){
- var me = this;
- me.fxDefaults = Ext.apply(me.fxDefaults || {}, {
- block : FALSE,
- concurrent : FALSE,
- stopFx : FALSE
- });
- return me;
- },
- nextFx : function(){
- var ef = getQueue(this.dom.id)[0];
- if(ef){
- ef.call(this);
- }
- },
- hasActiveFx : function(){
- return getQueue(this.dom.id)[0];
- },
- stopFx : function(finish){
- var me = this,
- id = me.dom.id;
- if(me.hasActiveFx()){
- var cur = getQueue(id)[0];
- if(cur && cur.anim){
- if(cur.anim.isAnimated){
- setQueue(id, [cur]);
- cur.anim.stop(finish !== undefined ? finish : TRUE);
- }else{
- setQueue(id, []);
- }
- }
- }
- return me;
- },
- beforeFx : function(o){
- if(this.hasActiveFx() && !o.concurrent){
- if(o.stopFx){
- this.stopFx();
- return TRUE;
- }
- return FALSE;
- }
- return TRUE;
- },
- hasFxBlock : function(){
- var q = getQueue(this.dom.id);
- return q && q[0] && q[0].block;
- },
- queueFx : function(o, fn){
- var me = fly(this.dom);
- if(!me.hasFxBlock()){
- Ext.applyIf(o, me.fxDefaults);
- if(!o.concurrent){
- var run = me.beforeFx(o);
- fn.block = o.block;
- getQueue(me.dom.id).push(fn);
- if(run){
- me.nextFx();
- }
- }else{
- fn.call(me);
- }
- }
- return me;
- },
- fxWrap : function(pos, o, vis){
- var dom = this.dom,
- wrap,
- wrapXY;
- if(!o.wrap || !(wrap = Ext.getDom(o.wrap))){
- if(o.fixPosition){
- wrapXY = fly(dom).getXY();
- }
- var div = document.createElement("div");
- div.style.visibility = vis;
- wrap = dom.parentNode.insertBefore(div, dom);
- fly(wrap).setPositioning(pos);
- if(fly(wrap).isStyle(POSITION, "static")){
- fly(wrap).position("relative");
- }
- fly(dom).clearPositioning('auto');
- fly(wrap).clip();
- wrap.appendChild(dom);
- if(wrapXY){
- fly(wrap).setXY(wrapXY);
- }
- }
- return wrap;
- },
- fxUnwrap : function(wrap, pos, o){
- var dom = this.dom;
- fly(dom).clearPositioning();
- fly(dom).setPositioning(pos);
- if(!o.wrap){
- var pn = fly(wrap).dom.parentNode;
- pn.insertBefore(dom, wrap);
- fly(wrap).remove();
- }
- },
- getFxRestore : function(){
- var st = this.dom.style;
- return {pos: this.getPositioning(), width: st.width, height : st.height};
- },
- afterFx : function(o){
- var dom = this.dom,
- id = dom.id;
- if(o.afterStyle){
- fly(dom).setStyle(o.afterStyle);
- }
- if(o.afterCls){
- fly(dom).addClass(o.afterCls);
- }
- if(o.remove == TRUE){
- fly(dom).remove();
- }
- if(o.callback){
- o.callback.call(o.scope, fly(dom));
- }
- if(!o.concurrent){
- getQueue(id).shift();
- fly(dom).nextFx();
- }
- },
- fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
- animType = animType || 'run';
- opt = opt || {};
- var anim = Ext.lib.Anim[animType](
- this.dom,
- args,
- (opt.duration || defaultDur) || .35,
- (opt.easing || defaultEase) || EASEOUT,
- cb,
- this
- );
- opt.anim = anim;
- return anim;
- }
- };
- Ext.Fx.resize = Ext.Fx.scale;
- Ext.Element.addMethods(Ext.Fx);
- })();
- Ext.CompositeElementLite = function(els, root){
- this.elements = [];
- this.add(els, root);
- this.el = new Ext.Element.Flyweight();
- };
- Ext.CompositeElementLite.prototype = {
- isComposite: true,
- getElement : function(el){
- var e = this.el;
- e.dom = el;
- e.id = el.id;
- return e;
- },
- transformElement : function(el){
- return Ext.getDom(el);
- },
- getCount : function(){
- return this.elements.length;
- },
- add : function(els, root){
- var me = this,
- elements = me.elements;
- if(!els){
- return this;
- }
- if(Ext.isString(els)){
- els = Ext.Element.selectorFunction(els, root);
- }else if(els.isComposite){
- els = els.elements;
- }else if(!Ext.isIterable(els)){
- els = [els];
- }
- for(var i = 0, len = els.length; i < len; ++i){
- elements.push(me.transformElement(els[i]));
- }
- return me;
- },
- invoke : function(fn, args){
- var me = this,
- els = me.elements,
- len = els.length,
- e;
- for(i = 0; i<len; i++) {
- e = els[i];
- if(e){
- Ext.Element.prototype[fn].apply(me.getElement(e), args);
- }
- }
- return me;
- },
- item : function(index){
- var me = this,
- el = me.elements[index],
- out = null;
- if(el){
- out = me.getElement(el);
- }
- return out;
- },
- addListener : function(eventName, handler, scope, opt){
- var els = this.elements,
- len = els.length,
- i, e;
- for(i = 0; i<len; i++) {
- e = els[i];
- if(e) {
- Ext.EventManager.on(e, eventName, handler, scope || e, opt);
- }
- }
- return this;
- },
- each : function(fn, scope){
- var me = this,
- els = me.elements,
- len = els.length,
- i, e;
- for(i = 0; i<len; i++) {
- e = els[i];
- if(e){
- e = this.getElement(e);
- if(fn.call(scope || e, e, me, i)){
- break;
- }
- }
- }
- return me;
- },
- fill : function(els){
- var me = this;
- me.elements = [];
- me.add(els);
- return me;
- },
- filter : function(selector){
- var els = [],
- me = this,
- elements = me.elements,
- fn = Ext.isFunction(selector) ? selector
- : function(el){
- return el.is(selector);
- };
- me.each(function(el, self, i){
- if(fn(el, i) !== false){
- els[els.length] = me.transformElement(el);
- }
- });
- me.elements = els;
- return me;
- },
- indexOf : function(el){
- return this.elements.indexOf(this.transformElement(el));
- },
- replaceElement : function(el, replacement, domReplace){
- var index = !isNaN(el) ? el : this.indexOf(el),
- d;
- if(index > -1){
- replacement = Ext.getDom(replacement);
- if(domReplace){
- d = this.elements[index];
- d.parentNode.insertBefore(replacement, d);
- Ext.removeNode(d);
- }
- this.elements.splice(index, 1, replacement);
- }
- return this;
- },
- clear : function(){
- this.elements = [];
- }
- };
- Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
- (function(){
- var fnName,
- ElProto = Ext.Element.prototype,
- CelProto = Ext.CompositeElementLite.prototype;
- for(fnName in ElProto){
- if(Ext.isFunction(ElProto[fnName])){
- (function(fnName){
- CelProto[fnName] = CelProto[fnName] || function(){
- return this.invoke(fnName, arguments);
- };
- }).call(CelProto, fnName);
- }
- }
- })();
- if(Ext.DomQuery){
- Ext.Element.selectorFunction = Ext.DomQuery.select;
- }
- Ext.Element.select = function(selector, root){
- var els;
- if(typeof selector == "string"){
- els = Ext.Element.selectorFunction(selector, root);
- }else if(selector.length !== undefined){
- els = selector;
- }else{
- throw "Invalid selector";
- }
- return new Ext.CompositeElementLite(els);
- };
- Ext.select = Ext.Element.select;
- Ext.apply(Ext.CompositeElementLite.prototype, {
- addElements : function(els, root){
- if(!els){
- return this;
- }
- if(typeof els == "string"){
- els = Ext.Element.selectorFunction(els, root);
- }
- var yels = this.elements;
- Ext.each(els, function(e) {
- yels.push(Ext.get(e));
- });
- return this;
- },
- first : function(){
- return this.item(0);
- },
- last : function(){
- return this.item(this.getCount()-1);
- },
- contains : function(el){
- return this.indexOf(el) != -1;
- },
- removeElement : function(keys, removeDom){
- var me = this,
- els = this.elements,
- el;
- Ext.each(keys, function(val){
- if ((el = (els[val] || els[val = me.indexOf(val)]))) {
- if(removeDom){
- if(el.dom){
- el.remove();
- }else{
- Ext.removeNode(el);
- }
- }
- els.splice(val, 1);
- }
- });
- return this;
- }
- });
- Ext.CompositeElement = function(els, root){
- this.elements = [];
- this.add(els, root);
- };
- Ext.extend(Ext.CompositeElement, Ext.CompositeElementLite, {
- getElement : function(el){
- return el;
- },
- transformElement : function(el){
- return Ext.get(el);
- }
- });
- Ext.Element.select = function(selector, unique, root){
- var els;
- if(typeof selector == "string"){
- els = Ext.Element.selectorFunction(selector, root);
- }else if(selector.length !== undefined){
- els = selector;
- }else{
- throw "Invalid selector";
- }
- return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
- };
- Ext.select = Ext.Element.select;(function(){
- var BEFOREREQUEST = "beforerequest",
- REQUESTCOMPLETE = "requestcomplete",
- REQUESTEXCEPTION = "requestexception",
- UNDEFINED = undefined,
- LOAD = 'load',
- POST = 'POST',
- GET = 'GET',
- WINDOW = window;
- Ext.data.Connection = function(config){
- Ext.apply(this, config);
- this.addEvents(
- BEFOREREQUEST,
- REQUESTCOMPLETE,
- REQUESTEXCEPTION
- );
- Ext.data.Connection.superclass.constructor.call(this);
- };
- Ext.extend(Ext.data.Connection, Ext.util.Observable, {
- timeout : 30000,
- autoAbort:false,
- disableCaching: true,
- disableCachingParam: '_dc',
- request : function(o){
- var me = this;
- if(me.fireEvent(BEFOREREQUEST, me, o)){
- if (o.el) {
- if(!Ext.isEmpty(o.indicatorText)){
- me.indicatorText = '<div class="loading-indicator">'+o.indicatorText+"</div>";
- }
- if(me.indicatorText) {
- Ext.getDom(o.el).innerHTML = me.indicatorText;
- }
- o.success = (Ext.isFunction(o.success) ? o.success : function(){}).createInterceptor(function(response) {
- Ext.getDom(o.el).innerHTML = response.responseText;
- });
- }
- var p = o.params,
- url = o.url || me.url,
- method,
- cb = {success: me.handleResponse,
- failure: me.handleFailure,
- scope: me,
- argument: {options: o},
- timeout : o.timeout || me.timeout
- },
- form,
- serForm;
- if (Ext.isFunction(p)) {
- p = p.call(o.scope||WINDOW, o);
- }
- p = Ext.urlEncode(me.extraParams, Ext.isObject(p) ? Ext.urlEncode(p) : p);
- if (Ext.isFunction(url)) {
- url = url.call(o.scope || WINDOW, o);
- }
- if((form = Ext.getDom(o.form))){
- url = url || form.action;
- if(o.isUpload || /multipart/form-data/i.test(form.getAttribute("enctype"))) {
- return me.doFormUpload.call(me, o, p, url);
- }
- serForm = Ext.lib.Ajax.serializeForm(form);
- p = p ? (p + '&' + serForm) : serForm;
- }
- method = o.method || me.method || ((p || o.xmlData || o.jsonData) ? POST : GET);
- if(method === GET && (me.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
- var dcp = o.disableCachingParam || me.disableCachingParam;
- url = Ext.urlAppend(url, dcp + '=' + (new Date().getTime()));
- }
- o.headers = Ext.apply(o.headers || {}, me.defaultHeaders || {});
- if(o.autoAbort === true || me.autoAbort) {
- me.abort();
- }
- if((method == GET || o.xmlData || o.jsonData) && p){
- url = Ext.urlAppend(url, p);
- p = '';
- }
- return (me.transId = Ext.lib.Ajax.request(method, url, cb, p, o));
- }else{
- return o.callback ? o.callback.apply(o.scope, [o,UNDEFINED,UNDEFINED]) : null;
- }
- },
- isLoading : function(transId){
- return transId ? Ext.lib.Ajax.isCallInProgress(transId) : !! this.transId;
- },
- abort : function(transId){
- if(transId || this.isLoading()){
- Ext.lib.Ajax.abort(transId || this.transId);
- }
- },
- handleResponse : function(response){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent(REQUESTCOMPLETE, this, response, options);
- if(options.success){
- options.success.call(options.scope, response, options);
- }
- if(options.callback){
- options.callback.call(options.scope, options, true, response);
- }
- },
- handleFailure : function(response, e){
- this.transId = false;
- var options = response.argument.options;
- response.argument = options ? options.argument : null;
- this.fireEvent(REQUESTEXCEPTION, this, response, options, e);
- if(options.failure){
- options.failure.call(options.scope, response, options);
- }
- if(options.callback){
- options.callback.call(options.scope, options, false, response);
- }
- },
- doFormUpload : function(o, ps, url){
- var id = Ext.id(),
- doc = document,
- frame = doc.createElement('iframe'),
- form = Ext.getDom(o.form),
- hiddens = [],
- hd,
- encoding = 'multipart/form-data',
- buf = {
- target: form.target,
- method: form.method,
- encoding: form.encoding,
- enctype: form.enctype,
- action: form.action
- };
- Ext.fly(frame).set({
- id: id,
- name: id,
- cls: 'x-hidden',
- src: Ext.SSL_SECURE_URL
- });
- doc.body.appendChild(frame);
- if(Ext.isIE){
- document.frames[id].name = id;
- }
- Ext.fly(form).set({
- target: id,
- method: POST,
- enctype: encoding,
- encoding: encoding,
- action: url || buf.action
- });
- Ext.iterate(Ext.urlDecode(ps, false), function(k, v){
- hd = doc.createElement('input');
- Ext.fly(hd).set({
- type: 'hidden',
- value: v,
- name: k
- });
- form.appendChild(hd);
- hiddens.push(hd);
- });
- function cb(){
- var me = this,
- r = {responseText : '',
- responseXML : null,
- argument : o.argument},
- doc,
- firstChild;
- try{
- doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
- if(doc){
- if(doc.body){
- if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){
- r.responseText = firstChild.value;
- }else{
- r.responseText = doc.body.innerHTML;
- }
- }
- r.responseXML = doc.XMLDocument || doc;
- }
- }
- catch(e) {}
- Ext.EventManager.removeListener(frame, LOAD, cb, me);
- me.fireEvent(REQUESTCOMPLETE, me, r, o);
- function runCallback(fn, scope, args){
- if(Ext.isFunction(fn)){
- fn.apply(scope, args);
- }
- }
- runCallback(o.success, o.scope, [r, o]);
- runCallback(o.callback, o.scope, [o, true, r]);
- if(!me.debugUploads){
- setTimeout(function(){Ext.removeNode(frame);}, 100);
- }
- }
- Ext.EventManager.on(frame, LOAD, cb, this);
- form.submit();
- Ext.fly(form).set(buf);
- Ext.each(hiddens, function(h) {
- Ext.removeNode(h);
- });
- }
- });
- })();
- Ext.Ajax = new Ext.data.Connection({
- autoAbort : false,
- serializeForm : function(form){
- return Ext.lib.Ajax.serializeForm(form);
- }
- });
- Ext.UpdateManager = Ext.Updater = Ext.extend(Ext.util.Observable,
- function() {
- var BEFOREUPDATE = "beforeupdate",
- UPDATE = "update",
- FAILURE = "failure";
- function processSuccess(response){
- var me = this;
- me.transaction = null;
- if (response.argument.form && response.argument.reset) {
- try {
- response.argument.form.reset();
- } catch(e){}
- }
- if (me.loadScripts) {
- me.renderer.render(me.el, response, me,
- updateComplete.createDelegate(me, [response]));
- } else {
- me.renderer.render(me.el, response, me);
- updateComplete.call(me, response);
- }
- }
- function updateComplete(response, type, success){
- this.fireEvent(type || UPDATE, this.el, response);
- if(Ext.isFunction(response.argument.callback)){
- response.argument.callback.call(response.argument.scope, this.el, Ext.isEmpty(success) ? true : false, response, response.argument.options);
- }
- }
- function processFailure(response){
- updateComplete.call(this, response, FAILURE, !!(this.transaction = null));
- }
- return {
- constructor: function(el, forceNew){
- var me = this;
- el = Ext.get(el);
- if(!forceNew && el.updateManager){
- return el.updateManager;
- }
- me.el = el;
- me.defaultUrl = null;
- me.addEvents(
- BEFOREUPDATE,
- UPDATE,
- FAILURE
- );
- Ext.apply(me, Ext.Updater.defaults);
- me.transaction = null;
- me.refreshDelegate = me.refresh.createDelegate(me);
- me.updateDelegate = me.update.createDelegate(me);
- me.formUpdateDelegate = (me.formUpdate || function(){}).createDelegate(me);
- me.renderer = me.renderer || me.getDefaultRenderer();
- Ext.Updater.superclass.constructor.call(me);
- },
- setRenderer : function(renderer){
- this.renderer = renderer;
- },
- getRenderer : function(){
- return this.renderer;
- },
- getDefaultRenderer: function() {
- return new Ext.Updater.BasicRenderer();
- },
- setDefaultUrl : function(defaultUrl){
- this.defaultUrl = defaultUrl;
- },
- getEl : function(){
- return this.el;
- },
- update : function(url, params, callback, discardUrl){
- var me = this,
- cfg,
- callerScope;
- if(me.fireEvent(BEFOREUPDATE, me.el, url, params) !== false){
- if(Ext.isObject(url)){
- cfg = url;
- url = cfg.url;
- params = params || cfg.params;
- callback = callback || cfg.callback;
- discardUrl = discardUrl || cfg.discardUrl;
- callerScope = cfg.scope;
- if(!Ext.isEmpty(cfg.nocache)){me.disableCaching = cfg.nocache;};
- if(!Ext.isEmpty(cfg.text)){me.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
- if(!Ext.isEmpty(cfg.scripts)){me.loadScripts = cfg.scripts;};
- if(!Ext.isEmpty(cfg.timeout)){me.timeout = cfg.timeout;};
- }
- me.showLoading();
- if(!discardUrl){
- me.defaultUrl = url;
- }
- if(Ext.isFunction(url)){
- url = url.call(me);
- }
- var o = Ext.apply({}, {
- url : url,
- params: (Ext.isFunction(params) && callerScope) ? params.createDelegate(callerScope) : params,
- success: processSuccess,
- failure: processFailure,
- scope: me,
- callback: undefined,
- timeout: (me.timeout*1000),
- disableCaching: me.disableCaching,
- argument: {
- "options": cfg,
- "url": url,
- "form": null,
- "callback": callback,
- "scope": callerScope || window,
- "params": params
- }
- }, cfg);
- me.transaction = Ext.Ajax.request(o);
- }
- },
- formUpdate : function(form, url, reset, callback){
- var me = this;
- if(me.fireEvent(BEFOREUPDATE, me.el, form, url) !== false){
- if(Ext.isFunction(url)){
- url = url.call(me);
- }
- form = Ext.getDom(form)
- me.transaction = Ext.Ajax.request({
- form: form,
- url:url,
- success: processSuccess,
- failure: processFailure,
- scope: me,
- timeout: (me.timeout*1000),
- argument: {
- "url": url,
- "form": form,
- "callback": callback,
- "reset": reset
- }
- });
- me.showLoading.defer(1, me);
- }
- },
- startAutoRefresh : function(interval, url, params, callback, refreshNow){
- var me = this;
- if(refreshNow){
- me.update(url || me.defaultUrl, params, callback, true);
- }
- if(me.autoRefreshProcId){
- clearInterval(me.autoRefreshProcId);
- }
- me.autoRefreshProcId = setInterval(me.update.createDelegate(me, [url || me.defaultUrl, params, callback, true]), interval * 1000);
- },
- stopAutoRefresh : function(){
- if(this.autoRefreshProcId){
- clearInterval(this.autoRefreshProcId);
- delete this.autoRefreshProcId;
- }
- },
- isAutoRefreshing : function(){
- return !!this.autoRefreshProcId;
- },
- showLoading : function(){
- if(this.showLoadIndicator){
- this.el.dom.innerHTML = this.indicatorText;
- }
- },
- abort : function(){
- if(this.transaction){
- Ext.Ajax.abort(this.transaction);
- }
- },
- isUpdating : function(){
- return this.transaction ? Ext.Ajax.isLoading(this.transaction) : false;
- },
- refresh : function(callback){
- if(this.defaultUrl){
- this.update(this.defaultUrl, null, callback, true);
- }
- }
- }
- }());
- Ext.Updater.defaults = {
- timeout : 30,
- disableCaching : false,
- showLoadIndicator : true,
- indicatorText : '<div class="loading-indicator">Loading...</div>',
- loadScripts : false,
- sslBlankUrl : Ext.SSL_SECURE_URL
- };
- Ext.Updater.updateElement = function(el, url, params, options){
- var um = Ext.get(el).getUpdater();
- Ext.apply(um, options);
- um.update(url, params, options ? options.callback : null);
- };
- Ext.Updater.BasicRenderer = function(){};
- Ext.Updater.BasicRenderer.prototype = {
- render : function(el, response, updateManager, callback){
- el.update(response.responseText, updateManager.loadScripts, callback);
- }
- };
- (function() {
- Date.useStrict = false;
- function xf(format) {
- var args = Array.prototype.slice.call(arguments, 1);
- return format.replace(/{(d+)}/g, function(m, i) {
- return args[i];
- });
- }
- Date.formatCodeToRegex = function(character, currentGroup) {
- var p = Date.parseCodes[character];
- if (p) {
- p = typeof p == 'function'? p() : p;
- Date.parseCodes[character] = p;
- }
- return p? Ext.applyIf({
- c: p.c? xf(p.c, currentGroup || "{0}") : p.c
- }, p) : {
- g:0,
- c:null,
- s:Ext.escapeRe(character)
- }
- }
- var $f = Date.formatCodeToRegex;
- Ext.apply(Date, {
- parseFunctions: {
- "M$": function(input, strict) {
- var re = new RegExp('\/Date\(([-+])?(\d+)(?:[+-]\d{4})?\)\/');
- var r = (input || '').match(re);
- return r? new Date(((r[1] || '') + r[2]) * 1) : null;
- }
- },
- parseRegexes: [],
- formatFunctions: {
- "M$": function() {
- return '\/Date(' + this.getTime() + ')\/';
- }
- },
- y2kYear : 50,
- MILLI : "ms",
- SECOND : "s",
- MINUTE : "mi",
- HOUR : "h",
- DAY : "d",
- MONTH : "mo",
- YEAR : "y",
- defaults: {},
- dayNames : [
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
- ],
- monthNames : [
- "January",
- "February",
- "March",
- "April",
- "May",
- "June",
- "July",
- "August",
- "September",
- "October",
- "November",
- "December"
- ],
- monthNumbers : {
- Jan:0,
- Feb:1,
- Mar:2,
- Apr:3,
- May:4,
- Jun:5,
- Jul:6,
- Aug:7,
- Sep:8,
- Oct:9,
- Nov:10,
- Dec:11
- },
- getShortMonthName : function(month) {
- return Date.monthNames[month].substring(0, 3);
- },
- getShortDayName : function(day) {
- return Date.dayNames[day].substring(0, 3);
- },
- getMonthNumber : function(name) {
- return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
- },
- formatCodes : {
- d: "String.leftPad(this.getDate(), 2, '0')",
- D: "Date.getShortDayName(this.getDay())",
- j: "this.getDate()",
- l: "Date.dayNames[this.getDay()]",
- N: "(this.getDay() ? this.getDay() : 7)",
- S: "this.getSuffix()",
- w: "this.getDay()",
- z: "this.getDayOfYear()",
- W: "String.leftPad(this.getWeekOfYear(), 2, '0')",
- F: "Date.monthNames[this.getMonth()]",
- m: "String.leftPad(this.getMonth() + 1, 2, '0')",
- M: "Date.getShortMonthName(this.getMonth())",
- n: "(this.getMonth() + 1)",
- t: "this.getDaysInMonth()",
- L: "(this.isLeapYear() ? 1 : 0)",
- o: "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0)))",
- Y: "this.getFullYear()",
- y: "('' + this.getFullYear()).substring(2, 4)",
- a: "(this.getHours() < 12 ? 'am' : 'pm')",
- A: "(this.getHours() < 12 ? 'AM' : 'PM')",
- g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
- G: "this.getHours()",
- h: "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
- H: "String.leftPad(this.getHours(), 2, '0')",
- i: "String.leftPad(this.getMinutes(), 2, '0')",
- s: "String.leftPad(this.getSeconds(), 2, '0')",
- u: "String.leftPad(this.getMilliseconds(), 3, '0')",
- O: "this.getGMTOffset()",
- P: "this.getGMTOffset(true)",
- T: "this.getTimezone()",
- Z: "(this.getTimezoneOffset() * -60)",
- c: function() {
- for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
- var e = c.charAt(i);
- code.push(e == "T" ? "'T'" : Date.getFormatCode(e));
- }
- return code.join(" + ");
- },
- U: "Math.round(this.getTime() / 1000)"
- },
- isValid : function(y, m, d, h, i, s, ms) {
- h = h || 0;
- i = i || 0;
- s = s || 0;
- ms = ms || 0;
- var dt = new Date(y, m - 1, d, h, i, s, ms);
- return y == dt.getFullYear() &&
- m == dt.getMonth() + 1 &&
- d == dt.getDate() &&
- h == dt.getHours() &&
- i == dt.getMinutes() &&
- s == dt.getSeconds() &&
- ms == dt.getMilliseconds();
- },
- parseDate : function(input, format, strict) {
- var p = Date.parseFunctions;
- if (p[format] == null) {
- Date.createParser(format);
- }
- return p[format](input, Ext.isDefined(strict) ? strict : Date.useStrict);
- },
- getFormatCode : function(character) {
- var f = Date.formatCodes[character];
- if (f) {
- f = typeof f == 'function'? f() : f;
- Date.formatCodes[character] = f;
- }
- return f || ("'" + String.escape(character) + "'");
- },
- createFormat : function(format) {
- var code = [],
- special = false,
- ch = '';
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\") {
- special = true;
- } else if (special) {
- special = false;
- code.push("'" + String.escape(ch) + "'");
- } else {
- code.push(Date.getFormatCode(ch))
- }
- }
- Date.formatFunctions[format] = new Function("return " + code.join('+'));
- },
- createParser : function() {
- var code = [
- "var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
- "def = Date.defaults,",
- "results = String(input).match(Date.parseRegexes[{0}]);",
- "if(results){",
- "{1}",
- "if(u != null){",
- "v = new Date(u * 1000);",
- "}else{",
- "dt = (new Date()).clearTime();",
- "y = y >= 0? y : Ext.num(def.y, dt.getFullYear());",
- "m = m >= 0? m : Ext.num(def.m - 1, dt.getMonth());",
- "d = d >= 0? d : Ext.num(def.d, dt.getDate());",
- "h = h || Ext.num(def.h, dt.getHours());",
- "i = i || Ext.num(def.i, dt.getMinutes());",
- "s = s || Ext.num(def.s, dt.getSeconds());",
- "ms = ms || Ext.num(def.ms, dt.getMilliseconds());",
- "if(z >= 0 && y >= 0){",
- "v = new Date(y, 0, 1, h, i, s, ms);",
- "v = !strict? v : (strict === true && (z <= 364 || (v.isLeapYear() && z <= 365))? v.add(Date.DAY, z) : null);",
- "}else if(strict === true && !Date.isValid(y, m + 1, d, h, i, s, ms)){",
- "v = null;",
- "}else{",
- "v = new Date(y, m, d, h, i, s, ms);",
- "}",
- "}",
- "}",
- "if(v){",
- "if(zz != null){",
- "v = v.add(Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
- "}else if(o){",
- "v = v.add(Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
- "}",
- "}",
- "return v;"
- ].join('n');
- return function(format) {
- var regexNum = Date.parseRegexes.length,
- currentGroup = 1,
- calc = [],
- regex = [],
- special = false,
- ch = "";
- for (var i = 0; i < format.length; ++i) {
- ch = format.charAt(i);
- if (!special && ch == "\") {
- special = true;
- } else if (special) {
- special = false;
- regex.push(String.escape(ch));
- } else {
- var obj = $f(ch, currentGroup);
- currentGroup += obj.g;
- regex.push(obj.s);
- if (obj.g && obj.c) {
- calc.push(obj.c);
- }
- }
- }
- Date.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", "i");
- Date.parseFunctions[format] = new Function("input", "strict", xf(code, regexNum, calc.join('')));
- }
- }(),
- parseCodes : {
- d: {
- g:1,
- c:"d = parseInt(results[{0}], 10);n",
- s:"(\d{2})"
- },
- j: {
- g:1,
- c:"d = parseInt(results[{0}], 10);n",
- s:"(\d{1,2})"
- },
- D: function() {
- for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i);
- return {
- g:0,
- c:null,
- s:"(?:" + a.join("|") +")"
- }
- },
- l: function() {
- return {
- g:0,
- c:null,
- s:"(?:" + Date.dayNames.join("|") + ")"
- }
- },
- N: {
- g:0,
- c:null,
- s:"[1-7]"
- },
- S: {
- g:0,
- c:null,
- s:"(?:st|nd|rd|th)"
- },
- w: {
- g:0,
- c:null,
- s:"[0-6]"
- },
- z: {
- g:1,
- c:"z = parseInt(results[{0}], 10);n",
- s:"(\d{1,3})"
- },
- W: {
- g:0,
- c:null,
- s:"(?:\d{2})"
- },
- F: function() {
- return {
- g:1,
- c:"m = parseInt(Date.getMonthNumber(results[{0}]), 10);n",
- s:"(" + Date.monthNames.join("|") + ")"
- }
- },
- M: function() {
- for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i);
- return Ext.applyIf({
- s:"(" + a.join("|") + ")"
- }, $f("F"));
- },
- m: {
- g:1,
- c:"m = parseInt(results[{0}], 10) - 1;n",
- s:"(\d{2})"
- },
- n: {
- g:1,
- c:"m = parseInt(results[{0}], 10) - 1;n",
- s:"(\d{1,2})"
- },
- t: {
- g:0,
- c:null,
- s:"(?:\d{2})"
- },
- L: {
- g:0,
- c:null,
- s:"(?:1|0)"
- },
- o: function() {
- return $f("Y");
- },
- Y: {
- g:1,
- c:"y = parseInt(results[{0}], 10);n",
- s:"(\d{4})"
- },
- y: {
- g:1,
- c:"var ty = parseInt(results[{0}], 10);n"
- + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;n",
- s:"(\d{1,2})"
- },
- a: {
- g:1,
- c:"if (results[{0}] == 'am') {n"
- + "if (!h || h == 12) { h = 0; }n"
- + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
- s:"(am|pm)"
- },
- A: {
- g:1,
- c:"if (results[{0}] == 'AM') {n"
- + "if (!h || h == 12) { h = 0; }n"
- + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
- s:"(AM|PM)"
- },
- g: function() {
- return $f("G");
- },
- G: {
- g:1,
- c:"h = parseInt(results[{0}], 10);n",
- s:"(\d{1,2})"
- },
- h: function() {
- return $f("H");
- },
- H: {
- g:1,
- c:"h = parseInt(results[{0}], 10);n",
- s:"(\d{2})"
- },
- i: {
- g:1,
- c:"i = parseInt(results[{0}], 10);n",
- s:"(\d{2})"
- },
- s: {
- g:1,
- c:"s = parseInt(results[{0}], 10);n",
- s:"(\d{2})"
- },
- u: {
- g:1,
- c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);n",
- s:"(\d+)"
- },
- O: {
- g:1,
- c:[
- "o = results[{0}];",
- "var sn = o.substring(0,1),",
- "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
- "mn = o.substring(3,5) % 60;",
- "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;n"
- ].join("n"),
- s: "([+-]\d{4})"
- },
- P: {
- g:1,
- c:[
- "o = results[{0}];",
- "var sn = o.substring(0,1),",
- "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
- "mn = o.substring(4,6) % 60;",
- "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;n"
- ].join("n"),
- s: "([+-]\d{2}:\d{2})"
- },
- T: {
- g:0,
- c:null,
- s:"[A-Z]{1,4}"
- },
- Z: {
- g:1,
- c:"zz = results[{0}] * 1;n"
- + "zz = (-43200 <= zz && zz <= 50400)? zz : null;n",
- s:"([+-]?\d{1,5})"
- },
- c: function() {
- var calc = [],
- arr = [
- $f("Y", 1),
- $f("m", 2),
- $f("d", 3),
- $f("h", 4),
- $f("i", 5),
- $f("s", 6),
- {c:"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);n"},
- {c:[
- "if(results[8]) {",
- "if(results[8] == 'Z'){",
- "zz = 0;",
- "}else if (results[8].indexOf(':') > -1){",
- $f("P", 8).c,
- "}else{",
- $f("O", 8).c,
- "}",
- "}"
- ].join('n')}
- ];
- for (var i = 0, l = arr.length; i < l; ++i) {
- calc.push(arr[i].c);
- }
- return {
- g:1,
- c:calc.join(""),
- s:[
- arr[0].s,
- "(?:", "-", arr[1].s,
- "(?:", "-", arr[2].s,
- "(?:",
- "(?:T| )?",
- arr[3].s, ":", arr[4].s,
- "(?::", arr[5].s, ")?",
- "(?:(?:\.|,)(\d+))?",
- "(Z|(?:[-+]\d{2}(?::)?\d{2}))?",
- ")?",
- ")?",
- ")?"
- ].join("")
- }
- },
- U: {
- g:1,
- c:"u = parseInt(results[{0}], 10);n",
- s:"(-?\d+)"
- }
- }
- });
- }());
- Ext.apply(Date.prototype, {
- dateFormat : function(format) {
- if (Date.formatFunctions[format] == null) {
- Date.createFormat(format);
- }
- return Date.formatFunctions[format].call(this);
- },
- getTimezone : function() {
- return this.toString().replace(/^.* (?:((.*))|([A-Z]{1,4})(?:[-+][0-9]{4})?(?: -?d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
- },
- getGMTOffset : function(colon) {
- return (this.getTimezoneOffset() > 0 ? "-" : "+")
- + String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset()) / 60), 2, "0")
- + (colon ? ":" : "")
- + String.leftPad(Math.abs(this.getTimezoneOffset() % 60), 2, "0");
- },
- getDayOfYear: function() {
- var num = 0,
- d = this.clone(),
- m = this.getMonth(),
- i;
- for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {
- num += d.getDaysInMonth();
- }
- return num + this.getDate() - 1;
- },
- getWeekOfYear : function() {
- var ms1d = 864e5,
- ms7d = 7 * ms1d;
- return function() {
- var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d,
- AWN = Math.floor(DC3 / 7),
- Wyr = new Date(AWN * ms7d).getUTCFullYear();
- return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
- }
- }(),
- isLeapYear : function() {
- var year = this.getFullYear();
- return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
- },
- getFirstDayOfMonth : function() {
- var day = (this.getDay() - (this.getDate() - 1)) % 7;
- return (day < 0) ? (day + 7) : day;
- },
- getLastDayOfMonth : function() {
- return this.getLastDateOfMonth().getDay();
- },
- getFirstDateOfMonth : function() {
- return new Date(this.getFullYear(), this.getMonth(), 1);
- },
- getLastDateOfMonth : function() {
- return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
- },
- getDaysInMonth: function() {
- var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- return function() {
- var m = this.getMonth();
- return m == 1 && this.isLeapYear() ? 29 : daysInMonth[m];
- }
- }(),
- getSuffix : function() {
- switch (this.getDate()) {
- case 1:
- case 21:
- case 31:
- return "st";
- case 2:
- case 22:
- return "nd";
- case 3:
- case 23:
- return "rd";
- default:
- return "th";
- }
- },
- clone : function() {
- return new Date(this.getTime());
- },
- isDST : function() {
- return new Date(this.getFullYear(), 0, 1).getTimezoneOffset() != this.getTimezoneOffset();
- },
- clearTime : function(clone) {
- if (clone) {
- return this.clone().clearTime();
- }
- var d = this.getDate();
- this.setHours(0);
- this.setMinutes(0);
- this.setSeconds(0);
- this.setMilliseconds(0);
- if (this.getDate() != d) {
- for (var hr = 1, c = this.add(Date.HOUR, hr); c.getDate() != d; hr++, c = this.add(Date.HOUR, hr));
- this.setDate(d);
- this.setHours(c.getHours());
- }
- return this;
- },
- add : function(interval, value) {
- var d = this.clone();
- if (!interval || value === 0) return d;
- switch(interval.toLowerCase()) {
- case Date.MILLI:
- d.setMilliseconds(this.getMilliseconds() + value);
- break;
- case Date.SECOND:
- d.setSeconds(this.getSeconds() + value);
- break;
- case Date.MINUTE:
- d.setMinutes(this.getMinutes() + value);
- break;
- case Date.HOUR:
- d.setHours(this.getHours() + value);
- break;
- case Date.DAY:
- d.setDate(this.getDate() + value);
- break;
- case Date.MONTH:
- var day = this.getDate();
- if (day > 28) {
- day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
- }
- d.setDate(day);
- d.setMonth(this.getMonth() + value);
- break;
- case Date.YEAR:
- d.setFullYear(this.getFullYear() + value);
- break;
- }
- return d;
- },
- between : function(start, end) {
- var t = this.getTime();
- return start.getTime() <= t && t <= end.getTime();
- }
- });
- Date.prototype.format = Date.prototype.dateFormat;
- if (Ext.isSafari && (navigator.userAgent.match(/WebKit/(d+)/)[1] || NaN) < 420) {
- Ext.apply(Date.prototype, {
- _xMonth : Date.prototype.setMonth,
- _xDate : Date.prototype.setDate,
- setMonth : function(num) {
- if (num <= -1) {
- var n = Math.ceil(-num),
- back_year = Math.ceil(n / 12),
- month = (n % 12) ? 12 - n % 12 : 0;
- this.setFullYear(this.getFullYear() - back_year);
- return this._xMonth(month);
- } else {
- return this._xMonth(num);
- }
- },
- setDate : function(d) {
- return this.setTime(this.getTime() - (this.getDate() - d) * 864e5);
- }
- });
- }
- Ext.util.MixedCollection = function(allowFunctions, keyFn){
- this.items = [];
- this.map = {};
- this.keys = [];
- this.length = 0;
- this.addEvents(
- 'clear',
- 'add',
- 'replace',
- 'remove',
- 'sort'
- );
- this.allowFunctions = allowFunctions === true;
- if(keyFn){
- this.getKey = keyFn;
- }
- Ext.util.MixedCollection.superclass.constructor.call(this);
- };
- Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {
- allowFunctions : false,
- add : function(key, o){
- if(arguments.length == 1){
- o = arguments[0];
- key = this.getKey(o);
- }
- if(typeof key != 'undefined' && key !== null){
- var old = this.map[key];
- if(typeof old != 'undefined'){
- return this.replace(key, o);
- }
- this.map[key] = o;
- }
- this.length++;
- this.items.push(o);
- this.keys.push(key);
- this.fireEvent('add', this.length-1, o, key);
- return o;
- },
- getKey : function(o){
- return o.id;
- },
- replace : function(key, o){
- if(arguments.length == 1){
- o = arguments[0];
- key = this.getKey(o);
- }
- var old = this.map[key];
- if(typeof key == 'undefined' || key === null || typeof old == 'undefined'){
- return this.add(key, o);
- }
- var index = this.indexOfKey(key);
- this.items[index] = o;
- this.map[key] = o;
- this.fireEvent('replace', key, old, o);
- return o;
- },
- addAll : function(objs){
- if(arguments.length > 1 || Ext.isArray(objs)){
- var args = arguments.length > 1 ? arguments : objs;
- for(var i = 0, len = args.length; i < len; i++){
- this.add(args[i]);
- }
- }else{
- for(var key in objs){
- if(this.allowFunctions || typeof objs[key] != 'function'){
- this.add(key, objs[key]);
- }
- }
- }
- },
- each : function(fn, scope){
- var items = [].concat(this.items);
- for(var i = 0, len = items.length; i < len; i++){
- if(fn.call(scope || items[i], items[i], i, len) === false){
- break;
- }
- }
- },
- eachKey : function(fn, scope){
- for(var i = 0, len = this.keys.length; i < len; i++){
- fn.call(scope || window, this.keys[i], this.items[i], i, len);
- }
- },
- find : function(fn, scope){
- for(var i = 0, len = this.items.length; i < len; i++){
- if(fn.call(scope || window, this.items[i], this.keys[i])){
- return this.items[i];
- }
- }
- return null;
- },
- insert : function(index, key, o){
- if(arguments.length == 2){
- o = arguments[1];
- key = this.getKey(o);
- }
- if(this.containsKey(key)){
- this.suspendEvents();
- this.removeKey(key);
- this.resumeEvents();
- }
- if(index >= this.length){
- return this.add(key, o);
- }
- this.length++;
- this.items.splice(index, 0, o);
- if(typeof key != 'undefined' && key !== null){
- this.map[key] = o;
- }
- this.keys.splice(index, 0, key);
- this.fireEvent('add', index, o, key);
- return o;
- },
- remove : function(o){
- return this.removeAt(this.indexOf(o));
- },
- removeAt : function(index){
- if(index < this.length && index >= 0){
- this.length--;
- var o = this.items[index];
- this.items.splice(index, 1);
- var key = this.keys[index];
- if(typeof key != 'undefined'){
- delete this.map[key];
- }
- this.keys.splice(index, 1);
- this.fireEvent('remove', o, key);
- return o;
- }
- return false;
- },
- removeKey : function(key){
- return this.removeAt(this.indexOfKey(key));
- },
- getCount : function(){
- return this.length;
- },
- indexOf : function(o){
- return this.items.indexOf(o);
- },
- indexOfKey : function(key){
- return this.keys.indexOf(key);
- },
- item : function(key){
- var mk = this.map[key],
- item = mk !== undefined ? mk : (typeof key == 'number') ? this.items[key] : undefined;
- return !Ext.isFunction(item) || this.allowFunctions ? item : null;
- },
- itemAt : function(index){
- return this.items[index];
- },
- key : function(key){
- return this.map[key];
- },
- contains : function(o){
- return this.indexOf(o) != -1;
- },
- containsKey : function(key){
- return typeof this.map[key] != 'undefined';
- },
- clear : function(){
- this.length = 0;
- this.items = [];
- this.keys = [];
- this.map = {};
- this.fireEvent('clear');
- },
- first : function(){
- return this.items[0];
- },
- last : function(){
- return this.items[this.length-1];
- },
- _sort : function(property, dir, fn){
- var i,
- len,
- dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
- c = [], k = this.keys, items = this.items;
- fn = fn || function(a, b){
- return a-b;
- };
- for(i = 0, len = items.length; i < len; i++){
- c[c.length] = {key: k[i], value: items[i], index: i};
- }
- c.sort(function(a, b){
- var v = fn(a[property], b[property]) * dsc;
- if(v === 0){
- v = (a.index < b.index ? -1 : 1);
- }
- return v;
- });
- for(i = 0, len = c.length; i < len; i++){
- items[i] = c[i].value;
- k[i] = c[i].key;
- }
- this.fireEvent('sort', this);
- },
- sort : function(dir, fn){
- this._sort('value', dir, fn);
- },
- keySort : function(dir, fn){
- this._sort('key', dir, fn || function(a, b){
- var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();
- return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
- });
- },
- getRange : function(start, end){
- var items = this.items;
- if(items.length < 1){
- return [];
- }
- start = start || 0;
- end = Math.min(typeof end == 'undefined' ? this.length-1 : end, this.length-1);
- var i, r = [];
- if(start <= end){
- for(i = start; i <= end; i++) {
- r[r.length] = items[i];
- }
- }else{
- for(i = start; i >= end; i--) {
- r[r.length] = items[i];
- }
- }
- return r;
- },
- filter : function(property, value, anyMatch, caseSensitive){
- if(Ext.isEmpty(value, false)){
- return this.clone();
- }
- value = this.createValueMatcher(value, anyMatch, caseSensitive);
- return this.filterBy(function(o){
- return o && value.test(o[property]);
- });
- },
- filterBy : function(fn, scope){
- var r = new Ext.util.MixedCollection();
- r.getKey = this.getKey;
- var k = this.keys, it = this.items;
- for(var i = 0, len = it.length; i < len; i++){
- if(fn.call(scope||this, it[i], k[i])){
- r.add(k[i], it[i]);
- }
- }
- return r;
- },
- findIndex : function(property, value, start, anyMatch, caseSensitive){
- if(Ext.isEmpty(value, false)){
- return -1;
- }
- value = this.createValueMatcher(value, anyMatch, caseSensitive);
- return this.findIndexBy(function(o){
- return o && value.test(o[property]);
- }, null, start);
- },
- findIndexBy : function(fn, scope, start){
- var k = this.keys, it = this.items;
- for(var i = (start||0), len = it.length; i < len; i++){
- if(fn.call(scope||this, it[i], k[i])){
- return i;
- }
- }
- return -1;
- },
- createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {
- if (!value.exec) {
- var er = Ext.escapeRe;
- value = String(value);
- if (anyMatch === true) {
- value = er(value);
- } else {
- value = '^' + er(value);
- if (exactMatch === true) {
- value += '$';
- }
- }
- value = new RegExp(value, caseSensitive ? '' : 'i');
- }
- return value;
- },
- clone : function(){
- var r = new Ext.util.MixedCollection();
- var k = this.keys, it = this.items;
- for(var i = 0, len = it.length; i < len; i++){
- r.add(k[i], it[i]);
- }
- r.getKey = this.getKey;
- return r;
- }
- });
- Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
- Ext.util.JSON = new (function(){
- var useHasOwn = !!{}.hasOwnProperty,
- isNative = function() {
- var useNative = null;
- return function() {
- if (useNative === null) {
- useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
- }
- return useNative;
- };
- }(),
- pad = function(n) {
- return n < 10 ? "0" + n : n;
- },
- doDecode = function(json){
- return eval("(" + json + ')');
- },
- doEncode = function(o){
- if(!Ext.isDefined(o) || o === null){
- return "null";
- }else if(Ext.isArray(o)){
- return encodeArray(o);
- }else if(Ext.isDate(o)){
- return Ext.util.JSON.encodeDate(o);
- }else if(Ext.isString(o)){
- return encodeString(o);
- }else if(typeof o == "number"){
- return isFinite(o) ? String(o) : "null";
- }else if(Ext.isBoolean(o)){
- return String(o);
- }else {
- var a = ["{"], b, i, v;
- for (i in o) {
- if(!o.getElementsByTagName){
- if(!useHasOwn || o.hasOwnProperty(i)) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if(b){
- a.push(',');
- }
- a.push(doEncode(i), ":",
- v === null ? "null" : doEncode(v));
- b = true;
- }
- }
- }
- }
- a.push("}");
- return a.join("");
- }
- },
- m = {
- "b": '\b',
- "t": '\t',
- "n": '\n',
- "f": '\f',
- "r": '\r',
- '"' : '\"',
- "\": '\\'
- },
- encodeString = function(s){
- if (/["\x00-x1f]/.test(s)) {
- return '"' + s.replace(/([x00-x1f\"])/g, function(a, b) {
- var c = m[b];
- if(c){
- return c;
- }
- c = b.charCodeAt();
- return "\u00" +
- Math.floor(c / 16).toString(16) +
- (c % 16).toString(16);
- }) + '"';
- }
- return '"' + s + '"';
- },
- encodeArray = function(o){
- var a = ["["], b, i, l = o.length, v;
- for (i = 0; i < l; i += 1) {
- v = o[i];
- switch (typeof v) {
- case "undefined":
- case "function":
- case "unknown":
- break;
- default:
- if (b) {
- a.push(',');
- }
- a.push(v === null ? "null" : Ext.util.JSON.encode(v));
- b = true;
- }
- }
- a.push("]");
- return a.join("");
- };
- this.encodeDate = function(o){
- return '"' + o.getFullYear() + "-" +
- pad(o.getMonth() + 1) + "-" +
- pad(o.getDate()) + "T" +
- pad(o.getHours()) + ":" +
- pad(o.getMinutes()) + ":" +
- pad(o.getSeconds()) + '"';
- };
- this.encode = function() {
- var ec;
- return function(o) {
- if (!ec) {
- ec = isNative() ? JSON.stringify : doEncode;
- }
- return ec(o);
- };
- }();
- this.decode = function() {
- var dc;
- return function(json) {
- if (!dc) {
- dc = isNative() ? JSON.parse : doDecode;
- }
- return dc(json);
- };
- }();
- })();
- Ext.encode = Ext.util.JSON.encode;
- Ext.decode = Ext.util.JSON.decode;
- Ext.util.Format = function(){
- var trimRe = /^s+|s+$/g,
- stripTagsRE = /</?[^>]+>/gi,
- stripScriptsRe = /(?:<script.*?>)((n|r|.)*?)(?:</script>)/ig,
- nl2brRe = /r?n/g;
- return {
- ellipsis : function(value, len, word){
- if(value && value.length > len){
- if(word){
- var vs = value.substr(0, len - 2),
- index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
- if(index == -1 || index < (len - 15)){
- return value.substr(0, len - 3) + "...";
- }else{
- return vs.substr(0, index) + "...";
- }
- } else{
- return value.substr(0, len - 3) + "...";
- }
- }
- return value;
- },
- undef : function(value){
- return value !== undefined ? value : "";
- },
- defaultValue : function(value, defaultValue){
- return value !== undefined && value !== '' ? value : defaultValue;
- },
- htmlEncode : function(value){
- return !value ? value : String(value).replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
- },
- htmlDecode : function(value){
- return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&");
- },
- trim : function(value){
- return String(value).replace(trimRe, "");
- },
- substr : function(value, start, length){
- return String(value).substr(start, length);
- },
- lowercase : function(value){
- return String(value).toLowerCase();
- },
- uppercase : function(value){
- return String(value).toUpperCase();
- },
- capitalize : function(value){
- return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
- },
- call : function(value, fn){
- if(arguments.length > 2){
- var args = Array.prototype.slice.call(arguments, 2);
- args.unshift(value);
- return eval(fn).apply(window, args);
- }else{
- return eval(fn).call(window, value);
- }
- },
- usMoney : function(v){
- v = (Math.round((v-0)*100))/100;
- v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
- v = String(v);
- var ps = v.split('.'),
- whole = ps[0],
- sub = ps[1] ? '.'+ ps[1] : '.00',
- r = /(d+)(d{3})/;
- while (r.test(whole)) {
- whole = whole.replace(r, '$1' + ',' + '$2');
- }
- v = whole + sub;
- if(v.charAt(0) == '-'){
- return '-$' + v.substr(1);
- }
- return "$" + v;
- },
- date : function(v, format){
- if(!v){
- return "";
- }
- if(!Ext.isDate(v)){
- v = new Date(Date.parse(v));
- }
- return v.dateFormat(format || "m/d/Y");
- },
- dateRenderer : function(format){
- return function(v){
- return Ext.util.Format.date(v, format);
- };
- },
- stripTags : function(v){
- return !v ? v : String(v).replace(stripTagsRE, "");
- },
- stripScripts : function(v){
- return !v ? v : String(v).replace(stripScriptsRe, "");
- },
- fileSize : function(size){
- if(size < 1024) {
- return size + " bytes";
- } else if(size < 1048576) {
- return (Math.round(((size*10) / 1024))/10) + " KB";
- } else {
- return (Math.round(((size*10) / 1048576))/10) + " MB";
- }
- },
- math : function(){
- var fns = {};
- return function(v, a){
- if(!fns[a]){
- fns[a] = new Function('v', 'return v ' + a + ';');
- }
- return fns[a](v);
- }
- }(),
- round : function(value, precision) {
- var result = Number(value);
- if (typeof precision == 'number') {
- precision = Math.pow(10, precision);
- result = Math.round(value * precision) / precision;
- }
- return result;
- },
- number: function(v, format) {
- if(!format){
- return v;
- }
- v = Ext.num(v, NaN);
- if (isNaN(v)){
- return '';
- }
- var comma = ',',
- dec = '.',
- i18n = false,
- neg = v < 0;
- v = Math.abs(v);
- if(format.substr(format.length - 2) == '/i'){
- format = format.substr(0, format.length - 2);
- i18n = true;
- comma = '.';
- dec = ',';
- }
- var hasComma = format.indexOf(comma) != -1,
- psplit = (i18n ? format.replace(/[^d,]/g, '') : format.replace(/[^d.]/g, '')).split(dec);
- if(1 < psplit.length){
- v = v.toFixed(psplit[1].length);
- }else if(2 < psplit.length){
- throw ('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
- }else{
- v = v.toFixed(0);
- }
- var fnum = v.toString();
- if(hasComma){
- psplit = fnum.split('.');
- var cnum = psplit[0], parr = [], j = cnum.length, m = Math.floor(j / 3), n = cnum.length % 3 || 3;
- for(var i = 0; i < j; i += n){
- if(i != 0){
- n = 3;
- }
- parr[parr.length] = cnum.substr(i, n);
- m -= 1;
- }
- fnum = parr.join(comma);
- if(psplit[1]){
- fnum += dec + psplit[1];
- }
- }
- return (neg ? '-' : '') + format.replace(/[d,?.?]+/, fnum);
- },
- numberRenderer : function(format){
- return function(v){
- return Ext.util.Format.number(v, format);
- };
- },
- plural : function(v, s, p){
- return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
- },
- nl2br : function(v){
- return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');
- }
- }
- }();
- Ext.XTemplate = function(){
- Ext.XTemplate.superclass.constructor.apply(this, arguments);
- var me = this,
- s = me.html,
- re = /<tplb[^>]*>((?:(?=([^<]+))2|<(?!tplb[^>]*>))*?)</tpl>/,
- nameRe = /^<tplb[^>]*?for="(.*?)"/,
- ifRe = /^<tplb[^>]*?if="(.*?)"/,
- execRe = /^<tplb[^>]*?exec="(.*?)"/,
- m,
- id = 0,
- tpls = [],
- VALUES = 'values',
- PARENT = 'parent',
- XINDEX = 'xindex',
- XCOUNT = 'xcount',
- RETURN = 'return ',
- WITHVALUES = 'with(values){ ';
- s = ['<tpl>', s, '</tpl>'].join('');
- while((m = s.match(re))){
- var m2 = m[0].match(nameRe),
- m3 = m[0].match(ifRe),
- m4 = m[0].match(execRe),
- exp = null,
- fn = null,
- exec = null,
- name = m2 && m2[1] ? m2[1] : '';
- if (m3) {
- exp = m3 && m3[1] ? m3[1] : null;
- if(exp){
- fn = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES + RETURN +(Ext.util.Format.htmlDecode(exp))+'; }');
- }
- }
- if (m4) {
- exp = m4 && m4[1] ? m4[1] : null;
- if(exp){
- exec = new Function(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES +(Ext.util.Format.htmlDecode(exp))+'; }');
- }
- }
- if(name){
- switch(name){
- case '.': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + VALUES + '; }'); break;
- case '..': name = new Function(VALUES, PARENT, WITHVALUES + RETURN + PARENT + '; }'); break;
- default: name = new Function(VALUES, PARENT, WITHVALUES + RETURN + name + '; }');
- }
- }
- tpls.push({
- id: id,
- target: name,
- exec: exec,
- test: fn,
- body: m[1]||''
- });
- s = s.replace(m[0], '{xtpl'+ id + '}');
- ++id;
- }
- Ext.each(tpls, function(t) {
- me.compileTpl(t);
- });
- me.master = tpls[tpls.length-1];
- me.tpls = tpls;
- };
- Ext.extend(Ext.XTemplate, Ext.Template, {
- re : /{([w-.#]+)(?::([w.]*)(?:((.*?)?))?)?(s?[+-*\]s?[d.+-*\()]+)?}/g,
- codeRe : /{[((?:\]|.|n)*?)]}/g,
- applySubTemplate : function(id, values, parent, xindex, xcount){
- var me = this,
- len,
- t = me.tpls[id],
- vs,
- buf = [];
- if ((t.test && !t.test.call(me, values, parent, xindex, xcount)) ||
- (t.exec && t.exec.call(me, values, parent, xindex, xcount))) {
- return '';
- }
- vs = t.target ? t.target.call(me, values, parent) : values;
- len = vs.length;
- parent = t.target ? values : parent;
- if(t.target && Ext.isArray(vs)){
- Ext.each(vs, function(v, i) {
- buf[buf.length] = t.compiled.call(me, v, parent, i+1, len);
- });
- return buf.join('');
- }
- return t.compiled.call(me, vs, parent, xindex, xcount);
- },
- compileTpl : function(tpl){
- var fm = Ext.util.Format,
- useF = this.disableFormats !== true,
- sep = Ext.isGecko ? "+" : ",",
- body;
- function fn(m, name, format, args, math){
- if(name.substr(0, 4) == 'xtpl'){
- return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
- }
- var v;
- if(name === '.'){
- v = 'values';
- }else if(name === '#'){
- v = 'xindex';
- }else if(name.indexOf('.') != -1){
- v = name;
- }else{
- v = "values['" + name + "']";
- }
- if(math){
- v = '(' + v + math + ')';
- }
- if (format && useF) {
- args = args ? ',' + args : "";
- if(format.substr(0, 5) != "this."){
- format = "fm." + format + '(';
- }else{
- format = 'this.call("'+ format.substr(5) + '", ';
- args = ", values";
- }
- } else {
- args= ''; format = "("+v+" === undefined ? '' : ";
- }
- return "'"+ sep + format + v + args + ")"+sep+"'";
- }
- function codeFn(m, code){
- return "'" + sep + '(' + code.replace(/\'/g, "'") + ')' + sep + "'";
- }
- if(Ext.isGecko){
- body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
- tpl.body.replace(/(rn|n)/g, '\n').replace(/'/g, "\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
- "';};";
- }else{
- body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
- body.push(tpl.body.replace(/(rn|n)/g, '\n').replace(/'/g, "\'").replace(this.re, fn).replace(this.codeRe, codeFn));
- body.push("'].join('');};");
- body = body.join('');
- }
- eval(body);
- return this;
- },
- applyTemplate : function(values){
- return this.master.compiled.call(this, values, {}, 1, 1);
- },
- compile : function(){return this;}
- });
- Ext.XTemplate.prototype.apply = Ext.XTemplate.prototype.applyTemplate;
- Ext.XTemplate.from = function(el){
- el = Ext.getDom(el);
- return new Ext.XTemplate(el.value || el.innerHTML);
- };
- Ext.util.CSS = function(){
- var rules = null;
- var doc = document;
- var camelRe = /(-[a-z])/gi;
- var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
- return {
- createStyleSheet : function(cssText, id){
- var ss;
- var head = doc.getElementsByTagName("head")[0];
- var rules = doc.createElement("style");
- rules.setAttribute("type", "text/css");
- if(id){
- rules.setAttribute("id", id);
- }
- if(Ext.isIE){
- head.appendChild(rules);
- ss = rules.styleSheet;
- ss.cssText = cssText;
- }else{
- try{
- rules.appendChild(doc.createTextNode(cssText));
- }catch(e){
- rules.cssText = cssText;
- }
- head.appendChild(rules);
- ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
- }
- this.cacheStyleSheet(ss);
- return ss;
- },
- removeStyleSheet : function(id){
- var existing = doc.getElementById(id);
- if(existing){
- existing.parentNode.removeChild(existing);
- }
- },
- swapStyleSheet : function(id, url){
- this.removeStyleSheet(id);
- var ss = doc.createElement("link");
- ss.setAttribute("rel", "stylesheet");
- ss.setAttribute("type", "text/css");
- ss.setAttribute("id", id);
- ss.setAttribute("href", url);
- doc.getElementsByTagName("head")[0].appendChild(ss);
- },
- refreshCache : function(){
- return this.getRules(true);
- },
- cacheStyleSheet : function(ss){
- if(!rules){
- rules = {};
- }
- try{
- var ssRules = ss.cssRules || ss.rules;
- for(var j = ssRules.length-1; j >= 0; --j){
- rules[ssRules[j].selectorText.toLowerCase()] = ssRules[j];
- }
- }catch(e){}
- },
- getRules : function(refreshCache){
- if(rules === null || refreshCache){
- rules = {};
- var ds = doc.styleSheets;
- for(var i =0, len = ds.length; i < len; i++){
- try{
- this.cacheStyleSheet(ds[i]);
- }catch(e){}
- }
- }
- return rules;
- },
- getRule : function(selector, refreshCache){
- var rs = this.getRules(refreshCache);
- if(!Ext.isArray(selector)){
- return rs[selector.toLowerCase()];
- }
- for(var i = 0; i < selector.length; i++){
- if(rs[selector[i]]){
- return rs[selector[i].toLowerCase()];
- }
- }
- return null;
- },
- updateRule : function(selector, property, value){
- if(!Ext.isArray(selector)){
- var rule = this.getRule(selector);
- if(rule){
- rule.style[property.replace(camelRe, camelFn)] = value;
- return true;
- }
- }else{
- for(var i = 0; i < selector.length; i++){
- if(this.updateRule(selector[i], property, value)){
- return true;
- }
- }
- }
- return false;
- }
- };
- }();
- Ext.util.ClickRepeater = function(el, config)
- {
- this.el = Ext.get(el);
- this.el.unselectable();
- Ext.apply(this, config);
- this.addEvents(
- "mousedown",
- "click",
- "mouseup"
- );
- if(!this.disabled){
- this.disabled = true;
- this.enable();
- }
- if(this.handler){
- this.on("click", this.handler, this.scope || this);
- }
- Ext.util.ClickRepeater.superclass.constructor.call(this);
- };
- Ext.extend(Ext.util.ClickRepeater, Ext.util.Observable, {
- interval : 20,
- delay: 250,
- preventDefault : true,
- stopDefault : false,
- timer : 0,
- enable: function(){
- if(this.disabled){
- this.el.on('mousedown', this.handleMouseDown, this);
- if(this.preventDefault || this.stopDefault){
- this.el.on('click', this.eventOptions, this);
- }
- }
- this.disabled = false;
- },
- disable: function( force){
- if(force || !this.disabled){
- clearTimeout(this.timer);
- if(this.pressClass){
- this.el.removeClass(this.pressClass);
- }
- Ext.getDoc().un('mouseup', this.handleMouseUp, this);
- this.el.removeAllListeners();
- }
- this.disabled = true;
- },
- setDisabled: function(disabled){
- this[disabled ? 'disable' : 'enable']();
- },
- eventOptions: function(e){
- if(this.preventDefault){
- e.preventDefault();
- }
- if(this.stopDefault){
- e.stopEvent();
- }
- },
- destroy : function() {
- this.disable(true);
- Ext.destroy(this.el);
- this.purgeListeners();
- },
- handleMouseDown : function(){
- clearTimeout(this.timer);
- this.el.blur();
- if(this.pressClass){
- this.el.addClass(this.pressClass);
- }
- this.mousedownTime = new Date();
- Ext.getDoc().on("mouseup", this.handleMouseUp, this);
- this.el.on("mouseout", this.handleMouseOut, this);
- this.fireEvent("mousedown", this);
- this.fireEvent("click", this);
- if (this.accelerate) {
- this.delay = 400;
- }
- this.timer = this.click.defer(this.delay || this.interval, this);
- },
- click : function(){
- this.fireEvent("click", this);
- this.timer = this.click.defer(this.accelerate ?
- this.easeOutExpo(this.mousedownTime.getElapsed(),
- 400,
- -390,
- 12000) :
- this.interval, this);
- },
- easeOutExpo : function (t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- },
- handleMouseOut : function(){
- clearTimeout(this.timer);
- if(this.pressClass){
- this.el.removeClass(this.pressClass);
- }
- this.el.on("mouseover", this.handleMouseReturn, this);
- },
- handleMouseReturn : function(){
- this.el.un("mouseover", this.handleMouseReturn, this);
- if(this.pressClass){
- this.el.addClass(this.pressClass);
- }
- this.click();
- },
- handleMouseUp : function(){
- clearTimeout(this.timer);
- this.el.un("mouseover", this.handleMouseReturn, this);
- this.el.un("mouseout", this.handleMouseOut, this);
- Ext.getDoc().un("mouseup", this.handleMouseUp, this);
- this.el.removeClass(this.pressClass);
- this.fireEvent("mouseup", this);
- }
- });
- Ext.KeyNav = function(el, config){
- this.el = Ext.get(el);
- Ext.apply(this, config);
- if(!this.disabled){
- this.disabled = true;
- this.enable();
- }
- };
- Ext.KeyNav.prototype = {
- disabled : false,
- defaultEventAction: "stopEvent",
- forceKeyDown : false,
- relay : function(e){
- var k = e.getKey();
- var h = this.keyToHandler[k];
- if(h && this[h]){
- if(this.doRelay(e, this[h], h) !== true){
- e[this.defaultEventAction]();
- }
- }
- },
- doRelay : function(e, h, hname){
- return h.call(this.scope || this, e);
- },
- enter : false,
- left : false,
- right : false,
- up : false,
- down : false,
- tab : false,
- esc : false,
- pageUp : false,
- pageDown : false,
- del : false,
- home : false,
- end : false,
- keyToHandler : {
- 37 : "left",
- 39 : "right",
- 38 : "up",
- 40 : "down",
- 33 : "pageUp",
- 34 : "pageDown",
- 46 : "del",
- 36 : "home",
- 35 : "end",
- 13 : "enter",
- 27 : "esc",
- 9 : "tab"
- },
- stopKeyUp: function(e) {
- var k = e.getKey();
- if (k >= 37 && k <= 40) {
- e.stopEvent();
- }
- },
- destroy: function(){
- this.disable();
- },
- enable: function() {
- if (this.disabled) {
- if (Ext.isSafari2) {
- this.el.on('keyup', this.stopKeyUp, this);
- }
- this.el.on(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
- this.disabled = false;
- }
- },
- disable: function() {
- if (!this.disabled) {
- if (Ext.isSafari2) {
- this.el.un('keyup', this.stopKeyUp, this);
- }
- this.el.un(this.isKeydown()? 'keydown' : 'keypress', this.relay, this);
- this.disabled = true;
- }
- },
- setDisabled : function(disabled){
- this[disabled ? "disable" : "enable"]();
- },
- isKeydown: function(){
- return this.forceKeyDown || Ext.EventManager.useKeydown;
- }
- };
- Ext.KeyMap = function(el, config, eventName){
- this.el = Ext.get(el);
- this.eventName = eventName || "keydown";
- this.bindings = [];
- if(config){
- this.addBinding(config);
- }
- this.enable();
- };
- Ext.KeyMap.prototype = {
- stopEvent : false,
- addBinding : function(config){
- if(Ext.isArray(config)){
- Ext.each(config, function(c){
- this.addBinding(c);
- }, this);
- return;
- }
- var keyCode = config.key,
- fn = config.fn || config.handler,
- scope = config.scope;
- if (config.stopEvent) {
- this.stopEvent = config.stopEvent;
- }
- if(typeof keyCode == "string"){
- var ks = [];
- var keyString = keyCode.toUpperCase();
- for(var j = 0, len = keyString.length; j < len; j++){
- ks.push(keyString.charCodeAt(j));
- }
- keyCode = ks;
- }
- var keyArray = Ext.isArray(keyCode);
- var handler = function(e){
- if(this.checkModifiers(config, e)){
- var k = e.getKey();
- if(keyArray){
- for(var i = 0, len = keyCode.length; i < len; i++){
- if(keyCode[i] == k){
- if(this.stopEvent){
- e.stopEvent();
- }
- fn.call(scope || window, k, e);
- return;
- }
- }
- }else{
- if(k == keyCode){
- if(this.stopEvent){
- e.stopEvent();
- }
- fn.call(scope || window, k, e);
- }
- }
- }
- };
- this.bindings.push(handler);
- },
- checkModifiers: function(config, e){
- var val, key, keys = ['shift', 'ctrl', 'alt'];
- for (var i = 0, len = keys.length; i < len; ++i){
- key = keys[i];
- val = config[key];
- if(!(val === undefined || (val === e[key + 'Key']))){
- return false;
- }
- }
- return true;
- },
- on : function(key, fn, scope){
- var keyCode, shift, ctrl, alt;
- if(typeof key == "object" && !Ext.isArray(key)){
- keyCode = key.key;
- shift = key.shift;
- ctrl = key.ctrl;
- alt = key.alt;
- }else{
- keyCode = key;
- }
- this.addBinding({
- key: keyCode,
- shift: shift,
- ctrl: ctrl,
- alt: alt,
- fn: fn,
- scope: scope
- });
- },
- handleKeyDown : function(e){
- if(this.enabled){
- var b = this.bindings;
- for(var i = 0, len = b.length; i < len; i++){
- b[i].call(this, e);
- }
- }
- },
- isEnabled : function(){
- return this.enabled;
- },
- enable: function(){
- if(!this.enabled){
- this.el.on(this.eventName, this.handleKeyDown, this);
- this.enabled = true;
- }
- },
- disable: function(){
- if(this.enabled){
- this.el.removeListener(this.eventName, this.handleKeyDown, this);
- this.enabled = false;
- }
- },
- setDisabled : function(disabled){
- this[disabled ? "disable" : "enable"]();
- }
- };
- Ext.util.TextMetrics = function(){
- var shared;
- return {
- measure : function(el, text, fixedWidth){
- if(!shared){
- shared = Ext.util.TextMetrics.Instance(el, fixedWidth);
- }
- shared.bind(el);
- shared.setFixedWidth(fixedWidth || 'auto');
- return shared.getSize(text);
- },
- createInstance : function(el, fixedWidth){