4 * base class for bootstrap elements.
8 Roo.bootstrap = Roo.bootstrap || {};
10 * @class Roo.bootstrap.Component
11 * @extends Roo.Component
13 * @children Roo.bootstrap.Component
14 * Bootstrap Component base class
15 * @cfg {String} cls css class
16 * @cfg {String} style any extra css
17 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
18 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
19 * @cfg {string} dataId cutomer id
20 * @cfg {string} name Specifies name attribute
21 * @cfg {string} tooltip Text for the tooltip
22 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
23 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
26 * Do not use directly - it does not do anything..
27 * @param {Object} config The config object
32 Roo.bootstrap.Component = function(config){
33 Roo.bootstrap.Component.superclass.constructor.call(this, config);
37 * @event childrenrendered
38 * Fires when the children have been rendered..
39 * @param {Roo.bootstrap.Component} this
41 "childrenrendered" : true
50 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
53 allowDomMove : false, // to stop relocations in parent onRender...
63 * Initialize Events for the element
65 initEvents : function() { },
71 can_build_overlaid : true,
73 container_method : false,
80 // returns the parent component..
81 return Roo.ComponentMgr.get(this.parentId)
87 onRender : function(ct, position)
89 // Roo.log("Call onRender: " + this.xtype);
91 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
94 if (this.el.attr('xtype')) {
95 this.el.attr('xtypex', this.el.attr('xtype'));
96 this.el.dom.removeAttribute('xtype');
106 var cfg = Roo.apply({}, this.getAutoCreate());
108 cfg.id = this.id || Roo.id();
110 // fill in the extra attributes
111 if (this.xattr && typeof(this.xattr) =='object') {
112 for (var i in this.xattr) {
113 cfg[i] = this.xattr[i];
118 cfg.dataId = this.dataId;
122 cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
125 if (this.style) { // fixme needs to support more complex style data.
126 cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
130 cfg.name = this.name;
133 this.el = ct.createChild(cfg, position);
136 this.tooltipEl().attr('tooltip', this.tooltip);
139 if(this.tabIndex !== undefined){
140 this.el.dom.setAttribute('tabIndex', this.tabIndex);
147 * Fetch the element to add children to
148 * @return {Roo.Element} defaults to this.el
150 getChildContainer : function()
154 getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
156 return Roo.get(document.body);
160 * Fetch the element to display the tooltip on.
161 * @return {Roo.Element} defaults to this.el
163 tooltipEl : function()
168 addxtype : function(tree,cntr)
172 cn = Roo.factory(tree);
173 //Roo.log(['addxtype', cn]);
175 cn.parentType = this.xtype; //??
176 cn.parentId = this.id;
178 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
179 if (typeof(cn.container_method) == 'string') {
180 cntr = cn.container_method;
184 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
186 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
188 var build_from_html = Roo.XComponent.build_from_html;
190 var is_body = (tree.xtype == 'Body') ;
192 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
194 var self_cntr_el = Roo.get(this[cntr](false));
196 // do not try and build conditional elements
197 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
201 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
202 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
203 return this.addxtypeChild(tree,cntr, is_body);
206 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
209 return this.addxtypeChild(Roo.apply({}, tree),cntr);
212 Roo.log('skipping render');
218 if (!build_from_html) {
222 // this i think handles overlaying multiple children of the same type
223 // with the sam eelement.. - which might be buggy..
225 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
231 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
235 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
242 addxtypeChild : function (tree, cntr, is_body)
244 Roo.debug && Roo.log('addxtypeChild:' + cntr);
246 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
249 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
250 (typeof(tree['flexy:foreach']) != 'undefined');
254 skip_children = false;
255 // render the element if it's not BODY.
258 // if parent was disabled, then do not try and create the children..
259 if(!this[cntr](true)){
264 cn = Roo.factory(tree);
266 cn.parentType = this.xtype; //??
267 cn.parentId = this.id;
269 var build_from_html = Roo.XComponent.build_from_html;
272 // does the container contain child eleemnts with 'xtype' attributes.
273 // that match this xtype..
274 // note - when we render we create these as well..
275 // so we should check to see if body has xtype set.
276 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
278 var self_cntr_el = Roo.get(this[cntr](false));
279 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
281 //Roo.log(Roo.XComponent.build_from_html);
282 //Roo.log("got echild:");
285 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
286 // and are not displayed -this causes this to use up the wrong element when matching.
287 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
290 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
291 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
297 //echild.dom.removeAttribute('xtype');
299 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
300 Roo.debug && Roo.log(self_cntr_el);
301 Roo.debug && Roo.log(echild);
302 Roo.debug && Roo.log(cn);
308 // if object has flexy:if - then it may or may not be rendered.
309 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
310 // skip a flexy if element.
311 Roo.debug && Roo.log('skipping render');
312 Roo.debug && Roo.log(tree);
314 Roo.debug && Roo.log('skipping all children');
315 skip_children = true;
320 // actually if flexy:foreach is found, we really want to create
321 // multiple copies here...
323 //Roo.log(this[cntr]());
324 // some elements do not have render methods.. like the layouts...
326 if(this[cntr](true) === false){
331 cn.render && cn.render(this[cntr](true));
334 // then add the element..
341 if (typeof (tree.menu) != 'undefined') {
342 tree.menu.parentType = cn.xtype;
343 tree.menu.triggerEl = cn.el;
344 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
348 if (!tree.items || !tree.items.length) {
350 //Roo.log(["no children", this]);
355 var items = tree.items;
358 //Roo.log(items.length);
360 if (!skip_children) {
361 for(var i =0;i < items.length;i++) {
362 // Roo.log(['add child', items[i]]);
363 nitems.push(cn.addxtype(items[i].xns == false ? items[i] : Roo.apply({}, items[i])));
369 //Roo.log("fire childrenrendered");
371 cn.fireEvent('childrenrendered', this);
377 * Set the element that will be used to show or hide
379 setVisibilityEl : function(el)
381 this.visibilityEl = el;
385 * Get the element that will be used to show or hide
387 getVisibilityEl : function()
389 if (typeof(this.visibilityEl) == 'object') {
390 return this.visibilityEl;
393 if (typeof(this.visibilityEl) == 'string') {
394 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
401 * Show a component - removes 'hidden' class
405 if(!this.getVisibilityEl()){
409 this.getVisibilityEl().removeClass(['hidden','d-none']);
411 this.fireEvent('show', this);
416 * Hide a component - adds 'hidden' class
420 if(!this.getVisibilityEl()){
424 this.getVisibilityEl().addClass(['hidden','d-none']);
426 this.fireEvent('hide', this);
434 * based on jquery fullcalendar
438 Roo.bootstrap = Roo.bootstrap || {};
440 * @class Roo.bootstrap.Calendar
441 * @extends Roo.bootstrap.Component
442 * Bootstrap Calendar class
443 * @cfg {Boolean} loadMask (true|false) default false
444 * @cfg {Object} header generate the user specific header of the calendar, default false
447 * Create a new Container
448 * @param {Object} config The config object
453 Roo.bootstrap.Calendar = function(config){
454 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
458 * Fires when a date is selected
459 * @param {DatePicker} this
460 * @param {Date} date The selected date
465 * Fires when the displayed month changes
466 * @param {DatePicker} this
467 * @param {Date} date The selected month
472 * Fires when mouse over an event
473 * @param {Calendar} this
474 * @param {event} Event
479 * Fires when the mouse leaves an
480 * @param {Calendar} this
486 * Fires when the mouse click an
487 * @param {Calendar} this
496 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
499 * @cfg {Roo.data.Store} store
500 * The data source for the calendar
504 * @cfg {Number} startDay
505 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
513 getAutoCreate : function(){
516 var fc_button = function(name, corner, style, content ) {
517 return Roo.apply({},{
519 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
521 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
524 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
535 style : 'width:100%',
542 cls : 'fc-header-left',
544 fc_button('prev', 'left', 'arrow', '‹' ),
545 fc_button('next', 'right', 'arrow', '›' ),
546 { tag: 'span', cls: 'fc-header-space' },
547 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
555 cls : 'fc-header-center',
559 cls: 'fc-header-title',
562 html : 'month / year'
570 cls : 'fc-header-right',
572 /* fc_button('month', 'left', '', 'month' ),
573 fc_button('week', '', '', 'week' ),
574 fc_button('day', 'right', '', 'day' )
586 header = this.header;
589 var cal_heads = function() {
591 // fixme - handle this.
593 for (var i =0; i < Date.dayNames.length; i++) {
594 var d = Date.dayNames[i];
597 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
598 html : d.substring(0,3)
602 ret[0].cls += ' fc-first';
603 ret[6].cls += ' fc-last';
606 var cal_cell = function(n) {
609 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
614 cls: 'fc-day-number',
618 cls: 'fc-day-content',
622 style: 'position: relative;' // height: 17px;
634 var cal_rows = function() {
637 for (var r = 0; r < 6; r++) {
644 for (var i =0; i < Date.dayNames.length; i++) {
645 var d = Date.dayNames[i];
646 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
649 row.cn[0].cls+=' fc-first';
650 row.cn[0].cn[0].style = 'min-height:90px';
651 row.cn[6].cls+=' fc-last';
655 ret[0].cls += ' fc-first';
656 ret[4].cls += ' fc-prev-last';
657 ret[5].cls += ' fc-last';
664 cls: 'fc-border-separate',
665 style : 'width:100%',
673 cls : 'fc-first fc-last',
692 style : "position: relative;",
695 cls : 'fc-view fc-view-month fc-grid',
696 style : 'position: relative',
700 cls : 'fc-event-container',
701 style : 'position:absolute;z-index:8;top:0;left:0;'
719 initEvents : function()
722 throw "can not find store for calendar";
728 style: "text-align:center",
732 style: "background-color:white;width:50%;margin:250 auto",
736 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
747 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
749 var size = this.el.select('.fc-content', true).first().getSize();
750 this.maskEl.setSize(size.width, size.height);
751 this.maskEl.enableDisplayMode("block");
756 this.store = Roo.factory(this.store, Roo.data);
757 this.store.on('load', this.onLoad, this);
758 this.store.on('beforeload', this.onBeforeLoad, this);
762 this.cells = this.el.select('.fc-day',true);
763 //Roo.log(this.cells);
764 this.textNodes = this.el.query('.fc-day-number');
765 this.cells.addClassOnOver('fc-state-hover');
767 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
768 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
769 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
770 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
772 this.on('monthchange', this.onMonthChange, this);
774 this.update(new Date().clearTime());
777 resize : function() {
778 var sz = this.el.getSize();
780 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
781 this.el.select('.fc-day-content div',true).setHeight(34);
786 showPrevMonth : function(e){
787 this.update(this.activeDate.add("mo", -1));
789 showToday : function(e){
790 this.update(new Date().clearTime());
793 showNextMonth : function(e){
794 this.update(this.activeDate.add("mo", 1));
798 showPrevYear : function(){
799 this.update(this.activeDate.add("y", -1));
803 showNextYear : function(){
804 this.update(this.activeDate.add("y", 1));
809 update : function(date)
811 var vd = this.activeDate;
812 this.activeDate = date;
813 // if(vd && this.el){
814 // var t = date.getTime();
815 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
816 // Roo.log('using add remove');
818 // this.fireEvent('monthchange', this, date);
820 // this.cells.removeClass("fc-state-highlight");
821 // this.cells.each(function(c){
822 // if(c.dateValue == t){
823 // c.addClass("fc-state-highlight");
824 // setTimeout(function(){
825 // try{c.dom.firstChild.focus();}catch(e){}
835 var days = date.getDaysInMonth();
837 var firstOfMonth = date.getFirstDateOfMonth();
838 var startingPos = firstOfMonth.getDay()-this.startDay;
840 if(startingPos < this.startDay){
844 var pm = date.add(Date.MONTH, -1);
845 var prevStart = pm.getDaysInMonth()-startingPos;
847 this.cells = this.el.select('.fc-day',true);
848 this.textNodes = this.el.query('.fc-day-number');
849 this.cells.addClassOnOver('fc-state-hover');
851 var cells = this.cells.elements;
852 var textEls = this.textNodes;
854 Roo.each(cells, function(cell){
855 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
860 // convert everything to numbers so it's fast
862 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
865 //Roo.log(prevStart);
867 var today = new Date().clearTime().getTime();
868 var sel = date.clearTime().getTime();
869 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
870 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
871 var ddMatch = this.disabledDatesRE;
872 var ddText = this.disabledDatesText;
873 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
874 var ddaysText = this.disabledDaysText;
875 var format = this.format;
877 var setCellClass = function(cal, cell){
881 //Roo.log('set Cell Class');
889 cell.className += " fc-today";
890 cell.className += " fc-state-highlight";
891 cell.title = cal.todayText;
894 // disable highlight in other month..
895 //cell.className += " fc-state-highlight";
900 cell.className = " fc-state-disabled";
901 cell.title = cal.minText;
905 cell.className = " fc-state-disabled";
906 cell.title = cal.maxText;
910 if(ddays.indexOf(d.getDay()) != -1){
911 cell.title = ddaysText;
912 cell.className = " fc-state-disabled";
915 if(ddMatch && format){
916 var fvalue = d.dateFormat(format);
917 if(ddMatch.test(fvalue)){
918 cell.title = ddText.replace("%0", fvalue);
919 cell.className = " fc-state-disabled";
923 if (!cell.initialClassName) {
924 cell.initialClassName = cell.dom.className;
927 cell.dom.className = cell.initialClassName + ' ' + cell.className;
932 for(; i < startingPos; i++) {
933 textEls[i].innerHTML = (++prevStart);
934 d.setDate(d.getDate()+1);
936 cells[i].className = "fc-past fc-other-month";
937 setCellClass(this, cells[i]);
942 for(; i < days; i++){
943 intDay = i - startingPos + 1;
944 textEls[i].innerHTML = (intDay);
945 d.setDate(d.getDate()+1);
947 cells[i].className = ''; // "x-date-active";
948 setCellClass(this, cells[i]);
953 textEls[i].innerHTML = (++extraDays);
954 d.setDate(d.getDate()+1);
956 cells[i].className = "fc-future fc-other-month";
957 setCellClass(this, cells[i]);
960 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
962 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
964 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
965 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
968 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
969 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
972 this.fireEvent('monthchange', this, date);
976 if(!this.internalRender){
977 var main = this.el.dom.firstChild;
978 var w = main.offsetWidth;
979 this.el.setWidth(w + this.el.getBorderWidth("lr"));
980 Roo.fly(main).setWidth(w);
981 this.internalRender = true;
982 // opera does not respect the auto grow header center column
983 // then, after it gets a width opera refuses to recalculate
984 // without a second pass
985 if(Roo.isOpera && !this.secondPass){
986 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
987 this.secondPass = true;
988 this.update.defer(10, this, [date]);
995 findCell : function(dt) {
996 dt = dt.clearTime().getTime();
998 this.cells.each(function(c){
999 //Roo.log("check " +c.dateValue + '?=' + dt);
1000 if(c.dateValue == dt){
1010 findCells : function(ev) {
1011 var s = ev.start.clone().clearTime().getTime();
1013 var e= ev.end.clone().clearTime().getTime();
1016 this.cells.each(function(c){
1017 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
1019 if(c.dateValue > e){
1022 if(c.dateValue < s){
1031 // findBestRow: function(cells)
1035 // for (var i =0 ; i < cells.length;i++) {
1036 // ret = Math.max(cells[i].rows || 0,ret);
1043 addItem : function(ev)
1045 // look for vertical location slot in
1046 var cells = this.findCells(ev);
1048 // ev.row = this.findBestRow(cells);
1050 // work out the location.
1054 for(var i =0; i < cells.length; i++) {
1056 cells[i].row = cells[0].row;
1059 cells[i].row = cells[i].row + 1;
1069 if (crow.start.getY() == cells[i].getY()) {
1071 crow.end = cells[i];
1088 cells[0].events.push(ev);
1090 this.calevents.push(ev);
1093 clearEvents: function() {
1095 if(!this.calevents){
1099 Roo.each(this.cells.elements, function(c){
1105 Roo.each(this.calevents, function(e) {
1106 Roo.each(e.els, function(el) {
1107 el.un('mouseenter' ,this.onEventEnter, this);
1108 el.un('mouseleave' ,this.onEventLeave, this);
1113 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
1119 renderEvents: function()
1123 this.cells.each(function(c) {
1132 if(c.row != c.events.length){
1133 r = 4 - (4 - (c.row - c.events.length));
1136 c.events = ev.slice(0, r);
1137 c.more = ev.slice(r);
1139 if(c.more.length && c.more.length == 1){
1140 c.events.push(c.more.pop());
1143 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
1147 this.cells.each(function(c) {
1149 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
1152 for (var e = 0; e < c.events.length; e++){
1153 var ev = c.events[e];
1156 for(var i = 0; i < rows.length; i++) {
1158 // how many rows should it span..
1161 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
1162 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
1164 unselectable : "on",
1167 cls: 'fc-event-inner',
1171 // cls: 'fc-event-time',
1172 // html : cells.length > 1 ? '' : ev.time
1176 cls: 'fc-event-title',
1177 html : String.format('{0}', ev.title)
1184 cls: 'ui-resizable-handle ui-resizable-e',
1185 html : '  '
1192 cfg.cls += ' fc-event-start';
1194 if ((i+1) == rows.length) {
1195 cfg.cls += ' fc-event-end';
1198 var ctr = _this.el.select('.fc-event-container',true).first();
1199 var cg = ctr.createChild(cfg);
1201 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
1202 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
1204 var r = (c.more.length) ? 1 : 0;
1205 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
1206 cg.setWidth(ebox.right - sbox.x -2);
1208 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
1209 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
1210 cg.on('click', _this.onEventClick, _this, ev);
1221 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
1222 style : 'position: absolute',
1223 unselectable : "on",
1226 cls: 'fc-event-inner',
1230 cls: 'fc-event-title',
1238 cls: 'ui-resizable-handle ui-resizable-e',
1239 html : '  '
1245 var ctr = _this.el.select('.fc-event-container',true).first();
1246 var cg = ctr.createChild(cfg);
1248 var sbox = c.select('.fc-day-content',true).first().getBox();
1249 var ebox = c.select('.fc-day-content',true).first().getBox();
1251 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
1252 cg.setWidth(ebox.right - sbox.x -2);
1254 cg.on('click', _this.onMoreEventClick, _this, c.more);
1264 onEventEnter: function (e, el,event,d) {
1265 this.fireEvent('evententer', this, el, event);
1268 onEventLeave: function (e, el,event,d) {
1269 this.fireEvent('eventleave', this, el, event);
1272 onEventClick: function (e, el,event,d) {
1273 this.fireEvent('eventclick', this, el, event);
1276 onMonthChange: function () {
1280 onMoreEventClick: function(e, el, more)
1284 this.calpopover.placement = 'right';
1285 this.calpopover.setTitle('More');
1287 this.calpopover.setContent('');
1289 var ctr = this.calpopover.el.select('.popover-content', true).first();
1291 Roo.each(more, function(m){
1293 cls : 'fc-event-hori fc-event-draggable',
1296 var cg = ctr.createChild(cfg);
1298 cg.on('click', _this.onEventClick, _this, m);
1301 this.calpopover.show(el);
1308 this.calevents = [];
1311 if(this.store.getCount() > 0){
1312 this.store.data.each(function(d){
1315 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
1316 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
1317 time : d.data.start_time,
1318 title : d.data.title,
1319 description : d.data.description,
1320 venue : d.data.venue
1325 this.renderEvents();
1327 if(this.calevents.length && this.loadMask){
1332 onBeforeLoad: function()
1345 * based on jquery fullcalendar
1351 * @class Roo.Calendar
1352 * @extends Roo.Component
1353 * Bootstrap Calendar class
1356 * Create a new Container
1357 * @param {Object} config The config object
1360 Roo.panel.Calendar = function(config){
1362 Roo.log("cal panel ctr");
1364 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
1365 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
1367 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
1369 Roo.panel.Calendar.superclass.constructor.call(this, this.wrapper, config);
1374 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
1376 // xtype created footer. - not sure if will work as we normally have to render first..
1377 if (this.footer && !this.footer.el && this.footer.xtype) {
1379 //this.footer.container = this.grid.getView().getFooterPanel(true);
1380 //this.footer.dataSource = this.grid.dataSource;
1381 //this.footer = Roo.factory(this.footer, Roo);
1384 this.view = new Roo.calendar.View(Roo.apply({
1385 skipNavHeader : true,
1386 skipMonthHeader : false
1391 this.on('activate', function()
1393 Roo.log('activate');
1395 //console.log('render tree');
1402 * Fires when a date is selected
1403 * @param {DatePicker} this
1404 * @param {Date} date The selected date
1408 * @event monthchange
1409 * Fires when the displayed month changes
1410 * @param {DatePicker} this
1411 * @param {Date} date The selected month
1413 'monthchange': true,
1416 * Fires when mouse over an event
1417 * @param {Calendar} this
1418 * @param {event} Event
1423 * Fires when the mouse leaves an
1424 * @param {Calendar} this
1430 * Fires when the mouse click an
1431 * @param {Calendar} this
1437 * Fires when the grid is rendered
1438 * @param {Calendar} this
1445 this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
1448 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
1452 Roo.extend(Roo.panel.Calendar, Roo.panel.Content, {
1457 var ct = this.el.appendChild(document.createElement("div"));
1458 this.onRender(this.el, false)
1461 onRender : function(ct, position)
1463 if (this.rendered) {
1466 this.rendered = true;
1468 Roo.log("render calendar");
1471 //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1474 var cfg = Roo.apply({}, this.view.getAutoCreate());
1477 // fill in the extra attributes
1478 if (this.xattr && typeof(this.xattr) =='object') {
1479 for (var i in this.xattr) {
1480 cfg[i] = this.xattr[i];
1485 cfg.dataId = this.dataId;
1489 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
1492 if (this.style) { // fixme needs to support more complex style data.
1493 cfg.style = this.style;
1497 cfg.name = this.name;
1500 this.view.el = ct.createChild(cfg, position);
1502 //if(this.tabIndex !== undefined){
1503 // this.el.dom.setAttribute('tabIndex', this.tabIndex);
1507 this.view.initEvents();
1508 this.fireEvent('rendered');