* <script type="text/javascript">
*/
/**
- * @class Roo.ContentPanel
+ * @class Roo.bootstrap.paenl.Content
* @extends Roo.util.Observable
- * A basic ContentPanel element.
+ * @children Roo.bootstrap.Component
+ * @parent builder Roo.bootstrap.layout.Border
+ * A basic ContentPanel element. - a panel that contain any content (eg. forms etc.)
* @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
* @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
* @cfg {Boolean/Object} autoCreate True to auto generate the DOM element for this panel, or a {@link Roo.DomHelper} config of the element to create
* @cfg {String} title The title for this panel
* @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
* @cfg {String} url Calls {@link #setUrl} with this value
- * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
+ * @cfg {String} region [required] (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
* @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
* @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
* @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
-
+ * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
+ * @cfg {Boolean} badges render the badges
+ * @cfg {String} cls extra classes to use
+ * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
+
* @constructor
* Create a new ContentPanel.
- * @param {String/HTMLElement/Roo.Element} el The container element for this panel
* @param {String/Object} config A string to set only the title or a config object
- * @param {String} content (optional) Set the HTML content for this panel
- * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
+
*/
Roo.bootstrap.panel.Content = function( config){
+ this.tpl = config.tpl || false;
+
var el = config.el;
var content = config.content;
this.el = Roo.DomHelper.append(document.body,
config.autoCreate, true);
}else{
- this.el = Roo.DomHelper.append(document.body,
- {tag: "div", cls: "roo-layout-inactive-content " , id: config.id||el}, true);
+ var elcfg = {
+ tag: "div",
+ cls: (config.cls || '') +
+ (config.background ? ' bg-' + config.background : '') +
+ " roo-layout-inactive-content",
+ id: config.id||el
+ };
+ if (config.iframe) {
+ elcfg.cn = [
+ {
+ tag : 'iframe',
+ style : 'border: 0px',
+ src : 'about:blank'
+ }
+ ];
+ }
+
+ if (config.html) {
+ elcfg.html = config.html;
+
+ }
+
+ this.el = Roo.DomHelper.append(document.body, elcfg , true);
+ if (config.iframe) {
+ this.iframeEl = this.el.select('iframe',true).first();
+ }
}
- }
+ }
this.closable = false;
this.loaded = false;
this.active = false;
- if(typeof config == "string"){
- this.title = config;
- }else{
- Roo.apply(this, config);
+
+
+ if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
+
+ this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
+
+ this.wrapEl = this.el; //this.el.wrap();
+ var ti = [];
+ if (config.toolbar.items) {
+ ti = config.toolbar.items ;
+ delete config.toolbar.items ;
+ }
+
+ var nitems = [];
+ this.toolbar.render(this.wrapEl, 'before');
+ for(var i =0;i < ti.length;i++) {
+ // Roo.log(['add child', items[i]]);
+ nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
+ }
+ this.toolbar.items = nitems;
+ this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
+ delete config.toolbar;
+
}
/*
- if (this.toolbar && !this.toolbar.el && this.toolbar.xtype) {
- this.wrapEl = this.el.wrap();
- this.toolbar.container = this.el.insertSibling(false, 'before');
- this.toolbar = new Roo.Toolbar(this.toolbar);
- }
-
// xtype created footer. - not sure if will work as we normally have to render first..
if (this.footer && !this.footer.el && this.footer.xtype) {
if (!this.wrapEl) {
}
*/
+
+ if(typeof config == "string"){
+ this.title = config;
+ }else{
+ Roo.apply(this, config);
+ }
+
if(this.resizeEl){
this.resizeEl = Roo.get(this.resizeEl, true);
}else{
* Fires when this tab is created
* @param {Roo.ContentPanel} this
*/
- "render" : true
+ "render" : true,
+
+ /**
+ * @event scroll
+ * Fires when this content is scrolled
+ * @param {Roo.ContentPanel} this
+ * @param {Event} scrollEvent
+ */
+ "scroll" : true
- if(this.autoScroll){
+ if(this.autoScroll && !this.iframe){
this.resizeEl.setStyle("overflow", "auto");
+ this.resizeEl.on('scroll', this.onScroll, this);
} else {
// fix randome scrolling
- this.el.on('scroll', function() {
- Roo.log('fix random scolling');
- this.scrollTo('top',0);
- });
+ //this.el.on('scroll', function() {
+ // Roo.log('fix random scolling');
+ // this.scrollTo('top',0);
+ //});
}
content = content || this.content;
if(content){
this.fireEvent('render', this);
};
-Roo.extend(Roo.bootstrap.panel.Content, Roo.util.Observable, {
- tabTip:'',
+Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
+
+ cls : '',
+ background : '',
+
+ tabTip : '',
+
+ iframe : false,
+ iframeEl : false,
+
+ /* Resize Element - use this to work out scroll etc. */
+ resizeEl : false,
+
setRegion : function(region){
this.region = region;
- if(region){
+ this.setActiveClass(region && !this.background);
+ },
+
+
+ setActiveClass: function(state)
+ {
+ if(state){
this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
+ this.el.setStyle('position','relative');
}else{
this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
+ this.el.setStyle('position', 'absolute');
}
},
return this.toolbar;
},
- setActiveState : function(active){
+ setActiveState : function(active)
+ {
this.active = active;
+ this.setActiveClass(active);
if(!active){
- this.fireEvent("deactivate", this);
- }else{
- this.fireEvent("activate", this);
+ if(this.fireEvent("deactivate", this) === false){
+ return false;
+ }
+ return true;
}
+ this.fireEvent("activate", this);
+ return true;
},
/**
- * Updates this panel's element
+ * Updates this panel's element (not for iframe)
* @param {String} content The new content
* @param {Boolean} loadScripts (optional) true to look for and process scripts
*/
setContent : function(content, loadScripts){
+ if (this.iframe) {
+ return;
+ }
+
this.el.update(content, loadScripts);
},
* @return {Roo.UpdateManager} The UpdateManager
*/
getUpdateManager : function(){
+ if (this.iframe) {
+ return false;
+ }
return this.el.getUpdateManager();
},
/**
* Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
+ * Does not work with IFRAME contents
* @param {Object/String/Function} url The url for this request or a function to call to get the url or a config object containing any of the following options:
<pre><code>
panel.load({
scripts: false
});
</code></pre>
+
* The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
* are shorthand for <i>disableCaching</i>, <i>indicatorText</i> and <i>loadScripts</i> and are used to set their associated property on this panel UpdateManager instance.
* @param {String/Object} params (optional) The parameters to pass as either a URL encoded string "param1=1&param2=2" or an object {param1: 1, param2: 2}
* @return {Roo.ContentPanel} this
*/
load : function(){
+
+ if (this.iframe) {
+ return this;
+ }
+
var um = this.el.getUpdateManager();
um.update.apply(um, arguments);
return this;
* @param {String/Function} url The URL to load the content from or a function to call to get the URL
* @param {String/Object} params (optional) The string params for the update call or an object of the params. See {@link Roo.UpdateManager#update} for more details. (Defaults to null)
* @param {Boolean} loadOnce (optional) Whether to only load the content once. If this is false it makes the Ajax call every time this panel is activated. (Defaults to false)
- * @return {Roo.UpdateManager} The UpdateManager
+ * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
*/
setUrl : function(url, params, loadOnce){
+ if (this.iframe) {
+ this.iframeEl.dom.src = url;
+ return false;
+ }
+
if(this.refreshDelegate){
this.removeListener("activate", this.refreshDelegate);
}
return this.wrapEl || this.el;
},
+
+
adjustForComponents : function(width, height)
{
//Roo.log('adjustForComponents ');
}
if(this.toolbar){
var te = this.toolbar.getEl();
- height -= te.getHeight();
te.setWidth(width);
+ height -= te.getHeight();
}
if(this.footer){
var te = this.footer.getEl();
- Roo.log("footer:" + te.getHeight());
-
- height -= te.getHeight();
te.setWidth(width);
+ height -= te.getHeight();
}
this.el.setSize(width, height);
}
var size = this.adjustForComponents(width, height);
+ if (this.iframe) {
+ this.iframeEl.setSize(width,height);
+ }
+
this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
this.fireEvent('resize', this, size.width, size.height);
+
+
}
},
* @return {String}
*/
getTitle : function(){
- return this.title;
+
+ if (typeof(this.title) != 'object') {
+ return this.title;
+ }
+
+ var t = '';
+ for (var k in this.title) {
+ if (!this.title.hasOwnProperty(k)) {
+ continue;
+ }
+
+ if (k.indexOf('-') >= 0) {
+ var s = k.split('-');
+ for (var i = 0; i<s.length; i++) {
+ t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
+ }
+ } else {
+ t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
+ }
+ }
+ return t;
},
/**
* @param {Object} cfg Xtype definition of item to add.
*/
- addxtype : function(cfg) {
+
+ getChildContainer: function () {
+ return this.getEl();
+ },
+
+
+ onScroll : function(e)
+ {
+ this.fireEvent('scroll', this, e);
+ }
+
+
+ /*
+ var ret = new Roo.factory(cfg);
+ return ret;
+
+
// add form..
if (cfg.xtype.match(/^Form$/)) {
}
return false;
}
+ \*/
});
\ No newline at end of file