ext-all-debug.js
资源名称:demo.zip [点击查看]
上传用户:chliyg
上传日期:2016-05-15
资源大小:3196k
文件大小:951k
源码类别:
Jsp/Servlet
开发平台:
Java
- this.updating = true;
- },
- endUpdate : function(){
- this.updating = false;
- this.sync(true);
- },
- hideUnders : function(negOffset){
- if(this.shadow){
- this.shadow.hide();
- }
- this.hideShim();
- },
- constrainXY : function(){
- if(this.constrain){
- var vw = Ext.lib.Dom.getViewWidth(),
- vh = Ext.lib.Dom.getViewHeight();
- var s = Ext.getDoc().getScroll();
- var xy = this.getXY();
- var x = xy[0], y = xy[1];
- var w = this.dom.offsetWidth+this.shadowOffset, h = this.dom.offsetHeight+this.shadowOffset;
- var moved = false;
- if((x + w) > vw+s.left){
- x = vw - w - this.shadowOffset;
- moved = true;
- }
- if((y + h) > vh+s.top){
- y = vh - h - this.shadowOffset;
- moved = true;
- }
- if(x < s.left){
- x = s.left;
- moved = true;
- }
- if(y < s.top){
- y = s.top;
- moved = true;
- }
- if(moved){
- if(this.avoidY){
- var ay = this.avoidY;
- if(y <= ay && (y+h) >= ay){
- y = ay-h-5;
- }
- }
- xy = [x, y];
- this.storeXY(xy);
- supr.setXY.call(this, xy);
- this.sync();
- }
- }
- },
- isVisible : function(){
- return this.visible;
- },
- showAction : function(){
- this.visible = true; if(this.useDisplay === true){
- this.setDisplayed("");
- }else if(this.lastXY){
- supr.setXY.call(this, this.lastXY);
- }else if(this.lastLT){
- supr.setLeftTop.call(this, this.lastLT[0], this.lastLT[1]);
- }
- },
- hideAction : function(){
- this.visible = false;
- if(this.useDisplay === true){
- this.setDisplayed(false);
- }else{
- this.setLeftTop(-10000,-10000);
- }
- },
- setVisible : function(v, a, d, c, e){
- if(v){
- this.showAction();
- }
- if(a && v){
- var cb = function(){
- this.sync(true);
- if(c){
- c();
- }
- }.createDelegate(this);
- supr.setVisible.call(this, true, true, d, cb, e);
- }else{
- if(!v){
- this.hideUnders(true);
- }
- var cb = c;
- if(a){
- cb = function(){
- this.hideAction();
- if(c){
- c();
- }
- }.createDelegate(this);
- }
- supr.setVisible.call(this, v, a, d, cb, e);
- if(v){
- this.sync(true);
- }else if(!a){
- this.hideAction();
- }
- }
- },
- storeXY : function(xy){
- delete this.lastLT;
- this.lastXY = xy;
- },
- storeLeftTop : function(left, top){
- delete this.lastXY;
- this.lastLT = [left, top];
- },
- beforeFx : function(){
- this.beforeAction();
- return Ext.Layer.superclass.beforeFx.apply(this, arguments);
- },
- afterFx : function(){
- Ext.Layer.superclass.afterFx.apply(this, arguments);
- this.sync(this.isVisible());
- },
- beforeAction : function(){
- if(!this.updating && this.shadow){
- this.shadow.hide();
- }
- },
- setLeft : function(left){
- this.storeLeftTop(left, this.getTop(true));
- supr.setLeft.apply(this, arguments);
- this.sync();
- },
- setTop : function(top){
- this.storeLeftTop(this.getLeft(true), top);
- supr.setTop.apply(this, arguments);
- this.sync();
- },
- setLeftTop : function(left, top){
- this.storeLeftTop(left, top);
- supr.setLeftTop.apply(this, arguments);
- this.sync();
- },
- setXY : function(xy, a, d, c, e){
- this.fixDisplay();
- this.beforeAction();
- this.storeXY(xy);
- var cb = this.createCB(c);
- supr.setXY.call(this, xy, a, d, cb, e);
- if(!a){
- cb();
- }
- },
- createCB : function(c){
- var el = this;
- return function(){
- el.constrainXY();
- el.sync(true);
- if(c){
- c();
- }
- };
- },
- setX : function(x, a, d, c, e){
- this.setXY([x, this.getY()], a, d, c, e);
- },
- setY : function(y, a, d, c, e){
- this.setXY([this.getX(), y], a, d, c, e);
- },
- setSize : function(w, h, a, d, c, e){
- this.beforeAction();
- var cb = this.createCB(c);
- supr.setSize.call(this, w, h, a, d, cb, e);
- if(!a){
- cb();
- }
- },
- setWidth : function(w, a, d, c, e){
- this.beforeAction();
- var cb = this.createCB(c);
- supr.setWidth.call(this, w, a, d, cb, e);
- if(!a){
- cb();
- }
- },
- setHeight : function(h, a, d, c, e){
- this.beforeAction();
- var cb = this.createCB(c);
- supr.setHeight.call(this, h, a, d, cb, e);
- if(!a){
- cb();
- }
- },
- setBounds : function(x, y, w, h, a, d, c, e){
- this.beforeAction();
- var cb = this.createCB(c);
- if(!a){
- this.storeXY([x, y]);
- supr.setXY.call(this, [x, y]);
- supr.setSize.call(this, w, h, a, d, cb, e);
- cb();
- }else{
- supr.setBounds.call(this, x, y, w, h, a, d, cb, e);
- }
- return this;
- },
- setZIndex : function(zindex){
- this.zindex = zindex;
- this.setStyle("z-index", zindex + 2);
- if(this.shadow){
- this.shadow.setZIndex(zindex + 1);
- }
- if(this.shim){
- this.shim.setStyle("z-index", zindex);
- }
- }
- });
- })(); Ext.Shadow = function(config){ Ext.apply(this, config); if(typeof this.mode != "string"){ this.mode = this.defaultMode; } var o = this.offset, a = {h: 0}; var rad = Math.floor(this.offset/2); switch(this.mode.toLowerCase()){ case "drop": a.w = 0; a.l = a.t = o; a.t -= 1; if(Ext.isIE){ a.l -= this.offset + rad; a.t -= this.offset + rad; a.w -= rad; a.h -= rad; a.t += 1; } break; case "sides": a.w = (o*2); a.l = -o; a.t = o-1; if(Ext.isIE){ a.l -= (this.offset - rad); a.t -= this.offset + rad; a.l += 1; a.w -= (this.offset - rad)*2; a.w -= rad + 1; a.h -= 1; } break; case "frame": a.w = a.h = (o*2); a.l = a.t = -o; a.t += 1; a.h -= 2; if(Ext.isIE){ a.l -= (this.offset - rad); a.t -= (this.offset - rad); a.l += 1; a.w -= (this.offset + rad + 1); a.h -= (this.offset + rad); a.h += 1; } break; }; this.adjusts = a; }; Ext.Shadow.prototype = { offset: 4, defaultMode: "drop", show : function(target){ target = Ext.get(target); if(!this.el){ this.el = Ext.Shadow.Pool.pull(); if(this.el.dom.nextSibling != target.dom){ this.el.insertBefore(target); } } this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1); if(Ext.isIE){ this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")"; } this.realign( target.getLeft(true), target.getTop(true), target.getWidth(), target.getHeight() ); this.el.dom.style.display = "block"; }, isVisible : function(){ return this.el ? true : false; }, realign : function(l, t, w, h){ if(!this.el){ return; } var a = this.adjusts, d = this.el.dom, s = d.style; var iea = 0; s.left = (l+a.l)+"px"; s.top = (t+a.t)+"px"; var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px"; if(s.width != sws || s.height != shs){ s.width = sws; s.height = shs; if(!Ext.isIE){ var cn = d.childNodes; var sww = Math.max(0, (sw-12))+"px"; cn[0].childNodes[1].style.width = sww; cn[1].childNodes[1].style.width = sww; cn[2].childNodes[1].style.width = sww; cn[1].style.height = Math.max(0, (sh-12))+"px"; } } }, hide : function(){ if(this.el){ this.el.dom.style.display = "none"; Ext.Shadow.Pool.push(this.el); delete this.el; } }, setZIndex : function(z){ this.zIndex = z; if(this.el){ this.el.setStyle("z-index", z); } } }; Ext.Shadow.Pool = function(){ var p = []; var markup = Ext.isIE ? '<div class="x-ie-shadow"></div>' : '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>'; return { pull : function(){ var sh = p.shift(); if(!sh){ sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup)); sh.autoBoxAdjust = false; } return sh; }, push : function(sh){ p.push(sh); } }; }(); Ext.BoxComponent = Ext.extend(Ext.Component, { initComponent : function(){ Ext.BoxComponent.superclass.initComponent.call(this); this.addEvents( 'resize', 'move' ); }, boxReady : false, deferHeight: false, setSize : function(w, h){ if(typeof w == 'object'){ h = w.height; w = w.width; } if(!this.boxReady){ this.width = w; this.height = h; return this; } if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){ return this; } this.lastSize = {width: w, height: h}; var adj = this.adjustSize(w, h); var aw = adj.width, ah = adj.height; if(aw !== undefined || ah !== undefined){ var rz = this.getResizeEl(); if(!this.deferHeight && aw !== undefined && ah !== undefined){ rz.setSize(aw, ah); }else if(!this.deferHeight && ah !== undefined){ rz.setHeight(ah); }else if(aw !== undefined){ rz.setWidth(aw); } this.onResize(aw, ah, w, h); this.fireEvent('resize', this, aw, ah, w, h); } return this; }, setWidth : function(width){ return this.setSize(width); }, setHeight : function(height){ return this.setSize(undefined, height); }, getSize : function(){ return this.el.getSize(); }, getPosition : function(local){ if(local === true){ return [this.el.getLeft(true), this.el.getTop(true)]; } return this.xy || this.el.getXY(); }, getBox : function(local){ var s = this.el.getSize(); if(local === true){ s.x = this.el.getLeft(true); s.y = this.el.getTop(true); }else{ var xy = this.xy || this.el.getXY(); s.x = xy[0]; s.y = xy[1]; } return s; }, updateBox : function(box){ this.setSize(box.width, box.height); this.setPagePosition(box.x, box.y); return this; }, getResizeEl : function(){ return this.resizeEl || this.el; }, getPositionEl : function(){ return this.positionEl || this.el; }, setPosition : function(x, y){ if(x && typeof x[1] == 'number'){ y = x[1]; x = x[0]; } this.x = x; this.y = y; if(!this.boxReady){ return this; } var adj = this.adjustPosition(x, y); var ax = adj.x, ay = adj.y; var el = this.getPositionEl(); if(ax !== undefined || ay !== undefined){ if(ax !== undefined && ay !== undefined){ el.setLeftTop(ax, ay); }else if(ax !== undefined){ el.setLeft(ax); }else if(ay !== undefined){ el.setTop(ay); } this.onPosition(ax, ay); this.fireEvent('move', this, ax, ay); } return this; }, setPagePosition : function(x, y){ if(x && typeof x[1] == 'number'){ y = x[1]; x = x[0]; } this.pageX = x; this.pageY = y; if(!this.boxReady){ return; } if(x === undefined || y === undefined){ return; } var p = this.el.translatePoints(x, y); this.setPosition(p.left, p.top); return this; }, onRender : function(ct, position){ Ext.BoxComponent.superclass.onRender.call(this, ct, position); if(this.resizeEl){ this.resizeEl = Ext.get(this.resizeEl); } if(this.positionEl){ this.positionEl = Ext.get(this.positionEl); } }, afterRender : function(){ Ext.BoxComponent.superclass.afterRender.call(this); this.boxReady = true; this.setSize(this.width, this.height); if(this.x || this.y){ this.setPosition(this.x, this.y); }else if(this.pageX || this.pageY){ this.setPagePosition(this.pageX, this.pageY); } }, syncSize : function(){ delete this.lastSize; this.setSize(this.autoWidth ? undefined : this.el.getWidth(), this.autoHeight ? undefined : this.el.getHeight()); return this; }, onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){ }, onPosition : function(x, y){ }, adjustSize : function(w, h){ if(this.autoWidth){ w = 'auto'; } if(this.autoHeight){ h = 'auto'; } return {width : w, height: h}; }, adjustPosition : function(x, y){ return {x : x, y: y}; } }); Ext.reg('box', Ext.BoxComponent);
- Ext.SplitBar = function(dragElement, resizingElement, orientation, placement, existingProxy){
- this.el = Ext.get(dragElement, true);
- this.el.dom.unselectable = "on";
- this.resizingEl = Ext.get(resizingElement, true);
- this.orientation = orientation || Ext.SplitBar.HORIZONTAL;
- this.minSize = 0;
- this.maxSize = 2000;
- this.animate = false;
- this.useShim = false;
- this.shim = null;
- if(!existingProxy){
- this.proxy = Ext.SplitBar.createProxy(this.orientation);
- }else{
- this.proxy = Ext.get(existingProxy).dom;
- }
- this.dd = new Ext.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
- this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
- this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
- this.dragSpecs = {};
- this.adapter = new Ext.SplitBar.BasicLayoutAdapter();
- this.adapter.init(this);
- if(this.orientation == Ext.SplitBar.HORIZONTAL){
- this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? Ext.SplitBar.LEFT : Ext.SplitBar.RIGHT);
- this.el.addClass("x-splitbar-h");
- }else{
- this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? Ext.SplitBar.TOP : Ext.SplitBar.BOTTOM);
- this.el.addClass("x-splitbar-v");
- }
- this.addEvents(
- "resize",
- "moved",
- "beforeresize",
- "beforeapply"
- );
- Ext.SplitBar.superclass.constructor.call(this);
- };
- Ext.extend(Ext.SplitBar, Ext.util.Observable, {
- onStartProxyDrag : function(x, y){
- this.fireEvent("beforeresize", this);
- this.overlay = Ext.DomHelper.append(document.body, {cls: "x-drag-overlay", html: " "}, true);
- this.overlay.unselectable();
- this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
- this.overlay.show();
- Ext.get(this.proxy).setDisplayed("block");
- var size = this.adapter.getElementSize(this);
- this.activeMinSize = this.getMinimumSize();;
- this.activeMaxSize = this.getMaximumSize();;
- var c1 = size - this.activeMinSize;
- var c2 = Math.max(this.activeMaxSize - size, 0);
- if(this.orientation == Ext.SplitBar.HORIZONTAL){
- this.dd.resetConstraints();
- this.dd.setXConstraint(
- this.placement == Ext.SplitBar.LEFT ? c1 : c2,
- this.placement == Ext.SplitBar.LEFT ? c2 : c1
- );
- this.dd.setYConstraint(0, 0);
- }else{
- this.dd.resetConstraints();
- this.dd.setXConstraint(0, 0);
- this.dd.setYConstraint(
- this.placement == Ext.SplitBar.TOP ? c1 : c2,
- this.placement == Ext.SplitBar.TOP ? c2 : c1
- );
- }
- this.dragSpecs.startSize = size;
- this.dragSpecs.startPoint = [x, y];
- Ext.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
- },
- onEndProxyDrag : function(e){
- Ext.get(this.proxy).setDisplayed(false);
- var endPoint = Ext.lib.Event.getXY(e);
- if(this.overlay){
- this.overlay.remove();
- delete this.overlay;
- }
- var newSize;
- if(this.orientation == Ext.SplitBar.HORIZONTAL){
- newSize = this.dragSpecs.startSize +
- (this.placement == Ext.SplitBar.LEFT ?
- endPoint[0] - this.dragSpecs.startPoint[0] :
- this.dragSpecs.startPoint[0] - endPoint[0]
- );
- }else{
- newSize = this.dragSpecs.startSize +
- (this.placement == Ext.SplitBar.TOP ?
- endPoint[1] - this.dragSpecs.startPoint[1] :
- this.dragSpecs.startPoint[1] - endPoint[1]
- );
- }
- newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
- if(newSize != this.dragSpecs.startSize){
- if(this.fireEvent('beforeapply', this, newSize) !== false){
- this.adapter.setElementSize(this, newSize);
- this.fireEvent("moved", this, newSize);
- this.fireEvent("resize", this, newSize);
- }
- }
- },
- getAdapter : function(){
- return this.adapter;
- },
- setAdapter : function(adapter){
- this.adapter = adapter;
- this.adapter.init(this);
- },
- getMinimumSize : function(){
- return this.minSize;
- },
- setMinimumSize : function(minSize){
- this.minSize = minSize;
- },
- getMaximumSize : function(){
- return this.maxSize;
- },
- setMaximumSize : function(maxSize){
- this.maxSize = maxSize;
- },
- setCurrentSize : function(size){
- var oldAnimate = this.animate;
- this.animate = false;
- this.adapter.setElementSize(this, size);
- this.animate = oldAnimate;
- },
- destroy : function(removeEl){
- if(this.shim){
- this.shim.remove();
- }
- this.dd.unreg();
- Ext.removeNode(this.proxy);
- if(removeEl){
- this.el.remove();
- }
- }
- });
- Ext.SplitBar.createProxy = function(dir){
- var proxy = new Ext.Element(document.createElement("div"));
- proxy.unselectable();
- var cls = 'x-splitbar-proxy';
- proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
- document.body.appendChild(proxy.dom);
- return proxy.dom;
- };
- Ext.SplitBar.BasicLayoutAdapter = function(){
- };
- Ext.SplitBar.BasicLayoutAdapter.prototype = {
- init : function(s){
- },
- getElementSize : function(s){
- if(s.orientation == Ext.SplitBar.HORIZONTAL){
- return s.resizingEl.getWidth();
- }else{
- return s.resizingEl.getHeight();
- }
- },
- setElementSize : function(s, newSize, onComplete){
- if(s.orientation == Ext.SplitBar.HORIZONTAL){
- if(!s.animate){
- s.resizingEl.setWidth(newSize);
- if(onComplete){
- onComplete(s, newSize);
- }
- }else{
- s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
- }
- }else{
- if(!s.animate){
- s.resizingEl.setHeight(newSize);
- if(onComplete){
- onComplete(s, newSize);
- }
- }else{
- s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
- }
- }
- }
- };
- Ext.SplitBar.AbsoluteLayoutAdapter = function(container){
- this.basic = new Ext.SplitBar.BasicLayoutAdapter();
- this.container = Ext.get(container);
- };
- Ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
- init : function(s){
- this.basic.init(s);
- },
- getElementSize : function(s){
- return this.basic.getElementSize(s);
- },
- setElementSize : function(s, newSize, onComplete){
- this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
- },
- moveSplitter : function(s){
- var yes = Ext.SplitBar;
- switch(s.placement){
- case yes.LEFT:
- s.el.setX(s.resizingEl.getRight());
- break;
- case yes.RIGHT:
- s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
- break;
- case yes.TOP:
- s.el.setY(s.resizingEl.getBottom());
- break;
- case yes.BOTTOM:
- s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
- break;
- }
- }
- };
- Ext.SplitBar.VERTICAL = 1;
- Ext.SplitBar.HORIZONTAL = 2;
- Ext.SplitBar.LEFT = 1;
- Ext.SplitBar.RIGHT = 2;
- Ext.SplitBar.TOP = 3;
- Ext.SplitBar.BOTTOM = 4;
- Ext.Container = Ext.extend(Ext.BoxComponent, { autoDestroy: true, defaultType: 'panel', initComponent : function(){ Ext.Container.superclass.initComponent.call(this); this.addEvents( 'afterlayout', 'beforeadd', 'beforeremove', 'add', 'remove' ); var items = this.items; if(items){ delete this.items; if(Ext.isArray(items)){ this.add.apply(this, items); }else{ this.add(items); } } }, initItems : function(){ if(!this.items){ this.items = new Ext.util.MixedCollection(false, this.getComponentId); this.getLayout(); } }, setLayout : function(layout){ if(this.layout && this.layout != layout){ this.layout.setContainer(null); } this.initItems(); this.layout = layout; layout.setContainer(this); }, render : function(){ Ext.Container.superclass.render.apply(this, arguments); if(this.layout){ if(typeof this.layout == 'string'){ this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig); } this.setLayout(this.layout); if(this.activeItem !== undefined){ var item = this.activeItem; delete this.activeItem; this.layout.setActiveItem(item); return; } } if(!this.ownerCt){ this.doLayout(); } if(this.monitorResize === true){ Ext.EventManager.onWindowResize(this.doLayout, this, [false]); } }, getLayoutTarget : function(){ return this.el; }, getComponentId : function(comp){ return comp.itemId || comp.id; }, add : function(comp){ if(!this.items){ this.initItems(); } var a = arguments, len = a.length; if(len > 1){ for(var i = 0; i < len; i++) { this.add(a[i]); } return; } var c = this.lookupComponent(this.applyDefaults(comp)); var pos = this.items.length; if(this.fireEvent('beforeadd', this, c, pos) !== false && this.onBeforeAdd(c) !== false){ this.items.add(c); c.ownerCt = this; this.fireEvent('add', this, c, pos); } return c; }, insert : function(index, comp){ if(!this.items){ this.initItems(); } var a = arguments, len = a.length; if(len > 2){ for(var i = len-1; i >= 1; --i) { this.insert(index, a[i]); } return; } var c = this.lookupComponent(this.applyDefaults(comp)); if(c.ownerCt == this && this.items.indexOf(c) < index){ --index; } if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){ this.items.insert(index, c); c.ownerCt = this; this.fireEvent('add', this, c, index); } return c; }, applyDefaults : function(c){ if(this.defaults){ if(typeof c == 'string'){ c = Ext.ComponentMgr.get(c); Ext.apply(c, this.defaults); }else if(!c.events){ Ext.applyIf(c, this.defaults); }else{ Ext.apply(c, this.defaults); } } return c; }, onBeforeAdd : function(item){ if(item.ownerCt){ item.ownerCt.remove(item, false); } if(this.hideBorders === true){ item.border = (item.border === true); } }, remove : function(comp, autoDestroy){ var c = this.getComponent(comp); if(c && this.fireEvent('beforeremove', this, c) !== false){ this.items.remove(c); delete c.ownerCt; if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){ c.destroy(); } if(this.layout && this.layout.activeItem == c){ delete this.layout.activeItem; } this.fireEvent('remove', this, c); } return c; }, getComponent : function(comp){ if(typeof comp == 'object'){ return comp; } return this.items.get(comp); }, lookupComponent : function(comp){ if(typeof comp == 'string'){ return Ext.ComponentMgr.get(comp); }else if(!comp.events){ return this.createComponent(comp); } return comp; }, createComponent : function(config){ return Ext.ComponentMgr.create(config, this.defaultType); }, doLayout : function(shallow){ if(this.rendered && this.layout){ this.layout.layout(); } if(shallow !== false && this.items){ var cs = this.items.items; for(var i = 0, len = cs.length; i < len; i++) { var c = cs[i]; if(c.doLayout){ c.doLayout(); } } } }, getLayout : function(){ if(!this.layout){ var layout = new Ext.layout.ContainerLayout(this.layoutConfig); this.setLayout(layout); } return this.layout; }, beforeDestroy : function(){ if(this.items){ Ext.destroy.apply(Ext, this.items.items); } if(this.monitorResize){ Ext.EventManager.removeResizeListener(this.doLayout, this); } if (this.layout && this.layout.destroy) { this.layout.destroy(); } Ext.Container.superclass.beforeDestroy.call(this); }, bubble : function(fn, scope, args){ var p = this; while(p){ if(fn.apply(scope || p, args || [p]) === false){ break; } p = p.ownerCt; } }, cascade : function(fn, scope, args){ if(fn.apply(scope || this, args || [this]) !== false){ if(this.items){ var cs = this.items.items; for(var i = 0, len = cs.length; i < len; i++){ if(cs[i].cascade){ cs[i].cascade(fn, scope, args); }else{ fn.apply(scope || cs[i], args || [cs[i]]); } } } } }, findById : function(id){ var m, ct = this; this.cascade(function(c){ if(ct != c && c.id === id){ m = c; return false; } }); return m || null; }, findByType : function(xtype){ return typeof xtype == 'function' ? this.findBy(function(c){ return c.constructor === xtype; }) : this.findBy(function(c){ return c.constructor.xtype === xtype; }); }, find : function(prop, value){ return this.findBy(function(c){ return c[prop] === value; }); }, findBy : function(fn, scope){ var m = [], ct = this; this.cascade(function(c){ if(ct != c && fn.call(scope || c, c, ct) === true){ m.push(c); } }); return m; } }); Ext.Container.LAYOUTS = {}; Ext.reg('container', Ext.Container); Ext.layout.ContainerLayout = function(config){ Ext.apply(this, config); }; Ext.layout.ContainerLayout.prototype = { monitorResize:false, activeItem : null, layout : function(){ var target = this.container.getLayoutTarget(); this.onLayout(this.container, target); this.container.fireEvent('afterlayout', this.container, this); }, onLayout : function(ct, target){ this.renderAll(ct, target); }, isValidParent : function(c, target){ var el = c.getPositionEl ? c.getPositionEl() : c.getEl(); return el.dom.parentNode == target.dom; }, renderAll : function(ct, target){ var items = ct.items.items; for(var i = 0, len = items.length; i < len; i++) { var c = items[i]; if(c && (!c.rendered || !this.isValidParent(c, target))){ this.renderItem(c, i, target); } } }, renderItem : function(c, position, target){ if(c && !c.rendered){ c.render(target, position); if(this.extraCls){ var t = c.getPositionEl ? c.getPositionEl() : c; t.addClass(this.extraCls); } if (this.renderHidden && c != this.activeItem) { c.hide(); } }else if(c && !this.isValidParent(c, target)){ if(this.extraCls){ c.addClass(this.extraCls); } if(typeof position == 'number'){ position = target.dom.childNodes[position]; } target.dom.insertBefore(c.getEl().dom, position || null); if (this.renderHidden && c != this.activeItem) { c.hide(); } } }, onResize: function(){ if(this.container.collapsed){ return; } var b = this.container.bufferResize; if(b){ if(!this.resizeTask){ this.resizeTask = new Ext.util.DelayedTask(this.layout, this); this.resizeBuffer = typeof b == 'number' ? b : 100; } this.resizeTask.delay(this.resizeBuffer); }else{ this.layout(); } }, setContainer : function(ct){ if(this.monitorResize && ct != this.container){ if(this.container){ this.container.un('resize', this.onResize, this); } if(ct){ ct.on('resize', this.onResize, this); } } this.container = ct; }, parseMargins : function(v){ var ms = v.split(' '); var len = ms.length; if(len == 1){ ms[1] = ms[0]; ms[2] = ms[0]; ms[3] = ms[0]; } if(len == 2){ ms[2] = ms[0]; ms[3] = ms[1]; } return { top:parseInt(ms[0], 10) || 0, right:parseInt(ms[1], 10) || 0, bottom:parseInt(ms[2], 10) || 0, left:parseInt(ms[3], 10) || 0 }; }, destroy : Ext.emptyFn }; Ext.Container.LAYOUTS['auto'] = Ext.layout.ContainerLayout;
- Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:true,
- onLayout : function(ct, target){
- Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
- if(!this.container.collapsed){
- this.setItemSize(this.activeItem || ct.items.itemAt(0), target.getStyleSize());
- }
- },
- setItemSize : function(item, size){
- if(item && size.height > 0){ item.setSize(size);
- }
- }
- });
- Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;
- Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
- deferredRender : false,
- renderHidden : true,
- setActiveItem : function(item){
- item = this.container.getComponent(item);
- if(this.activeItem != item){
- if(this.activeItem){
- this.activeItem.hide();
- }
- this.activeItem = item;
- item.show();
- this.layout();
- }
- },
- renderAll : function(ct, target){
- if(this.deferredRender){
- this.renderItem(this.activeItem, undefined, target);
- }else{
- Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
- }
- }
- });
- Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;
- Ext.layout.AnchorLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:true,
- getAnchorViewSize : function(ct, target){
- return target.dom == document.body ?
- target.getViewSize() : target.getStyleSize();
- },
- onLayout : function(ct, target){
- Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target);
- var size = this.getAnchorViewSize(ct, target);
- var w = size.width, h = size.height;
- if(w < 20 || h < 20){
- return;
- }
- var aw, ah;
- if(ct.anchorSize){
- if(typeof ct.anchorSize == 'number'){
- aw = ct.anchorSize;
- }else{
- aw = ct.anchorSize.width;
- ah = ct.anchorSize.height;
- }
- }else{
- aw = ct.initialConfig.width;
- ah = ct.initialConfig.height;
- }
- var cs = ct.items.items, len = cs.length, i, c, a, cw, ch;
- for(i = 0; i < len; i++){
- c = cs[i];
- if(c.anchor){
- a = c.anchorSpec;
- if(!a){ var vs = c.anchor.split(' ');
- c.anchorSpec = a = {
- right: this.parseAnchor(vs[0], c.initialConfig.width, aw),
- bottom: this.parseAnchor(vs[1], c.initialConfig.height, ah)
- };
- }
- cw = a.right ? this.adjustWidthAnchor(a.right(w), c) : undefined;
- ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h), c) : undefined;
- if(cw || ch){
- c.setSize(cw || undefined, ch || undefined);
- }
- }
- }
- },
- parseAnchor : function(a, start, cstart){
- if(a && a != 'none'){
- var last;
- if(/^(r|right|b|bottom)$/i.test(a)){ var diff = cstart - start;
- return function(v){
- if(v !== last){
- last = v;
- return v - diff;
- }
- }
- }else if(a.indexOf('%') != -1){
- var ratio = parseFloat(a.replace('%', ''))*.01; return function(v){
- if(v !== last){
- last = v;
- return Math.floor(v*ratio);
- }
- }
- }else{
- a = parseInt(a, 10);
- if(!isNaN(a)){ return function(v){
- if(v !== last){
- last = v;
- return v + a;
- }
- }
- }
- }
- }
- return false;
- },
- adjustWidthAnchor : function(value, comp){
- return value;
- },
- adjustHeightAnchor : function(value, comp){
- return value;
- }
- });
- Ext.Container.LAYOUTS['anchor'] = Ext.layout.AnchorLayout;
- Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:true,
- extraCls: 'x-column',
- scrollOffset : 0,
- isValidParent : function(c, target){
- return c.getEl().dom.parentNode == this.innerCt.dom;
- },
- onLayout : function(ct, target){
- var cs = ct.items.items, len = cs.length, c, i;
- if(!this.innerCt){
- target.addClass('x-column-layout-ct');
- this.innerCt = target.createChild({cls:'x-column-inner'});
- this.innerCt.createChild({cls:'x-clear'});
- }
- this.renderAll(ct, this.innerCt);
- var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();
- if(size.width < 1 && size.height < 1){ return;
- }
- var w = size.width - target.getPadding('lr') - this.scrollOffset,
- h = size.height - target.getPadding('tb'),
- pw = w;
- this.innerCt.setWidth(w);
- for(i = 0; i < len; i++){
- c = cs[i];
- if(!c.columnWidth){
- pw -= (c.getSize().width + c.getEl().getMargins('lr'));
- }
- }
- pw = pw < 0 ? 0 : pw;
- for(i = 0; i < len; i++){
- c = cs[i];
- if(c.columnWidth){
- c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));
- }
- }
- }
- });
- Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout; Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, { monitorResize:true, rendered : false, onLayout : function(ct, target){ var collapsed; if(!this.rendered){ target.position(); target.addClass('x-border-layout-ct'); var items = ct.items.items; collapsed = []; for(var i = 0, len = items.length; i < len; i++) { var c = items[i]; var pos = c.region; if(c.collapsed){ collapsed.push(c); } c.collapsed = false; if(!c.rendered){ c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel'; c.render(target, i); } this[pos] = pos != 'center' && c.split ? new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) : new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos); this[pos].render(target, c); } this.rendered = true; } var size = target.getViewSize(); if(size.width < 20 || size.height < 20){ if(collapsed){ this.restoreCollapsed = collapsed; } return; }else if(this.restoreCollapsed){ collapsed = this.restoreCollapsed; delete this.restoreCollapsed; } var w = size.width, h = size.height; var centerW = w, centerH = h, centerY = 0, centerX = 0; var n = this.north, s = this.south, west = this.west, e = this.east, c = this.center; if(!c){ throw 'No center region defined in BorderLayout ' + ct.id; } if(n && n.isVisible()){ var b = n.getSize(); var m = n.getMargins(); b.width = w - (m.left+m.right); b.x = m.left; b.y = m.top; centerY = b.height + b.y + m.bottom; centerH -= centerY; n.applyLayout(b); } if(s && s.isVisible()){ var b = s.getSize(); var m = s.getMargins(); b.width = w - (m.left+m.right); b.x = m.left; var totalHeight = (b.height + m.top + m.bottom); b.y = h - totalHeight + m.top; centerH -= totalHeight; s.applyLayout(b); } if(west && west.isVisible()){ var b = west.getSize(); var m = west.getMargins(); b.height = centerH - (m.top+m.bottom); b.x = m.left; b.y = centerY + m.top; var totalWidth = (b.width + m.left + m.right); centerX += totalWidth; centerW -= totalWidth; west.applyLayout(b); } if(e && e.isVisible()){ var b = e.getSize(); var m = e.getMargins(); b.height = centerH - (m.top+m.bottom); var totalWidth = (b.width + m.left + m.right); b.x = w - totalWidth + m.left; b.y = centerY + m.top; centerW -= totalWidth; e.applyLayout(b); } var m = c.getMargins(); var centerBox = { x: centerX + m.left, y: centerY + m.top, width: centerW - (m.left+m.right), height: centerH - (m.top+m.bottom) }; c.applyLayout(centerBox); if(collapsed){ for(var i = 0, len = collapsed.length; i < len; i++){ collapsed[i].collapse(false); } } if(Ext.isIE && Ext.isStrict){ target.repaint(); } }, destroy: function() { var r = ['north', 'south', 'east', 'west']; for (var i = 0; i < r.length; i++) { var region = this[r[i]]; if (region && region.split) { region.split.destroy(true); } } Ext.layout.BorderLayout.superclass.destroy.call(this); } }); Ext.layout.BorderLayout.Region = function(layout, config, pos){ Ext.apply(this, config); this.layout = layout; this.position = pos; this.state = {}; if(typeof this.margins == 'string'){ this.margins = this.layout.parseMargins(this.margins); } this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins); if(this.collapsible){ if(typeof this.cmargins == 'string'){ this.cmargins = this.layout.parseMargins(this.cmargins); } if(this.collapseMode == 'mini' && !this.cmargins){ this.cmargins = {left:0,top:0,right:0,bottom:0}; }else{ this.cmargins = Ext.applyIf(this.cmargins || {}, pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins); } } }; Ext.layout.BorderLayout.Region.prototype = { collapsible : false, split:false, floatable: true, minWidth:50, minHeight:50, defaultMargins : {left:0,top:0,right:0,bottom:0}, defaultNSCMargins : {left:5,top:5,right:5,bottom:5}, defaultEWCMargins : {left:5,top:0,right:5,bottom:0}, isCollapsed : false, render : function(ct, p){ this.panel = p; p.el.enableDisplayMode(); this.targetEl = ct; this.el = p.el; var gs = p.getState, ps = this.position; p.getState = function(){ return Ext.apply(gs.call(p) || {}, this.state); }.createDelegate(this); if(ps != 'center'){ p.allowQueuedExpand = false; p.on({ beforecollapse: this.beforeCollapse, collapse: this.onCollapse, beforeexpand: this.beforeExpand, expand: this.onExpand, hide: this.onHide, show: this.onShow, scope: this }); if(this.collapsible){ p.collapseEl = 'el'; p.slideAnchor = this.getSlideAnchor(); } if(p.tools && p.tools.toggle){ p.tools.toggle.addClass('x-tool-collapse-'+ps); p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over'); } } }, getCollapsedEl : function(){ if(!this.collapsedEl){ if(!this.toolTemplate){ var tt = new Ext.Template( '<div class="x-tool x-tool-{id}"> </div>' ); tt.disableFormats = true; tt.compile(); Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt; } this.collapsedEl = this.targetEl.createChild({ cls: "x-layout-collapsed x-layout-collapsed-"+this.position, id: this.panel.id + '-xcollapsed' }); this.collapsedEl.enableDisplayMode('block'); if(this.collapseMode == 'mini'){ this.collapsedEl.addClass('x-layout-cmini-'+this.position); this.miniCollapsedEl = this.collapsedEl.createChild({ cls: "x-layout-mini x-layout-mini-"+this.position, html: " " }); this.miniCollapsedEl.addClassOnOver('x-layout-mini-over'); this.collapsedEl.addClassOnOver("x-layout-collapsed-over"); this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true}); }else { var t = this.toolTemplate.append( this.collapsedEl.dom, {id:'expand-'+this.position}, true); t.addClassOnOver('x-tool-expand-'+this.position+'-over'); t.on('click', this.onExpandClick, this, {stopEvent:true}); if(this.floatable !== false){ this.collapsedEl.addClassOnOver("x-layout-collapsed-over"); this.collapsedEl.on("click", this.collapseClick, this); } } } return this.collapsedEl; }, onExpandClick : function(e){ if(this.isSlid){ this.afterSlideIn(); this.panel.expand(false); }else{ this.panel.expand(); } }, onCollapseClick : function(e){ this.panel.collapse(); }, beforeCollapse : function(p, animate){ this.lastAnim = animate; if(this.splitEl){ this.splitEl.hide(); } this.getCollapsedEl().show(); this.panel.el.setStyle('z-index', 100); this.isCollapsed = true; this.layout.layout(); }, onCollapse : function(animate){ this.panel.el.setStyle('z-index', 1); if(this.lastAnim === false || this.panel.animCollapse === false){ this.getCollapsedEl().dom.style.visibility = 'visible'; }else{ this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2}); } this.state.collapsed = true; this.panel.saveState(); }, beforeExpand : function(animate){ var c = this.getCollapsedEl(); this.el.show(); if(this.position == 'east' || this.position == 'west'){ this.panel.setSize(undefined, c.getHeight()); }else{ this.panel.setSize(c.getWidth(), undefined); } c.hide(); c.dom.style.visibility = 'hidden'; this.panel.el.setStyle('z-index', 100); }, onExpand : function(){ this.isCollapsed = false; if(this.splitEl){ this.splitEl.show(); } this.layout.layout(); this.panel.el.setStyle('z-index', 1); this.state.collapsed = false; this.panel.saveState(); }, collapseClick : function(e){ if(this.isSlid){ e.stopPropagation(); this.slideIn(); }else{ e.stopPropagation(); this.slideOut(); } }, onHide : function(){ if(this.isCollapsed){ this.getCollapsedEl().hide(); }else if(this.splitEl){ this.splitEl.hide(); } }, onShow : function(){ if(this.isCollapsed){ this.getCollapsedEl().show(); }else if(this.splitEl){ this.splitEl.show(); } }, isVisible : function(){ return !this.panel.hidden; }, getMargins : function(){ return this.isCollapsed && this.cmargins ? this.cmargins : this.margins; }, getSize : function(){ return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize(); }, setPanel : function(panel){ this.panel = panel; }, getMinWidth: function(){ return this.minWidth; }, getMinHeight: function(){ return this.minHeight; }, applyLayoutCollapsed : function(box){ var ce = this.getCollapsedEl(); ce.setLeftTop(box.x, box.y); ce.setSize(box.width, box.height); }, applyLayout : function(box){ if(this.isCollapsed){ this.applyLayoutCollapsed(box); }else{ this.panel.setPosition(box.x, box.y); this.panel.setSize(box.width, box.height); } }, beforeSlide: function(){ this.panel.beforeEffect(); }, afterSlide : function(){ this.panel.afterEffect(); }, initAutoHide : function(){ if(this.autoHide !== false){ if(!this.autoHideHd){ var st = new Ext.util.DelayedTask(this.slideIn, this); this.autoHideHd = { "mouseout": function(e){ if(!e.within(this.el, true)){ st.delay(500); } }, "mouseover" : function(e){ st.cancel(); }, scope : this }; } this.el.on(this.autoHideHd); } }, clearAutoHide : function(){ if(this.autoHide !== false){ this.el.un("mouseout", this.autoHideHd.mouseout); this.el.un("mouseover", this.autoHideHd.mouseover); } }, clearMonitor : function(){ Ext.getDoc().un("click", this.slideInIf, this); }, slideOut : function(){ if(this.isSlid || this.el.hasActiveFx()){ return; } this.isSlid = true; var ts = this.panel.tools; if(ts && ts.toggle){ ts.toggle.hide(); } this.el.show(); if(this.position == 'east' || this.position == 'west'){ this.panel.setSize(undefined, this.collapsedEl.getHeight()); }else{ this.panel.setSize(this.collapsedEl.getWidth(), undefined); } this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top]; this.el.alignTo(this.collapsedEl, this.getCollapseAnchor()); this.el.setStyle("z-index", 102); if(this.animFloat !== false){ this.beforeSlide(); this.el.slideIn(this.getSlideAnchor(), { callback: function(){ this.afterSlide(); this.initAutoHide(); Ext.getDoc().on("click", this.slideInIf, this); }, scope: this, block: true }); }else{ this.initAutoHide(); Ext.getDoc().on("click", this.slideInIf, this); } }, afterSlideIn : function(){ this.clearAutoHide(); this.isSlid = false; this.clearMonitor(); this.el.setStyle("z-index", ""); this.el.dom.style.left = this.restoreLT[0]; this.el.dom.style.top = this.restoreLT[1]; var ts = this.panel.tools; if(ts && ts.toggle){ ts.toggle.show(); } }, slideIn : function(cb){ if(!this.isSlid || this.el.hasActiveFx()){ Ext.callback(cb); return; } this.isSlid = false; if(this.animFloat !== false){ this.beforeSlide(); this.el.slideOut(this.getSlideAnchor(), { callback: function(){ this.el.hide(); this.afterSlide(); this.afterSlideIn(); Ext.callback(cb); }, scope: this, block: true }); }else{ this.el.hide(); this.afterSlideIn(); } }, slideInIf : function(e){ if(!e.within(this.el)){ this.slideIn(); } }, anchors : { "west" : "left", "east" : "right", "north" : "top", "south" : "bottom" }, sanchors : { "west" : "l", "east" : "r", "north" : "t", "south" : "b" }, canchors : { "west" : "tl-tr", "east" : "tr-tl", "north" : "tl-bl", "south" : "bl-tl" }, getAnchor : function(){ return this.anchors[this.position]; }, getCollapseAnchor : function(){ return this.canchors[this.position]; }, getSlideAnchor : function(){ return this.sanchors[this.position]; }, getAlignAdj : function(){ var cm = this.cmargins; switch(this.position){ case "west": return [0, 0]; break; case "east": return [0, 0]; break; case "north": return [0, 0]; break; case "south": return [0, 0]; break; } }, getExpandAdj : function(){ var c = this.collapsedEl, cm = this.cmargins; switch(this.position){ case "west": return [-(cm.right+c.getWidth()+cm.left), 0]; break; case "east": return [cm.right+c.getWidth()+cm.left, 0]; break; case "north": return [0, -(cm.top+cm.bottom+c.getHeight())]; break; case "south": return [0, cm.top+cm.bottom+c.getHeight()]; break; } } }; Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){ Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos); this.applyLayout = this.applyFns[pos]; }; Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, { splitTip : "Drag to resize.", collapsibleSplitTip : "Drag to resize. Double click to hide.", useSplitTips : false, splitSettings : { north : { orientation: Ext.SplitBar.VERTICAL, placement: Ext.SplitBar.TOP, maxFn : 'getVMaxSize', minProp: 'minHeight', maxProp: 'maxHeight' }, south : { orientation: Ext.SplitBar.VERTICAL, placement: Ext.SplitBar.BOTTOM, maxFn : 'getVMaxSize', minProp: 'minHeight', maxProp: 'maxHeight' }, east : { orientation: Ext.SplitBar.HORIZONTAL, placement: Ext.SplitBar.RIGHT, maxFn : 'getHMaxSize', minProp: 'minWidth', maxProp: 'maxWidth' }, west : { orientation: Ext.SplitBar.HORIZONTAL, placement: Ext.SplitBar.LEFT, maxFn : 'getHMaxSize', minProp: 'minWidth', maxProp: 'maxWidth' } }, applyFns : { west : function(box){ if(this.isCollapsed){ return this.applyLayoutCollapsed(box); } var sd = this.splitEl.dom, s = sd.style; this.panel.setPosition(box.x, box.y); var sw = sd.offsetWidth; s.left = (box.x+box.width-sw)+'px'; s.top = (box.y)+'px'; s.height = Math.max(0, box.height)+'px'; this.panel.setSize(box.width-sw, box.height); }, east : function(box){ if(this.isCollapsed){ return this.applyLayoutCollapsed(box); } var sd = this.splitEl.dom, s = sd.style; var sw = sd.offsetWidth; this.panel.setPosition(box.x+sw, box.y); s.left = (box.x)+'px'; s.top = (box.y)+'px'; s.height = Math.max(0, box.height)+'px'; this.panel.setSize(box.width-sw, box.height); }, north : function(box){ if(this.isCollapsed){ return this.applyLayoutCollapsed(box); } var sd = this.splitEl.dom, s = sd.style; var sh = sd.offsetHeight; this.panel.setPosition(box.x, box.y); s.left = (box.x)+'px'; s.top = (box.y+box.height-sh)+'px'; s.width = Math.max(0, box.width)+'px'; this.panel.setSize(box.width, box.height-sh); }, south : function(box){ if(this.isCollapsed){ return this.applyLayoutCollapsed(box); } var sd = this.splitEl.dom, s = sd.style; var sh = sd.offsetHeight; this.panel.setPosition(box.x, box.y+sh); s.left = (box.x)+'px'; s.top = (box.y)+'px'; s.width = Math.max(0, box.width)+'px'; this.panel.setSize(box.width, box.height-sh); } }, render : function(ct, p){ Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p); var ps = this.position; this.splitEl = ct.createChild({ cls: "x-layout-split x-layout-split-"+ps, html: " ", id: this.panel.id + '-xsplit' }); if(this.collapseMode == 'mini'){ this.miniSplitEl = this.splitEl.createChild({ cls: "x-layout-mini x-layout-mini-"+ps, html: " " }); this.miniSplitEl.addClassOnOver('x-layout-mini-over'); this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true}); } var s = this.splitSettings[ps]; this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation); this.split.placement = s.placement; this.split.getMaximumSize = this[s.maxFn].createDelegate(this); this.split.minSize = this.minSize || this[s.minProp]; this.split.on("beforeapply", this.onSplitMove, this); this.split.useShim = this.useShim === true; this.maxSize = this.maxSize || this[s.maxProp]; if(p.hidden){ this.splitEl.hide(); } if(this.useSplitTips){ this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip; } if(this.collapsible){ this.splitEl.on("dblclick", this.onCollapseClick, this); } }, getSize : function(){ if(this.isCollapsed){ return this.collapsedEl.getSize(); } var s = this.panel.getSize(); if(this.position == 'north' || this.position == 'south'){ s.height += this.splitEl.dom.offsetHeight; }else{ s.width += this.splitEl.dom.offsetWidth; } return s; }, getHMaxSize : function(){ var cmax = this.maxSize || 10000; var center = this.layout.center; return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth()); }, getVMaxSize : function(){ var cmax = this.maxSize || 10000; var center = this.layout.center; return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight()); }, onSplitMove : function(split, newSize){ var s = this.panel.getSize(); this.lastSplitSize = newSize; if(this.position == 'north' || this.position == 'south'){ this.panel.setSize(s.width, newSize); this.state.height = newSize; }else{ this.panel.setSize(newSize, s.height); this.state.width = newSize; } this.layout.layout(); this.panel.saveState(); return false; }, getSplitBar : function(){ return this.split; } }); Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout; Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, { labelSeparator : ':', getAnchorViewSize : function(ct, target){ return ct.body.getStyleSize(); }, setContainer : function(ct){ Ext.layout.FormLayout.superclass.setContainer.call(this, ct); if(ct.labelAlign){ ct.addClass('x-form-label-'+ct.labelAlign); } if(ct.hideLabels){ this.labelStyle = "display:none"; this.elementStyle = "padding-left:0;"; this.labelAdjust = 0; }else{ this.labelSeparator = ct.labelSeparator || this.labelSeparator; ct.labelWidth = ct.labelWidth || 100; if(typeof ct.labelWidth == 'number'){ var pad = (typeof ct.labelPad == 'number' ? ct.labelPad : 5); this.labelAdjust = ct.labelWidth+pad; this.labelStyle = "width:"+ct.labelWidth+"px;"; this.elementStyle = "padding-left:"+(ct.labelWidth+pad)+'px'; } if(ct.labelAlign == 'top'){ this.labelStyle = "width:auto;"; this.labelAdjust = 0; this.elementStyle = "padding-left:0;"; } } if(!this.fieldTpl){ var t = new Ext.Template( '<div class="x-form-item {5}" tabIndex="-1">', '<label for="{0}" style="{2}" class="x-form-item-label">{1}{4}</label>', '<div class="x-form-element" id="x-form-el-{0}" style="{3}">', '</div><div class="{6}"></div>', '</div>' ); t.disableFormats = true; t.compile(); Ext.layout.FormLayout.prototype.fieldTpl = t; } }, renderItem : function(c, position, target){ if(c && !c.rendered && c.isFormField && c.inputType != 'hidden'){ var args = [ c.id, c.fieldLabel, c.labelStyle||this.labelStyle||'', this.elementStyle||'', typeof c.labelSeparator == 'undefined' ? this.labelSeparator : c.labelSeparator, (c.itemCls||this.container.itemCls||'') + (c.hideLabel ? ' x-hide-label' : ''), c.clearCls || 'x-form-clear-left' ]; if(typeof position == 'number'){ position = target.dom.childNodes[position] || null; } if(position){ this.fieldTpl.insertBefore(position, args); }else{ this.fieldTpl.append(target, args); } c.render('x-form-el-'+c.id); }else { Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments); } }, adjustWidthAnchor : function(value, comp){ return value - (comp.isFormField ? (comp.hideLabel ? 0 : this.labelAdjust) : 0); }, isValidParent : function(c, target){ return true; } }); Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
- Ext.layout.Accordion = Ext.extend(Ext.layout.FitLayout, {
- fill : true,
- autoWidth : true,
- titleCollapse : true,
- hideCollapseTool : false,
- collapseFirst : false,
- animate : false,
- sequence : false,
- activeOnTop : false,
- renderItem : function(c){
- if(this.animate === false){
- c.animCollapse = false;
- }
- c.collapsible = true;
- if(this.autoWidth){
- c.autoWidth = true;
- }
- if(this.titleCollapse){
- c.titleCollapse = true;
- }
- if(this.hideCollapseTool){
- c.hideCollapseTool = true;
- }
- if(this.collapseFirst !== undefined){
- c.collapseFirst = this.collapseFirst;
- }
- if(!this.activeItem && !c.collapsed){
- this.activeItem = c;
- }else if(this.activeItem){
- c.collapsed = true;
- }
- Ext.layout.Accordion.superclass.renderItem.apply(this, arguments);
- c.header.addClass('x-accordion-hd');
- c.on('beforeexpand', this.beforeExpand, this);
- },
- beforeExpand : function(p, anim){
- var ai = this.activeItem;
- if(ai){
- if(this.sequence){
- delete this.activeItem;
- if (!ai.collapsed){
- ai.collapse({callback:function(){
- p.expand(anim || true);
- }, scope: this});
- return false;
- }
- }else{
- ai.collapse(this.animate);
- }
- }
- this.activeItem = p;
- if(this.activeOnTop){
- p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
- }
- this.layout();
- },
- setItemSize : function(item, size){
- if(this.fill && item){
- var items = this.container.items.items;
- var hh = 0;
- for(var i = 0, len = items.length; i < len; i++){
- var p = items[i];
- if(p != item){
- hh += (p.getSize().height - p.bwrap.getHeight());
- }
- }
- size.height -= hh;
- item.setSize(size);
- }
- }
- });
- Ext.Container.LAYOUTS['accordion'] = Ext.layout.Accordion;
- Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:false,
- setContainer : function(ct){
- Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
- this.currentRow = 0;
- this.currentColumn = 0;
- this.cells = [];
- },
- onLayout : function(ct, target){
- var cs = ct.items.items, len = cs.length, c, i;
- if(!this.table){
- target.addClass('x-table-layout-ct');
- this.table = target.createChild(
- {tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, null, true);
- this.renderAll(ct, target);
- }
- },
- getRow : function(index){
- var row = this.table.tBodies[0].childNodes[index];
- if(!row){
- row = document.createElement('tr');
- this.table.tBodies[0].appendChild(row);
- }
- return row;
- },
- getNextCell : function(c){
- var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
- var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
- for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
- if(!this.cells[rowIndex]){
- this.cells[rowIndex] = [];
- }
- for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
- this.cells[rowIndex][colIndex] = true;
- }
- }
- var td = document.createElement('td');
- if(c.cellId){
- td.id = c.cellId;
- }
- var cls = 'x-table-layout-cell';
- if(c.cellCls){
- cls += ' ' + c.cellCls;
- }
- td.className = cls;
- if(c.colspan){
- td.colSpan = c.colspan;
- }
- if(c.rowspan){
- td.rowSpan = c.rowspan;
- }
- this.getRow(curRow).appendChild(td);
- return td;
- },
- getNextNonSpan: function(colIndex, rowIndex){
- var cols = this.columns;
- while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
- if(cols && colIndex >= cols){
- rowIndex++;
- colIndex = 0;
- }else{
- colIndex++;
- }
- }
- return [colIndex, rowIndex];
- },
- renderItem : function(c, position, target){
- if(c && !c.rendered){
- c.render(this.getNextCell(c));
- }
- },
- isValidParent : function(c, target){
- return true;
- }
- });
- Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
- Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
- extraCls: 'x-abs-layout-item',
- isForm: false,
- setContainer : function(ct){
- Ext.layout.AbsoluteLayout.superclass.setContainer.call(this, ct);
- if(ct.isXType('form')){
- this.isForm = true;
- }
- },
- onLayout : function(ct, target){
- if(this.isForm){ ct.body.position(); } else { target.position(); }
- Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
- },
- getAnchorViewSize : function(ct, target){
- return this.isForm ? ct.body.getStyleSize() : Ext.layout.AbsoluteLayout.superclass.getAnchorViewSize.call(this, ct, target);
- },
- isValidParent : function(c, target){
- return this.isForm ? true : Ext.layout.AbsoluteLayout.superclass.isValidParent.call(this, c, target);
- },
- adjustWidthAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[0] : value;
- },
- adjustHeightAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[1] : value;
- }
- });
- Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
- Ext.Viewport = Ext.extend(Ext.Container, {
- initComponent : function() {
- Ext.Viewport.superclass.initComponent.call(this);
- document.getElementsByTagName('html')[0].className += ' x-viewport';
- this.el = Ext.getBody();
- this.el.setHeight = Ext.emptyFn;
- this.el.setWidth = Ext.emptyFn;
- this.el.setSize = Ext.emptyFn;
- this.el.dom.scroll = 'no';
- this.allowDomMove = false;
- this.autoWidth = true;
- this.autoHeight = true;
- Ext.EventManager.onWindowResize(this.fireResize, this);
- this.renderTo = this.el;
- },
- fireResize : function(w, h){
- this.fireEvent('resize', this, w, h, w, h);
- }
- });
- Ext.reg('viewport', Ext.Viewport); Ext.Panel = Ext.extend(Ext.Container, { baseCls : 'x-panel', collapsedCls : 'x-panel-collapsed', maskDisabled: true, animCollapse: Ext.enableFx, headerAsText: true, buttonAlign: 'right', collapsed : false, collapseFirst: true, minButtonWidth:75, elements : 'body', toolTarget : 'header', collapseEl : 'bwrap', slideAnchor : 't', disabledClass: '', deferHeight: true, expandDefaults: { duration:.25 }, collapseDefaults: { duration:.25 }, initComponent : function(){ Ext.Panel.superclass.initComponent.call(this); this.addEvents( 'bodyresize', 'titlechange', 'collapse', 'expand', 'beforecollapse', 'beforeexpand', 'beforeclose', 'close', 'activate', 'deactivate' ); if(this.tbar){ this.elements += ',tbar'; if(typeof this.tbar == 'object'){ this.topToolbar = this.tbar; } delete this.tbar; } if(this.bbar){ this.elements += ',bbar'; if(typeof this.bbar == 'object'){ this.bottomToolbar = this.bbar; } delete this.bbar; } if(this.header === true){ this.elements += ',header'; delete this.header; }else if(this.title && this.header !== false){ this.elements += ',header'; } if(this.footer === true){ this.elements += ',footer'; delete this.footer; } if(this.buttons){ var btns = this.buttons; this.buttons = []; for(var i = 0, len = btns.length; i < len; i++) { if(btns[i].render){ btns[i].ownerCt = this; this.buttons.push(btns[i]); }else{ this.addButton(btns[i]); } } } if(this.autoLoad){ this.on('render', this.doAutoLoad, this, {delay:10}); } }, createElement : function(name, pnode){ if(this[name]){ pnode.appendChild(this[name].dom); return; } if(name === 'bwrap' || this.elements.indexOf(name) != -1){ if(this[name+'Cfg']){ this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']); }else{ var el = document.createElement('div'); el.className = this[name+'Cls']; this[name] = Ext.get(pnode.appendChild(el)); } } }, onRender : function(ct, position){ Ext.Panel.superclass.onRender.call(this, ct, position); this.createClasses(); if(this.el){ this.el.addClass(this.baseCls); this.header = this.el.down('.'+this.headerCls); this.bwrap = this.el.down('.'+this.bwrapCls); var cp = this.bwrap ? this.bwrap : this.el; this.tbar = cp.down('.'+this.tbarCls); this.body = cp.down('.'+this.bodyCls); this.bbar = cp.down('.'+this.bbarCls); this.footer = cp.down('.'+this.footerCls); this.fromMarkup = true; }else{ this.el = ct.createChild({ id: this.id, cls: this.baseCls }, position); } var el = this.el, d = el.dom; if(this.cls){ this.el.addClass(this.cls); } if(this.buttons){ this.elements += ',footer'; } if(this.frame){ el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls)); this.createElement('header', d.firstChild.firstChild.firstChild); this.createElement('bwrap', d); var bw = this.bwrap.dom; var ml = d.childNodes[1], bl = d.childNodes[2]; bw.appendChild(ml); bw.appendChild(bl); var mc = bw.firstChild.firstChild.firstChild; this.createElement('tbar', mc); this.createElement('body', mc); this.createElement('bbar', mc); this.createElement('footer', bw.lastChild.firstChild.firstChild); if(!this.footer){ this.bwrap.dom.lastChild.className += ' x-panel-nofooter'; } }else{ this.createElement('header', d); this.createElement('bwrap', d); var bw = this.bwrap.dom; this.createElement('tbar', bw); this.createElement('body', bw); this.createElement('bbar', bw); this.createElement('footer', bw); if(!this.header){ this.body.addClass(this.bodyCls + '-noheader'); if(this.tbar){ this.tbar.addClass(this.tbarCls + '-noheader'); } } } if(this.border === false){ this.el.addClass(this.baseCls + '-noborder'); this.body.addClass(this.bodyCls + '-noborder'); if(this.header){ this.header.addClass(this.headerCls + '-noborder'); } if(this.footer){ this.footer.addClass(this.footerCls + '-noborder'); } if(this.tbar){ this.tbar.addClass(this.tbarCls + '-noborder'); } if(this.bbar){ this.bbar.addClass(this.bbarCls + '-noborder'); } } if(this.bodyBorder === false){ this.body.addClass(this.bodyCls + '-noborder'); } if(this.bodyStyle){ this.body.applyStyles(this.bodyStyle); } this.bwrap.enableDisplayMode('block'); if(this.header){ this.header.unselectable(); if(this.headerAsText){ this.header.dom.innerHTML = '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>'; if(this.iconCls){ this.setIconClass(this.iconCls); } } } if(this.floating){ this.makeFloating(this.floating); } if(this.collapsible){ this.tools = this.tools ? this.tools.slice(0) : []; if(!this.hideCollapseTool){ this.tools[this.collapseFirst?'unshift':'push']({ id: 'toggle', handler : this.toggleCollapse, scope: this }); } if(this.titleCollapse && this.header){ this.header.on('click', this.toggleCollapse, this); this.header.setStyle('cursor', 'pointer'); } } if(this.tools){ var ts = this.tools; this.tools = {}; this.addTool.apply(this, ts); }else{ this.tools = {}; } if(this.buttons && this.buttons.length > 0){ var tb = this.footer.createChild({cls:'x-panel-btns-ct', cn: { cls:"x-panel-btns x-panel-btns-"+this.buttonAlign, html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>' }}, null, true); var tr = tb.getElementsByTagName('tr')[0]; for(var i = 0, len = this.buttons.length; i < len; i++) { var b = this.buttons[i]; var td = document.createElement('td'); td.className = 'x-panel-btn-td'; b.render(tr.appendChild(td)); } } if(this.tbar && this.topToolbar){ if(Ext.isArray(this.topToolbar)){ this.topToolbar = new Ext.Toolbar(this.topToolbar); } this.topToolbar.render(this.tbar); this.topToolbar.ownerCt = this; } if(this.bbar && this.bottomToolbar){ if(Ext.isArray(this.bottomToolbar)){ this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar); } this.bottomToolbar.render(this.bbar); this.bottomToolbar.ownerCt = this; } }, setIconClass : function(cls){ var old = this.iconCls; this.iconCls = cls; if(this.rendered && this.header){ if(this.frame){ this.header.addClass('x-panel-icon'); this.header.replaceClass(old, this.iconCls); }else{ var hd = this.header.dom; var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null; if(img){ Ext.fly(img).replaceClass(old, this.iconCls); }else{ Ext.DomHelper.insertBefore(hd.firstChild, { tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls }); } } } }, makeFloating : function(cfg){ this.floating = true; this.el = new Ext.Layer( typeof cfg == 'object' ? cfg : { shadow: this.shadow !== undefined ? this.shadow : 'sides', shadowOffset: this.shadowOffset, constrain:false, shim: this.shim === false ? false : undefined }, this.el ); }, getTopToolbar : function(){ return this.topToolbar; }, getBottomToolbar : function(){ return this.bottomToolbar; }, addButton : function(config, handler, scope){ var bc = { handler: handler, scope: scope, minWidth: this.minButtonWidth, hideParent:true }; if(typeof config == "string"){ bc.text = config; }else{ Ext.apply(bc, config); } var btn = new Ext.Button(bc); btn.ownerCt = this; if(!this.buttons){ this.buttons = []; } this.buttons.push(btn); return btn; }, addTool : function(){ if(!this[this.toolTarget]) { return; } if(!this.toolTemplate){ var tt = new Ext.Template( '<div class="x-tool x-tool-{id}"> </div>' ); tt.disableFormats = true; tt.compile(); Ext.Panel.prototype.toolTemplate = tt; } for(var i = 0, a = arguments, len = a.length; i < len; i++) { var tc = a[i], overCls = 'x-tool-'+tc.id+'-over'; var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true); this.tools[tc.id] = t; t.enableDisplayMode('block'); t.on('click', this.createToolHandler(t, tc, overCls, this)); if(tc.on){ t.on(tc.on); } if(tc.hidden){ t.hide(); } if(tc.qtip){ if(typeof tc.qtip == 'object'){ Ext.QuickTips.register(Ext.apply({ target: t.id }, tc.qtip)); } else { t.dom.qtip = tc.qtip; } } t.addClassOnOver(overCls); } }, onShow : function(){ if(this.floating){ return this.el.show(); } Ext.Panel.superclass.onShow.call(this); }, onHide : function(){ if(this.floating){ return this.el.hide(); } Ext.Panel.superclass.onHide.call(this); }, createToolHandler : function(t, tc, overCls, panel){ return function(e){ t.removeClass(overCls); e.stopEvent(); if(tc.handler){ tc.handler.call(tc.scope || t, e, t, panel); } }; }, afterRender : function(){ if(this.fromMarkup && this.height === undefined && !this.autoHeight){ this.height = this.el.getHeight(); } if(this.floating && !this.hidden && !this.initHidden){ this.el.show(); } if(this.title){ this.setTitle(this.title); } this.setAutoScroll(); if(this.html){ this.body.update(typeof this.html == 'object' ? Ext.DomHelper.markup(this.html) : this.html); delete this.html; } if(this.contentEl){ var ce = Ext.getDom(this.contentEl); Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']); this.body.dom.appendChild(ce); } if(this.collapsed){ this.collapsed = false; this.collapse(false); } Ext.Panel.superclass.afterRender.call(this); this.initEvents(); }, setAutoScroll : function(){ if(this.rendered && this.autoScroll){ var el = this.body || this.el; if(el){ el.setOverflow('auto'); } } }, getKeyMap : function(){ if(!this.keyMap){ this.keyMap = new Ext.KeyMap(this.el, this.keys); } return this.keyMap; }, initEvents : function(){ if(this.keys){ this.getKeyMap(); } if(this.draggable){ this.initDraggable(); } }, initDraggable : function(){ this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable); }, beforeEffect : function(){ if(this.floating){ this.el.beforeAction(); } this.el.addClass('x-panel-animated'); }, afterEffect : function(){ this.syncShadow(); this.el.removeClass('x-panel-animated'); }, createEffect : function(a, cb, scope){ var o = { scope:scope, block:true }; if(a === true){ o.callback = cb; return o; }else if(!a.callback){ o.callback = cb; }else { o.callback = function(){ cb.call(scope); Ext.callback(a.callback, a.scope); }; } return Ext.applyIf(o, a); }, collapse : function(animate){ if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){ return; } var doAnim = animate === true || (animate !== false && this.animCollapse); this.beforeEffect(); this.onCollapse(doAnim, animate); return this; }, onCollapse : function(doAnim, animArg){ if(doAnim){ this[this.collapseEl].slideOut(this.slideAnchor, Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this), this.collapseDefaults)); }else{ this[this.collapseEl].hide(); this.afterCollapse(); } }, afterCollapse : function(){ this.collapsed = true; this.el.addClass(this.collapsedCls); this.afterEffect(); this.fireEvent('collapse', this); }, expand : function(animate){ if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){ return; } var doAnim = animate === true || (animate !== false && this.animCollapse); this.el.removeClass(this.collapsedCls); this.beforeEffect(); this.onExpand(doAnim, animate); return this; }, onExpand : function(doAnim, animArg){ if(doAnim){ this[this.collapseEl].slideIn(this.slideAnchor, Ext.apply(this.createEffect(animArg||true, this.afterExpand, this), this.expandDefaults)); }else{ this[this.collapseEl].show(); this.afterExpand(); } }, afterExpand : function(){ this.collapsed = false; this.afterEffect(); this.fireEvent('expand', this); }, toggleCollapse : function(animate){ this[this.collapsed ? 'expand' : 'collapse'](animate); return this; }, onDisable : function(){ if(this.rendered && this.maskDisabled){ this.el.mask(); } Ext.Panel.superclass.onDisable.call(this); }, onEnable : function(){ if(this.rendered && this.maskDisabled){ this.el.unmask(); } Ext.Panel.superclass.onEnable.call(this); }, onResize : function(w, h){ if(w !== undefined || h !== undefined){ if(!this.collapsed){ if(typeof w == 'number'){ this.body.setWidth( this.adjustBodyWidth(w - this.getFrameWidth())); }else if(w == 'auto'){ this.body.setWidth(w); } if(typeof h == 'number'){ this.body.setHeight( this.adjustBodyHeight(h - this.getFrameHeight())); }else if(h == 'auto'){ this.body.setHeight(h); } if(this.disabled && this.el._mask){ this.el._mask.setSize(this.el.dom.clientWidth, this.el.getHeight()); } }else{ this.queuedBodySize = {width: w, height: h}; if(!this.queuedExpand && this.allowQueuedExpand !== false){ this.queuedExpand = true; this.on('expand', function(){ delete this.queuedExpand; this.onResize(this.queuedBodySize.width, this.queuedBodySize.height); this.doLayout(); }, this, {single:true}); } } this.fireEvent('bodyresize', this, w, h); } this.syncShadow(); }, adjustBodyHeight : function(h){ return h; }, adjustBodyWidth : function(w){ return w; }, onPosition : function(){ this.syncShadow(); }, getFrameWidth : function(){ var w = this.el.getFrameWidth('lr'); if(this.frame){ var l = this.bwrap.dom.firstChild; w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r')); var mc = this.bwrap.dom.firstChild.firstChild.firstChild; w += Ext.fly(mc).getFrameWidth('lr'); } return w; }, getFrameHeight : function(){ var h = this.el.getFrameWidth('tb'); h += (this.tbar ? this.tbar.getHeight() : 0) + (this.bbar ? this.bbar.getHeight() : 0); if(this.frame){ var hd = this.el.dom.firstChild; var ft = this.bwrap.dom.lastChild; h += (hd.offsetHeight + ft.offsetHeight); var mc = this.bwrap.dom.firstChild.firstChild.firstChild; h += Ext.fly(mc).getFrameWidth('tb'); }else{ h += (this.header ? this.header.getHeight() : 0) + (this.footer ? this.footer.getHeight() : 0); } return h; }, getInnerWidth : function(){ return this.getSize().width - this.getFrameWidth(); }, getInnerHeight : function(){ return this.getSize().height - this.getFrameHeight(); }, syncShadow : function(){ if(this.floating){ this.el.sync(true); } }, getLayoutTarget : function(){ return this.body; }, setTitle : function(title, iconCls){ this.title = title; if(this.header && this.headerAsText){ this.header.child('span').update(title); } if(iconCls){ this.setIconClass(iconCls); } this.fireEvent('titlechange', this, title); return this; }, getUpdater : function(){ return this.body.getUpdater(); }, load : function(){ var um = this.body.getUpdater(); um.update.apply(um, arguments); return this; }, beforeDestroy : function(){ Ext.Element.uncache( this.header, this.tbar, this.bbar, this.footer, this.body ); if(this.tools){ for(var k in this.tools){ Ext.destroy(this.tools[k]); } } if(this.buttons){ for(var b in this.buttons){ Ext.destroy(this.buttons[b]); } } Ext.destroy( this.topToolbar, this.bottomToolbar ); Ext.Panel.superclass.beforeDestroy.call(this); }, createClasses : function(){ this.headerCls = this.baseCls + '-header'; this.headerTextCls = this.baseCls + '-header-text'; this.bwrapCls = this.baseCls + '-bwrap'; this.tbarCls = this.baseCls + '-tbar'; this.bodyCls = this.baseCls + '-body'; this.bbarCls = this.baseCls + '-bbar'; this.footerCls = this.baseCls + '-footer'; }, createGhost : function(cls, useShim, appendTo){ var el = document.createElement('div'); el.className = 'x-panel-ghost ' + (cls ? cls : ''); if(this.header){ el.appendChild(this.el.dom.firstChild.cloneNode(true)); } Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight()); el.style.width = this.el.dom.offsetWidth + 'px';; if(!appendTo){ this.container.dom.appendChild(el); }else{ Ext.getDom(appendTo).appendChild(el); } if(useShim !== false && this.el.useShim !== false){ var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el); layer.show(); return layer; }else{ return new Ext.Element(el); } }, doAutoLoad : function(){ this.body.load( typeof this.autoLoad == 'object' ? this.autoLoad : {url: this.autoLoad}); } }); Ext.reg('panel', Ext.Panel); Ext.Window = Ext.extend(Ext.Panel, { baseCls : 'x-window', resizable:true, draggable:true, closable : true, constrain:false, constrainHeader:false, plain:false, minimizable : false, maximizable : false, minHeight: 100, minWidth: 200, expandOnShow: true, closeAction: 'close', elements: 'header,body', collapsible:false, initHidden : true, monitorResize : true, frame:true, floating:true, initComponent : function(){ Ext.Window.superclass.initComponent.call(this); this.addEvents( 'resize', 'maximize', 'minimize', 'restore' ); }, getState : function(){ return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox()); }, onRender : function(ct, position){ Ext.Window.superclass.onRender.call(this, ct, position); if(this.plain){ this.el.addClass('x-window-plain'); } this.focusEl = this.el.createChild({ tag: "a", href:"#", cls:"x-dlg-focus", tabIndex:"-1", html: " "}); this.focusEl.swallowEvent('click', true); this.proxy = this.el.createProxy("x-window-proxy"); this.proxy.enableDisplayMode('block'); if(this.modal){ this.mask = this.container.createChild({cls:"ext-el-mask"}, this.el.dom); this.mask.enableDisplayMode("block"); this.mask.hide(); } }, initEvents : function(){ Ext.Window.superclass.initEvents.call(this); if(this.animateTarget){ this.setAnimateTarget(this.animateTarget); } if(this.resizable){ this.resizer = new Ext.Resizable(this.el, { minWidth: this.minWidth, minHeight:this.minHeight, handles: this.resizeHandles || "all", pinned: true, resizeElement : this.resizerAction }); this.resizer.window = this; this.resizer.on("beforeresize", this.beforeResize, this); } if(this.draggable){ this.header.addClass("x-window-draggable"); } this.initTools(); this.el.on("mousedown", this.toFront, this); this.manager = this.manager || Ext.WindowMgr; this.manager.register(this); this.hidden = true; if(this.maximized){ this.maximized = false; this.maximize(); } if(this.closable){ var km = this.getKeyMap(); km.on(27, this.onEsc, this); km.disable(); } }, initDraggable : function(){ this.dd = new Ext.Window.DD(this); }, onEsc : function(){ this[this.closeAction](); }, beforeDestroy : function(){ Ext.destroy( this.resizer, this.dd, this.proxy, this.mask ); Ext.Window.superclass.beforeDestroy.call(this); }, onDestroy : function(){ if(this.manager){ this.manager.unregister(this); } Ext.Window.superclass.onDestroy.call(this); }, initTools : function(){ if(this.minimizable){ this.addTool({ id: 'minimize', handler: this.minimize.createDelegate(this, []) }); } if(this.maximizable){ this.addTool({ id: 'maximize', handler: this.maximize.createDelegate(this, []) }); this.addTool({ id: 'restore', handler: this.restore.createDelegate(this, []), hidden:true }); this.header.on('dblclick', this.toggleMaximize, this); } if(this.closable){ this.addTool({ id: 'close', handler: this[this.closeAction].createDelegate(this, []) }); } }, resizerAction : function(){ var box = this.proxy.getBox(); this.proxy.hide(); this.window.handleResize(box); return box; }, beforeResize : function(){ this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40); this.resizeBox = this.el.getBox(); }, updateHandles : function(){ if(Ext.isIE && this.resizer){ this.resizer.syncHandleHeight(); this.el.repaint(); } }, handleResize : function(box){ var rz = this.resizeBox; if(rz.x != box.x || rz.y != box.y){ this.updateBox(box); }else{ this.setSize(box); } this.focus(); this.updateHandles(); this.saveState(); if(this.layout){ this.doLayout(); } this.fireEvent("resize", this, box.width, box.height); }, focus : function(){ var f = this.focusEl, db = this.defaultButton, t = typeof db; if(t != 'undefined'){ if(t == 'number'){ f = this.buttons[db]; }else if(t == 'string'){ f = Ext.getCmp(db); }else{ f = db; } } f.focus.defer(10, f); }, setAnimateTarget : function(el){ el = Ext.get(el); this.animateTarget = el; }, beforeShow : function(){ delete this.el.lastXY; delete this.el.lastLT; if(this.x === undefined || this.y === undefined){ var xy = this.el.getAlignToXY(this.container, 'c-c'); var pos = this.el.translatePoints(xy[0], xy[1]); this.x = this.x === undefined? pos.left : this.x; this.y = this.y === undefined? pos.top : this.y; } this.el.setLeftTop(this.x, this.y); if(this.expandOnShow){ this.expand(false); } if(this.modal){ Ext.getBody().addClass("x-body-masked"); this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true)); this.mask.show(); } }, show : function(animateTarget, cb, scope){ if(!this.rendered){ this.render(Ext.getBody()); } if(this.hidden === false){ this.toFront(); return; } if(this.fireEvent("beforeshow", this) === false){ return; } if(cb){ this.on('show', cb, scope, {single:true}); } this.hidden = false; if(animateTarget !== undefined){ this.setAnimateTarget(animateTarget); } this.beforeShow(); if(this.animateTarget){ this.animShow(); }else{ this.afterShow(); } }, afterShow : function(){ this.proxy.hide(); this.el.setStyle('display', 'block'); this.el.show(); if(this.maximized){ this.fitContainer(); } if(Ext.isMac && Ext.isGecko){ this.cascade(this.setAutoScroll); } if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){ Ext.EventManager.onWindowResize(this.onWindowResize, this); } this.doConstrain(); if(this.layout){ this.doLayout(); } if(this.keyMap){ this.keyMap.enable(); } this.toFront(); this.updateHandles(); this.fireEvent("show", this); }, animShow : function(){ this.proxy.show(); this.proxy.setBox(this.animateTarget.getBox()); this.proxy.setOpacity(0); var b = this.getBox(false); b.callback = this.afterShow; b.scope = this; b.duration = .25; b.easing = 'easeNone'; b.opacity = .5; b.block = true; this.el.setStyle('display', 'none'); this.proxy.shift(b); }, hide : function(animateTarget, cb, scope){ if(this.activeGhost){ this.hide.defer(100, this, [animateTarget, cb, scope]); return; } if(this.hidden || this.fireEvent("beforehide", this) === false){ return; } if(cb){ this.on('hide', cb, scope, {single:true}); } this.hidden = true; if(animateTarget !== undefined){ this.setAnimateTarget(animateTarget); } if(this.animateTarget){ this.animHide(); }else{ this.el.hide(); this.afterHide(); } }, afterHide : function(){ this.proxy.hide(); if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){ Ext.EventManager.removeResizeListener(this.onWindowResize, this); } if(this.modal){ this.mask.hide(); Ext.getBody().removeClass("x-body-masked"); } if(this.keyMap){ this.keyMap.disable(); } this.fireEvent("hide", this); }, animHide : function(){ this.proxy.setOpacity(.5); this.proxy.show(); var tb = this.getBox(false); this.proxy.setBox(tb); this.el.hide(); var b = this.animateTarget.getBox(); b.callback = this.afterHide; b.scope = this; b.duration = .25; b.easing = 'easeNone'; b.block = true; b.opacity = 0; this.proxy.shift(b); }, onWindowResize : function(){ if(this.maximized){ this.fitContainer(); } if(this.modal){ this.mask.setSize('100%', '100%'); var force = this.mask.dom.offsetHeight; this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true)); } this.doConstrain(); }, doConstrain : function(){ if(this.constrain || this.constrainHeader){ var offsets; if(this.constrain){ offsets = { right:this.el.shadowOffset, left:this.el.shadowOffset, bottom:this.el.shadowOffset }; }else { var s = this.getSize(); offsets = { right:-(s.width - 100), bottom:-(s.height - 25) }; } var xy = this.el.getConstrainToXY(this.container, true, offsets); if(xy){ this.setPosition(xy[0], xy[1]); } } }, ghost : function(cls){ var ghost = this.createGhost(cls); var box = this.getBox(true); ghost.setLeftTop(box.x, box.y); ghost.setWidth(box.width); this.el.hide(); this.activeGhost = ghost; return ghost; }, unghost : function(show, matchPosition){ if(show !== false){ this.el.show(); this.focus(); if(Ext.isMac && Ext.isGecko){ this.cascade(this.setAutoScroll); } } if(matchPosition !== false){ this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true)); } this.activeGhost.hide(); this.activeGhost.remove(); delete this.activeGhost; }, minimize : function(){ this.fireEvent('minimize', this); }, close : function(){ if(this.fireEvent("beforeclose", this) !== false){ this.hide(null, function(){ this.fireEvent('close', this); this.destroy(); }, this); } }, maximize : function(){ if(!this.maximized){ this.expand(false); this.restoreSize = this.getSize(); this.restorePos = this.getPosition(true); if (this.maximizable){ this.tools.maximize.hide(); this.tools.restore.show(); } this.maximized = true; this.el.disableShadow(); if(this.dd){ this.dd.lock(); } if(this.collapsible){ this.tools.toggle.hide(); } this.el.addClass('x-window-maximized'); this.container.addClass('x-window-maximized-ct'); this.setPosition(0, 0); this.fitContainer(); this.fireEvent('maximize', this); } }, restore : function(){ if(this.maximized){ this.el.removeClass('x-window-maximized'); this.tools.restore.hide(); this.tools.maximize.show(); this.setPosition(this.restorePos[0], this.restorePos[1]); this.setSize(this.restoreSize.width, this.restoreSize.height); delete this.restorePos; delete this.restoreSize; this.maximized = false; this.el.enableShadow(true); if(this.dd){ this.dd.unlock(); } if(this.collapsible){ this.tools.toggle.show(); } this.container.removeClass('x-window-maximized-ct'); this.doConstrain(); this.fireEvent('restore', this); } }, toggleMaximize : function(){ this[this.maximized ? 'restore' : 'maximize'](); }, fitContainer : function(){ var vs = this.container.getViewSize(); this.setSize(vs.width, vs.height); }, setZIndex : function(index){ if(this.modal){ this.mask.setStyle("z-index", index); } this.el.setZIndex(++index); index += 5; if(this.resizer){ this.resizer.proxy.setStyle("z-index", ++index); } this.lastZIndex = index; }, alignTo : function(element, position, offsets){ var xy = this.el.getAlignToXY(element, position, offsets); this.setPagePosition(xy[0], xy[1]); return this; }, anchorTo : function(el, alignment, offsets, monitorScroll, _pname){ var action = function(){ this.alignTo(el, alignment, offsets); }; Ext.EventManager.onWindowResize(action, this); var tm = typeof monitorScroll; if(tm != 'undefined'){ Ext.EventManager.on(window, 'scroll', action, this, {buffer: tm == 'number' ? monitorScroll : 50}); } action.call(this); this[_pname] = action; return this; }, toFront : function(){ if(this.manager.bringToFront(this)){ this.focus(); } return this; }, setActive : function(active){ if(active){ if(!this.maximized){ this.el.enableShadow(true); } this.fireEvent('activate', this); }else{ this.el.disableShadow(); this.fireEvent('deactivate', this); } }, toBack : function(){ this.manager.sendToBack(this); return this; }, center : function(){ var xy = this.el.getAlignToXY(this.container, 'c-c'); this.setPagePosition(xy[0], xy[1]); return this; } }); Ext.reg('window', Ext.Window); Ext.Window.DD = function(win){ this.win = win; Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id); this.setHandleElId(win.header.id); this.scroll = false; }; Ext.extend(Ext.Window.DD, Ext.dd.DD, { moveOnly:true, headerOffsets:[100, 25], startDrag : function(){ var w = this.win; this.proxy = w.ghost(); if(w.constrain !== false){ var so = w.el.shadowOffset; this.constrainTo(w.container, {right: so, left: so, bottom: so}); }else if(w.constrainHeader !== false){ var s = this.proxy.getSize(); this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])}); } }, b4Drag : Ext.emptyFn, onDrag : function(e){ this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY()); }, endDrag : function(e){ this.win.unghost(); this.win.saveState(); } }); Ext.WindowGroup = function(){ var list = {}; var accessList = []; var front = null; var sortWindows = function(d1, d2){ return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1; }; var orderWindows = function(){ var a = accessList, len = a.length; if(len > 0){ a.sort(sortWindows); var seed = a[0].manager.zseed; for(var i = 0; i < len; i++){ var win = a[i]; if(win && !win.hidden){ win.setZIndex(seed + (i*10)); } } } activateLast(); }; var setActiveWin = function(win){ if(win != front){ if(front){ front.setActive(false); } front = win; if(win){ win.setActive(true); } } }; var activateLast = function(){ for(var i = accessList.length-1; i >=0; --i) { if(!accessList[i].hidden){ setActiveWin(accessList[i]); return; } } setActiveWin(null); }; return { zseed : 9000, register : function(win){ list[win.id] = win; accessList.push(win); win.on('hide', activateLast); }, unregister : function(win){ delete list[win.id]; win.un('hide', activateLast); accessList.remove(win); }, get : function(id){ return typeof id == "object" ? id : list[id]; }, bringToFront : function(win){ win = this.get(win); if(win != front){ win._lastAccess = new Date().getTime(); orderWindows(); return true; } return false; }, sendToBack : function(win){ win = this.get(win); win._lastAccess = -(new Date().getTime()); orderWindows(); return win; }, hideAll : function(){ for(var id in list){ if(list[id] && typeof list[id] != "function" && list[id].isVisible()){ list[id].hide(); } } }, getActive : function(){ return front; }, getBy : function(fn, scope){ var r = []; for(var i = accessList.length-1; i >=0; --i) { var win = accessList[i]; if(fn.call(scope||win, win) !== false){ r.push(win); } } return r; }, each : function(fn, scope){ for(var id in list){ if(list[id] && typeof list[id] != "function"){ if(fn.call(scope || list[id], list[id]) === false){ return; } } } } }; }; Ext.WindowMgr = new Ext.WindowGroup();
- Ext.dd.PanelProxy = function(panel, config){
- this.panel = panel;
- this.id = this.panel.id +'-ddproxy';
- Ext.apply(this, config);
- };
- Ext.dd.PanelProxy.prototype = {
- insertProxy : true,
- setStatus : Ext.emptyFn,
- reset : Ext.emptyFn,
- update : Ext.emptyFn,
- stop : Ext.emptyFn,
- sync: Ext.emptyFn,
- getEl : function(){
- return this.ghost;
- },
- getGhost : function(){
- return this.ghost;
- },
- getProxy : function(){
- return this.proxy;
- },
- hide : function(){
- if(this.ghost){
- if(this.proxy){
- this.proxy.remove();
- delete this.proxy;
- }
- this.panel.el.dom.style.display = '';
- this.ghost.remove();
- delete this.ghost;
- }
- },
- show : function(){
- if(!this.ghost){
- this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
- this.ghost.setXY(this.panel.el.getXY())
- if(this.insertProxy){
- this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
- this.proxy.setSize(this.panel.getSize());
- }
- this.panel.el.dom.style.display = 'none';
- }
- },
- repair : function(xy, callback, scope){
- this.hide();
- if(typeof callback == "function"){
- callback.call(scope || this);
- }
- },
- moveProxy : function(parentNode, before){
- if(this.proxy){
- parentNode.insertBefore(this.proxy.dom, before);
- }
- }
- };
- Ext.Panel.DD = function(panel, cfg){
- this.panel = panel;
- this.dragData = {panel: panel};
- this.proxy = new Ext.dd.PanelProxy(panel, cfg);
- Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
- var h = panel.header;
- if(h){
- this.setHandleElId(h.id);
- }
- (h ? h : this.panel.body).setStyle('cursor', 'move');
- this.scroll = false;
- };
- Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
- showFrame: Ext.emptyFn,
- startDrag: Ext.emptyFn,
- b4StartDrag: function(x, y) {
- this.proxy.show();
- },
- b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
- this.autoOffset(x, y);
- },
- onInitDrag : function(x, y){
- this.onStartDrag(x, y);
- return true;
- },
- createFrame : Ext.emptyFn,
- getDragEl : function(e){
- return this.proxy.ghost.dom;
- },
- endDrag : function(e){
- this.proxy.hide();
- this.panel.saveState();
- },
- autoOffset : function(x, y) {
- x -= this.startPageX;
- y -= this.startPageY;
- this.setDelta(x, y);
- }
- });
- Ext.state.Provider = function(){
- this.addEvents("statechange");
- this.state = {};
- Ext.state.Provider.superclass.constructor.call(this);
- };
- Ext.extend(Ext.state.Provider, Ext.util.Observable, {
- get : function(name, defaultValue){
- return typeof this.state[name] == "undefined" ?
- defaultValue : this.state[name];
- },
- clear : function(name){
- delete this.state[name];
- this.fireEvent("statechange", this, name, null);
- },
- set : function(name, value){
- this.state[name] = value;
- this.fireEvent("statechange", this, name, value);
- },
- decodeValue : function(cookie){
- var re = /^(a|n|d|b|s|o):(.*)$/;
- var matches = re.exec(unescape(cookie));
- if(!matches || !matches[1]) return; var type = matches[1];
- var v = matches[2];
- switch(type){
- case "n":
- return parseFloat(v);
- case "d":
- return new Date(Date.parse(v));
- case "b":
- return (v == "1");
- case "a":
- var all = [];
- var values = v.split("^");
- for(var i = 0, len = values.length; i < len; i++){
- all.push(this.decodeValue(values[i]));
- }
- return all;
- case "o":
- var all = {};
- var values = v.split("^");
- for(var i = 0, len = values.length; i < len; i++){
- var kv = values[i].split("=");
- all[kv[0]] = this.decodeValue(kv[1]);
- }
- return all;
- default:
- return v;
- }
- },
- encodeValue : function(v){
- var enc;
- if(typeof v == "number"){
- enc = "n:" + v;
- }else if(typeof v == "boolean"){
- enc = "b:" + (v ? "1" : "0");
- }else if(Ext.isDate(v)){
- enc = "d:" + v.toGMTString();
- }else if(Ext.isArray(v)){
- var flat = "";
- for(var i = 0, len = v.length; i < len; i++){
- flat += this.encodeValue(v[i]);
- if(i != len-1) flat += "^";
- }
- enc = "a:" + flat;
- }else if(typeof v == "object"){
- var flat = "";
- for(var key in v){
- if(typeof v[key] != "function" && v[key] !== undefined){
- flat += key + "=" + this.encodeValue(v[key]) + "^";
- }
- }
- enc = "o:" + flat.substring(0, flat.length-1);
- }else{
- enc = "s:" + v;
- }
- return escape(enc);
- }
- });
- Ext.state.Manager = function(){
- var provider = new Ext.state.Provider();
- return {
- setProvider : function(stateProvider){
- provider = stateProvider;
- },
- get : function(key, defaultValue){
- return provider.get(key, defaultValue);
- },
- set : function(key, value){
- provider.set(key, value);
- },
- clear : function(key){
- provider.clear(key);
- },
- getProvider : function(){
- return provider;
- }
- };
- }();
- Ext.state.CookieProvider = function(config){
- Ext.state.CookieProvider.superclass.constructor.call(this);
- this.path = "/";
- this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); this.domain = null;
- this.secure = false;
- Ext.apply(this, config);
- this.state = this.readCookies();
- };
- Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
- set : function(name, value){
- if(typeof value == "undefined" || value === null){
- this.clear(name);
- return;
- }
- this.setCookie(name, value);
- Ext.state.CookieProvider.superclass.set.call(this, name, value);
- },
- clear : function(name){
- this.clearCookie(name);
- Ext.state.CookieProvider.superclass.clear.call(this, name);
- },
- readCookies : function(){
- var cookies = {};
- var c = document.cookie + ";";
- var re = /s?(.*?)=(.*?);/g;
- var matches;
- while((matches = re.exec(c)) != null){
- var name = matches[1];
- var value = matches[2];
- if(name && name.substring(0,3) == "ys-"){
- cookies[name.substr(3)] = this.decodeValue(value);
- }
- }
- return cookies;
- },
- setCookie : function(name, value){
- document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
- ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- },
- clearCookie : function(name){
- document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- }
- }); Ext.DataView = Ext.extend(Ext.BoxComponent, { selectedClass : "x-view-selected", emptyText : "", deferEmptyText: true, trackOver: false, last: false, initComponent : function(){ Ext.DataView.superclass.initComponent.call(this); if(typeof this.tpl == "string"){ this.tpl = new Ext.XTemplate(this.tpl); } this.addEvents( "beforeclick", "click", "mouseenter", "mouseleave", "containerclick", "dblclick", "contextmenu", "selectionchange", "beforeselect" ); this.all = new Ext.CompositeElementLite(); this.selected = new Ext.CompositeElementLite(); }, onRender : function(){ if(!this.el){ this.el = document.createElement('div'); this.el.id = this.id; } Ext.DataView.superclass.onRender.apply(this, arguments); }, afterRender : function(){ Ext.DataView.superclass.afterRender.call(this); this.el.on({ "click": this.onClick, "dblclick": this.onDblClick, "contextmenu": this.onContextMenu, scope:this }); if(this.overClass || this.trackOver){ this.el.on({ "mouseover": this.onMouseOver, "mouseout": this.onMouseOut, scope:this }); } if(this.store){ this.setStore(this.store, true); } }, refresh : function(){ this.clearSelections(false, true); this.el.update(""); var records = this.store.getRange(); if(records.length < 1){ if(!this.deferEmptyText || this.hasSkippedEmptyText){ this.el.update(this.emptyText); } this.hasSkippedEmptyText = true; this.all.clear(); return; } this.tpl.overwrite(this.el, this.collectData(records, 0)); this.all.fill(Ext.query(this.itemSelector, this.el.dom)); this.updateIndexes(0); }, prepareData : function(data){ return data; }, collectData : function(records, startIndex){ var r = []; for(var i = 0, len = records.length; i < len; i++){ r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]); } return r; }, bufferRender : function(records){ var div = document.createElement('div'); this.tpl.overwrite(div, this.collectData(records)); return Ext.query(this.itemSelector, div); }, onUpdate : function(ds, record){ var index = this.store.indexOf(record); var sel = this.isSelected(index); var original = this.all.elements[index]; var node = this.bufferRender([record], index)[0]; this.all.replaceElement(index, node, true); if(sel){ this.selected.replaceElement(original, node); this.all.item(index).addClass(this.selectedClass); } this.updateIndexes(index, index); }, onAdd : function(ds, records, index){ if(this.all.getCount() == 0){ this.refresh(); return; } var nodes = this.bufferRender(records, index), n, a = this.all.elements; if(index < this.all.getCount()){ n = this.all.item(index).insertSibling(nodes, 'before', true); a.splice.apply(a, [index, 0].concat(nodes)); }else{ n = this.all.last().insertSibling(nodes, 'after', true); a.push.apply(a, nodes); } this.updateIndexes(index); }, onRemove : function(ds, record, index){ this.deselect(index); this.all.removeElement(index, true); this.updateIndexes(index); }, refreshNode : function(index){ this.onUpdate(this.store, this.store.getAt(index)); }, updateIndexes : function(startIndex, endIndex){ var ns = this.all.elements; startIndex = startIndex || 0; endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1)); for(var i = startIndex; i <= endIndex; i++){ ns[i].viewIndex = i; } }, setStore : function(store, initial){ if(!initial && this.store){ this.store.un("beforeload", this.onBeforeLoad, this); this.store.un("datachanged", this.refresh, this); this.store.un("add", this.onAdd, this); this.store.un("remove", this.onRemove, this); this.store.un("update", this.onUpdate, this); this.store.un("clear", this.refresh, this); } if(store){ store = Ext.StoreMgr.lookup(store); store.on("beforeload", this.onBeforeLoad, this); store.on("datachanged", this.refresh, this); store.on("add", this.onAdd, this); store.on("remove", this.onRemove, this); store.on("update", this.onUpdate, this); store.on("clear", this.refresh, this); } this.store = store; if(store){ this.refresh(); } }, findItemFromChild : function(node){ return Ext.fly(node).findParent(this.itemSelector, this.el); }, onClick : function(e){ var item = e.getTarget(this.itemSelector, this.el); if(item){ var index = this.indexOf(item); if(this.onItemClick(item, index, e) !== false){ this.fireEvent("click", this, index, item, e); } }else{ if(this.fireEvent("containerclick", this, e) !== false){ this.clearSelections(); } } }, onContextMenu : function(e){ var item = e.getTarget(this.itemSelector, this.el); if(item){ this.fireEvent("contextmenu", this, this.indexOf(item), item, e); } }, onDblClick : function(e){ var item = e.getTarget(this.itemSelector, this.el); if(item){ this.fireEvent("dblclick", this, this.indexOf(item), item, e); } }, onMouseOver : function(e){ var item = e.getTarget(this.itemSelector, this.el); if(item && item !== this.lastItem){ this.lastItem = item; Ext.fly(item).addClass(this.overClass); this.fireEvent("mouseenter", this, this.indexOf(item), item, e); } }, onMouseOut : function(e){ if(this.lastItem){ if(!e.within(this.lastItem, true)){ Ext.fly(this.lastItem).removeClass(this.overClass); this.fireEvent("mouseleave", this, this.indexOf(this.lastItem), this.lastItem, e); delete this.lastItem; } } }, onItemClick : function(item, index, e){ if(this.fireEvent("beforeclick", this, index, item, e) === false){ return false; } if(this.multiSelect){ this.doMultiSelection(item, index, e); e.preventDefault(); }else if(this.singleSelect){ this.doSingleSelection(item, index, e); e.preventDefault(); } return true; }, doSingleSelection : function(item, index, e){ if(e.ctrlKey && this.isSelected(index)){ this.deselect(index); }else{ this.select(index, false); } }, doMultiSelection : function(item, index, e){ if(e.shiftKey && this.last !== false){ var last = this.last; this.selectRange(last, index, e.ctrlKey); this.last = last; }else{ if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){ this.deselect(index); }else{ this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect); } } }, getSelectionCount : function(){ return this.selected.getCount() }, getSelectedNodes : function(){ return this.selected.elements; }, getSelectedIndexes : function(){ var indexes = [], s = this.selected.elements; for(var i = 0, len = s.length; i < len; i++){ indexes.push(s[i].viewIndex); } return indexes; }, getSelectedRecords : function(){ var r = [], s = this.selected.elements; for(var i = 0, len = s.length; i < len; i++){ r[r.length] = this.store.getAt(s[i].viewIndex); } return r; }, getRecords : function(nodes){ var r = [], s = nodes; for(var i = 0, len = s.length; i < len; i++){ r[r.length] = this.store.getAt(s[i].viewIndex); } return r; }, getRecord : function(node){ return this.store.getAt(node.viewIndex); }, clearSelections : function(suppressEvent, skipUpdate){ if((this.multiSelect || this.singleSelect) && this.selected.getCount() > 0){ if(!skipUpdate){ this.selected.removeClass(this.selectedClass); } this.selected.clear(); this.last = false; if(!suppressEvent){ this.fireEvent("selectionchange", this, this.selected.elements); } } }, isSelected : function(node){ return this.selected.contains(this.getNode(node)); }, deselect : function(node){ if(this.isSelected(node)){ node = this.getNode(node); this.selected.removeElement(node); if(this.last == node.viewIndex){ this.last = false; } Ext.fly(node).removeClass(this.selectedClass); this.fireEvent("selectionchange", this, this.selected.elements); } }, select : function(nodeInfo, keepExisting, suppressEvent){ if(Ext.isArray(nodeInfo)){ if(!keepExisting){ this.clearSelections(true); } for(var i = 0, len = nodeInfo.length; i < len; i++){ this.select(nodeInfo[i], true, true); } if(!suppressEvent){ this.fireEvent("selectionchange", this, this.selected.elements); } } else{ var node = this.getNode(nodeInfo); if(!keepExisting){ this.clearSelections(true); } if(node && !this.isSelected(node)){ if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){ Ext.fly(node).addClass(this.selectedClass); this.selected.add(node); this.last = node.viewIndex; if(!suppressEvent){ this.fireEvent("selectionchange", this, this.selected.elements); } } } } }, selectRange : function(start, end, keepExisting){ if(!keepExisting){ this.clearSelections(true); } this.select(this.getNodes(start, end), true); }, getNode : function(nodeInfo){ if(typeof nodeInfo == "string"){ return document.getElementById(nodeInfo); }else if(typeof nodeInfo == "number"){ return this.all.elements[nodeInfo]; } return nodeInfo; }, getNodes : function(start, end){ var ns = this.all.elements; start = start || 0; end = typeof end == "undefined" ? Math.max(ns.length - 1, 0) : end; var nodes = [], i; if(start <= end){ for(i = start; i <= end && ns[i]; i++){ nodes.push(ns[i]); } } else{ for(i = start; i >= end && ns[i]; i--){ nodes.push(ns[i]); } } return nodes; }, indexOf : function(node){ node = this.getNode(node); if(typeof node.viewIndex == "number"){ return node.viewIndex; } return this.all.indexOf(node); }, onBeforeLoad : function(){ if(this.loadingText){ this.clearSelections(false, true); this.el.update('<div class="loading-indicator">'+this.loadingText+'</div>'); this.all.clear(); } }, onDestroy : function(){ Ext.DataView.superclass.onDestroy.call(this); this.setStore(null); } }); Ext.reg('dataview', Ext.DataView); Ext.ColorPalette = function(config){ Ext.ColorPalette.superclass.constructor.call(this, config); this.addEvents( 'select' ); if(this.handler){ this.on("select", this.handler, this.scope, true); } }; Ext.extend(Ext.ColorPalette, Ext.Component, { itemCls : "x-color-palette", value : null, clickEvent:'click', ctype: "Ext.ColorPalette", allowReselect : false, colors : [ "000000", "993300", "333300", "003300", "003366", "000080", "333399", "333333", "800000", "FF6600", "808000", "008000", "008080", "0000FF", "666699", "808080", "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF", "800080", "969696", "FF00FF", "FFCC00", "FFFF00", "00FF00", "00FFFF", "00CCFF", "993366", "C0C0C0", "FF99CC", "FFCC99", "FFFF99", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF" ], onRender : function(container, position){ var t = this.tpl || new Ext.XTemplate( '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>' ); var el = document.createElement("div"); el.className = this.itemCls; t.overwrite(el, this.colors); container.dom.insertBefore(el, position); this.el = Ext.get(el); this.el.on(this.clickEvent, this.handleClick, this, {delegate: "a"}); if(this.clickEvent != 'click'){ this.el.on('click', Ext.emptyFn, this, {delegate: "a", preventDefault:true}); } }, afterRender : function(){ Ext.ColorPalette.superclass.afterRender.call(this); if(this.value){ var s = this.value; this.value = null; this.select(s); } }, handleClick : function(e, t){ e.preventDefault(); if(!this.disabled){ var c = t.className.match(/(?:^|s)color-(.{6})(?:s|$)/)[1]; this.select(c.toUpperCase()); } }, select : function(color){ color = color.replace("#", ""); if(color != this.value || this.allowReselect){ var el = this.el; if(this.value){ el.child("a.color-"+this.value).removeClass("x-color-palette-sel"); } el.child("a.color-"+color).addClass("x-color-palette-sel"); this.value = color; this.fireEvent("select", this, color); } } }); Ext.reg('colorpalette', Ext.ColorPalette);
- Ext.DatePicker = Ext.extend(Ext.Component, {
- todayText : "Today",
- okText : " OK ",
- cancelText : "Cancel",
- todayTip : "{0} (Spacebar)",
- minText : "This date is before the minimum date",
- maxText : "This date is after the maximum date",
- format : "m/d/y",
- disabledDaysText : "Disabled",
- disabledDatesText : "Disabled",
- constrainToViewport : true,
- monthNames : Date.monthNames,
- dayNames : Date.dayNames,
- nextText: 'Next Month (Control+Right)',
- prevText: 'Previous Month (Control+Left)',
- monthYearText: 'Choose a month (Control+Up/Down to move years)',
- startDay : 0,
- showToday : true,
- initComponent : function(){
- Ext.DatePicker.superclass.initComponent.call(this);
- this.value = this.value ?
- this.value.clearTime() : new Date().clearTime();
- this.addEvents(
- 'select'
- );
- if(this.handler){
- this.on("select", this.handler, this.scope || this);
- }
- this.initDisabledDays();
- },
- initDisabledDays : function(){
- if(!this.disabledDatesRE && this.disabledDates){
- var dd = this.disabledDates;
- var re = "(?:";
- for(var i = 0; i < dd.length; i++){
- re += dd[i];
- if(i != dd.length-1) re += "|";
- }
- this.disabledDatesRE = new RegExp(re + ")");
- }
- },
- setDisabledDates : function(dd){
- if(Ext.isArray(dd)){
- this.disabledDates = dd;
- this.disabledDatesRE = null;
- }else{
- this.disabledDatesRE = dd;
- }
- this.initDisabledDays();
- this.update(this.value, true);
- },
- setDisabledDays : function(dd){
- this.disabledDays = dd;
- this.update(this.value, true);
- },
- setMinDate : function(dt){
- this.minDate = dt;
- this.update(this.value, true);
- },
- setMaxDate : function(dt){
- this.maxDate = dt;
- this.update(this.value, true);
- },
- setValue : function(value){
- var old = this.value;
- this.value = value.clearTime(true);
- if(this.el){
- this.update(this.value);
- }
- },
- getValue : function(){
- return this.value;
- },
- focus : function(){
- if(this.el){
- this.update(this.activeDate);
- }
- },
- onRender : function(container, position){
- var m = [
- '<table cellspacing="0">',
- '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
- '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
- var dn = this.dayNames;
- for(var i = 0; i < 7; i++){
- var d = this.startDay+i;
- if(d > 6){
- d = d-7;
- }
- m.push("<th><span>", dn[d].substr(0,1), "</span></th>");
- }
- m[m.length] = "</tr></thead><tbody><tr>";
- for(var i = 0; i < 42; i++) {
- if(i % 7 == 0 && i != 0){
- m[m.length] = "</tr><tr>";
- }
- m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
- }
- m.push('</tr></tbody></table></td></tr>',
- this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
- '</table><div class="x-date-mp"></div>');
- var el = document.createElement("div");
- el.className = "x-date-picker";
- el.innerHTML = m.join("");
- container.dom.insertBefore(el, position);
- this.el = Ext.get(el);
- this.eventEl = Ext.get(el.firstChild);
- new Ext.util.ClickRepeater(this.el.child("td.x-date-left a"), {
- handler: this.showPrevMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- new Ext.util.ClickRepeater(this.el.child("td.x-date-right a"), {
- handler: this.showNextMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- this.eventEl.on("mousewheel", this.handleMouseWheel, this);
- this.monthPicker = this.el.down('div.x-date-mp');
- this.monthPicker.enableDisplayMode('block');
- var kn = new Ext.KeyNav(this.eventEl, {
- "left" : function(e){
- e.ctrlKey ?
- this.showPrevMonth() :
- this.update(this.activeDate.add("d", -1));
- },
- "right" : function(e){
- e.ctrlKey ?
- this.showNextMonth() :
- this.update(this.activeDate.add("d", 1));
- },
- "up" : function(e){
- e.ctrlKey ?
- this.showNextYear() :
- this.update(this.activeDate.add("d", -7));
- },
- "down" : function(e){
- e.ctrlKey ?
- this.showPrevYear() :
- this.update(this.activeDate.add("d", 7));
- },
- "pageUp" : function(e){
- this.showNextMonth();
- },
- "pageDown" : function(e){
- this.showPrevMonth();
- },
- "enter" : function(e){
- e.stopPropagation();
- return true;
- },
- scope : this
- });
- this.eventEl.on("click", this.handleDateClick, this, {delegate: "a.x-date-date"});
- this.el.unselectable();
- this.cells = this.el.select("table.x-date-inner tbody td");
- this.textNodes = this.el.query("table.x-date-inner tbody span");
- this.mbtn = new Ext.Button({
- text: " ",
- tooltip: this.monthYearText,
- renderTo: this.el.child("td.x-date-middle", true)
- });
- this.mbtn.on('click', this.showMonthPicker, this);
- this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");
- if(this.showToday){
- this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
- var today = (new Date()).dateFormat(this.format);
- this.todayBtn = new Ext.Button({
- renderTo: this.el.child("td.x-date-bottom", true),
- text: String.format(this.todayText, today),
- tooltip: String.format(this.todayTip, today),
- handler: this.selectToday,
- scope: this
- });
- }
- if(Ext.isIE){
- this.el.repaint();
- }
- this.update(this.value);
- },
- createMonthPicker : function(){
- if(!this.monthPicker.dom.firstChild){
- var buf = ['<table border="0" cellspacing="0">'];
- for(var i = 0; i < 6; i++){
- buf.push(
- '<tr><td class="x-date-mp-month"><a href="#">', this.monthNames[i].substr(0, 3), '</a></td>',
- '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', this.monthNames[i+6].substr(0, 3), '</a></td>',
- i == 0 ?
- '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
- '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
- );
- }
- buf.push(
- '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
- this.okText,
- '</button><button type="button" class="x-date-mp-cancel">',
- this.cancelText,
- '</button></td></tr>',
- '</table>'
- );
- this.monthPicker.update(buf.join(''));
- this.monthPicker.on('click', this.onMonthClick, this);
- this.monthPicker.on('dblclick', this.onMonthDblClick, this);
- this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
- this.mpYears = this.monthPicker.select('td.x-date-mp-year');
- this.mpMonths.each(function(m, a, i){
- i += 1;
- if((i%2) == 0){
- m.dom.xmonth = 5 + Math.round(i * .5);
- }else{
- m.dom.xmonth = Math.round((i-1) * .5);
- }
- });
- }
- },
- showMonthPicker : function(){
- this.createMonthPicker();
- var size = this.el.getSize();
- this.monthPicker.setSize(size);
- this.monthPicker.child('table').setSize(size);
- this.mpSelMonth = (this.activeDate || this.value).getMonth();
- this.updateMPMonth(this.mpSelMonth);
- this.mpSelYear = (this.activeDate || this.value).getFullYear();
- this.updateMPYear(this.mpSelYear);
- this.monthPicker.slideIn('t', {duration:.2});
- },
- updateMPYear : function(y){
- this.mpyear = y;
- var ys = this.mpYears.elements;
- for(var i = 1; i <= 10; i++){
- var td = ys[i-1], y2;
- if((i%2) == 0){
- y2 = y + Math.round(i * .5);
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }else{
- y2 = y - (5-Math.round(i * .5));
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }
- this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
- }
- },
- updateMPMonth : function(sm){
- this.mpMonths.each(function(m, a, i){
- m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
- });
- },
- selectMPMonth: function(m){
- },
- onMonthClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if(el.is('button.x-date-mp-cancel')){
- this.hideMonthPicker();
- }
- else if(el.is('button.x-date-mp-ok')){
- var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
- if(d.getMonth() != this.mpSelMonth){
- d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
- }
- this.update(d);
- this.hideMonthPicker();
- }
- else if(pn = el.up('td.x-date-mp-month', 2)){
- this.mpMonths.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelMonth = pn.dom.xmonth;
- }
- else if(pn = el.up('td.x-date-mp-year', 2)){
- this.mpYears.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelYear = pn.dom.xyear;
- }
- else if(el.is('a.x-date-mp-prev')){
- this.updateMPYear(this.mpyear-10);
- }
- else if(el.is('a.x-date-mp-next')){
- this.updateMPYear(this.mpyear+10);
- }
- },
- onMonthDblClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if(pn = el.up('td.x-date-mp-month', 2)){
- this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- else if(pn = el.up('td.x-date-mp-year', 2)){
- this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- },
- hideMonthPicker : function(disableAnim){
- if(this.monthPicker){
- if(disableAnim === true){
- this.monthPicker.hide();
- }else{
- this.monthPicker.slideOut('t', {duration:.2});
- }
- }
- },
- showPrevMonth : function(e){
- this.update(this.activeDate.add("mo", -1));
- },
- showNextMonth : function(e){
- this.update(this.activeDate.add("mo", 1));
- },
- showPrevYear : function(){
- this.update(this.activeDate.add("y", -1));
- },
- showNextYear : function(){
- this.update(this.activeDate.add("y", 1));
- },
- handleMouseWheel : function(e){
- var delta = e.getWheelDelta();
- if(delta > 0){
- this.showPrevMonth();
- e.stopEvent();
- } else if(delta < 0){
- this.showNextMonth();
- e.stopEvent();
- }
- },
- handleDateClick : function(e, t){
- e.stopEvent();
- if(t.dateValue && !Ext.fly(t.parentNode).hasClass("x-date-disabled")){
- this.setValue(new Date(t.dateValue));
- this.fireEvent("select", this, this.value);
- }
- },
- selectToday : function(){
- if(this.todayBtn && !this.todayBtn.disabled){
- this.setValue(new Date().clearTime());
- this.fireEvent("select", this, this.value);
- }
- },