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 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass(['hidden','d-none']);
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass(['hidden','d-none']);
433 this.fireEvent('hide', this);
441 * based on jquery fullcalendar
445 Roo.bootstrap = Roo.bootstrap || {};
447 * @class Roo.bootstrap.Calendar
448 * @extends Roo.bootstrap.Component
449 * Bootstrap Calendar class
450 * @cfg {Boolean} loadMask (true|false) default false
451 * @cfg {Object} header generate the user specific header of the calendar, default false
454 * Create a new Container
455 * @param {Object} config The config object
460 Roo.bootstrap.Calendar = function(config){
461 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
465 * Fires when a date is selected
466 * @param {DatePicker} this
467 * @param {Date} date The selected date
472 * Fires when the displayed month changes
473 * @param {DatePicker} this
474 * @param {Date} date The selected month
479 * Fires when mouse over an event
480 * @param {Calendar} this
481 * @param {event} Event
486 * Fires when the mouse leaves an
487 * @param {Calendar} this
493 * Fires when the mouse click an
494 * @param {Calendar} this
503 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
506 * @cfg {Number} startDay
507 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
515 getAutoCreate : function(){
518 var fc_button = function(name, corner, style, content ) {
519 return Roo.apply({},{
521 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
523 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
526 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
537 style : 'width:100%',
544 cls : 'fc-header-left',
546 fc_button('prev', 'left', 'arrow', '‹' ),
547 fc_button('next', 'right', 'arrow', '›' ),
548 { tag: 'span', cls: 'fc-header-space' },
549 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
557 cls : 'fc-header-center',
561 cls: 'fc-header-title',
564 html : 'month / year'
572 cls : 'fc-header-right',
574 /* fc_button('month', 'left', '', 'month' ),
575 fc_button('week', '', '', 'week' ),
576 fc_button('day', 'right', '', 'day' )
588 header = this.header;
591 var cal_heads = function() {
593 // fixme - handle this.
595 for (var i =0; i < Date.dayNames.length; i++) {
596 var d = Date.dayNames[i];
599 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
600 html : d.substring(0,3)
604 ret[0].cls += ' fc-first';
605 ret[6].cls += ' fc-last';
608 var cal_cell = function(n) {
611 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
616 cls: 'fc-day-number',
620 cls: 'fc-day-content',
624 style: 'position: relative;' // height: 17px;
636 var cal_rows = function() {
639 for (var r = 0; r < 6; r++) {
646 for (var i =0; i < Date.dayNames.length; i++) {
647 var d = Date.dayNames[i];
648 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
651 row.cn[0].cls+=' fc-first';
652 row.cn[0].cn[0].style = 'min-height:90px';
653 row.cn[6].cls+=' fc-last';
657 ret[0].cls += ' fc-first';
658 ret[4].cls += ' fc-prev-last';
659 ret[5].cls += ' fc-last';
666 cls: 'fc-border-separate',
667 style : 'width:100%',
675 cls : 'fc-first fc-last',
694 style : "position: relative;",
697 cls : 'fc-view fc-view-month fc-grid',
698 style : 'position: relative',
702 cls : 'fc-event-container',
703 style : 'position:absolute;z-index:8;top:0;left:0;'
721 initEvents : function()
724 throw "can not find store for calendar";
730 style: "text-align:center",
734 style: "background-color:white;width:50%;margin:250 auto",
738 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
749 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
751 var size = this.el.select('.fc-content', true).first().getSize();
752 this.maskEl.setSize(size.width, size.height);
753 this.maskEl.enableDisplayMode("block");
758 this.store = Roo.factory(this.store, Roo.data);
759 this.store.on('load', this.onLoad, this);
760 this.store.on('beforeload', this.onBeforeLoad, this);
764 this.cells = this.el.select('.fc-day',true);
765 //Roo.log(this.cells);
766 this.textNodes = this.el.query('.fc-day-number');
767 this.cells.addClassOnOver('fc-state-hover');
769 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
770 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
771 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
772 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
774 this.on('monthchange', this.onMonthChange, this);
776 this.update(new Date().clearTime());
779 resize : function() {
780 var sz = this.el.getSize();
782 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
783 this.el.select('.fc-day-content div',true).setHeight(34);
788 showPrevMonth : function(e){
789 this.update(this.activeDate.add("mo", -1));
791 showToday : function(e){
792 this.update(new Date().clearTime());
795 showNextMonth : function(e){
796 this.update(this.activeDate.add("mo", 1));
800 showPrevYear : function(){
801 this.update(this.activeDate.add("y", -1));
805 showNextYear : function(){
806 this.update(this.activeDate.add("y", 1));
811 update : function(date)
813 var vd = this.activeDate;
814 this.activeDate = date;
815 // if(vd && this.el){
816 // var t = date.getTime();
817 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
818 // Roo.log('using add remove');
820 // this.fireEvent('monthchange', this, date);
822 // this.cells.removeClass("fc-state-highlight");
823 // this.cells.each(function(c){
824 // if(c.dateValue == t){
825 // c.addClass("fc-state-highlight");
826 // setTimeout(function(){
827 // try{c.dom.firstChild.focus();}catch(e){}
837 var days = date.getDaysInMonth();
839 var firstOfMonth = date.getFirstDateOfMonth();
840 var startingPos = firstOfMonth.getDay()-this.startDay;
842 if(startingPos < this.startDay){
846 var pm = date.add(Date.MONTH, -1);
847 var prevStart = pm.getDaysInMonth()-startingPos;
849 this.cells = this.el.select('.fc-day',true);
850 this.textNodes = this.el.query('.fc-day-number');
851 this.cells.addClassOnOver('fc-state-hover');
853 var cells = this.cells.elements;
854 var textEls = this.textNodes;
856 Roo.each(cells, function(cell){
857 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
862 // convert everything to numbers so it's fast
864 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
867 //Roo.log(prevStart);
869 var today = new Date().clearTime().getTime();
870 var sel = date.clearTime().getTime();
871 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
872 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
873 var ddMatch = this.disabledDatesRE;
874 var ddText = this.disabledDatesText;
875 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
876 var ddaysText = this.disabledDaysText;
877 var format = this.format;
879 var setCellClass = function(cal, cell){
883 //Roo.log('set Cell Class');
891 cell.className += " fc-today";
892 cell.className += " fc-state-highlight";
893 cell.title = cal.todayText;
896 // disable highlight in other month..
897 //cell.className += " fc-state-highlight";
902 cell.className = " fc-state-disabled";
903 cell.title = cal.minText;
907 cell.className = " fc-state-disabled";
908 cell.title = cal.maxText;
912 if(ddays.indexOf(d.getDay()) != -1){
913 cell.title = ddaysText;
914 cell.className = " fc-state-disabled";
917 if(ddMatch && format){
918 var fvalue = d.dateFormat(format);
919 if(ddMatch.test(fvalue)){
920 cell.title = ddText.replace("%0", fvalue);
921 cell.className = " fc-state-disabled";
925 if (!cell.initialClassName) {
926 cell.initialClassName = cell.dom.className;
929 cell.dom.className = cell.initialClassName + ' ' + cell.className;
934 for(; i < startingPos; i++) {
935 textEls[i].innerHTML = (++prevStart);
936 d.setDate(d.getDate()+1);
938 cells[i].className = "fc-past fc-other-month";
939 setCellClass(this, cells[i]);
944 for(; i < days; i++){
945 intDay = i - startingPos + 1;
946 textEls[i].innerHTML = (intDay);
947 d.setDate(d.getDate()+1);
949 cells[i].className = ''; // "x-date-active";
950 setCellClass(this, cells[i]);
955 textEls[i].innerHTML = (++extraDays);
956 d.setDate(d.getDate()+1);
958 cells[i].className = "fc-future fc-other-month";
959 setCellClass(this, cells[i]);
962 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
964 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
966 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
967 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
970 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
971 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
974 this.fireEvent('monthchange', this, date);
978 if(!this.internalRender){
979 var main = this.el.dom.firstChild;
980 var w = main.offsetWidth;
981 this.el.setWidth(w + this.el.getBorderWidth("lr"));
982 Roo.fly(main).setWidth(w);
983 this.internalRender = true;
984 // opera does not respect the auto grow header center column
985 // then, after it gets a width opera refuses to recalculate
986 // without a second pass
987 if(Roo.isOpera && !this.secondPass){
988 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
989 this.secondPass = true;
990 this.update.defer(10, this, [date]);
997 findCell : function(dt) {
998 dt = dt.clearTime().getTime();
1000 this.cells.each(function(c){
1001 //Roo.log("check " +c.dateValue + '?=' + dt);
1002 if(c.dateValue == dt){
1012 findCells : function(ev) {
1013 var s = ev.start.clone().clearTime().getTime();
1015 var e= ev.end.clone().clearTime().getTime();
1018 this.cells.each(function(c){
1019 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
1021 if(c.dateValue > e){
1024 if(c.dateValue < s){
1033 // findBestRow: function(cells)
1037 // for (var i =0 ; i < cells.length;i++) {
1038 // ret = Math.max(cells[i].rows || 0,ret);
1045 addItem : function(ev)
1047 // look for vertical location slot in
1048 var cells = this.findCells(ev);
1050 // ev.row = this.findBestRow(cells);
1052 // work out the location.
1056 for(var i =0; i < cells.length; i++) {
1058 cells[i].row = cells[0].row;
1061 cells[i].row = cells[i].row + 1;
1071 if (crow.start.getY() == cells[i].getY()) {
1073 crow.end = cells[i];
1090 cells[0].events.push(ev);
1092 this.calevents.push(ev);
1095 clearEvents: function() {
1097 if(!this.calevents){
1101 Roo.each(this.cells.elements, function(c){
1107 Roo.each(this.calevents, function(e) {
1108 Roo.each(e.els, function(el) {
1109 el.un('mouseenter' ,this.onEventEnter, this);
1110 el.un('mouseleave' ,this.onEventLeave, this);
1115 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
1121 renderEvents: function()
1125 this.cells.each(function(c) {
1134 if(c.row != c.events.length){
1135 r = 4 - (4 - (c.row - c.events.length));
1138 c.events = ev.slice(0, r);
1139 c.more = ev.slice(r);
1141 if(c.more.length && c.more.length == 1){
1142 c.events.push(c.more.pop());
1145 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
1149 this.cells.each(function(c) {
1151 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
1154 for (var e = 0; e < c.events.length; e++){
1155 var ev = c.events[e];
1158 for(var i = 0; i < rows.length; i++) {
1160 // how many rows should it span..
1163 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
1164 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
1166 unselectable : "on",
1169 cls: 'fc-event-inner',
1173 // cls: 'fc-event-time',
1174 // html : cells.length > 1 ? '' : ev.time
1178 cls: 'fc-event-title',
1179 html : String.format('{0}', ev.title)
1186 cls: 'ui-resizable-handle ui-resizable-e',
1187 html : '  '
1194 cfg.cls += ' fc-event-start';
1196 if ((i+1) == rows.length) {
1197 cfg.cls += ' fc-event-end';
1200 var ctr = _this.el.select('.fc-event-container',true).first();
1201 var cg = ctr.createChild(cfg);
1203 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
1204 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
1206 var r = (c.more.length) ? 1 : 0;
1207 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
1208 cg.setWidth(ebox.right - sbox.x -2);
1210 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
1211 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
1212 cg.on('click', _this.onEventClick, _this, ev);
1223 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
1224 style : 'position: absolute',
1225 unselectable : "on",
1228 cls: 'fc-event-inner',
1232 cls: 'fc-event-title',
1240 cls: 'ui-resizable-handle ui-resizable-e',
1241 html : '  '
1247 var ctr = _this.el.select('.fc-event-container',true).first();
1248 var cg = ctr.createChild(cfg);
1250 var sbox = c.select('.fc-day-content',true).first().getBox();
1251 var ebox = c.select('.fc-day-content',true).first().getBox();
1253 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
1254 cg.setWidth(ebox.right - sbox.x -2);
1256 cg.on('click', _this.onMoreEventClick, _this, c.more);
1266 onEventEnter: function (e, el,event,d) {
1267 this.fireEvent('evententer', this, el, event);
1270 onEventLeave: function (e, el,event,d) {
1271 this.fireEvent('eventleave', this, el, event);
1274 onEventClick: function (e, el,event,d) {
1275 this.fireEvent('eventclick', this, el, event);
1278 onMonthChange: function () {
1282 onMoreEventClick: function(e, el, more)
1286 this.calpopover.placement = 'right';
1287 this.calpopover.setTitle('More');
1289 this.calpopover.setContent('');
1291 var ctr = this.calpopover.el.select('.popover-content', true).first();
1293 Roo.each(more, function(m){
1295 cls : 'fc-event-hori fc-event-draggable',
1298 var cg = ctr.createChild(cfg);
1300 cg.on('click', _this.onEventClick, _this, m);
1303 this.calpopover.show(el);
1310 this.calevents = [];
1313 if(this.store.getCount() > 0){
1314 this.store.data.each(function(d){
1317 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
1318 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
1319 time : d.data.start_time,
1320 title : d.data.title,
1321 description : d.data.description,
1322 venue : d.data.venue
1327 this.renderEvents();
1329 if(this.calevents.length && this.loadMask){
1334 onBeforeLoad: function()
1347 * based on jquery fullcalendar
1353 * @class Roo.Calendar
1354 * @extends Roo.Component
1355 * Bootstrap Calendar class
1358 * Create a new Container
1359 * @param {Object} config The config object
1362 Roo.CalendarPanel = function(config){
1364 Roo.log("cal panel ctr");
1366 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
1367 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
1369 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
1371 Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
1376 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
1378 // xtype created footer. - not sure if will work as we normally have to render first..
1379 if (this.footer && !this.footer.el && this.footer.xtype) {
1381 //this.footer.container = this.grid.getView().getFooterPanel(true);
1382 //this.footer.dataSource = this.grid.dataSource;
1383 //this.footer = Roo.factory(this.footer, Roo);
1386 this.view = new Roo.calendar.View(Roo.apply({
1387 skipNavHeader : true,
1388 skipMonthHeader : false
1393 this.on('activate', function()
1395 Roo.log('activate');
1397 //console.log('render tree');
1404 * Fires when a date is selected
1405 * @param {DatePicker} this
1406 * @param {Date} date The selected date
1410 * @event monthchange
1411 * Fires when the displayed month changes
1412 * @param {DatePicker} this
1413 * @param {Date} date The selected month
1415 'monthchange': true,
1418 * Fires when mouse over an event
1419 * @param {Calendar} this
1420 * @param {event} Event
1425 * Fires when the mouse leaves an
1426 * @param {Calendar} this
1432 * Fires when the mouse click an
1433 * @param {Calendar} this
1439 * Fires when the grid is rendered
1440 * @param {Calendar} this
1447 this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
1450 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
1454 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
1459 var ct = this.el.appendChild(document.createElement("div"));
1460 this.onRender(this.el, false)
1463 onRender : function(ct, position)
1465 if (this.rendered) {
1468 this.rendered = true;
1470 Roo.log("render calendar");
1473 //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1476 var cfg = Roo.apply({}, this.view.getAutoCreate());
1479 // fill in the extra attributes
1480 if (this.xattr && typeof(this.xattr) =='object') {
1481 for (var i in this.xattr) {
1482 cfg[i] = this.xattr[i];
1487 cfg.dataId = this.dataId;
1491 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
1494 if (this.style) { // fixme needs to support more complex style data.
1495 cfg.style = this.style;
1499 cfg.name = this.name;
1502 this.view.el = ct.createChild(cfg, position);
1504 //if(this.tabIndex !== undefined){
1505 // this.el.dom.setAttribute('tabIndex', this.tabIndex);
1509 this.view.initEvents();
1510 this.fireEvent('rendered');