ext-all-debug.js
资源名称:EXT_study.rar [点击查看]
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:910k
源码类别:
JavaScript
开发平台:
JavaScript
- each : function(fn, scope){
- Ext.each(this.items, fn, scope);
- },
- callEach : function(fnName, args){
- var cs = this.items;
- for(var i = 0, len = cs.length; i < len; i++){
- cs[i][fnName].apply(cs[i], args);
- }
- },
- addComponent : function(comp){
- this.items.push(comp);
- comp.on('destroy', this.removeComponent, this);
- },
- removeComponent : function(comp){
- this.items.remove(comp);
- },
- execute : function(){
- this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
- }
- };
- (function(){
- Ext.Layer = function(config, existingEl){
- config = config || {};
- var dh = Ext.DomHelper;
- var cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
- if(existingEl){
- this.dom = Ext.getDom(existingEl);
- }
- if(!this.dom){
- var o = config.dh || {tag: "div", cls: "x-layer"};
- this.dom = dh.append(pel, o);
- }
- if(config.cls){
- this.addClass(config.cls);
- }
- this.constrain = config.constrain !== false;
- this.visibilityMode = Ext.Element.VISIBILITY;
- if(config.id){
- this.id = this.dom.id = config.id;
- }else{
- this.id = Ext.id(this.dom);
- }
- this.zindex = config.zindex || this.getZIndex();
- this.position("absolute", this.zindex);
- if(config.shadow){
- this.shadowOffset = config.shadowOffset || 4;
- this.shadow = new Ext.Shadow({
- offset : this.shadowOffset,
- mode : config.shadow
- });
- }else{
- this.shadowOffset = 0;
- }
- this.useShim = config.shim !== false && Ext.useShims;
- this.useDisplay = config.useDisplay;
- this.hide();
- };
- var supr = Ext.Element.prototype;
- var shims = [];
- Ext.extend(Ext.Layer, Ext.Element, {
- getZIndex : function(){
- return this.zindex || parseInt(this.getStyle("z-index"), 10) || 11000;
- },
- getShim : function(){
- if(!this.useShim){
- return null;
- }
- if(this.shim){
- return this.shim;
- }
- var shim = shims.shift();
- if(!shim){
- shim = this.createShim();
- shim.enableDisplayMode('block');
- shim.dom.style.display = 'none';
- shim.dom.style.visibility = 'visible';
- }
- var pn = this.dom.parentNode;
- if(shim.dom.parentNode != pn){
- pn.insertBefore(shim.dom, this.dom);
- }
- shim.setStyle('z-index', this.getZIndex()-2);
- this.shim = shim;
- return shim;
- },
- hideShim : function(){
- if(this.shim){
- this.shim.setDisplayed(false);
- shims.push(this.shim);
- delete this.shim;
- }
- },
- disableShadow : function(){
- if(this.shadow){
- this.shadowDisabled = true;
- this.shadow.hide();
- this.lastShadowOffset = this.shadowOffset;
- this.shadowOffset = 0;
- }
- },
- enableShadow : function(show){
- if(this.shadow){
- this.shadowDisabled = false;
- this.shadowOffset = this.lastShadowOffset;
- delete this.lastShadowOffset;
- if(show){
- this.sync(true);
- }
- }
- },
- sync : function(doShow){
- var sw = this.shadow;
- if(!this.updating && this.isVisible() && (sw || this.useShim)){
- var sh = this.getShim();
- var w = this.getWidth(),
- h = this.getHeight();
- var l = this.getLeft(true),
- t = this.getTop(true);
- if(sw && !this.shadowDisabled){
- if(doShow && !sw.isVisible()){
- sw.show(this);
- }else{
- sw.realign(l, t, w, h);
- }
- if(sh){
- if(doShow){
- sh.show();
- }
- var a = sw.adjusts, s = sh.dom.style;
- s.left = (Math.min(l, l+a.l))+"px";
- s.top = (Math.min(t, t+a.t))+"px";
- s.width = (w+a.w)+"px";
- s.height = (h+a.h)+"px";
- }
- }else if(sh){
- if(doShow){
- sh.show();
- }
- sh.setSize(w, h);
- sh.setLeftTop(l, t);
- }
- }
- },
- destroy : function(){
- this.hideShim();
- if(this.shadow){
- this.shadow.hide();
- }
- this.removeAllListeners();
- Ext.removeNode(this.dom);
- Ext.Element.uncache(this.id);
- },
- remove : function(){
- this.destroy();
- },
- beginUpdate : function(){
- 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;
- },
- onDestroy : function(){
- if(this.items){
- var cs = this.items.items;
- for(var i = 0, len = cs.length; i < len; i++) {
- Ext.destroy(cs[i]);
- }
- }
- if(this.monitorResize){
- Ext.EventManager.removeResizeListener(this.doLayout, this);
- }
- Ext.Container.superclass.onDestroy.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 || this, 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
- };
- }
- };
- 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 = 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();
- }
- }
- });
- 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;
- 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',
- 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){ 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);
- }
- if(this.bbar && this.bottomToolbar){
- if(Ext.isArray(this.bottomToolbar)){
- this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
- }
- this.bottomToolbar.render(this.bbar);
- }
- },
- 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(this[this.toolTarget], 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){
- this.body.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);
- }
- }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();
- },
- onDestroy : function(){
- 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.onDestroy.call(this);
- },
- 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
- );
- },
- 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',
- collapsible:false,
- initHidden : true,
- monitorResize : true,
- elements: 'header,body',
- 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();
- 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.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);
- 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(){