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"}, true);
25         
26     //this.wrapper.dom.appendChild(grid.getGridEl().dom);
27     
28     Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
29     
30     Roo.log(this.el);
31     
32     if(this.toolbar){
33         this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
34     }
35     // xtype created footer. - not sure if will work as we normally have to render first..
36     if (this.footer && !this.footer.el && this.footer.xtype) {
37         
38         //this.footer.container = this.grid.getView().getFooterPanel(true);
39         //this.footer.dataSource = this.grid.dataSource;
40         //this.footer = Roo.factory(this.footer, Roo);
41         
42     }
43     
44     this.on('activate', function()
45     {
46         Roo.log('activate');
47         if (this.rendered) {
48             return;
49         }
50         this.rendered = true;
51         //console.log('render tree');
52         this.render();
53     },this);
54     
55     this.addEvents({
56         /**
57              * @event select
58              * Fires when a date is selected
59              * @param {DatePicker} this
60              * @param {Date} date The selected date
61              */
62         'select': true,
63         /**
64              * @event monthchange
65              * Fires when the displayed month changes 
66              * @param {DatePicker} this
67              * @param {Date} date The selected month
68              */
69         'monthchange': true,
70         /**
71              * @event evententer
72              * Fires when mouse over an event
73              * @param {Calendar} this
74              * @param {event} Event
75              */
76         'evententer': true,
77         /**
78              * @event eventleave
79              * Fires when the mouse leaves an
80              * @param {Calendar} this
81              * @param {event}
82              */
83         'eventleave': true,
84         /**
85              * @event eventclick
86              * Fires when the mouse click an
87              * @param {Calendar} this
88              * @param {event}
89              */
90         'eventclick': true
91         
92     });
93     
94     //this.grid = grid;
95     //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
96 };
97
98 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
99     getId : function(){
100         return this.id;
101     },
102     /*
103     setSize : function(width, height){
104         if(!this.ignoreResize(width, height)){
105             var grid = this.grid;
106             var size = this.adjustForComponents(width, height);
107             grid.getGridEl().setSize(size.width, size.height);
108             grid.autoSize();
109         }
110     },
111     
112     beforeSlide : function(){
113         this.grid.getView().scroller.clip();
114     },
115     
116     afterSlide : function(){
117         this.grid.getView().scroller.unclip();
118     },
119     */
120     destroy : function(){
121       //  this.grid.destroy();
122        // delete this.grid;
123         Roo.GridPanel.superclass.destroy.call(this);
124          
125     },
126     
127     
128     render : function()
129     {
130         if (this.rendered) {
131             return;
132         }
133         this.rendered = true;
134         
135         Roo.log("render calendar");
136         
137         Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
138         
139         
140         var cfg = Roo.apply({},  this.getAutoCreate());
141         cfg.id = Roo.id();
142         
143         // fill in the extra attributes 
144         if (this.xattr && typeof(this.xattr) =='object') {
145             for (var i in this.xattr) {
146                 cfg[i] = this.xattr[i];
147             }
148         }
149         
150         if(this.dataId){
151             cfg.dataId = this.dataId;
152         }
153         
154         if (this.cls) {
155             cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
156         }
157         
158         if (this.style) { // fixme needs to support more complex style data.
159             cfg.style = this.style;
160         }
161         
162         if(this.name){
163             cfg.name = this.name;
164         }
165         
166         this.el = ct.createChild(cfg, position);
167         
168         if(this.tabIndex !== undefined){
169             this.el.dom.setAttribute('tabIndex', this.tabIndex);
170         }
171         this.initEvents();
172     },
173     
174     
175     getAutoCreate : Roo.bootstrap.Calendar.prototype.getAutoCreate,
176     
177     initEvents : Roo.bootstrap.Calendar.prototype.initEvents 
178     
179     
180 });