4 * based on jquery fullcalendar
11 * @extends Roo.Component
12 * Bootstrap Calendar class
15 * Create a new Container
16 * @param {Object} config The config object
19 Roo.CalendarPanel = function(config){
21 Roo.log("cal panel ctr");
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);
26 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
28 Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
33 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
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) {
38 //this.footer.container = this.grid.getView().getFooterPanel(true);
39 //this.footer.dataSource = this.grid.dataSource;
40 //this.footer = Roo.factory(this.footer, Roo);
44 this.on('activate', function()
51 //console.log('render tree');
58 * Fires when a date is selected
59 * @param {DatePicker} this
60 * @param {Date} date The selected date
65 * Fires when the displayed month changes
66 * @param {DatePicker} this
67 * @param {Date} date The selected month
72 * Fires when mouse over an event
73 * @param {Calendar} this
74 * @param {event} Event
79 * Fires when the mouse leaves an
80 * @param {Calendar} this
86 * Fires when the mouse click an
87 * @param {Calendar} this
95 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
98 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
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);
112 beforeSlide : function(){
113 this.grid.getView().scroller.clip();
116 afterSlide : function(){
117 this.grid.getView().scroller.unclip();
120 destroy : function(){
121 // this.grid.destroy();
123 Roo.GridPanel.superclass.destroy.call(this);
130 Roo.log("render calendar");
131 var res = Roo.bootstrap.Calendar.prototype.getAutoCreate();
137 getAutoCreate : function(){
140 fc_button = function(name, corner, style, content ) {
141 return Roo.apply({},{
143 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
145 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
148 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
156 style : 'width:100%',
163 cls : 'fc-header-left',
165 fc_button('prev', 'left', 'arrow', '‹' ),
166 fc_button('next', 'right', 'arrow', '›' ),
167 { tag: 'span', cls: 'fc-header-space' },
168 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
176 cls : 'fc-header-center',
180 cls: 'fc-header-title',
183 html : 'month / year'
191 cls : 'fc-header-right',
193 /* fc_button('month', 'left', '', 'month' ),
194 fc_button('week', '', '', 'week' ),
195 fc_button('day', 'right', '', 'day' )
207 var cal_heads = function() {
209 // fixme - handle this.
211 for (var i =0; i < Date.dayNames.length; i++) {
212 var d = Date.dayNames[i];
215 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
216 html : d.substring(0,3)
220 ret[0].cls += ' fc-first';
221 ret[6].cls += ' fc-last';
224 var cal_cell = function(n) {
227 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
232 cls: 'fc-day-number',
236 cls: 'fc-day-content',
240 style: 'position: relative;' // height: 17px;
252 var cal_rows = function() {
255 for (var r = 0; r < 6; r++) {
262 for (var i =0; i < Date.dayNames.length; i++) {
263 var d = Date.dayNames[i];
264 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
267 row.cn[0].cls+=' fc-first';
268 row.cn[0].cn[0].style = 'min-height:90px';
269 row.cn[6].cls+=' fc-last';
273 ret[0].cls += ' fc-first';
274 ret[4].cls += ' fc-prev-last';
275 ret[5].cls += ' fc-last';
282 cls: 'fc-border-separate',
283 style : 'width:100%',
291 cls : 'fc-first fc-last',
310 style : "position: relative;",
313 cls : 'fc-view fc-view-month fc-grid',
314 style : 'position: relative',
318 cls : 'fc-event-container',
319 style : 'position:absolute;z-index:8;top:0;left:0;'
337 initEvents : function()
340 throw "can not find store for combo";
343 this.store = Roo.factory(this.store, Roo.data);
344 this.store.on('load', this.onLoad, this);
347 this.cells = this.el.select('.fc-day',true);
349 this.textNodes = this.el.query('.fc-day-number');
350 this.cells.addClassOnOver('fc-state-hover');
352 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
353 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
354 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
355 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
357 this.on('monthchange', this.onMonthChange, this);
359 this.update(new Date().clearTime());