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.
414 xAdd : function (tree, cntr, is_body)
416 Roo.debug && Roo.log('xadd:' + cntr);
418 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
420 var parent_ctnr = this[cntr](true);
421 if(parent_ctnr === false){
422 return false; // getChildContainer an return false explicitly to block children being added?
425 throw new Exception("could not find parent Container for item");
428 var cn = Roo.factory(tree);
429 // at this point items[] array may be set..
430 // constructors should not really be building their children?
431 cn.parentType = this.xtype; //??
432 cn.parentId = this.id;
435 cn.render && cn.render(parent_ctnr);
437 cn.xAddChildren(tree.items || cn.items);
438 delete tree.items; // not really needed?
444 * Set the element that will be used to show or hide
446 setVisibilityEl : function(el)
448 this.visibilityEl = el;
452 * Get the element that will be used to show or hide
454 getVisibilityEl : function()
456 if (typeof(this.visibilityEl) == 'object') {
457 return this.visibilityEl;
460 if (typeof(this.visibilityEl) == 'string') {
461 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
468 * Show a component - removes 'hidden' class
472 if(!this.getVisibilityEl()){
476 this.getVisibilityEl().removeClass(['hidden','d-none']);
478 this.fireEvent('show', this);
483 * Hide a component - adds 'hidden' class
487 if(!this.getVisibilityEl()){
491 this.getVisibilityEl().addClass(['hidden','d-none']);
493 this.fireEvent('hide', this);
501 * based on jquery fullcalendar
505 Roo.bootstrap = Roo.bootstrap || {};
507 * @class Roo.bootstrap.Calendar
508 * @extends Roo.bootstrap.Component
509 * Bootstrap Calendar class
510 * @cfg {Boolean} loadMask (true|false) default false
511 * @cfg {Object} header generate the user specific header of the calendar, default false
514 * Create a new Container
515 * @param {Object} config The config object
520 Roo.bootstrap.Calendar = function(config){
521 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
525 * Fires when a date is selected
526 * @param {DatePicker} this
527 * @param {Date} date The selected date
532 * Fires when the displayed month changes
533 * @param {DatePicker} this
534 * @param {Date} date The selected month
539 * Fires when mouse over an event
540 * @param {Calendar} this
541 * @param {event} Event
546 * Fires when the mouse leaves an
547 * @param {Calendar} this
553 * Fires when the mouse click an
554 * @param {Calendar} this
563 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
566 * @cfg {Number} startDay
567 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
575 getAutoCreate : function(){
578 var fc_button = function(name, corner, style, content ) {
579 return Roo.apply({},{
581 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
583 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
586 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
597 style : 'width:100%',
604 cls : 'fc-header-left',
606 fc_button('prev', 'left', 'arrow', '‹' ),
607 fc_button('next', 'right', 'arrow', '›' ),
608 { tag: 'span', cls: 'fc-header-space' },
609 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
617 cls : 'fc-header-center',
621 cls: 'fc-header-title',
624 html : 'month / year'
632 cls : 'fc-header-right',
634 /* fc_button('month', 'left', '', 'month' ),
635 fc_button('week', '', '', 'week' ),
636 fc_button('day', 'right', '', 'day' )
648 header = this.header;
651 var cal_heads = function() {
653 // fixme - handle this.
655 for (var i =0; i < Date.dayNames.length; i++) {
656 var d = Date.dayNames[i];
659 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
660 html : d.substring(0,3)
664 ret[0].cls += ' fc-first';
665 ret[6].cls += ' fc-last';
668 var cal_cell = function(n) {
671 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
676 cls: 'fc-day-number',
680 cls: 'fc-day-content',
684 style: 'position: relative;' // height: 17px;
696 var cal_rows = function() {
699 for (var r = 0; r < 6; r++) {
706 for (var i =0; i < Date.dayNames.length; i++) {
707 var d = Date.dayNames[i];
708 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
711 row.cn[0].cls+=' fc-first';
712 row.cn[0].cn[0].style = 'min-height:90px';
713 row.cn[6].cls+=' fc-last';
717 ret[0].cls += ' fc-first';
718 ret[4].cls += ' fc-prev-last';
719 ret[5].cls += ' fc-last';
726 cls: 'fc-border-separate',
727 style : 'width:100%',
735 cls : 'fc-first fc-last',
754 style : "position: relative;",
757 cls : 'fc-view fc-view-month fc-grid',
758 style : 'position: relative',
762 cls : 'fc-event-container',
763 style : 'position:absolute;z-index:8;top:0;left:0;'
781 initEvents : function()
784 throw "can not find store for calendar";
790 style: "text-align:center",
794 style: "background-color:white;width:50%;margin:250 auto",
798 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
809 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
811 var size = this.el.select('.fc-content', true).first().getSize();
812 this.maskEl.setSize(size.width, size.height);
813 this.maskEl.enableDisplayMode("block");
818 this.store = Roo.factory(this.store, Roo.data);
819 this.store.on('load', this.onLoad, this);
820 this.store.on('beforeload', this.onBeforeLoad, this);
824 this.cells = this.el.select('.fc-day',true);
825 //Roo.log(this.cells);
826 this.textNodes = this.el.query('.fc-day-number');
827 this.cells.addClassOnOver('fc-state-hover');
829 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
830 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
831 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
832 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
834 this.on('monthchange', this.onMonthChange, this);
836 this.update(new Date().clearTime());
839 resize : function() {
840 var sz = this.el.getSize();
842 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
843 this.el.select('.fc-day-content div',true).setHeight(34);
848 showPrevMonth : function(e){
849 this.update(this.activeDate.add("mo", -1));
851 showToday : function(e){
852 this.update(new Date().clearTime());
855 showNextMonth : function(e){
856 this.update(this.activeDate.add("mo", 1));
860 showPrevYear : function(){
861 this.update(this.activeDate.add("y", -1));
865 showNextYear : function(){
866 this.update(this.activeDate.add("y", 1));
871 update : function(date)
873 var vd = this.activeDate;
874 this.activeDate = date;
875 // if(vd && this.el){
876 // var t = date.getTime();
877 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
878 // Roo.log('using add remove');
880 // this.fireEvent('monthchange', this, date);
882 // this.cells.removeClass("fc-state-highlight");
883 // this.cells.each(function(c){
884 // if(c.dateValue == t){
885 // c.addClass("fc-state-highlight");
886 // setTimeout(function(){
887 // try{c.dom.firstChild.focus();}catch(e){}
897 var days = date.getDaysInMonth();
899 var firstOfMonth = date.getFirstDateOfMonth();
900 var startingPos = firstOfMonth.getDay()-this.startDay;
902 if(startingPos < this.startDay){
906 var pm = date.add(Date.MONTH, -1);
907 var prevStart = pm.getDaysInMonth()-startingPos;
909 this.cells = this.el.select('.fc-day',true);
910 this.textNodes = this.el.query('.fc-day-number');
911 this.cells.addClassOnOver('fc-state-hover');
913 var cells = this.cells.elements;
914 var textEls = this.textNodes;
916 Roo.each(cells, function(cell){
917 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
922 // convert everything to numbers so it's fast
924 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
927 //Roo.log(prevStart);
929 var today = new Date().clearTime().getTime();
930 var sel = date.clearTime().getTime();
931 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
932 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
933 var ddMatch = this.disabledDatesRE;
934 var ddText = this.disabledDatesText;
935 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
936 var ddaysText = this.disabledDaysText;
937 var format = this.format;
939 var setCellClass = function(cal, cell){
943 //Roo.log('set Cell Class');
951 cell.className += " fc-today";
952 cell.className += " fc-state-highlight";
953 cell.title = cal.todayText;
956 // disable highlight in other month..
957 //cell.className += " fc-state-highlight";
962 cell.className = " fc-state-disabled";
963 cell.title = cal.minText;
967 cell.className = " fc-state-disabled";
968 cell.title = cal.maxText;
972 if(ddays.indexOf(d.getDay()) != -1){
973 cell.title = ddaysText;
974 cell.className = " fc-state-disabled";
977 if(ddMatch && format){
978 var fvalue = d.dateFormat(format);
979 if(ddMatch.test(fvalue)){
980 cell.title = ddText.replace("%0", fvalue);
981 cell.className = " fc-state-disabled";
985 if (!cell.initialClassName) {
986 cell.initialClassName = cell.dom.className;
989 cell.dom.className = cell.initialClassName + ' ' + cell.className;
994 for(; i < startingPos; i++) {
995 textEls[i].innerHTML = (++prevStart);
996 d.setDate(d.getDate()+1);
998 cells[i].className = "fc-past fc-other-month";
999 setCellClass(this, cells[i]);
1004 for(; i < days; i++){
1005 intDay = i - startingPos + 1;
1006 textEls[i].innerHTML = (intDay);
1007 d.setDate(d.getDate()+1);
1009 cells[i].className = ''; // "x-date-active";
1010 setCellClass(this, cells[i]);
1014 for(; i < 42; i++) {
1015 textEls[i].innerHTML = (++extraDays);
1016 d.setDate(d.getDate()+1);
1018 cells[i].className = "fc-future fc-other-month";
1019 setCellClass(this, cells[i]);
1022 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
1024 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
1026 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
1027 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
1030 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
1031 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
1034 this.fireEvent('monthchange', this, date);
1038 if(!this.internalRender){
1039 var main = this.el.dom.firstChild;
1040 var w = main.offsetWidth;
1041 this.el.setWidth(w + this.el.getBorderWidth("lr"));
1042 Roo.fly(main).setWidth(w);
1043 this.internalRender = true;
1044 // opera does not respect the auto grow header center column
1045 // then, after it gets a width opera refuses to recalculate
1046 // without a second pass
1047 if(Roo.isOpera && !this.secondPass){
1048 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
1049 this.secondPass = true;
1050 this.update.defer(10, this, [date]);
1057 findCell : function(dt) {
1058 dt = dt.clearTime().getTime();
1060 this.cells.each(function(c){
1061 //Roo.log("check " +c.dateValue + '?=' + dt);
1062 if(c.dateValue == dt){
1072 findCells : function(ev) {
1073 var s = ev.start.clone().clearTime().getTime();
1075 var e= ev.end.clone().clearTime().getTime();
1078 this.cells.each(function(c){
1079 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
1081 if(c.dateValue > e){
1084 if(c.dateValue < s){
1093 // findBestRow: function(cells)
1097 // for (var i =0 ; i < cells.length;i++) {
1098 // ret = Math.max(cells[i].rows || 0,ret);
1105 addItem : function(ev)
1107 // look for vertical location slot in
1108 var cells = this.findCells(ev);
1110 // ev.row = this.findBestRow(cells);
1112 // work out the location.
1116 for(var i =0; i < cells.length; i++) {
1118 cells[i].row = cells[0].row;
1121 cells[i].row = cells[i].row + 1;
1131 if (crow.start.getY() == cells[i].getY()) {
1133 crow.end = cells[i];
1150 cells[0].events.push(ev);
1152 this.calevents.push(ev);
1155 clearEvents: function() {
1157 if(!this.calevents){
1161 Roo.each(this.cells.elements, function(c){
1167 Roo.each(this.calevents, function(e) {
1168 Roo.each(e.els, function(el) {
1169 el.un('mouseenter' ,this.onEventEnter, this);
1170 el.un('mouseleave' ,this.onEventLeave, this);
1175 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
1181 renderEvents: function()
1185 this.cells.each(function(c) {
1194 if(c.row != c.events.length){
1195 r = 4 - (4 - (c.row - c.events.length));
1198 c.events = ev.slice(0, r);
1199 c.more = ev.slice(r);
1201 if(c.more.length && c.more.length == 1){
1202 c.events.push(c.more.pop());
1205 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
1209 this.cells.each(function(c) {
1211 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
1214 for (var e = 0; e < c.events.length; e++){
1215 var ev = c.events[e];
1218 for(var i = 0; i < rows.length; i++) {
1220 // how many rows should it span..
1223 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
1224 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
1226 unselectable : "on",
1229 cls: 'fc-event-inner',
1233 // cls: 'fc-event-time',
1234 // html : cells.length > 1 ? '' : ev.time
1238 cls: 'fc-event-title',
1239 html : String.format('{0}', ev.title)
1246 cls: 'ui-resizable-handle ui-resizable-e',
1247 html : '  '
1254 cfg.cls += ' fc-event-start';
1256 if ((i+1) == rows.length) {
1257 cfg.cls += ' fc-event-end';
1260 var ctr = _this.el.select('.fc-event-container',true).first();
1261 var cg = ctr.createChild(cfg);
1263 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
1264 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
1266 var r = (c.more.length) ? 1 : 0;
1267 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
1268 cg.setWidth(ebox.right - sbox.x -2);
1270 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
1271 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
1272 cg.on('click', _this.onEventClick, _this, ev);
1283 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
1284 style : 'position: absolute',
1285 unselectable : "on",
1288 cls: 'fc-event-inner',
1292 cls: 'fc-event-title',
1300 cls: 'ui-resizable-handle ui-resizable-e',
1301 html : '  '
1307 var ctr = _this.el.select('.fc-event-container',true).first();
1308 var cg = ctr.createChild(cfg);
1310 var sbox = c.select('.fc-day-content',true).first().getBox();
1311 var ebox = c.select('.fc-day-content',true).first().getBox();
1313 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
1314 cg.setWidth(ebox.right - sbox.x -2);
1316 cg.on('click', _this.onMoreEventClick, _this, c.more);
1326 onEventEnter: function (e, el,event,d) {
1327 this.fireEvent('evententer', this, el, event);
1330 onEventLeave: function (e, el,event,d) {
1331 this.fireEvent('eventleave', this, el, event);
1334 onEventClick: function (e, el,event,d) {
1335 this.fireEvent('eventclick', this, el, event);
1338 onMonthChange: function () {
1342 onMoreEventClick: function(e, el, more)
1346 this.calpopover.placement = 'right';
1347 this.calpopover.setTitle('More');
1349 this.calpopover.setContent('');
1351 var ctr = this.calpopover.el.select('.popover-content', true).first();
1353 Roo.each(more, function(m){
1355 cls : 'fc-event-hori fc-event-draggable',
1358 var cg = ctr.createChild(cfg);
1360 cg.on('click', _this.onEventClick, _this, m);
1363 this.calpopover.show(el);
1370 this.calevents = [];
1373 if(this.store.getCount() > 0){
1374 this.store.data.each(function(d){
1377 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
1378 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
1379 time : d.data.start_time,
1380 title : d.data.title,
1381 description : d.data.description,
1382 venue : d.data.venue
1387 this.renderEvents();
1389 if(this.calevents.length && this.loadMask){
1394 onBeforeLoad: function()
1407 * based on jquery fullcalendar
1413 * @class Roo.Calendar
1414 * @extends Roo.Component
1415 * Bootstrap Calendar class
1418 * Create a new Container
1419 * @param {Object} config The config object
1422 Roo.CalendarPanel = function(config){
1424 Roo.log("cal panel ctr");
1426 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
1427 {tag: "div", cls: "x-layout-grid-wrapper x-layout-inactive-content"}, true);
1429 //this.wrapper.dom.appendChild(grid.getGridEl().dom);
1431 Roo.CalendarPanel.superclass.constructor.call(this, this.wrapper, config);
1436 this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);
1438 // xtype created footer. - not sure if will work as we normally have to render first..
1439 if (this.footer && !this.footer.el && this.footer.xtype) {
1441 //this.footer.container = this.grid.getView().getFooterPanel(true);
1442 //this.footer.dataSource = this.grid.dataSource;
1443 //this.footer = Roo.factory(this.footer, Roo);
1446 this.view = new Roo.calendar.View(Roo.apply({
1447 skipNavHeader : true,
1448 skipMonthHeader : false
1453 this.on('activate', function()
1455 Roo.log('activate');
1457 //console.log('render tree');
1464 * Fires when a date is selected
1465 * @param {DatePicker} this
1466 * @param {Date} date The selected date
1470 * @event monthchange
1471 * Fires when the displayed month changes
1472 * @param {DatePicker} this
1473 * @param {Date} date The selected month
1475 'monthchange': true,
1478 * Fires when mouse over an event
1479 * @param {Calendar} this
1480 * @param {event} Event
1485 * Fires when the mouse leaves an
1486 * @param {Calendar} this
1492 * Fires when the mouse click an
1493 * @param {Calendar} this
1499 * Fires when the grid is rendered
1500 * @param {Calendar} this
1507 this.relayEvents(this.view, ["select","monthchange","evententer","eventleave","rendered"]);
1510 //this.grid.getGridEl().replaceClass("x-layout-inactive-content", "x-layout-component-panel");
1514 Roo.extend(Roo.CalendarPanel, Roo.ContentPanel, {
1519 var ct = this.el.appendChild(document.createElement("div"));
1520 this.onRender(this.el, false)
1523 onRender : function(ct, position)
1525 if (this.rendered) {
1528 this.rendered = true;
1530 Roo.log("render calendar");
1533 //Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
1536 var cfg = Roo.apply({}, this.view.getAutoCreate());
1539 // fill in the extra attributes
1540 if (this.xattr && typeof(this.xattr) =='object') {
1541 for (var i in this.xattr) {
1542 cfg[i] = this.xattr[i];
1547 cfg.dataId = this.dataId;
1551 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
1554 if (this.style) { // fixme needs to support more complex style data.
1555 cfg.style = this.style;
1559 cfg.name = this.name;
1562 this.view.el = ct.createChild(cfg, position);
1564 //if(this.tabIndex !== undefined){
1565 // this.el.dom.setAttribute('tabIndex', this.tabIndex);
1569 this.view.initEvents();
1570 this.fireEvent('rendered');