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
47 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
50 allowDomMove : false, // to stop relocations in parent onRender...
60 * Initialize Events for the element
62 initEvents : function() { },
68 can_build_overlaid : true,
70 container_method : false,
77 // returns the parent component..
78 return Roo.ComponentMgr.get(this.parentId)
84 onRender : function(ct, position)
86 // Roo.log("Call onRender: " + this.xtype);
88 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
91 if (this.el.attr('xtype')) {
92 this.el.attr('xtypex', this.el.attr('xtype'));
93 this.el.dom.removeAttribute('xtype');
103 var cfg = Roo.apply({}, this.getAutoCreate());
105 cfg.id = this.id || Roo.id();
107 // fill in the extra attributes
108 if (this.xattr && typeof(this.xattr) =='object') {
109 for (var i in this.xattr) {
110 cfg[i] = this.xattr[i];
115 cfg.dataId = this.dataId;
119 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
122 if (this.style) { // fixme needs to support more complex style data.
123 cfg.style = this.style;
127 cfg.name = this.name;
130 this.el = ct.createChild(cfg, position);
133 this.tooltipEl().attr('tooltip', this.tooltip);
136 if(this.tabIndex !== undefined){
137 this.el.dom.setAttribute('tabIndex', this.tabIndex);
144 * Fetch the element to add children to
145 * @return {Roo.Element} defaults to this.el
147 getChildContainer : function()
152 * Fetch the element to display the tooltip on.
153 * @return {Roo.Element} defaults to this.el
155 tooltipEl : function()
160 * This is really a wrapper for addxtypeChild
161 * it handles stuff relating to flexy:foreach / flexy:if
162 * = some of our projects use a flat rendering of the output, and try and overlay it with dynamic data.
163 * -- this is a bit of a nightmare... and is even more confusing to debug..
168 addxtype : function(tree,cntr)
170 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
172 var cn = Roo.factory(tree); // this is posibly the first of two times that the ctor get's called...
173 cn.parentType = this.xtype; //??
174 cn.parentId = this.id;
175 if (typeof(cn.container_method) == 'string') {
176 cntr = cn.container_method;
180 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
182 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
184 var build_from_html = Roo.XComponent.build_from_html;
186 var is_body = (tree.xtype == 'Body') ;
188 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
190 var self_cntr_el = Roo.get(this[cntr](false));
192 // do not try and build conditional elements
193 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
197 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
198 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
199 //return this.addxtypeChild(tree,cntr, is_body);
200 return this.addxtypeChild(tree, cntr, is_body);
203 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
206 return this.addxtypeChild(Roo.apply({}, tree),cntr);
209 Roo.log('skipping render');
215 if (!build_from_html) {
219 // this i think handles overlaying multiple children of the same type
220 // with the sam eelement.. - which might be buggy..
222 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
228 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
232 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
238 * add a child to this element
239 * - turn the child.cfg into a child_instance
240 * - call child_instance.render( this { getContainerMethod()} )
241 * - loop through the children, and call addxtype.. (reall this) on newly created child.
245 addxtypeChild : function (tree, cntr, is_body)
247 Roo.debug && Roo.log('addxtypeChild:' + cntr);
249 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
252 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
253 (typeof(tree['flexy:foreach']) != 'undefined');
257 skip_children = false;
258 // render the element if it's not BODY.
261 // if parent was disabled, then do not try and create the children..
262 if(!this[cntr](true)){
267 cn = Roo.factory(tree);
269 cn.parentType = this.xtype; //??
270 cn.parentId = this.id;
272 var build_from_html = Roo.XComponent.build_from_html;
275 // does the container contain child eleemnts with 'xtype' attributes.
276 // that match this xtype..
277 // note - when we render we create these as well..
278 // so we should check to see if body has xtype set.
279 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
281 var self_cntr_el = Roo.get(this[cntr](false));
282 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
284 //Roo.log(Roo.XComponent.build_from_html);
285 //Roo.log("got echild:");
288 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
289 // and are not displayed -this causes this to use up the wrong element when matching.
290 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
293 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
294 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
300 //echild.dom.removeAttribute('xtype');
302 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
303 Roo.debug && Roo.log(self_cntr_el);
304 Roo.debug && Roo.log(echild);
305 Roo.debug && Roo.log(cn);
311 // if object has flexy:if - then it may or may not be rendered.
312 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
313 // skip a flexy if element.
314 Roo.debug && Roo.log('skipping render');
315 Roo.debug && Roo.log(tree);
317 Roo.debug && Roo.log('skipping all children');
318 skip_children = true;
323 // actually if flexy:foreach is found, we really want to create
324 // multiple copies here...
326 //Roo.log(this[cntr]());
327 // some elements do not have render methods.. like the layouts...
329 if(this[cntr](true) === false){
334 cn.render && cn.render(this[cntr](true));
337 // then add the element..
344 cn.addxtypeChildren(tree.items, skip_children);
350 * add a number of children to this object,
351 * which in turn calls render...
355 addxtypeChildren: function(child_array, skip_children)
358 if (!child_array || !child_array.length ) {
363 for(var i =0;i < child_array.length;i++) {
367 // Roo.log(['add child', items[i]]);
368 nitems.push(this.addxtype(Roo.apply({}, child_array[i])));
372 this.fireEvent('childrenrendered', this);
382 * xAddChildren - the 'sub-compentized' version of the above idea..
384 xAddChildren: function(child_array, skip_children)
387 if (!child_array || !child_array.length ) {
392 for(var i =0;i < child_array.length;i++) {
396 // Roo.log(['add child', items[i]]);
397 nitems.push(this.xAdd(Roo.apply({}, child_array[i])));
401 this.fireEvent('childrenrendered', this);
407 * add a child to this element
408 * - turn the child.cfg into a child_instance
409 * - call child_instance.render( this { getContainerMethod()} )
410 * - loop through the children, and call addxtype.. (reall this) on newly created child.
416 xAdd : function (tree, cntr, is_body)
418 Roo.debug && Roo.log('xadd:' + cntr);
420 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
422 var parent_ctnr = this[cntr](true);
423 if(parent_ctnr === false){
424 return false; // getChildContainer an return false explicitly to block children being added?
427 throw new Exception("could not find parent Container for item");
430 var cn = Roo.factory(tree);
431 // at this point items[] array may be set..
432 // constructors should not really be building their children?
433 cn.parentType = this.xtype; //??
434 cn.parentId = this.id;
437 cn.render && cn.render(parent_ctnr);
439 cn.xAddChildren(tree.items);
440 delete tree.items; // not really needed?
446 * Set the element that will be used to show or hide
448 setVisibilityEl : function(el)
450 this.visibilityEl = el;
454 * Get the element that will be used to show or hide
456 getVisibilityEl : function()
458 if (typeof(this.visibilityEl) == 'object') {
459 return this.visibilityEl;
462 if (typeof(this.visibilityEl) == 'string') {
463 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
470 * Show a component - removes 'hidden' class
474 if(!this.getVisibilityEl()){
478 this.getVisibilityEl().removeClass(['hidden','d-none']);
480 this.fireEvent('show', this);
485 * Hide a component - adds 'hidden' class
489 if(!this.getVisibilityEl()){
493 this.getVisibilityEl().addClass(['hidden','d-none']);
495 this.fireEvent('hide', this);
503 * based on jquery fullcalendar
507 Roo.bootstrap = Roo.bootstrap || {};
509 * @class Roo.bootstrap.Calendar
510 * @extends Roo.bootstrap.Component
511 * Bootstrap Calendar class
512 * @cfg {Boolean} loadMask (true|false) default false
513 * @cfg {Object} header generate the user specific header of the calendar, default false
516 * Create a new Container
517 * @param {Object} config The config object
522 Roo.bootstrap.Calendar = function(config){
523 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
527 * Fires when a date is selected
528 * @param {DatePicker} this
529 * @param {Date} date The selected date
534 * Fires when the displayed month changes
535 * @param {DatePicker} this
536 * @param {Date} date The selected month
541 * Fires when mouse over an event
542 * @param {Calendar} this
543 * @param {event} Event
548 * Fires when the mouse leaves an
549 * @param {Calendar} this
555 * Fires when the mouse click an
556 * @param {Calendar} this
565 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
568 * @cfg {Number} startDay
569 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
577 getAutoCreate : function(){
580 var fc_button = function(name, corner, style, content ) {
581 return Roo.apply({},{
583 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
585 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
588 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
599 style : 'width:100%',
606 cls : 'fc-header-left',
608 fc_button('prev', 'left', 'arrow', '‹' ),
609 fc_button('next', 'right', 'arrow', '›' ),
610 { tag: 'span', cls: 'fc-header-space' },
611 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
619 cls : 'fc-header-center',
623 cls: 'fc-header-title',
626 html : 'month / year'
634 cls : 'fc-header-right',
636 /* fc_button('month', 'left', '', 'month' ),
637 fc_button('week', '', '', 'week' ),
638 fc_button('day', 'right', '', 'day' )
650 header = this.header;
653 var cal_heads = function() {
655 // fixme - handle this.
657 for (var i =0; i < Date.dayNames.length; i++) {
658 var d = Date.dayNames[i];
661 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
662 html : d.substring(0,3)
666 ret[0].cls += ' fc-first';
667 ret[6].cls += ' fc-last';
670 var cal_cell = function(n) {
673 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
678 cls: 'fc-day-number',
682 cls: 'fc-day-content',
686 style: 'position: relative;' // height: 17px;
698 var cal_rows = function() {
701 for (var r = 0; r < 6; r++) {
708 for (var i =0; i < Date.dayNames.length; i++) {
709 var d = Date.dayNames[i];
710 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
713 row.cn[0].cls+=' fc-first';
714 row.cn[0].cn[0].style = 'min-height:90px';
715 row.cn[6].cls+=' fc-last';
719 ret[0].cls += ' fc-first';
720 ret[4].cls += ' fc-prev-last';
721 ret[5].cls += ' fc-last';
728 cls: 'fc-border-separate',
729 style : 'width:100%',
737 cls : 'fc-first fc-last',
756 style : "position: relative;",
759 cls : 'fc-view fc-view-month fc-grid',
760 style : 'position: relative',
764 cls : 'fc-event-container',
765 style : 'position:absolute;z-index:8;top:0;left:0;'
783 initEvents : function()
786 throw "can not find store for calendar";
792 style: "text-align:center",
796 style: "background-color:white;width:50%;margin:250 auto",
800 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
811 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
813 var size = this.el.select('.fc-content', true).first().getSize();
814 this.maskEl.setSize(size.width, size.height);
815 this.maskEl.enableDisplayMode("block");
820 this.store = Roo.factory(this.store, Roo.data);
821 this.store.on('load', this.onLoad, this);
822 this.store.on('beforeload', this.onBeforeLoad, this);
826 this.cells = this.el.select('.fc-day',true);
827 //Roo.log(this.cells);
828 this.textNodes = this.el.query('.fc-day-number');
829 this.cells.addClassOnOver('fc-state-hover');
831 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
832 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
833 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
834 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
836 this.on('monthchange', this.onMonthChange, this);
838 this.update(new Date().clearTime());
841 resize : function() {
842 var sz = this.el.getSize();
844 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
845 this.el.select('.fc-day-content div',true).setHeight(34);
850 showPrevMonth : function(e){
851 this.update(this.activeDate.add("mo", -1));
853 showToday : function(e){
854 this.update(new Date().clearTime());
857 showNextMonth : function(e){
858 this.update(this.activeDate.add("mo", 1));
862 showPrevYear : function(){
863 this.update(this.activeDate.add("y", -1));
867 showNextYear : function(){
868 this.update(this.activeDate.add("y", 1));
873 update : function(date)
875 var vd = this.activeDate;
876 this.activeDate = date;
877 // if(vd && this.el){
878 // var t = date.getTime();
879 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
880 // Roo.log('using add remove');
882 // this.fireEvent('monthchange', this, date);
884 // this.cells.removeClass("fc-state-highlight");
885 // this.cells.each(function(c){
886 // if(c.dateValue == t){
887 // c.addClass("fc-state-highlight");
888 // setTimeout(function(){
889 // try{c.dom.firstChild.focus();}catch(e){}
899 var days = date.getDaysInMonth();
901 var firstOfMonth = date.getFirstDateOfMonth();
902 var startingPos = firstOfMonth.getDay()-this.startDay;
904 if(startingPos < this.startDay){
908 var pm = date.add(Date.MONTH, -1);
909 var prevStart = pm.getDaysInMonth()-startingPos;
911 this.cells = this.el.select('.fc-day',true);
912 this.textNodes = this.el.query('.fc-day-number');
913 this.cells.addClassOnOver('fc-state-hover');
915 var cells = this.cells.elements;
916 var textEls = this.textNodes;
918 Roo.each(cells, function(cell){
919 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
924 // convert everything to numbers so it's fast
926 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
929 //Roo.log(prevStart);
931 var today = new Date().clearTime().getTime();
932 var sel = date.clearTime().getTime();
933 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
934 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
935 var ddMatch = this.disabledDatesRE;
936 var ddText = this.disabledDatesText;
937 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
938 var ddaysText = this.disabledDaysText;
939 var format = this.format;
941 var setCellClass = function(cal, cell){
945 //Roo.log('set Cell Class');
953 cell.className += " fc-today";
954 cell.className += " fc-state-highlight";
955 cell.title = cal.todayText;
958 // disable highlight in other month..
959 //cell.className += " fc-state-highlight";
964 cell.className = " fc-state-disabled";
965 cell.title = cal.minText;
969 cell.className = " fc-state-disabled";
970 cell.title = cal.maxText;
974 if(ddays.indexOf(d.getDay()) != -1){
975 cell.title = ddaysText;
976 cell.className = " fc-state-disabled";
979 if(ddMatch && format){
980 var fvalue = d.dateFormat(format);
981 if(ddMatch.test(fvalue)){
982 cell.title = ddText.replace("%0", fvalue);
983 cell.className = " fc-state-disabled";
987 if (!cell.initialClassName) {
988 cell.initialClassName = cell.dom.className;
991 cell.dom.className = cell.initialClassName + ' ' + cell.className;
996 for(; i < startingPos; i++) {
997 textEls[i].innerHTML = (++prevStart);
998 d.setDate(d.getDate()+1);
1000 cells[i].className = "fc-past fc-other-month";
1001 setCellClass(this, cells[i]);
1006 for(; i < days; i++){
1007 intDay = i - startingPos + 1;
1008 textEls[i].innerHTML = (intDay);
1009 d.setDate(d.getDate()+1);
1011 cells[i].className = ''; // "x-date-active";
1012 setCellClass(this, cells[i]);
1016 for(; i < 42; i++) {
1017 textEls[i].innerHTML = (++extraDays);
1018 d.setDate(d.getDate()+1);
1020 cells[i].className = "fc-future fc-other-month";
1021 setCellClass(this, cells[i]);
1024 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
1026 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
1028 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
1029 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
1032 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
1033 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
1036 this.fireEvent('monthchange', this, date);
1040 if(!this.internalRender){
1041 var main = this.el.dom.firstChild;
1042 var w = main.offsetWidth;
1043 this.el.setWidth(w + this.el.getBorderWidth("lr"));
1044 Roo.fly(main).setWidth(w);
1045 this.internalRender = true;
1046 // opera does not respect the auto grow header center column
1047 // then, after it gets a width opera refuses to recalculate
1048 // without a second pass
1049 if(Roo.isOpera && !this.secondPass){
1050 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
1051 this.secondPass = true;
1052 this.update.defer(10, this, [date]);
1059 findCell : function(dt) {
1060 dt = dt.clearTime().getTime();
1062 this.cells.each(function(c){
1063 //Roo.log("check " +c.dateValue + '?=' + dt);
1064 if(c.dateValue == dt){
1074 findCells : function(ev) {
1075 var s = ev.start.clone().clearTime().getTime();
1077 var e= ev.end.clone().clearTime().getTime();
1080 this.cells.each(function(c){
1081 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
1083 if(c.dateValue > e){
1086 if(c.dateValue < s){
1095 // findBestRow: function(cells)
1099 // for (var i =0 ; i < cells.length;i++) {
1100 // ret = Math.max(cells[i].rows || 0,ret);
1107 addItem : function(ev)
1109 // look for vertical location slot in
1110 var cells = this.findCells(ev);
1112 // ev.row = this.findBestRow(cells);
1114 // work out the location.
1118 for(var i =0; i < cells.length; i++) {
1120 cells[i].row = cells[0].row;
1123 cells[i].row = cells[i].row + 1;
1133 if (crow.start.getY() == cells[i].getY()) {
1135 crow.end = cells[i];
1152 cells[0].events.push(ev);
1154 this.calevents.push(ev);
1157 clearEvents: function() {
1159 if(!this.calevents){
1163 Roo.each(this.cells.elements, function(c){
1169 Roo.each(this.calevents, function(e) {
1170 Roo.each(e.els, function(el) {
1171 el.un('mouseenter' ,this.onEventEnter, this);
1172 el.un('mouseleave' ,this.onEventLeave, this);
1177 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
1183 renderEvents: function()
1187 this.cells.each(function(c) {
1196 if(c.row != c.events.length){
1197 r = 4 - (4 - (c.row - c.events.length));
1200 c.events = ev.slice(0, r);
1201 c.more = ev.slice(r);
1203 if(c.more.length && c.more.length == 1){
1204 c.events.push(c.more.pop());
1207 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
1211 this.cells.each(function(c) {
1213 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
1216 for (var e = 0; e < c.events.length; e++){
1217 var ev = c.events[e];
1220 for(var i = 0; i < rows.length; i++) {
1222 // how many rows should it span..
1225 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
1226 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
1228 unselectable : "on",
1231 cls: 'fc-event-inner',
1235 // cls: 'fc-event-time',
1236 // html : cells.length > 1 ? '' : ev.time
1240 cls: 'fc-event-title',
1241 html : String.format('{0}', ev.title)
1248 cls: 'ui-resizable-handle ui-resizable-e',
1249 html : '  '
1256 cfg.cls += ' fc-event-start';
1258 if ((i+1) == rows.length) {
1259 cfg.cls += ' fc-event-end';
1262 var ctr = _this.el.select('.fc-event-container',true).first();
1263 var cg = ctr.createChild(cfg);
1265 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
1266 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
1268 var r = (c.more.length) ? 1 : 0;
1269 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
1270 cg.setWidth(ebox.right - sbox.x -2);
1272 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
1273 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
1274 cg.on('click', _this.onEventClick, _this, ev);
1285 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
1286 style : 'position: absolute',
1287 unselectable : "on",
1290 cls: 'fc-event-inner',
1294 cls: 'fc-event-title',
1302 cls: 'ui-resizable-handle ui-resizable-e',
1303 html : '  '
1309 var ctr = _this.el.select('.fc-event-container',true).first();
1310 var cg = ctr.createChild(cfg);
1312 var sbox = c.select('.fc-day-content',true).first().getBox();
1313 var ebox = c.select('.fc-day-content',true).first().getBox();
1315 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
1316 cg.setWidth(ebox.right - sbox.x -2);
1318 cg.on('click', _this.onMoreEventClick, _this, c.more);
1328 onEventEnter: function (e, el,event,d) {
1329 this.fireEvent('evententer', this, el, event);
1332 onEventLeave: function (e, el,event,d) {
1333 this.fireEvent('eventleave', this, el, event);
1336 onEventClick: function (e, el,event,d) {
1337 this.fireEvent('eventclick', this, el, event);
1340 onMonthChange: function () {
1344 onMoreEventClick: function(e, el, more)
1348 this.calpopover.placement = 'right';
1349 this.calpopover.setTitle('More');
1351 this.calpopover.setContent('');
1353 var ctr = this.calpopover.el.select('.popover-content', true).first();
1355 Roo.each(more, function(m){
1357 cls : 'fc-event-hori fc-event-draggable',
1360 var cg = ctr.createChild(cfg);
1362 cg.on('click', _this.onEventClick, _this, m);
1365 this.calpopover.show(el);
1372 this.calevents = [];
1375 if(this.store.getCount() > 0){
1376 this.store.data.each(function(d){
1379 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
1380 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
1381 time : d.data.start_time,
1382 title : d.data.title,
1383 description : d.data.description,
1384 venue : d.data.venue
1389 this.renderEvents();
1391 if(this.calevents.length && this.loadMask){
1396 onBeforeLoad: function()
1409 * based on jquery fullcalendar
1415 * @class Roo.Calendar
1416 * @extends Roo.Component
1417 * Bootstrap Calendar class
1420 * Create a new Container
1421 * @param {Object} config The config object
1424 Roo.CalendarPanel = function(config){
1426 Roo.log("cal panel ctr");
1428 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
1429 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
1431 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
1433 Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
1438 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
1440 // xtype created footer. - not sure if will work as we normally have to render first..
1441 if (this.footer && !this.footer.el && this.footer.xtype) {
1443 //this.footer.container = this.grid.getView().getFooterPanel(true);
1444 //this.footer.dataSource = this.grid.dataSource;
1445 //this.footer = Roo.factory(this.footer, Roo);
1448 this.view = new Roo.calendar.View(Roo.apply({
1449 skipNavHeader : true,
1450 skipMonthHeader : false
1455 this.on('activate', function()
1457 Roo.log('activate');
1459 //console.log('render tree');
1466 * Fires when a date is selected
1467 * @param {DatePicker} this
1468 * @param {Date} date The selected date
1472 * @event monthchange
1473 * Fires when the displayed month changes
1474 * @param {DatePicker} this
1475 * @param {Date} date The selected month
1477 'monthchange': true,
1480 * Fires when mouse over an event
1481 * @param {Calendar} this
1482 * @param {event} Event
1487 * Fires when the mouse leaves an
1488 * @param {Calendar} this
1494 * Fires when the mouse click an
1495 * @param {Calendar} this
1501 * Fires when the grid is rendered
1502 * @param {Calendar} this
1509 this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
1512 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
1516 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
1521 var ct = this.el.appendChild(document.createElement("div"));
1522 this.onRender(this.el, false)
1525 onRender : function(ct, position)
1527 if (this.rendered) {
1530 this.rendered = true;
1532 Roo.log("render calendar");
1535 //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1538 var cfg = Roo.apply({}, this.view.getAutoCreate());
1541 // fill in the extra attributes
1542 if (this.xattr && typeof(this.xattr) =='object') {
1543 for (var i in this.xattr) {
1544 cfg[i] = this.xattr[i];
1549 cfg.dataId = this.dataId;
1553 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
1556 if (this.style) { // fixme needs to support more complex style data.
1557 cfg.style = this.style;
1561 cfg.name = this.name;
1564 this.view.el = ct.createChild(cfg, position);
1566 //if(this.tabIndex !== undefined){
1567 // this.el.dom.setAttribute('tabIndex', this.tabIndex);
1571 this.view.initEvents();
1572 this.fireEvent('rendered');