add docblock for password
[roojs1] / Roo / bootstrap / MessageBar.js
index 1bb74a2..68170fa 100644 (file)
@@ -11,7 +11,9 @@
  * Bootstrap MessageBar class
  * @cfg {String} html contents of the MessageBar
  * @cfg {String} weight (info | success | warning | danger) default info
- * @cfg {Boolean} closable (true | false) default true
+ * @cfg {String} beforeClass insert the bar before the given class
+ * @cfg {Boolean} closable (true | false) default false
+ * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
  * 
  * @constructor
  * Create a new Element
@@ -26,13 +28,15 @@ Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
     
     html: '',
     weight: 'info',
-    closable: true,
+    closable: false,
+    fixed: false,
+    beforeClass: 'bootstrap-sticky-wrap',
     
     getAutoCreate : function(){
         
         var cfg = {
             tag: 'div',
-            cls: 'alert alert-dismissable alert-messages alert-' + this.weight,
+            cls: 'alert alert-dismissable alert-' + this.weight,
             cn: [
                 {
                     tag: 'span',
@@ -40,14 +44,18 @@ Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
                     html: this.html || ''
                 }
             ]
+        };
+        
+        if(this.fixed){
+            cfg.cls += ' alert-messages-fixed';
         }
         
         if(this.closable){
-            cfg.cn = {
+            cfg.cn.push({
                 tag: 'button',
                 cls: 'close',
                 html: 'x'
-            }
+            });
         }
         
         return cfg;
@@ -67,7 +75,9 @@ Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
             if (this.style) {
                 cfg.style = this.style;
             }
-            this.el = Roo.get(document.body).createChild(cfg, position);
+            this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
+            
+            this.el.setVisibilityMode(Roo.Element.DISPLAY);
         }
         
         this.el.select('>button.close').on('click', this.hide, this);
@@ -88,6 +98,10 @@ Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
     
     hide : function()
     {
+        if (!this.rendered) {
+            this.render();
+        }
+        
         this.el.hide();
         
         this.fireEvent('hide', this);
@@ -103,7 +117,7 @@ Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component,  {
 //        
 //        e.data = this.html || '';
 
-        this.el.dom.innerHTML = this.html || '';
+        this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
     }
    
 });