4 * base class for bootstrap elements.
8 Roo.bootstrap = Roo.bootstrap || {};
10 * @class Roo.bootstrap.Component
11 * @extends Roo.Component
12 * Bootstrap Component base class
13 * @cfg {String} cls css class
14 * @cfg {String} style any extra css
15 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
16 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
17 * @cfg {string} dataId cutomer id
18 * @cfg {string} name Specifies name attribute
19 * @cfg {string} tooltip Text for the tooltip
20 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
21 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
24 * Do not use directly - it does not do anything..
25 * @param {Object} config The config object
30 Roo.bootstrap.Component = function(config){
31 Roo.bootstrap.Component.superclass.constructor.call(this, config);
35 * @event childrenrendered
36 * Fires when the children have been rendered..
37 * @param {Roo.bootstrap.Component} this
39 "childrenrendered" : true
48 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
51 allowDomMove : false, // to stop relocations in parent onRender...
61 * Initialize Events for the element
63 initEvents : function() { },
69 can_build_overlaid : true,
71 container_method : false,
78 // returns the parent component..
79 return Roo.ComponentMgr.get(this.parentId)
85 onRender : function(ct, position)
87 // Roo.log("Call onRender: " + this.xtype);
89 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
92 if (this.el.attr('xtype')) {
93 this.el.attr('xtypex', this.el.attr('xtype'));
94 this.el.dom.removeAttribute('xtype');
104 var cfg = Roo.apply({}, this.getAutoCreate());
106 cfg.id = this.id || Roo.id();
108 // fill in the extra attributes
109 if (this.xattr && typeof(this.xattr) =='object') {
110 for (var i in this.xattr) {
111 cfg[i] = this.xattr[i];
116 cfg.dataId = this.dataId;
120 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
123 if (this.style) { // fixme needs to support more complex style data.
124 cfg.style = this.style;
128 cfg.name = this.name;
131 this.el = ct.createChild(cfg, position);
134 this.tooltipEl().attr('tooltip', this.tooltip);
137 if(this.tabIndex !== undefined){
138 this.el.dom.setAttribute('tabIndex', this.tabIndex);
145 * Fetch the element to add children to
146 * @return {Roo.Element} defaults to this.el
148 getChildContainer : function()
153 * Fetch the element to display the tooltip on.
154 * @return {Roo.Element} defaults to this.el
156 tooltipEl : function()
161 * This is really a wrapper for addxtypeChild
162 * it handles stuff relating to flexy:foreach / flexy:if
163 * = some of our projects use a flat rendering of the output, and try and overlay it with dynamic data.
164 * -- this is a bit of a nightmare... and is even more confusing to debug..
169 addxtype : function(tree,cntr)
173 cn = Roo.factory(tree);
174 //Roo.log(['addxtype', cn]);
176 cn.parentType = this.xtype; //??
177 cn.parentId = this.id;
179 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
180 if (typeof(cn.container_method) == 'string') {
181 cntr = cn.container_method;
185 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
187 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
189 var build_from_html = Roo.XComponent.build_from_html;
191 var is_body = (tree.xtype == 'Body') ;
193 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
195 var self_cntr_el = Roo.get(this[cntr](false));
197 // do not try and build conditional elements
198 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
202 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
203 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
204 return this.addxtypeChild(tree,cntr, is_body);
207 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
210 return this.addxtypeChild(Roo.apply({}, tree),cntr);
213 Roo.log('skipping render');
219 if (!build_from_html) {
223 // this i think handles overlaying multiple children of the same type
224 // with the sam eelement.. - which might be buggy..
226 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
232 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
236 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
242 * add a child to this element
243 * - turn the child.cfg into a child_instance
244 * - call child_instance.render( this { getContainerMethod()} )
245 * - loop through the children, and call addxtype.. (reall this) on newly created child.
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 cn.addxtypeChildren(tree.items, skip_children);
354 * add a number of children to this object,
355 * which in turn calls render...
359 addxtypeChildren: function(child_array, skip_children)
362 if (!child_array || !child_array.length ) {
367 for(var i =0;i < child_array.length;i++) {
371 // Roo.log(['add child', items[i]]);
372 nitems.push(this.addxtype(Roo.apply({}, child_array[i])));
376 this.fireEvent('childrenrendered', this);
383 * Set the element that will be used to show or hide
385 setVisibilityEl : function(el)
387 this.visibilityEl = el;
391 * Get the element that will be used to show or hide
393 getVisibilityEl : function()
395 if (typeof(this.visibilityEl) == 'object') {
396 return this.visibilityEl;
399 if (typeof(this.visibilityEl) == 'string') {
400 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
407 * Show a component - removes 'hidden' class
411 if(!this.getVisibilityEl()){
415 this.getVisibilityEl().removeClass(['hidden','d-none']);
417 this.fireEvent('show', this);
422 * Hide a component - adds 'hidden' class
426 if(!this.getVisibilityEl()){
430 this.getVisibilityEl().addClass(['hidden','d-none']);
432 this.fireEvent('hide', this);
440 * based on jquery fullcalendar
444 Roo.bootstrap = Roo.bootstrap || {};
446 * @class Roo.bootstrap.Calendar
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Calendar class
449 * @cfg {Boolean} loadMask (true|false) default false
450 * @cfg {Object} header generate the user specific header of the calendar, default false
453 * Create a new Container
454 * @param {Object} config The config object
459 Roo.bootstrap.Calendar = function(config){
460 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
464 * Fires when a date is selected
465 * @param {DatePicker} this
466 * @param {Date} date The selected date
471 * Fires when the displayed month changes
472 * @param {DatePicker} this
473 * @param {Date} date The selected month
478 * Fires when mouse over an event
479 * @param {Calendar} this
480 * @param {event} Event
485 * Fires when the mouse leaves an
486 * @param {Calendar} this
492 * Fires when the mouse click an
493 * @param {Calendar} this
502 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
505 * @cfg {Number} startDay
506 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
514 getAutoCreate : function(){
517 var fc_button = function(name, corner, style, content ) {
518 return Roo.apply({},{
520 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
522 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
525 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
536 style : 'width:100%',
543 cls : 'fc-header-left',
545 fc_button('prev', 'left', 'arrow', '‹' ),
546 fc_button('next', 'right', 'arrow', '›' ),
547 { tag: 'span', cls: 'fc-header-space' },
548 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
556 cls : 'fc-header-center',
560 cls: 'fc-header-title',
563 html : 'month / year'
571 cls : 'fc-header-right',
573 /* fc_button('month', 'left', '', 'month' ),
574 fc_button('week', '', '', 'week' ),
575 fc_button('day', 'right', '', 'day' )
587 header = this.header;
590 var cal_heads = function() {
592 // fixme - handle this.
594 for (var i =0; i < Date.dayNames.length; i++) {
595 var d = Date.dayNames[i];
598 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
599 html : d.substring(0,3)
603 ret[0].cls += ' fc-first';
604 ret[6].cls += ' fc-last';
607 var cal_cell = function(n) {
610 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
615 cls: 'fc-day-number',
619 cls: 'fc-day-content',
623 style: 'position: relative;' // height: 17px;
635 var cal_rows = function() {
638 for (var r = 0; r < 6; r++) {
645 for (var i =0; i < Date.dayNames.length; i++) {
646 var d = Date.dayNames[i];
647 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
650 row.cn[0].cls+=' fc-first';
651 row.cn[0].cn[0].style = 'min-height:90px';
652 row.cn[6].cls+=' fc-last';
656 ret[0].cls += ' fc-first';
657 ret[4].cls += ' fc-prev-last';
658 ret[5].cls += ' fc-last';
665 cls: 'fc-border-separate',
666 style : 'width:100%',
674 cls : 'fc-first fc-last',
693 style : "position: relative;",
696 cls : 'fc-view fc-view-month fc-grid',
697 style : 'position: relative',
701 cls : 'fc-event-container',
702 style : 'position:absolute;z-index:8;top:0;left:0;'
720 initEvents : function()
723 throw "can not find store for calendar";
729 style: "text-align:center",
733 style: "background-color:white;width:50%;margin:250 auto",
737 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
748 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
750 var size = this.el.select('.fc-content', true).first().getSize();
751 this.maskEl.setSize(size.width, size.height);
752 this.maskEl.enableDisplayMode("block");
757 this.store = Roo.factory(this.store, Roo.data);
758 this.store.on('load', this.onLoad, this);
759 this.store.on('beforeload', this.onBeforeLoad, this);
763 this.cells = this.el.select('.fc-day',true);
764 //Roo.log(this.cells);
765 this.textNodes = this.el.query('.fc-day-number');
766 this.cells.addClassOnOver('fc-state-hover');
768 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
769 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
770 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
771 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
773 this.on('monthchange', this.onMonthChange, this);
775 this.update(new Date().clearTime());
778 resize : function() {
779 var sz = this.el.getSize();
781 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
782 this.el.select('.fc-day-content div',true).setHeight(34);
787 showPrevMonth : function(e){
788 this.update(this.activeDate.add("mo", -1));
790 showToday : function(e){
791 this.update(new Date().clearTime());
794 showNextMonth : function(e){
795 this.update(this.activeDate.add("mo", 1));
799 showPrevYear : function(){
800 this.update(this.activeDate.add("y", -1));
804 showNextYear : function(){
805 this.update(this.activeDate.add("y", 1));
810 update : function(date)
812 var vd = this.activeDate;
813 this.activeDate = date;
814 // if(vd && this.el){
815 // var t = date.getTime();
816 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
817 // Roo.log('using add remove');
819 // this.fireEvent('monthchange', this, date);
821 // this.cells.removeClass("fc-state-highlight");
822 // this.cells.each(function(c){
823 // if(c.dateValue == t){
824 // c.addClass("fc-state-highlight");
825 // setTimeout(function(){
826 // try{c.dom.firstChild.focus();}catch(e){}
836 var days = date.getDaysInMonth();
838 var firstOfMonth = date.getFirstDateOfMonth();
839 var startingPos = firstOfMonth.getDay()-this.startDay;
841 if(startingPos < this.startDay){
845 var pm = date.add(Date.MONTH, -1);
846 var prevStart = pm.getDaysInMonth()-startingPos;
848 this.cells = this.el.select('.fc-day',true);
849 this.textNodes = this.el.query('.fc-day-number');
850 this.cells.addClassOnOver('fc-state-hover');
852 var cells = this.cells.elements;
853 var textEls = this.textNodes;
855 Roo.each(cells, function(cell){
856 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
861 // convert everything to numbers so it's fast
863 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
866 //Roo.log(prevStart);
868 var today = new Date().clearTime().getTime();
869 var sel = date.clearTime().getTime();
870 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
871 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
872 var ddMatch = this.disabledDatesRE;
873 var ddText = this.disabledDatesText;
874 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
875 var ddaysText = this.disabledDaysText;
876 var format = this.format;
878 var setCellClass = function(cal, cell){
882 //Roo.log('set Cell Class');
890 cell.className += " fc-today";
891 cell.className += " fc-state-highlight";
892 cell.title = cal.todayText;
895 // disable highlight in other month..
896 //cell.className += " fc-state-highlight";
901 cell.className = " fc-state-disabled";
902 cell.title = cal.minText;
906 cell.className = " fc-state-disabled";
907 cell.title = cal.maxText;
911 if(ddays.indexOf(d.getDay()) != -1){
912 cell.title = ddaysText;
913 cell.className = " fc-state-disabled";
916 if(ddMatch && format){
917 var fvalue = d.dateFormat(format);
918 if(ddMatch.test(fvalue)){
919 cell.title = ddText.replace("%0", fvalue);
920 cell.className = " fc-state-disabled";
924 if (!cell.initialClassName) {
925 cell.initialClassName = cell.dom.className;
928 cell.dom.className = cell.initialClassName + ' ' + cell.className;
933 for(; i < startingPos; i++) {
934 textEls[i].innerHTML = (++prevStart);
935 d.setDate(d.getDate()+1);
937 cells[i].className = "fc-past fc-other-month";
938 setCellClass(this, cells[i]);
943 for(; i < days; i++){
944 intDay = i - startingPos + 1;
945 textEls[i].innerHTML = (intDay);
946 d.setDate(d.getDate()+1);
948 cells[i].className = ''; // "x-date-active";
949 setCellClass(this, cells[i]);
954 textEls[i].innerHTML = (++extraDays);
955 d.setDate(d.getDate()+1);
957 cells[i].className = "fc-future fc-other-month";
958 setCellClass(this, cells[i]);
961 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
963 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
965 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
966 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
969 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
970 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
973 this.fireEvent('monthchange', this, date);
977 if(!this.internalRender){
978 var main = this.el.dom.firstChild;
979 var w = main.offsetWidth;
980 this.el.setWidth(w + this.el.getBorderWidth("lr"));
981 Roo.fly(main).setWidth(w);
982 this.internalRender = true;
983 // opera does not respect the auto grow header center column
984 // then, after it gets a width opera refuses to recalculate
985 // without a second pass
986 if(Roo.isOpera && !this.secondPass){
987 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
988 this.secondPass = true;
989 this.update.defer(10, this, [date]);
996 findCell : function(dt) {
997 dt = dt.clearTime().getTime();
999 this.cells.each(function(c){
1000 //Roo.log("check " +c.dateValue + '?=' + dt);
1001 if(c.dateValue == dt){
1011 findCells : function(ev) {
1012 var s = ev.start.clone().clearTime().getTime();
1014 var e= ev.end.clone().clearTime().getTime();
1017 this.cells.each(function(c){
1018 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
1020 if(c.dateValue > e){
1023 if(c.dateValue < s){
1032 // findBestRow: function(cells)
1036 // for (var i =0 ; i < cells.length;i++) {
1037 // ret = Math.max(cells[i].rows || 0,ret);
1044 addItem : function(ev)
1046 // look for vertical location slot in
1047 var cells = this.findCells(ev);
1049 // ev.row = this.findBestRow(cells);
1051 // work out the location.
1055 for(var i =0; i < cells.length; i++) {
1057 cells[i].row = cells[0].row;
1060 cells[i].row = cells[i].row + 1;
1070 if (crow.start.getY() == cells[i].getY()) {
1072 crow.end = cells[i];
1089 cells[0].events.push(ev);
1091 this.calevents.push(ev);
1094 clearEvents: function() {
1096 if(!this.calevents){
1100 Roo.each(this.cells.elements, function(c){
1106 Roo.each(this.calevents, function(e) {
1107 Roo.each(e.els, function(el) {
1108 el.un('mouseenter' ,this.onEventEnter, this);
1109 el.un('mouseleave' ,this.onEventLeave, this);
1114 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
1120 renderEvents: function()
1124 this.cells.each(function(c) {
1133 if(c.row != c.events.length){
1134 r = 4 - (4 - (c.row - c.events.length));
1137 c.events = ev.slice(0, r);
1138 c.more = ev.slice(r);
1140 if(c.more.length && c.more.length == 1){
1141 c.events.push(c.more.pop());
1144 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
1148 this.cells.each(function(c) {
1150 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
1153 for (var e = 0; e < c.events.length; e++){
1154 var ev = c.events[e];
1157 for(var i = 0; i < rows.length; i++) {
1159 // how many rows should it span..
1162 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
1163 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
1165 unselectable : "on",
1168 cls: 'fc-event-inner',
1172 // cls: 'fc-event-time',
1173 // html : cells.length > 1 ? '' : ev.time
1177 cls: 'fc-event-title',
1178 html : String.format('{0}', ev.title)
1185 cls: 'ui-resizable-handle ui-resizable-e',
1186 html : '  '
1193 cfg.cls += ' fc-event-start';
1195 if ((i+1) == rows.length) {
1196 cfg.cls += ' fc-event-end';
1199 var ctr = _this.el.select('.fc-event-container',true).first();
1200 var cg = ctr.createChild(cfg);
1202 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
1203 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
1205 var r = (c.more.length) ? 1 : 0;
1206 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
1207 cg.setWidth(ebox.right - sbox.x -2);
1209 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
1210 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
1211 cg.on('click', _this.onEventClick, _this, ev);
1222 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
1223 style : 'position: absolute',
1224 unselectable : "on",
1227 cls: 'fc-event-inner',
1231 cls: 'fc-event-title',
1239 cls: 'ui-resizable-handle ui-resizable-e',
1240 html : '  '
1246 var ctr = _this.el.select('.fc-event-container',true).first();
1247 var cg = ctr.createChild(cfg);
1249 var sbox = c.select('.fc-day-content',true).first().getBox();
1250 var ebox = c.select('.fc-day-content',true).first().getBox();
1252 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
1253 cg.setWidth(ebox.right - sbox.x -2);
1255 cg.on('click', _this.onMoreEventClick, _this, c.more);
1265 onEventEnter: function (e, el,event,d) {
1266 this.fireEvent('evententer', this, el, event);
1269 onEventLeave: function (e, el,event,d) {
1270 this.fireEvent('eventleave', this, el, event);
1273 onEventClick: function (e, el,event,d) {
1274 this.fireEvent('eventclick', this, el, event);
1277 onMonthChange: function () {
1281 onMoreEventClick: function(e, el, more)
1285 this.calpopover.placement = 'right';
1286 this.calpopover.setTitle('More');
1288 this.calpopover.setContent('');
1290 var ctr = this.calpopover.el.select('.popover-content', true).first();
1292 Roo.each(more, function(m){
1294 cls : 'fc-event-hori fc-event-draggable',
1297 var cg = ctr.createChild(cfg);
1299 cg.on('click', _this.onEventClick, _this, m);
1302 this.calpopover.show(el);
1309 this.calevents = [];
1312 if(this.store.getCount() > 0){
1313 this.store.data.each(function(d){
1316 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
1317 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
1318 time : d.data.start_time,
1319 title : d.data.title,
1320 description : d.data.description,
1321 venue : d.data.venue
1326 this.renderEvents();
1328 if(this.calevents.length && this.loadMask){
1333 onBeforeLoad: function()
1346 * based on jquery fullcalendar
1352 * @class Roo.Calendar
1353 * @extends Roo.Component
1354 * Bootstrap Calendar class
1357 * Create a new Container
1358 * @param {Object} config The config object
1361 Roo.CalendarPanel = function(config){
1363 Roo.log("cal panel ctr");
1365 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
1366 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
1368 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
1370 Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
1375 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
1377 // xtype created footer. - not sure if will work as we normally have to render first..
1378 if (this.footer && !this.footer.el && this.footer.xtype) {
1380 //this.footer.container = this.grid.getView().getFooterPanel(true);
1381 //this.footer.dataSource = this.grid.dataSource;
1382 //this.footer = Roo.factory(this.footer, Roo);
1385 this.view = new Roo.calendar.View(Roo.apply({
1386 skipNavHeader : true,
1387 skipMonthHeader : false
1392 this.on('activate', function()
1394 Roo.log('activate');
1396 //console.log('render tree');
1403 * Fires when a date is selected
1404 * @param {DatePicker} this
1405 * @param {Date} date The selected date
1409 * @event monthchange
1410 * Fires when the displayed month changes
1411 * @param {DatePicker} this
1412 * @param {Date} date The selected month
1414 'monthchange': true,
1417 * Fires when mouse over an event
1418 * @param {Calendar} this
1419 * @param {event} Event
1424 * Fires when the mouse leaves an
1425 * @param {Calendar} this
1431 * Fires when the mouse click an
1432 * @param {Calendar} this
1438 * Fires when the grid is rendered
1439 * @param {Calendar} this
1446 this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
1449 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
1453 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
1458 var ct = this.el.appendChild(document.createElement("div"));
1459 this.onRender(this.el, false)
1462 onRender : function(ct, position)
1464 if (this.rendered) {
1467 this.rendered = true;
1469 Roo.log("render calendar");
1472 //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1475 var cfg = Roo.apply({}, this.view.getAutoCreate());
1478 // fill in the extra attributes
1479 if (this.xattr && typeof(this.xattr) =='object') {
1480 for (var i in this.xattr) {
1481 cfg[i] = this.xattr[i];
1486 cfg.dataId = this.dataId;
1490 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
1493 if (this.style) { // fixme needs to support more complex style data.
1494 cfg.style = this.style;
1498 cfg.name = this.name;
1501 this.view.el = ct.createChild(cfg, position);
1503 //if(this.tabIndex !== undefined){
1504 // this.el.dom.setAttribute('tabIndex', this.tabIndex);
1508 this.view.initEvents();
1509 this.fireEvent('rendered');