ext-all-debug.js
资源名称:ext-3.1.0.zip [点击查看]
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:1167k
源码类别:
JavaScript
开发平台:
JavaScript
- return Ext.util.TextMetrics.Instance(el, fixedWidth);
- }
- };
- }();
- Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
- var ml = new Ext.Element(document.createElement('div'));
- document.body.appendChild(ml.dom);
- ml.position('absolute');
- ml.setLeftTop(-1000, -1000);
- ml.hide();
- if(fixedWidth){
- ml.setWidth(fixedWidth);
- }
- var instance = {
- getSize : function(text){
- ml.update(text);
- var s = ml.getSize();
- ml.update('');
- return s;
- },
- bind : function(el){
- ml.setStyle(
- Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')
- );
- },
- setFixedWidth : function(width){
- ml.setWidth(width);
- },
- getWidth : function(text){
- ml.dom.style.width = 'auto';
- return this.getSize(text).width;
- },
- getHeight : function(text){
- return this.getSize(text).height;
- }
- };
- instance.bind(bindTo);
- return instance;
- };
- Ext.Element.addMethods({
- getTextWidth : function(text, min, max){
- return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
- }
- });
- Ext.util.Cookies = {
- set : function(name, value){
- var argv = arguments;
- var argc = arguments.length;
- var expires = (argc > 2) ? argv[2] : null;
- var path = (argc > 3) ? argv[3] : '/';
- var domain = (argc > 4) ? argv[4] : null;
- var secure = (argc > 5) ? argv[5] : false;
- document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
- },
- get : function(name){
- var arg = name + "=";
- var alen = arg.length;
- var clen = document.cookie.length;
- var i = 0;
- var j = 0;
- while(i < clen){
- j = i + alen;
- if(document.cookie.substring(i, j) == arg){
- return Ext.util.Cookies.getCookieVal(j);
- }
- i = document.cookie.indexOf(" ", i) + 1;
- if(i === 0){
- break;
- }
- }
- return null;
- },
- clear : function(name){
- if(Ext.util.Cookies.get(name)){
- document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
- }
- },
- getCookieVal : function(offset){
- var endstr = document.cookie.indexOf(";", offset);
- if(endstr == -1){
- endstr = document.cookie.length;
- }
- return unescape(document.cookie.substring(offset, endstr));
- }
- };
- Ext.handleError = function(e) {
- throw e;
- };
- Ext.Error = function(message) {
- this.message = (this.lang[message]) ? this.lang[message] : message;
- }
- Ext.Error.prototype = new Error();
- Ext.apply(Ext.Error.prototype, {
- lang: {},
- name: 'Ext.Error',
- getName : function() {
- return this.name;
- },
- getMessage : function() {
- return this.message;
- },
- toJson : function() {
- return Ext.encode(this);
- }
- });
- Ext.ComponentMgr = function(){
- var all = new Ext.util.MixedCollection();
- var types = {};
- var ptypes = {};
- return {
- register : function(c){
- all.add(c);
- },
- unregister : function(c){
- all.remove(c);
- },
- get : function(id){
- return all.get(id);
- },
- onAvailable : function(id, fn, scope){
- all.on("add", function(index, o){
- if(o.id == id){
- fn.call(scope || o, o);
- all.un("add", fn, scope);
- }
- });
- },
- all : all,
- isRegistered : function(xtype){
- return types[xtype] !== undefined;
- },
- registerType : function(xtype, cls){
- types[xtype] = cls;
- cls.xtype = xtype;
- },
- create : function(config, defaultType){
- return config.render ? config : new types[config.xtype || defaultType](config);
- },
- registerPlugin : function(ptype, cls){
- ptypes[ptype] = cls;
- cls.ptype = ptype;
- },
- createPlugin : function(config, defaultType){
- var PluginCls = ptypes[config.ptype || defaultType];
- if (PluginCls.init) {
- return PluginCls;
- } else {
- return new PluginCls(config);
- }
- }
- };
- }();
- Ext.reg = Ext.ComponentMgr.registerType;
- Ext.preg = Ext.ComponentMgr.registerPlugin;
- Ext.create = Ext.ComponentMgr.create;
- Ext.Component = function(config){
- config = config || {};
- if(config.initialConfig){
- if(config.isAction){
- this.baseAction = config;
- }
- config = config.initialConfig;
- }else if(config.tagName || config.dom || Ext.isString(config)){
- config = {applyTo: config, id: config.id || config};
- }
- this.initialConfig = config;
- Ext.apply(this, config);
- this.addEvents(
- 'added',
- 'disable',
- 'enable',
- 'beforeshow',
- 'show',
- 'beforehide',
- 'hide',
- 'removed',
- 'beforerender',
- 'render',
- 'afterrender',
- 'beforedestroy',
- 'destroy',
- 'beforestaterestore',
- 'staterestore',
- 'beforestatesave',
- 'statesave'
- );
- this.getId();
- Ext.ComponentMgr.register(this);
- Ext.Component.superclass.constructor.call(this);
- if(this.baseAction){
- this.baseAction.addComponent(this);
- }
- this.initComponent();
- if(this.plugins){
- if(Ext.isArray(this.plugins)){
- for(var i = 0, len = this.plugins.length; i < len; i++){
- this.plugins[i] = this.initPlugin(this.plugins[i]);
- }
- }else{
- this.plugins = this.initPlugin(this.plugins);
- }
- }
- if(this.stateful !== false){
- this.initState();
- }
- if(this.applyTo){
- this.applyToMarkup(this.applyTo);
- delete this.applyTo;
- }else if(this.renderTo){
- this.render(this.renderTo);
- delete this.renderTo;
- }
- };
- Ext.Component.AUTO_ID = 1000;
- Ext.extend(Ext.Component, Ext.util.Observable, {
- disabled : false,
- hidden : false,
- autoEl : 'div',
- disabledClass : 'x-item-disabled',
- allowDomMove : true,
- autoShow : false,
- hideMode : 'display',
- hideParent : false,
- rendered : false,
- tplWriteMode : 'overwrite',
- ctype : 'Ext.Component',
- actionMode : 'el',
- getActionEl : function(){
- return this[this.actionMode];
- },
- initPlugin : function(p){
- if(p.ptype && !Ext.isFunction(p.init)){
- p = Ext.ComponentMgr.createPlugin(p);
- }else if(Ext.isString(p)){
- p = Ext.ComponentMgr.createPlugin({
- ptype: p
- });
- }
- p.init(this);
- return p;
- },
- initComponent : Ext.emptyFn,
- render : function(container, position){
- if(!this.rendered && this.fireEvent('beforerender', this) !== false){
- if(!container && this.el){
- this.el = Ext.get(this.el);
- container = this.el.dom.parentNode;
- this.allowDomMove = false;
- }
- this.container = Ext.get(container);
- if(this.ctCls){
- this.container.addClass(this.ctCls);
- }
- this.rendered = true;
- if(position !== undefined){
- if(Ext.isNumber(position)){
- position = this.container.dom.childNodes[position];
- }else{
- position = Ext.getDom(position);
- }
- }
- this.onRender(this.container, position || null);
- if(this.autoShow){
- this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
- }
- if(this.cls){
- this.el.addClass(this.cls);
- delete this.cls;
- }
- if(this.style){
- this.el.applyStyles(this.style);
- delete this.style;
- }
- if(this.overCls){
- this.el.addClassOnOver(this.overCls);
- }
- this.fireEvent('render', this);
- var contentTarget = this.getContentTarget();
- if (this.html){
- contentTarget.update(Ext.DomHelper.markup(this.html));
- delete this.html;
- }
- if (this.contentEl){
- var ce = Ext.getDom(this.contentEl);
- Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
- contentTarget.appendChild(ce);
- }
- if (this.tpl) {
- if (!this.tpl.compile) {
- this.tpl = new Ext.XTemplate(this.tpl);
- }
- if (this.data) {
- this.tpl[this.tplWriteMode](contentTarget, this.data);
- delete this.data;
- }
- }
- this.afterRender(this.container);
- if(this.hidden){
- this.doHide();
- }
- if(this.disabled){
- this.disable(true);
- }
- if(this.stateful !== false){
- this.initStateEvents();
- }
- this.fireEvent('afterrender', this);
- }
- return this;
- },
- update: function(htmlOrData, loadScripts, cb) {
- var contentTarget = this.getContentTarget();
- if (this.tpl && typeof htmlOrData !== "string") {
- this.tpl[this.tplWriteMode](contentTarget, htmlOrData || {});
- } else {
- var html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
- contentTarget.update(html, loadScripts, cb);
- }
- },
- onAdded : function(container, pos) {
- this.ownerCt = container;
- this.initRef();
- this.fireEvent('added', this, container, pos);
- },
- onRemoved : function() {
- this.removeRef();
- this.fireEvent('removed', this, this.ownerCt);
- delete this.ownerCt;
- },
- initRef : function() {
- if(this.ref && !this.refOwner){
- var levels = this.ref.split('/'),
- last = levels.length,
- i = 0,
- t = this;
- while(t && i < last){
- t = t.ownerCt;
- ++i;
- }
- if(t){
- t[this.refName = levels[--i]] = this;
- this.refOwner = t;
- }
- }
- },
- removeRef : function() {
- if (this.refOwner && this.refName) {
- delete this.refOwner[this.refName];
- delete this.refOwner;
- }
- },
- initState : function(){
- if(Ext.state.Manager){
- var id = this.getStateId();
- if(id){
- var state = Ext.state.Manager.get(id);
- if(state){
- if(this.fireEvent('beforestaterestore', this, state) !== false){
- this.applyState(Ext.apply({}, state));
- this.fireEvent('staterestore', this, state);
- }
- }
- }
- }
- },
- getStateId : function(){
- return this.stateId || ((this.id.indexOf('ext-comp-') == 0 || this.id.indexOf('ext-gen') == 0) ? null : this.id);
- },
- initStateEvents : function(){
- if(this.stateEvents){
- for(var i = 0, e; e = this.stateEvents[i]; i++){
- this.on(e, this.saveState, this, {delay:100});
- }
- }
- },
- applyState : function(state){
- if(state){
- Ext.apply(this, state);
- }
- },
- getState : function(){
- return null;
- },
- saveState : function(){
- if(Ext.state.Manager && this.stateful !== false){
- var id = this.getStateId();
- if(id){
- var state = this.getState();
- if(this.fireEvent('beforestatesave', this, state) !== false){
- Ext.state.Manager.set(id, state);
- this.fireEvent('statesave', this, state);
- }
- }
- }
- },
- applyToMarkup : function(el){
- this.allowDomMove = false;
- this.el = Ext.get(el);
- this.render(this.el.dom.parentNode);
- },
- addClass : function(cls){
- if(this.el){
- this.el.addClass(cls);
- }else{
- this.cls = this.cls ? this.cls + ' ' + cls : cls;
- }
- return this;
- },
- removeClass : function(cls){
- if(this.el){
- this.el.removeClass(cls);
- }else if(this.cls){
- this.cls = this.cls.split(' ').remove(cls).join(' ');
- }
- return this;
- },
- onRender : function(ct, position){
- if(!this.el && this.autoEl){
- if(Ext.isString(this.autoEl)){
- this.el = document.createElement(this.autoEl);
- }else{
- var div = document.createElement('div');
- Ext.DomHelper.overwrite(div, this.autoEl);
- this.el = div.firstChild;
- }
- if (!this.el.id) {
- this.el.id = this.getId();
- }
- }
- if(this.el){
- this.el = Ext.get(this.el);
- if(this.allowDomMove !== false){
- ct.dom.insertBefore(this.el.dom, position);
- if (div) {
- Ext.removeNode(div);
- div = null;
- }
- }
- }
- },
- getAutoCreate : function(){
- var cfg = Ext.isObject(this.autoCreate) ?
- this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
- if(this.id && !cfg.id){
- cfg.id = this.id;
- }
- return cfg;
- },
- afterRender : Ext.emptyFn,
- destroy : function(){
- if(!this.isDestroyed){
- if(this.fireEvent('beforedestroy', this) !== false){
- this.destroying = true;
- this.beforeDestroy();
- if(this.ownerCt && this.ownerCt.remove){
- this.ownerCt.remove(this, false);
- }
- if(this.rendered){
- this.el.remove();
- if(this.actionMode == 'container' || this.removeMode == 'container'){
- this.container.remove();
- }
- }
- this.onDestroy();
- Ext.ComponentMgr.unregister(this);
- this.fireEvent('destroy', this);
- this.purgeListeners();
- this.destroying = false;
- this.isDestroyed = true;
- }
- }
- },
- deleteMembers : function(){
- var args = arguments;
- for(var i = 0, len = args.length; i < len; ++i){
- delete this[args[i]];
- }
- },
- beforeDestroy : Ext.emptyFn,
- onDestroy : Ext.emptyFn,
- getEl : function(){
- return this.el;
- },
- getContentTarget : function(){
- return this.el;
- },
- getId : function(){
- return this.id || (this.id = 'ext-comp-' + (++Ext.Component.AUTO_ID));
- },
- getItemId : function(){
- return this.itemId || this.getId();
- },
- focus : function(selectText, delay){
- if(delay){
- this.focus.defer(Ext.isNumber(delay) ? delay : 10, this, [selectText, false]);
- return;
- }
- if(this.rendered){
- this.el.focus();
- if(selectText === true){
- this.el.dom.select();
- }
- }
- return this;
- },
- blur : function(){
- if(this.rendered){
- this.el.blur();
- }
- return this;
- },
- disable : function( silent){
- if(this.rendered){
- this.onDisable();
- }
- this.disabled = true;
- if(silent !== true){
- this.fireEvent('disable', this);
- }
- return this;
- },
- onDisable : function(){
- this.getActionEl().addClass(this.disabledClass);
- this.el.dom.disabled = true;
- },
- enable : function(){
- if(this.rendered){
- this.onEnable();
- }
- this.disabled = false;
- this.fireEvent('enable', this);
- return this;
- },
- onEnable : function(){
- this.getActionEl().removeClass(this.disabledClass);
- this.el.dom.disabled = false;
- },
- setDisabled : function(disabled){
- return this[disabled ? 'disable' : 'enable']();
- },
- show : function(){
- if(this.fireEvent('beforeshow', this) !== false){
- this.hidden = false;
- if(this.autoRender){
- this.render(Ext.isBoolean(this.autoRender) ? Ext.getBody() : this.autoRender);
- }
- if(this.rendered){
- this.onShow();
- }
- this.fireEvent('show', this);
- }
- return this;
- },
- onShow : function(){
- this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
- },
- hide : function(){
- if(this.fireEvent('beforehide', this) !== false){
- this.doHide();
- this.fireEvent('hide', this);
- }
- return this;
- },
- doHide: function(){
- this.hidden = true;
- if(this.rendered){
- this.onHide();
- }
- },
- onHide : function(){
- this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
- },
- getVisibilityEl : function(){
- return this.hideParent ? this.container : this.getActionEl();
- },
- setVisible : function(visible){
- return this[visible ? 'show' : 'hide']();
- },
- isVisible : function(){
- return this.rendered && this.getVisibilityEl().isVisible();
- },
- cloneConfig : function(overrides){
- overrides = overrides || {};
- var id = overrides.id || Ext.id();
- var cfg = Ext.applyIf(overrides, this.initialConfig);
- cfg.id = id;
- return new this.constructor(cfg);
- },
- getXType : function(){
- return this.constructor.xtype;
- },
- isXType : function(xtype, shallow){
- if (Ext.isFunction(xtype)){
- xtype = xtype.xtype;
- }else if (Ext.isObject(xtype)){
- xtype = xtype.constructor.xtype;
- }
- return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 : this.constructor.xtype == xtype;
- },
- getXTypes : function(){
- var tc = this.constructor;
- if(!tc.xtypes){
- var c = [], sc = this;
- while(sc && sc.constructor.xtype){
- c.unshift(sc.constructor.xtype);
- sc = sc.constructor.superclass;
- }
- tc.xtypeChain = c;
- tc.xtypes = c.join('/');
- }
- return tc.xtypes;
- },
- findParentBy : function(fn) {
- for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
- return p || null;
- },
- findParentByType : function(xtype) {
- return Ext.isFunction(xtype) ?
- this.findParentBy(function(p){
- return p.constructor === xtype;
- }) :
- this.findParentBy(function(p){
- return p.constructor.xtype === xtype;
- });
- },
- getPositionEl : function(){
- return this.positionEl || this.el;
- },
- purgeListeners : function(){
- Ext.Component.superclass.purgeListeners.call(this);
- if(this.mons){
- this.on('beforedestroy', this.clearMons, this, {single: true});
- }
- },
- clearMons : function(){
- Ext.each(this.mons, function(m){
- m.item.un(m.ename, m.fn, m.scope);
- }, this);
- this.mons = [];
- },
- createMons: function(){
- if(!this.mons){
- this.mons = [];
- this.on('beforedestroy', this.clearMons, this, {single: true});
- }
- },
- mon : function(item, ename, fn, scope, opt){
- this.createMons();
- if(Ext.isObject(ename)){
- var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
- var o = ename;
- for(var e in o){
- if(propRe.test(e)){
- continue;
- }
- if(Ext.isFunction(o[e])){
- this.mons.push({
- item: item, ename: e, fn: o[e], scope: o.scope
- });
- item.on(e, o[e], o.scope, o);
- }else{
- this.mons.push({
- item: item, ename: e, fn: o[e], scope: o.scope
- });
- item.on(e, o[e]);
- }
- }
- return;
- }
- this.mons.push({
- item: item, ename: ename, fn: fn, scope: scope
- });
- item.on(ename, fn, scope, opt);
- },
- mun : function(item, ename, fn, scope){
- var found, mon;
- this.createMons();
- for(var i = 0, len = this.mons.length; i < len; ++i){
- mon = this.mons[i];
- if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
- this.mons.splice(i, 1);
- item.un(ename, fn, scope);
- found = true;
- break;
- }
- }
- return found;
- },
- nextSibling : function(){
- if(this.ownerCt){
- var index = this.ownerCt.items.indexOf(this);
- if(index != -1 && index+1 < this.ownerCt.items.getCount()){
- return this.ownerCt.items.itemAt(index+1);
- }
- }
- return null;
- },
- previousSibling : function(){
- if(this.ownerCt){
- var index = this.ownerCt.items.indexOf(this);
- if(index > 0){
- return this.ownerCt.items.itemAt(index-1);
- }
- }
- return null;
- },
- getBubbleTarget : function(){
- return this.ownerCt;
- }
- });
- Ext.reg('component', Ext.Component);
- Ext.Action = Ext.extend(Object, {
- constructor : function(config){
- this.initialConfig = config;
- this.itemId = config.itemId = (config.itemId || config.id || Ext.id());
- this.items = [];
- },
- isAction : true,
- setText : function(text){
- this.initialConfig.text = text;
- this.callEach('setText', [text]);
- },
- getText : function(){
- return this.initialConfig.text;
- },
- setIconClass : function(cls){
- this.initialConfig.iconCls = cls;
- this.callEach('setIconClass', [cls]);
- },
- getIconClass : function(){
- return this.initialConfig.iconCls;
- },
- setDisabled : function(v){
- this.initialConfig.disabled = v;
- this.callEach('setDisabled', [v]);
- },
- enable : function(){
- this.setDisabled(false);
- },
- disable : function(){
- this.setDisabled(true);
- },
- isDisabled : function(){
- return this.initialConfig.disabled;
- },
- setHidden : function(v){
- this.initialConfig.hidden = v;
- this.callEach('setVisible', [!v]);
- },
- show : function(){
- this.setHidden(false);
- },
- hide : function(){
- this.setHidden(true);
- },
- isHidden : function(){
- return this.initialConfig.hidden;
- },
- setHandler : function(fn, scope){
- this.initialConfig.handler = fn;
- this.initialConfig.scope = scope;
- this.callEach('setHandler', [fn, scope]);
- },
- 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.setVisibilityMode(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.getShim() || 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);
- delete this.dom;
- },
- 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 so = this.shadowOffset;
- var w = this.dom.offsetWidth+so, h = this.dom.offsetHeight+so;
- var moved = false;
- if((x + w) > vw+s.left){
- x = vw - w - so;
- moved = true;
- }
- if((y + h) > vh+s.top){
- y = vh - h - so;
- 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();
- }
- }
- return this;
- },
- 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();
- }
- }
- return this;
- },
- 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();
- return this;
- },
- setTop : function(top){
- this.storeLeftTop(this.getLeft(true), top);
- supr.setTop.apply(this, arguments);
- this.sync();
- return this;
- },
- setLeftTop : function(left, top){
- this.storeLeftTop(left, top);
- supr.setLeftTop.apply(this, arguments);
- this.sync();
- return this;
- },
- 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();
- }
- return this;
- },
- 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);
- return this;
- },
- setY : function(y, a, d, c, e){
- this.setXY([this.getX(), y], a, d, c, e);
- return this;
- },
- 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();
- }
- return this;
- },
- 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();
- }
- return this;
- },
- 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();
- }
- return this;
- },
- 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);
- }
- return this;
- }
- });
- })();
- 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 (Ext.isDefined(w) && Ext.isDefined(this.boxMinWidth) && (w < this.boxMinWidth)) {
- w = this.boxMinWidth;
- }
- if (Ext.isDefined(h) && Ext.isDefined(this.boxMinHeight) && (h < this.boxMinHeight)) {
- h = this.boxMinHeight;
- }
- if (Ext.isDefined(w) && Ext.isDefined(this.boxMaxWidth) && (w > this.boxMaxWidth)) {
- w = this.boxMaxWidth;
- }
- if (Ext.isDefined(h) && Ext.isDefined(this.boxMaxHeight) && (h > this.boxMaxHeight)) {
- h = this.boxMaxHeight;
- }
- if(!this.boxReady){
- this.width = w, this.height = h;
- return this;
- }
- if(this.cacheSizes !== false && this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
- return this;
- }
- this.lastSize = {width: w, height: h};
- var adj = this.adjustSize(w, h),
- aw = adj.width,
- ah = adj.height,
- rz;
- if(aw !== undefined || ah !== undefined){
- 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);
- }
- return this;
- },
- setWidth : function(width){
- return this.setSize(width);
- },
- setHeight : function(height){
- return this.setSize(undefined, height);
- },
- getSize : function(){
- return this.getResizeEl().getSize();
- },
- getWidth : function(){
- return this.getResizeEl().getWidth();
- },
- getHeight : function(){
- return this.getResizeEl().getHeight();
- },
- getOuterSize : function(){
- var el = this.getResizeEl();
- return {width: el.getWidth() + el.getMargins('lr'),
- height: el.getHeight() + el.getMargins('tb')};
- },
- getPosition : function(local){
- var el = this.getPositionEl();
- if(local === true){
- return [el.getLeft(true), el.getTop(true)];
- }
- return this.xy || el.getXY();
- },
- getBox : function(local){
- var pos = this.getPosition(local);
- var s = this.getSize();
- s.x = pos[0];
- s.y = pos[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;
- },
- setAutoScroll : function(scroll){
- if(this.rendered){
- this.getContentTarget().setOverflow(scroll ? 'auto' : '');
- }
- this.autoScroll = scroll;
- return this;
- },
- 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.getPositionEl().translatePoints(x, y);
- this.setPosition(p.left, p.top);
- return this;
- },
- afterRender : function(){
- Ext.BoxComponent.superclass.afterRender.call(this);
- if(this.resizeEl){
- this.resizeEl = Ext.get(this.resizeEl);
- }
- if(this.positionEl){
- this.positionEl = Ext.get(this.positionEl);
- }
- this.boxReady = true;
- this.setAutoScroll(this.autoScroll);
- 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.getResizeEl().getWidth(), this.autoHeight ? undefined : this.getResizeEl().getHeight());
- return this;
- },
- onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
- this.fireEvent('resize', this, 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.Spacer = Ext.extend(Ext.BoxComponent, {
- autoEl:'div'
- });
- Ext.reg('spacer', Ext.Spacer);
- 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.tickSize
- );
- 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.tickSize
- );
- }
- 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){
- Ext.destroy(this.overlay);
- 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){
- Ext.destroy(this.shim, Ext.get(this.proxy));
- this.dd.unreg();
- if(removeEl){
- this.el.remove();
- }
- this.purgeListeners();
- }
- });
- Ext.SplitBar.createProxy = function(dir){
- var proxy = new Ext.Element(document.createElement("div"));
- document.body.appendChild(proxy.dom);
- proxy.unselectable();
- var cls = 'x-splitbar-proxy';
- proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
- 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, {
- bufferResize: 50,
- autoDestroy : true,
- forceLayout: false,
- defaultType : 'panel',
- resizeEvent: 'resize',
- bubbleEvents: ['add', 'remove'],
- initComponent : function(){
- Ext.Container.superclass.initComponent.call(this);
- this.addEvents(
- 'afterlayout',
- 'beforeadd',
- 'beforeremove',
- 'add',
- 'remove'
- );
- this.enableBubble(this.bubbleEvents);
- var items = this.items;
- if(items){
- delete this.items;
- 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);
- },
- afterRender: function(){
- this.layoutDone = false;
- if(!this.layout){
- this.layout = 'auto';
- }
- if(Ext.isObject(this.layout) && !this.layout.layout){
- this.layoutConfig = this.layout;
- this.layout = this.layoutConfig.type;
- }
- if(Ext.isString(this.layout)){
- this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
- }
- this.setLayout(this.layout);
- Ext.Container.superclass.afterRender.call(this);
- if(Ext.isDefined(this.activeItem)){
- var item = this.activeItem;
- delete this.activeItem;
- this.layout.setActiveItem(item);
- }
- if(!this.ownerCt && !this.layoutDone){
- this.doLayout(false, true);
- }
- if(this.monitorResize === true){
- Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
- }
- },
- getLayoutTarget : function(){
- return this.el;
- },
- getComponentId : function(comp){
- return comp.getItemId();
- },
- add : function(comp){
- this.initItems();
- var args = arguments.length > 1;
- if(args || Ext.isArray(comp)){
- var result = [];
- Ext.each(args ? arguments : comp, function(c){
- result.push(this.add(c));
- }, this);
- return result;
- }
- var c = this.lookupComponent(this.applyDefaults(comp));
- var index = this.items.length;
- if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
- this.items.add(c);
- c.onAdded(this, index);
- this.onAdd(c);
- this.fireEvent('add', this, c, index);
- }
- return c;
- },
- onAdd : function(c){
- },
- onAdded : function(container, pos) {
- this.ownerCt = container;
- this.initRef();
- this.cascade(function(c){
- c.initRef();
- });
- this.fireEvent('added', this, container, pos);
- },
- insert : function(index, comp){
- this.initItems();
- var a = arguments, len = a.length;
- if(len > 2){
- var result = [];
- for(var i = len-1; i >= 1; --i) {
- result.push(this.insert(index, a[i]));
- }
- return result;
- }
- var c = this.lookupComponent(this.applyDefaults(comp));
- index = Math.min(index, this.items.length);
- if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
- if(c.ownerCt == this){
- this.items.remove(c);
- }
- this.items.insert(index, c);
- c.onAdded(this, index);
- this.onAdd(c);
- this.fireEvent('add', this, c, index);
- }
- return c;
- },
- applyDefaults : function(c){
- var d = this.defaults;
- if(d){
- if(Ext.isFunction(d)){
- d = d.call(this, c);
- }
- if(Ext.isString(c)){
- c = Ext.ComponentMgr.get(c);
- Ext.apply(c, d);
- }else if(!c.events){
- Ext.applyIf(c, d);
- }else{
- Ext.apply(c, d);
- }
- }
- 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){
- this.initItems();
- var c = this.getComponent(comp);
- if(c && this.fireEvent('beforeremove', this, c) !== false){
- this.doRemove(c, autoDestroy);
- this.fireEvent('remove', this, c);
- }
- return c;
- },
- onRemove: function(c){
- },
- doRemove: function(c, autoDestroy){
- if(this.layout && this.rendered){
- this.layout.onRemove(c);
- }
- this.items.remove(c);
- c.onRemoved();
- this.onRemove(c);
- if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
- c.destroy();
- }
- },
- removeAll: function(autoDestroy){
- this.initItems();
- var item, rem = [], items = [];
- this.items.each(function(i){
- rem.push(i);
- });
- for (var i = 0, len = rem.length; i < len; ++i){
- item = rem[i];
- this.remove(item, autoDestroy);
- if(item.ownerCt !== this){
- items.push(item);
- }
- }
- return items;
- },
- getComponent : function(comp){
- if(Ext.isObject(comp)){
- comp = comp.getItemId();
- }
- return this.items.get(comp);
- },
- lookupComponent : function(comp){
- if(Ext.isString(comp)){
- return Ext.ComponentMgr.get(comp);
- }else if(!comp.events){
- return this.createComponent(comp);
- }
- return comp;
- },
- createComponent : function(config, defaultType){
- var c = config.render ? config : Ext.create(Ext.apply({
- ownerCt: this
- }, config), defaultType || this.defaultType);
- delete c.ownerCt;
- return c;
- },
- canLayout: function() {
- var el = this.getLayoutTarget(), vs;
- return !!(el && (vs = el.dom.offsetWidth || el.dom.offsetHeight));
- },
- doLayout: function(shallow, force){
- var rendered = this.rendered,
- forceLayout = force || this.forceLayout,
- cs, i, len, c;
- this.layoutDone = true;
- if(!this.canLayout() || this.collapsed){
- this.deferLayout = this.deferLayout || !shallow;
- if(!forceLayout){
- return;
- }
- shallow = shallow && !this.deferLayout;
- } else {
- delete this.deferLayout;
- }
- cs = (shallow !== true && this.items) ? this.items.items : [];
- for(i = 0, len = cs.length; i < len; i++){
- if ((c = cs[i]).layout) {
- c.suspendLayoutResize = true;
- }
- }
- if(rendered && this.layout){
- this.layout.layout();
- }
- for(i = 0; i < len; i++){
- if((c = cs[i]).doLayout){
- c.doLayout(false, forceLayout);
- }
- }
- if(rendered){
- this.onLayout(shallow, forceLayout);
- }
- this.hasLayout = true;
- delete this.forceLayout;
- for(i = 0; i < len; i++){
- if ((c = cs[i]).layout) {
- delete c.suspendLayoutResize;
- }
- }
- },
- onLayout : Ext.emptyFn,
- onResize: function(adjWidth, adjHeight, rawWidth, rawHeight){
- Ext.Container.superclass.onResize.apply(this, arguments);
- if ((this.rendered && this.layout && this.layout.monitorResize) && !this.suspendLayoutResize) {
- this.layout.onResize();
- }
- },
- hasLayoutPending: function(){
- var pending = this.layoutPending;
- this.ownerCt.bubble(function(c){
- return !(pending = c.layoutPending);
- });
- return pending;
- },
- onShow : function(){
- Ext.Container.superclass.onShow.call(this);
- if(Ext.isDefined(this.deferLayout)){
- this.doLayout(true);
- }
- },
- getLayout : function(){
- if(!this.layout){
- var layout = new Ext.layout.ContainerLayout(this.layoutConfig);
- this.setLayout(layout);
- }
- return this.layout;
- },
- beforeDestroy : function(){
- var c;
- if(this.items){
- while(c = this.items.first()){
- this.doRemove(c, true);
- }
- }
- if(this.monitorResize){
- Ext.EventManager.removeResizeListener(this.doLayout, this);
- }
- Ext.destroy(this.layout);
- 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;
- }
- return this;
- },
- 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]]);
- }
- }
- }
- }
- return this;
- },
- 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, shallow){
- return this.findBy(function(c){
- return c.isXType(xtype, shallow);
- });
- },
- 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;
- },
- get : function(key){
- return this.items.get(key);
- }
- });
- Ext.Container.LAYOUTS = {};
- Ext.reg('container', Ext.Container);
- Ext.layout.ContainerLayout = Ext.extend(Object, {
- monitorResize:false,
- activeItem : null,
- constructor : function(config){
- Ext.apply(this, config);
- },
- layout : function(){
- var target = this.container.getLayoutTarget();
- if(!(this.hasLayout || Ext.isEmpty(this.targetCls))){
- target.addClass(this.targetCls)
- }
- this.onLayout(this.container, target);
- this.container.fireEvent('afterlayout', this.container, this);
- this.hasLayout = true;
- },
- onLayout : function(ct, target){
- this.renderAll(ct, target);
- },
- isValidParent : function(c, target){
- return target && c.getPositionEl().dom.parentNode == (target.dom || target);
- },
- 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);
- this.configureItem(c, position);
- }else if(c && !this.isValidParent(c, target)){
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position];
- }
- target.dom.insertBefore(c.getPositionEl().dom, position || null);
- c.container = target;
- this.configureItem(c, position);
- }
- },
- configureItem: function(c, position){
- if(this.extraCls){
- var t = c.getPositionEl ? c.getPositionEl() : c;
- t.addClass(this.extraCls);
- }
- if(c.doLayout && this.forceLayout){
- c.doLayout(false, true);
- }
- if (this.renderHidden && c != this.activeItem) {
- c.hide();
- }
- },
- onRemove: function(c){
- if(this.activeItem == c){
- delete this.activeItem;
- }
- if(c.rendered && this.extraCls){
- var t = c.getPositionEl ? c.getPositionEl() : c;
- t.removeClass(this.extraCls);
- }
- },
- onResize: function(){
- var ct = this.container,
- b = ct.bufferResize;
- if (ct.collapsed){
- return;
- }
- if (b && ct.ownerCt) {
- if (!ct.hasLayoutPending()){
- if(!this.resizeTask){
- this.resizeTask = new Ext.util.DelayedTask(this.runLayout, this);
- this.resizeBuffer = Ext.isNumber(b) ? b : 50;
- }
- ct.layoutPending = true;
- this.resizeTask.delay(this.resizeBuffer);
- }
- }else{
- ct.doLayout(false, this.forceLayout);
- }
- },
- runLayout: function(){
- var ct = this.container;
- ct.doLayout();
- delete ct.layoutPending;
- },
- setContainer : function(ct){
- this.container = ct;
- },
- parseMargins : function(v){
- if(Ext.isNumber(v)){
- v = v.toString();
- }
- 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];
- }
- if(len == 3){
- 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
- };
- },
- fieldTpl: (function() {
- var t = new Ext.Template(
- '<div class="x-form-item {itemCls}" tabIndex="-1">',
- '<label for="{id}" style="{labelStyle}" class="x-form-item-label">{label}{labelSeparator}</label>',
- '<div class="x-form-element" id="x-form-el-{id}" style="{elementStyle}">',
- '</div><div class="{clearCls}"></div>',
- '</div>'
- );
- t.disableFormats = true;
- return t.compile();
- })(),
- destroy : function(){
- if(!Ext.isEmpty(this.targetCls)){
- var target = this.container.getLayoutTarget();
- if(target){
- target.removeClass(this.targetCls);
- }
- }
- }
- });
- 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.getViewSize(true));
- }
- },
- 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,
- layoutOnCardChange : false,
- renderHidden : true,
- constructor: function(config){
- Ext.layout.CardLayout.superclass.constructor.call(this, config);
- },
- setActiveItem : function(item){
- var ai = this.activeItem;
- item = this.container.getComponent(item);
- if(ai != item){
- if(ai){
- ai.hide();
- ai.fireEvent('deactivate', ai);
- }
- var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);
- this.activeItem = item;
- if(item){
- item.show();
- }
- this.layout();
- if(item && layout){
- item.doLayout();
- }
- item.fireEvent('activate', item);
- }
- },
- 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(true) : target.getStyleSize();
- },
- onLayout : function(ct, target){
- Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target);
- var size = target.getViewSize(true);
- 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, el, vs;
- for(i = 0; i < len; i++){
- c = cs[i];
- el = c.getPositionEl();
- if(c.anchor){
- a = c.anchorSpec;
- if(!a){
- 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) - el.getMargins('lr'), c) : undefined;
- ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h) - el.getMargins('tb'), 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,
- targetCls: 'x-column-layout-ct',
- isValidParent : function(c, target){
- return c.getPositionEl().dom.parentNode == this.innerCt.dom;
- },
- onLayout : function(ct, target){
- var cs = ct.items.items, len = cs.length, c, i;
- if(!this.innerCt){
- this.innerCt = target.createChild({cls:'x-column-inner'});
- this.innerCt.createChild({cls:'x-clear'});
- }
- this.renderAll(ct, this.innerCt);
- var size = target.getViewSize(true);
- if(size.width < 1 && size.height < 1){
- return;
- }
- var w = size.width - this.scrollOffset,
- h = size.height,
- pw = w;
- this.innerCt.setWidth(w);
- for(i = 0; i < len; i++){
- c = cs[i];
- if(!c.columnWidth){
- pw -= (c.getSize().width + c.getPositionEl().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.getPositionEl().getMargins('lr'));
- }
- }
- }
- });
- Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;
- Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:true,
- rendered : false,
- targetCls: 'x-border-layout-ct',
- onLayout : function(ct, target){
- var collapsed;
- if(!this.rendered){
- 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.render(target, i);
- c.getPositionEl().addClass('x-border-panel');
- }
- 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(false);
- 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 && Ext.layout.BorderLayout.WARN !== false){
- 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);
- }
- if(c){
- 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){
- if(region.destroy){
- region.destroy();
- }else if (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},
- floatingZIndex: 100,
- 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 || this.floatable){
- 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 {
- if(this.collapsible !== false && !this.hideCollapseTool) {
- 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.titleCollapse){
- this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
- this.collapsedEl.on("click", this[this.floatable ? 'collapseClick' : 'onExpandClick'], this);
- }
- }
- }
- return this.collapsedEl;
- },
- onExpandClick : function(e){
- if(this.isSlid){
- 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();
- var el = this.panel.getEl();
- this.originalZIndex = el.getStyle('z-index');
- 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){
- if(this.isSlid){
- this.afterSlideIn();
- }
- 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', this.floatingZIndex);
- },
- onExpand : function(){
- this.isCollapsed = false;
- if(this.splitEl){
- this.splitEl.show();
- }
- this.layout.layout();
- this.panel.el.setStyle('z-index', this.originalZIndex);
- 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);
- this.collapsedEl.on(this.autoHideHd);
- }
- },
- clearAutoHide : function(){
- if(this.autoHide !== false){
- this.el.un("mouseout", this.autoHideHd.mouseout);
- this.el.un("mouseover", this.autoHideHd.mouseover);
- this.collapsedEl.un("mouseout", this.autoHideHd.mouseout);
- this.collapsedEl.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", this.floatingZIndex+2);
- this.panel.el.replaceClass('x-panel-collapsed', 'x-panel-floating');
- 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.panel.el.replaceClass('x-panel-floating', 'x-panel-collapsed');
- 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;
- }
- },
- destroy : function(){
- Ext.destroy(this.miniCollapsedEl, this.collapsedEl);
- }
- };
- 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.tickSize = this.tickSize;
- 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;
- },
- destroy : function() {
- Ext.destroy(this.miniSplitEl, this.split, this.splitEl);
- Ext.layout.BorderLayout.SplitRegion.superclass.destroy.call(this);
- }
- });
- Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
- Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
- labelSeparator : ':',
- trackLabels: false,
- onRemove: function(c){
- Ext.layout.FormLayout.superclass.onRemove.call(this, c);
- if(this.trackLabels){
- c.un('show', this.onFieldShow, this);
- c.un('hide', this.onFieldHide, this);
- }
- var el = c.getPositionEl(),
- ct = c.getItemCt && c.getItemCt();
- if(c.rendered && ct){
- if (el && el.dom) {
- el.insertAfter(ct);
- }
- Ext.destroy(ct);
- Ext.destroyMembers(c, 'label', 'itemCt');
- if(c.customItemCt){
- Ext.destroyMembers(c, 'getItemCt', 'customItemCt');
- }
- }
- },
- setContainer : function(ct){
- Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
- if(ct.labelAlign){
- ct.addClass('x-form-label-'+ct.labelAlign);
- }
- if(ct.hideLabels){
- Ext.apply(this, {
- labelStyle: 'display:none',
- elementStyle: 'padding-left:0;',
- labelAdjust: 0
- });
- }else{
- this.labelSeparator = ct.labelSeparator || this.labelSeparator;
- ct.labelWidth = ct.labelWidth || 100;
- if(Ext.isNumber(ct.labelWidth)){
- var pad = Ext.isNumber(ct.labelPad) ? ct.labelPad : 5;
- Ext.apply(this, {
- labelAdjust: ct.labelWidth + pad,
- labelStyle: 'width:' + ct.labelWidth + 'px;',
- elementStyle: 'padding-left:' + (ct.labelWidth + pad) + 'px'
- });
- }
- if(ct.labelAlign == 'top'){
- Ext.apply(this, {
- labelStyle: 'width:auto;',
- labelAdjust: 0,
- elementStyle: 'padding-left:0;'
- });
- }
- }
- },
- isHide: function(c){
- return c.hideLabel || this.container.hideLabels;
- },
- onFieldShow: function(c){
- c.getItemCt().removeClass('x-hide-' + c.hideMode);
- },
- onFieldHide: function(c){
- c.getItemCt().addClass('x-hide-' + c.hideMode);
- },
- getLabelStyle: function(s){
- var ls = '', items = [this.labelStyle, s];
- for (var i = 0, len = items.length; i < len; ++i){
- if (items[i]){
- ls += items[i];
- if (ls.substr(-1, 1) != ';'){
- ls += ';'
- }
- }
- }
- return ls;
- },
- renderItem : function(c, position, target){
- if(c && (c.isFormField || c.fieldLabel) && c.inputType != 'hidden'){
- var args = this.getTemplateArgs(c);
- if(Ext.isNumber(position)){
- position = target.dom.childNodes[position] || null;
- }
- if(position){
- c.itemCt = this.fieldTpl.insertBefore(position, args, true);
- }else{
- c.itemCt = this.fieldTpl.append(target, args, true);
- }
- if(!c.getItemCt){
- Ext.apply(c, {
- getItemCt: function(){
- return c.itemCt;
- },
- customItemCt: true
- });
- }
- c.label = c.getItemCt().child('label.x-form-item-label');
- if(!c.rendered){
- c.render('x-form-el-' + c.id);
- }else if(!this.isValidParent(c, target)){
- Ext.fly('x-form-el-' + c.id).appendChild(c.getPositionEl());
- }
- if(this.trackLabels){
- if(c.hidden){
- this.onFieldHide(c);
- }
- c.on({
- scope: this,
- show: this.onFieldShow,
- hide: this.onFieldHide
- });
- }
- this.configureItem(c);
- }else {
- Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
- }
- },
- getTemplateArgs: function(field) {
- var noLabelSep = !field.fieldLabel || field.hideLabel;
- return {
- id: field.id,
- label: field.fieldLabel,
- labelStyle: this.getLabelStyle(field.labelStyle),
- elementStyle: this.elementStyle||'',
- labelSeparator: noLabelSep ? '' : (Ext.isDefined(field.labelSeparator) ? field.labelSeparator : this.labelSeparator),
- itemCls: (field.itemCls||this.container.itemCls||'') + (field.hideLabel ? ' x-hide-label' : ''),
- clearCls: field.clearCls || 'x-form-clear-left'
- };
- },
- adjustWidthAnchor: function(value, c){
- if(c.label && !this.isHide(c) && (this.container.labelAlign != 'top')){
- var adjust = Ext.isIE6 || (Ext.isIE && !Ext.isStrict);
- return value - this.labelAdjust + (adjust ? -3 : 0);
- }
- return value;
- },
- adjustHeightAnchor : function(value, c){
- if(c.label && !this.isHide(c) && (this.container.labelAlign == 'top')){
- return value - c.label.getHeight();
- }
- return value;
- },
- isValidParent : function(c, target){
- return target && this.container.getEl().contains(c.getPositionEl());
- }
- });
- Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
- Ext.layout.AccordionLayout = 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.setActiveItem(c, true);
- }else if(this.activeItem && this.activeItem != c){
- c.collapsed = true;
- }
- Ext.layout.AccordionLayout.superclass.renderItem.apply(this, arguments);
- c.header.addClass('x-accordion-hd');
- c.on('beforeexpand', this.beforeExpand, this);
- },
- onRemove: function(c){
- Ext.layout.AccordionLayout.superclass.onRemove.call(this, c);
- if(c.rendered){
- c.header.removeClass('x-accordion-hd');
- }
- c.un('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.setActive(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 hh = 0;
- this.container.items.each(function(p){
- if(p != item){
- hh += p.header.getHeight();
- }
- });
- size.height -= hh;
- item.setSize(size);
- }
- },
- setActiveItem : function(item){
- this.setActive(item, true);
- },
- setActive : function(item, expand){
- var ai = this.activeItem;
- item = this.container.getComponent(item);
- if(ai != item){
- if(item.rendered && item.collapsed && expand){
- item.expand();
- }else{
- if(ai){
- ai.fireEvent('deactivate', ai);
- }
- this.activeItem = item;
- item.fireEvent('activate', item);
- }
- }
- }
- });
- Ext.Container.LAYOUTS.accordion = Ext.layout.AccordionLayout;
- Ext.layout.Accordion = Ext.layout.AccordionLayout;
- Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
- monitorResize:false,
- targetCls: 'x-table-layout-ct',
- tableAttrs:null,
- 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){
- this.table = target.createChild(
- Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), 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));
- this.configureItem(c, position);
- }else if(c && !this.isValidParent(c, target)){
- var container = this.getNextCell(c);
- container.insertBefore(c.getPositionEl().dom, null);
- c.container = Ext.get(container);
- this.configureItem(c, position);
- }
- },
- isValidParent : function(c, target){
- return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
- }
- });
- Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
- Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
- extraCls: 'x-abs-layout-item',
- onLayout : function(ct, target){
- target.position();
- this.paddingLeft = target.getPadding('l');
- this.paddingTop = target.getPadding('t');
- Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
- },
- adjustWidthAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[0] + this.paddingLeft : value;
- },
- adjustHeightAnchor : function(value, comp){
- return value ? value - comp.getPosition(true)[1] + this.paddingTop : value;
- }
- });
- Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
- Ext.layout.BoxLayout = Ext.extend(Ext.layout.ContainerLayout, {
- defaultMargins : {left:0,top:0,right:0,bottom:0},
- padding : '0',
- pack : 'start',
- monitorResize : true,
- scrollOffset : 0,
- extraCls : 'x-box-item',
- targetCls : 'x-box-layout-ct',
- innerCls : 'x-box-inner',
- constructor : function(config){
- Ext.layout.BoxLayout.superclass.constructor.call(this, config);
- if(Ext.isString(this.defaultMargins)){
- this.defaultMargins = this.parseMargins(this.defaultMargins);
- }
- },
- isValidParent : function(c, target){
- return c.getPositionEl().dom.parentNode == this.innerCt.dom;
- },
- onLayout : function(ct, target){
- var cs = ct.items.items, len = cs.length, c, i, last = len-1, cm;
- if(!this.innerCt){
- this.innerCt = target.createChild({cls:this.innerCls});
- this.padding = this.parseMargins(this.padding);
- }
- this.renderAll(ct, this.innerCt);
- },
- renderItem : function(c){
- if(Ext.isString(c.margins)){
- c.margins = this.parseMargins(c.margins);
- }else if(!c.margins){
- c.margins = this.defaultMargins;
- }
- Ext.layout.BoxLayout.superclass.renderItem.apply(this, arguments);
- },
- getTargetSize : function(target){
- return (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getStyleSize() : target.getViewSize(true);
- },
- getItems: function(ct){
- var items = [];
- ct.items.each(function(c){
- if(c.isVisible()){
- items.push(c);
- }
- });
- return items;
- }
- });
- Ext.layout.VBoxLayout = Ext.extend(Ext.layout.BoxLayout, {
- align : 'left',
- onLayout : function(ct, target){
- Ext.layout.VBoxLayout.superclass.onLayout.call(this, ct, target);
- var cs = this.getItems(ct), cm, ch, margin, cl, diff, aw,
- size = target.getViewSize(true),
- w = size.width,
- h = size.height - this.scrollOffset,
- l = this.padding.left, t = this.padding.top,
- isStart = this.pack == 'start',
- stretchWidth = w - (this.padding.left + this.padding.right),
- extraHeight = 0,
- maxWidth = 0,
- totalFlex = 0,
- flexHeight = 0,
- usedHeight = 0,
- idx = 0,
- heights = [],
- restore = [],
- c,