roojs-ui.js
[roojs1] / roojs-bootstrap-debug.js
index 4549f2f..40af41e 100644 (file)
@@ -1433,7 +1433,18 @@ Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component,  {
         return cfg;
     },
     
-    getChildContainer : function() {
+    initEvents :function ()
+    {
+        //Roo.log(this.el.select('.navbar-toggle',true));
+        this.el.select('.navbar-toggle',true).on('click', function() {
+           // Roo.log('click');
+            this.el.select('.navbar-collapse',true).toggleClass('in');                                 
+        }, this);
+    },
+    
+    
+    getChildContainer : function()
+    {
         if (this.bar === true) {
             return this.el.select('.collapse',true).first();
         }
@@ -1522,66 +1533,6 @@ Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component,  {
 
  
 
- /*
- * - LGPL
- *
- * row
- * 
- */
-/**
- * @class Roo.bootstrap.Navbar.Button
- * @extends Roo.bootstrap.Component
- * Bootstrap Navbar.Button class
- * @cfg {String} href  link to
- * @cfg {String} html content of button
-    
- * @constructor
- * Create a new Navbar Button
- * @param {Object} config The config object
- */
-
-
-Roo.bootstrap.Navbar.Button = function(config){
-    Roo.bootstrap.Navbar.Button.superclass.constructor.call(this, config);
-};
-
-Roo.extend(Roo.bootstrap.Navbar.Button, Roo.bootstrap.Component,  {
-    
-    href : false,
-    html : false,
-    
-    autoCreate : {
-        cls: 'btn',
-        tag : 'button',
-        html: 'hello'
-    },
-    
-    getAutoCreate : function(){
-        
-        var cfg = {
-            cls: 'btn',
-            tag : 'button',
-            html: 'hello',
-            cn : []
-            
-        } ;
-        cfg.cn.push({
-            html : this.html || ''
-            //href : this.
-             //       )
-        });
-        cfg.cn.push({
-            tag: 'span',
-            cls : 'carat'
-        });
-        
-        return cfg;
-    }
-   
-});
-
-
  /*
  * - LGPL
  *
@@ -7969,6 +7920,7 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
             }
         };
         var cal_rows = function() {
+            
             var ret = []
             for (var r = 0; r < 6; r++) {
                 var row= {
@@ -7989,11 +7941,12 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
                 
             }
             ret[0].cls += ' fc-first';
-           
+            ret[4].cls += ' fc-prev-last';
             ret[5].cls += ' fc-last';
             return ret;
             
         };
+        
         var cal_table = {
             tag: 'table',
             cls: 'fc-border-separate',
@@ -8053,42 +8006,28 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
     
     initEvents : function()
     {
+        if(!this.store){
+            throw "can not find store for combo";
+        }
+        
+        this.store = Roo.factory(this.store, Roo.data);
+        this.store.on('load', this.onLoad, this);
+        
         this.resize();
         this.cells = this.el.select('.fc-day',true);
         this.textNodes = this.el.query('.fc-day-number');
-        this.update(new Date().clearTime());
+        this.cells.addClassOnOver('fc-state-hover');
+        
         this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
         this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
         this.el.select('.fc-button-today',true).on('click', this.showToday, this);
         this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
-        this.cells.addClassOnOver('fc-state-hover');
         
+        this.on('monthchange', this.onMonthChange, this);
         
-        // move to ... 
-        this.calevents = [];
-        
-        this.addItem({
-            start: new Date(),
-            end : new Date().add(Date.DAY, 2),
-            title : 'test'
-        });
-        this.addItem({
-            start: new Date().add(Date.DAY, -5), 
-            end : new Date().add(Date.DAY, 2),
-            title : 'test'
-        });
-        this.addItem({
-            start: new Date(), 
-            end : new Date().add(Date.HOUR, 2),
-            title : 'test'
-        });
-         this.addItem({
-            start: new Date(), 
-            end : new Date().add(Date.HOUR, 2),
-            title : 'test'
-        });
-        this.renderEvents();
+        this.update(new Date().clearTime());
     },
+    
     resize : function() {
         var sz  = this.el.getSize();
         
@@ -8123,7 +8062,6 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
    // private
     update : function(date)
     {
-       
         var vd = this.activeDate;
         this.activeDate = date;
         if(vd && this.el){
@@ -8146,10 +8084,11 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
         }
         
         var days = date.getDaysInMonth();
+        
         var firstOfMonth = date.getFirstDateOfMonth();
         var startingPos = firstOfMonth.getDay()-this.startDay;
 
-        if(startingPos <= this.startDay){
+        if(startingPos < this.startDay){
             startingPos += 7;
         }
 
@@ -8176,6 +8115,7 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
         var setCellClass = function(cal, cell){
             cell.title = "";
             var t = d.getTime();
+            
             cell.dateValue = t;
             if(t == today){
                 cell.className += " fc-today";
@@ -8232,14 +8172,26 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
             setCellClass(this, cells[i]);
         }
         var extraDays = 0;
+        
         for(; i < 42; i++) {
             textEls[i].innerHTML = (++extraDays);
             d.setDate(d.getDate()+1);
             cells[i].className = "fc-future fc-other-month";
             setCellClass(this, cells[i]);
         }
-
+        
         this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
+        
+        var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
+        
+        this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
+        this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
+        
+        if(totalRows != 6){
+            this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
+            this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
+        }
+        
         this.fireEvent('monthchange', this, date);
         
         
@@ -8274,7 +8226,7 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
             }
             return true;
         });
-        Roo.log(ret);
+        
         return ret;
     },
     
@@ -8293,27 +8245,27 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
             }
             ret.push(c);
         });
-        //Roo.log(ret);
+        
         return ret;    
     },
     
     findBestRow: function(cells)
     {
         var ret = 0;
+        
         for (var i =0 ; i < cells.length;i++) {
             ret  = Math.max(cells[i].rows || 0,ret);
         }
         return ret;
-        //d.setDate(d.ev()+1);
         
     },
     
     
     addItem : function(ev)
     {
-        
         // look for vertical location slot in
         var cells = this.findCells(ev);
+        
         ev.row = this.findBestRow(cells);
         
         // work out the location.
@@ -8341,6 +8293,7 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
             };
             
         }
+        
         rows.push(crow);
         ev.els = [];
         ev.rows = rows;
@@ -8354,6 +8307,15 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
     },
     
     clearEvents: function() {
+        
+        if(!this.calevents){
+            return;
+        }
+        
+        Roo.each(this.cells.elements, function(c){
+            c.rows = 0;
+        });
+        
         Roo.each(this.calevents, function(e) {
             Roo.each(e.els, function(el) {
                 el.un('mouseenter' ,this.onEventEnter, this);
@@ -8365,11 +8327,11 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
     },
     
     renderEvents: function()
-    {
-        this.clearEvents();
+    {   
         // first make sure there is enough space..
+        
         this.cells.each(function(c) {
-            Roo.log(c.select('.fc-day-content div',true).first(), Math.max(34, c.rows * 20));
+//            Roo.log(c.select('.fc-day-content div',true).first(), Math.max(34, c.rows * 20));
             c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.rows * 20));
         });
         
@@ -8395,7 +8357,7 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
                                 {
                                   tag:'span',
                                   cls: 'fc-event-time',
-                                  html : cells.length > 1 ? '' : '7pm'
+                                  html : cells.length > 1 ? '' : ev.time
                                 },
                                 {
                                   tag:'span',
@@ -8423,11 +8385,11 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
                 var ctr = this.el.select('.fc-event-container',true).first();
                 var cg = ctr.createChild(cfg);
                 
-                
                 cg.on('mouseenter' ,this.onEventEnter, this);
                 cg.on('mouseleave' ,this.onEventLeave, this);
                 
                 ev.els.push(cg);
+                
                 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
                 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
                 //Roo.log(cg);
@@ -8435,20 +8397,42 @@ Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component,  {
                 cg.setWidth(ebox.right - sbox.x -2);
             }
             
+            
         }
         
     },
     
     onEventEnter: function (e, el,c,d) {
-        Roo.log(e,el,c,d)
         this.fireEvent('evententer', this, el);
-        //code
     },
+    
     onEventLeave: function (e, el,c,d) {
-        Roo.log(e,el,c,d)
         this.fireEvent('eventleave', this, el);
-        //code
-    } 
+    },
+    
+    onMonthChange: function () {
+        this.store.load();
+    },
+    
+    onLoad: function () {
+        
+        this.clearEvents();
+        
+        this.calevents = [];
+        var cal = this;
+        if(this.store.getCount() > 0){
+            this.store.data.each(function(d){
+               cal.addItem({
+                    start: new Date(d.data.start_dt),
+                    end : new Date(d.data.end_dt),
+                    time : d.data.start_time,
+                    title : d.data.title
+                });
+            });
+        }
+        
+        this.renderEvents();
+    }
 });