* the space available, similar to FireFox 1.5 tabs (defaults to false)
* @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
* @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
+ * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
* @cfg {Boolean} hidden True to start the region hidden (defaults to false)
* @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
* @cfg {Number} height For North/South panels
* @cfg {Boolean} split To show the splitter
* @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
+ *
+ * @cfg {string} cls Extra CSS classes to add to region
+ *
* @cfg {Roo.bootstrap.layout.Manager} mgr The manager
* @cfg {string} region the region that it inhabits..
*
- * @cfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
- * @cfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
+ * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
+ * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
* @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
* @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
*/
Roo.bootstrap.layout.Region = function(config)
{
-
+ this.applyConfig(config);
+
var mgr = config.mgr;
var pos = config.region;
config.skipConfig = true;
- Roo.LayoutRegion.superclass.constructor.call(this, config);
- var dh = Roo.DomHelper;
- /** This region's container element
- * @type Roo.Element */
- this.el = dh.append(mgr.el.dom, {tag: "div", cls: "roo-layout-panel roo-layout-panel-" + this.position}, true);
- /** This region's title element
- * @type Roo.Element */
-
- this.titleEl = dh.append(this.el.dom,
- {
- tag: "div",
- unselectable: "on",
- cls: "roo-unselectable roo-layout-panel-hd roo-layout-title-" + this.position,
- children:[
- {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
- {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
- ]}, true);
-
- this.titleEl.enableDisplayMode();
- /** This region's title text element
- * @type HTMLElement */
- this.titleTextEl = this.titleEl.dom.firstChild;
- this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
+ Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
- this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
- this.closeBtn.enableDisplayMode();
- this.closeBtn.on("click", this.closeClicked, this);
- this.closeBtn.hide();
-
- this.createBody(config);
+ if (mgr.el) {
+ this.onRender(mgr.el);
+ }
+
this.visible = true;
this.collapsed = false;
-
- if(config.hideWhenEmpty){
- this.hide();
- this.on("paneladded", this.validateVisibility, this);
- this.on("panelremoved", this.validateVisibility, this);
- }
- this.applyConfig(config);
+ this.unrendered_panels = [];
};
Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
+ position: '', // set by wrapper (eg. north/south etc..)
+ unrendered_panels : null, // unrendered panels.
+
+ tabPosition : false,
+
+ mgr: false, // points to 'Border'
+
+
createBody : function(){
/** This region's body element
* @type Roo.Element */
});
},
+ onRender: function(ctr, pos)
+ {
+ var dh = Roo.DomHelper;
+ /** This region's container element
+ * @type Roo.Element */
+ this.el = dh.append(ctr.dom, {
+ tag: "div",
+ cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
+ }, true);
+ /** This region's title element
+ * @type Roo.Element */
+
+ this.titleEl = dh.append(this.el.dom, {
+ tag: "div",
+ unselectable: "on",
+ cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
+ children:[
+ {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
+ {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
+ ]
+ }, true);
+
+ this.titleEl.enableDisplayMode();
+ /** This region's title text element
+ * @type HTMLElement */
+ this.titleTextEl = this.titleEl.dom.firstChild;
+ this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
+ /*
+ this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
+ this.closeBtn.enableDisplayMode();
+ this.closeBtn.on("click", this.closeClicked, this);
+ this.closeBtn.hide();
+ */
+ this.createBody(this.config);
+ if(this.config.hideWhenEmpty){
+ this.hide();
+ this.on("paneladded", this.validateVisibility, this);
+ this.on("panelremoved", this.validateVisibility, this);
+ }
+ if(this.autoScroll){
+ this.bodyEl.setStyle("overflow", "auto");
+ }else{
+ this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
+ }
+ //if(c.titlebar !== false){
+ if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
+ this.titleEl.hide();
+ }else{
+ this.titleEl.show();
+ if(this.config.title){
+ this.titleTextEl.innerHTML = this.config.title;
+ }
+ }
+ //}
+ if(this.config.collapsed){
+ this.collapse(true);
+ }
+ if(this.config.hidden){
+ this.hide();
+ }
+
+ if (this.unrendered_panels && this.unrendered_panels.length) {
+ for (var i =0;i< this.unrendered_panels.length; i++) {
+ this.add(this.unrendered_panels[i]);
+ }
+ this.unrendered_panels = null;
+
+ }
+
+ },
+
applyConfig : function(c)
{
- /*if(c.collapsible && this.position != "center" && !this.collapsedEl){
+ /*
+ *if(c.collapsible && this.position != "center" && !this.collapsedEl){
var dh = Roo.DomHelper;
if(c.titlebar !== false){
this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
this.stickBtn.on("click", this.expand, this);
this.stickBtn.hide();
}
- */
+
}
+ */
/** This region's collapsed element
* @type Roo.Element */
/*
{top: 0, left: 2, right:2, bottom: 0} :
{top: 2, left: 0, right:0, bottom: 2});
*/
- this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
+ this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
- this.bottomTabs = c.tabPosition != "top";
+ this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
this.autoScroll = c.autoScroll || false;
- if(this.autoScroll){
- this.bodyEl.setStyle("overflow", "auto");
- }else{
- this.bodyEl.setStyle("overflow", "hidden");
- }
- //if(c.titlebar !== false){
- if((!c.titlebar && !c.title) || c.titlebar === false){
- this.titleEl.hide();
- }else{
- this.titleEl.show();
- if(c.title){
- this.titleTextEl.innerHTML = c.title;
- }
- }
- //}
+
+
+
+
this.duration = c.duration || .30;
this.slideDuration = c.slideDuration || .45;
this.config = c;
- if(c.collapsed){
- this.collapse(true);
- }
- if(c.hidden){
- this.hide();
- }
+
},
/**
* Returns true if this region is currently visible.
*/
updateBox : function(box)
{
+ if (!this.bodyEl) {
+ return; // not rendered yet..
+ }
+
this.box = box;
if(!this.collapsed){
this.el.dom.style.left = box.x + "px";
w += this.config.adjustments[0];
}
}
- if(h !== null){
+ if(h !== null && h > 0){
this.el.setHeight(h);
h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
h -= this.el.getBorderWidth("tb");
initTabs : function()
{
- this.bodyEl.setStyle("overflow", "hidden");
- var ts = new Roo.bootstrap.layout.Tab({
- el: this.bodyEl.dom,
- tabPosition: this.bottomTabs ? 'bottom' : 'top',
- disableTooltips: this.config.disableTabTips,
- toolbar : this.config.toolbar
- });
+ //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
+
+ var ts = new Roo.bootstrap.panel.Tabs({
+ el: this.bodyEl.dom,
+ region : this,
+ tabPosition: this.tabPosition ? this.tabPosition : 'top',
+ disableTooltips: this.config.disableTabTips,
+ toolbar : this.config.toolbar
+ });
if(this.config.hideTabs){
ts.stripWrap.setDisplayed(false);
ts.maxTabWidth = this.config.maxTabWidth || 250;
ts.preferredTabWidth = this.config.preferredTabWidth || 150;
ts.monitorResize = false;
- ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
+ //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
ts.bodyEl.addClass('roo-layout-tabs-body');
this.panels.each(this.initPanelAsTab, this);
},
initPanelAsTab : function(panel){
- var ti = this.tabs.addTab(panel.getEl().id, panel.getTitle(), null,
- this.config.closeOnTab && panel.isClosable());
+ var ti = this.tabs.addTab(
+ panel.getEl().id,
+ panel.getTitle(),
+ null,
+ this.config.closeOnTab && panel.isClosable(),
+ panel.tpl
+ );
if(panel.tabTip !== undefined){
ti.setTooltip(panel.tabTip);
}
ti.on("activate", function(){
this.setActivePanel(panel);
}, this);
+
if(this.config.closeOnTab){
ti.on("beforeclose", function(t, e){
e.cancel = true;
this.remove(panel);
}, this);
}
+
+ panel.tabItem = ti;
+
return ti;
},
- updatePanelTitle : function(panel, title){
+ updatePanelTitle : function(panel, title)
+ {
if(this.activePanel == panel){
this.updateTitle(title);
}
}
},
- setActivePanel : function(panel){
+ setActivePanel : function(panel)
+ {
panel = this.getPanel(panel);
if(this.activePanel && this.activePanel != panel){
- this.activePanel.setActiveState(false);
+ if(this.activePanel.setActiveState(false) === false){
+ return;
+ }
}
this.activePanel = panel;
panel.setActiveState(true);
* @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
* @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
*/
- add : function(panel){
+ add : function(panel)
+ {
if(arguments.length > 1){
for(var i = 0, len = arguments.length; i < len; i++) {
this.add(arguments[i]);
}
return null;
}
+
+ // if we have not been rendered yet, then we can not really do much of this..
+ if (!this.bodyEl) {
+ this.unrendered_panels.push(panel);
+ return panel;
+ }
+
+
+
+
if(this.hasPanel(panel)){
this.showPanel(panel);
return panel;
}
panel.setRegion(this);
this.panels.add(panel);
- if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
+ /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
+ // sinle panel - no tab...?? would it not be better to render it with the tabs,
+ // and hide them... ???
this.bodyEl.dom.appendChild(panel.getEl().dom);
if(panel.background !== true){
this.setActivePanel(panel);
this.fireEvent("paneladded", this, panel);
return panel;
}
+ */
if(!this.tabs){
this.initTabs();
}else{
this.initPanelAsTab(panel);
}
+
+
if(panel.background !== true){
this.tabs.activate(panel.getEl().id);
}
* @param {Boolean} preservePanel Overrides the config preservePanel option
* @return {Roo.ContentPanel} The panel that was removed
*/
- remove : function(panel, preservePanel){
+ remove : function(panel, preservePanel)
+ {
panel = this.getPanel(panel);
if(!panel){
return null;
},
createTool : function(parentEl, className){
- var btn = Roo.DomHelper.append(parentEl, {tag: "div", cls: "x-layout-tools-button",
- children: [{tag: "div", cls: "x-layout-tools-button-inner " + className, html: " "}]}, true);
- btn.addClassOnOver("x-layout-tools-button-over");
+ var btn = Roo.DomHelper.append(parentEl, {
+ tag: "div",
+ cls: "x-layout-tools-button",
+ children: [ {
+ tag: "div",
+ cls: "roo-layout-tools-button-inner " + className,
+ html: " "
+ }]
+ }, true);
+ btn.addClassOnOver("roo-layout-tools-button-over");
return btn;
}
});
\ No newline at end of file