Roo/CalendarPanel.js
[roojs1] / Roo / CalendarPanel.js
1 /*
2  * - LGPL
3  *
4  * based on jquery fullcalendar
5  * 
6  */
7
8
9 /**
10  * @class Roo.Calendar
11  * @extends Roo.Component
12  * Bootstrap Calendar class
13     
14  * @constructor
15  * Create a new Container
16  * @param {Object} config The config object
17  */
18
19 Roo.CalendarPanel = function(config){
20     
21     Roo.log("cal panel ctr");
22   
23     this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
24         {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content", ns: true}, true);
25     Roo.log(this.warpper);
26     Roo.log(this.config);
27     Roo.log(Roo.DomHelper.append(document.body),{}, true);
28     return;
29     //this.wrapper.dom.appendChild(grid.getGridEl().dom);
30     
31     Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
32     
33     Roo.log(this.el);
34     
35     if(this.toolbar){
36         this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
37     }
38     // xtype created footer. - not sure if will work as we normally have to render first..
39     if (this.footer && !this.footer.el && this.footer.xtype) {
40         
41         //this.footer.container = this.grid.getView().getFooterPanel(true);
42         //this.footer.dataSource = this.grid.dataSource;
43         //this.footer = Roo.factory(this.footer, Roo);
44         
45     }
46     this.view = new Roo.calendar.View(Roo.apply({
47         skipNavHeader : true,
48         skipMonthHeader : true
49         
50     },config));
51     
52      
53     this.on('activate', function()
54     {
55         Roo.log('CalendarPanel.js activate');
56          
57         //console.log('render tree');
58         this.render();
59     },this);
60     
61     this.addEvents({
62         /**
63              * @event select
64              * Fires when a date is selected
65              * @param {DatePicker} this
66              * @param {Date} date The selected date
67              */
68         'select': true,
69         /**
70              * @event monthchange
71              * Fires when the displayed month changes 
72              * @param {DatePicker} this
73              * @param {Date} date The selected month
74              */
75         'monthchange': true,
76         /**
77              * @event evententer
78              * Fires when mouse over an event
79              * @param {Calendar} this
80              * @param {event} Event
81              */
82         'evententer': true,
83         /**
84              * @event eventleave
85              * Fires when the mouse leaves an
86              * @param {Calendar} this
87              * @param {event}
88              */
89         'eventleave': true,
90         /**
91              * @event eventclick
92              * Fires when the mouse click an
93              * @param {Calendar} this
94              * @param {event}
95              */
96         'eventclick': true,
97         /**
98              * @event rendered
99              * Fires when the grid is rendered
100              * @param {Calendar} this
101             
102              */
103         'rendered': true
104         
105         
106     });
107     this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
108
109     //this.grid = grid;
110     //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
111 };
112
113
114 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
115     
116       
117     render : function()
118     {
119         var ct = this.el.appendChild(document.createElement("div"));
120         this.onRender(this.el, false)
121     },
122     
123     onRender : function(ct, position)
124     {
125         if (this.rendered) {
126             return;
127         }
128         this.rendered = true;
129         
130         Roo.log("CalendarPanel.js render calendar");
131         
132         
133         //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
134         
135         
136         var cfg = Roo.apply({},  this.view.getAutoCreate());
137         cfg.id = Roo.id();
138         
139         // fill in the extra attributes 
140         if (this.xattr && typeof(this.xattr) =='object') {
141             for (var i in this.xattr) {
142                 cfg[i] = this.xattr[i];
143             }
144         }
145         
146         if(this.dataId){
147             cfg.dataId = this.dataId;
148         }
149         
150         if (this.cls) {
151             cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
152         }
153         
154         if (this.style) { // fixme needs to support more complex style data.
155             cfg.style = this.style;
156         }
157         
158         if(this.name){
159             cfg.name = this.name;
160         }
161         
162         this.view.el =  ct.createChild(cfg, position);
163         Roo.log('this.view');
164         Roo.log(this.view);
165         //if(this.tabIndex !== undefined){
166         //    this.el.dom.setAttribute('tabIndex', this.tabIndex);
167         //}
168         
169         
170         this.view.initEvents();
171         this.fireEvent('rendered');
172     }
173     
174     
175     
176     
177 });
178
179