add extra sizes for image figures
[roojs1] / roojs-calendar.js
1 // Roo/bootstrap/Component.js
2 Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Component=function(A){Roo.bootstrap.Component.superclass.constructor.call(this,A);this.addEvents({"childrenrendered":true});};Roo.extend(Roo.bootstrap.Component,Roo.BoxComponent,{allowDomMove:false,cls:false,style:false,autoCreate:false,tooltip:null,initEvents:function(){}
3 ,xattr:false,parentId:false,can_build_overlaid:true,container_method:false,dataId:false,name:false,parent:function(){return Roo.ComponentMgr.get(this.parentId)},onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(this.el){if(this.el.attr('xtype')){this.el.attr('xtypex',this.el.attr('xtype'));
4 this.el.dom.removeAttribute('xtype');this.initEvents();}return;}var B=Roo.apply({},this.getAutoCreate());B.id=this.id||Roo.id();if(this.xattr&&typeof(this.xattr)=='object'){for(var i in this.xattr){B[i]=this.xattr[i];}}if(this.dataId){B.dataId=this.dataId;
5 }if(this.cls){B.cls=(typeof(B.cls)=='undefined'?this.cls:B.cls)+' '+this.cls;}if(this.style){B.style=(typeof(B.style)=='undefined'?this.style:B.style)+'; '+this.style;}if(this.name){B.name=this.name;}this.el=ct.createChild(B,A);if(this.tooltip){this.tooltipEl().attr('tooltip',this.tooltip);
6 }if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);}this.initEvents();},getChildContainer:function(){return this.el;},getDocumentBody:function(){return Roo.get(document.body);},tooltipEl:function(){return this.el;},addxtype:function(A,B){var cn=this;
7 cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;B=(typeof(B)=='undefined')?'getChildContainer':B;if(typeof(cn.container_method)=='string'){B=cn.container_method;}var C=(typeof(A['flexy:foreach'])!='undefined');var D=(typeof(A['flexy:if'])!='undefined');
8 var E=Roo.XComponent.build_from_html;var F=(A.xtype=='Body');var G=(Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body');var H=Roo.get(this[B](false));if((C||D||this.can_build_overlaid==false)&&E){return false;}if(!C||!E||F||!G){if(!D||typeof(A.name)=='undefined'||!E||F||!G){return this.addxtypeChild(A,B,F);
9 }var I=H?H.child('>*[name='+A.name+']'):false;if(I){return this.addxtypeChild(Roo.apply({},A),B);}Roo.log('skipping render');return cn;}var J=false;if(!E){return false;}while(true){var I=H?H.child('>*[xtype]'):false;if(!I){break;}if(I&&I.attr('xtype').split('.').pop()!=cn.xtype){break;
10 }J=this.addxtypeChild(Roo.apply({},A),B);}return J;},addxtypeChild:function(A,B,C){Roo.debug&&Roo.log('addxtypeChild:'+B);var cn=this;B=(typeof(B)=='undefined')?'getChildContainer':B;var D=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined');
11 skip_children=false;if(!C){if(!this[B](true)){A.items=[];return A;}cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(E&&Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B](false));
12 var G=F?F.child('>*[xtype]'):false;if(G){}if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else{Roo.debug&&Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));Roo.debug&&Roo.log(F);Roo.debug&&Roo.log(G);
13 Roo.debug&&Roo.log(cn);}}if(E&&D&&!cn.el&&cn.can_build_overlaid){Roo.debug&&Roo.log('skipping render');Roo.debug&&Roo.log(A);if(!cn.el){Roo.debug&&Roo.log('skipping all children');skip_children=true;}}else{cn.render&&cn.render(this[B](true));}}var H=[];if(!A.items||!A.items.length){cn.items=H;
14 return cn;}var I=A.items;delete A.items;if(!skip_children){for(var i=0;i<I.length;i++){H.push(cn.addxtype(Roo.apply({},I[i])));}}cn.items=H;cn.fireEvent('childrenrendered',this);return cn;},setVisibilityEl:function(el){this.visibilityEl=el;},getVisibilityEl:function(){if(typeof(this.visibilityEl)=='object'){return this.visibilityEl;
15 }if(typeof(this.visibilityEl)=='string'){return this.visibilityEl=='parent'?this.parent().getEl():this.getEl();}return this.getEl();},show:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().removeClass(['hidden','d-none']);this.fireEvent('show',this);
16 },hide:function(){if(!this.getVisibilityEl()){return;}this.getVisibilityEl().addClass(['hidden','d-none']);this.fireEvent('hide',this);}});
17 // Roo/bootstrap/Calendar.js
18 Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Calendar=function(A){Roo.bootstrap.Calendar.superclass.constructor.call(this,A);this.addEvents({'select':true,'monthchange':true,'evententer':true,'eventleave':true,'eventclick':true});};Roo.extend(Roo.bootstrap.Calendar,Roo.bootstrap.Component,{store:false,startDay:0,loadMask:false,header:false,getAutoCreate:function(){var A=function(H,I,J,K){return Roo.apply({}
19 ,{tag:'span',cls:'fc-button fc-button-'+H+' fc-state-default '+(I.length?'fc-corner-'+I.split(' ').join(' fc-corner-'):''),html:'<SPAN class="fc-text-'+J+'">'+K+'</SPAN>',unselectable:'on'});};var B={};if(!this.header){B={tag:'table',cls:'fc-header',style:'width:100%',cn:[{tag:'tr',cn:[{tag:'td',cls:'fc-header-left',cn:[A('prev','left','arrow','&#8249;'),A('next','right','arrow','&#8250;'),{tag:'span',cls:'fc-header-space'}
20 ,A('today','left right','','today')]},{tag:'td',cls:'fc-header-center',cn:[{tag:'span',cls:'fc-header-title',cn:{tag:'H2',html:'month / year'}}]},{tag:'td',cls:'fc-header-right',cn:[]}]}]};}B=this.header;var C=function(){var H=[];for(var i=0;i<Date.dayNames.length;
21 i++){var d=Date.dayNames[i];H.push({tag:'th',cls:'fc-day-header fc-'+d.substring(0,3).toLowerCase()+' fc-widget-header',html:d.substring(0,3)});}H[0].cls+=' fc-first';H[6].cls+=' fc-last';return H;};var D=function(n){return {tag:'td',cls:'fc-day fc-'+n+' fc-widget-content',cn:[{cn:[{cls:'fc-day-number',html:'D'}
22 ,{cls:'fc-day-content',cn:[{style:'position: relative;'}]}]}]}};var E=function(){var H=[];for(var r=0;r<6;r++){var I={tag:'tr',cls:'fc-week',cn:[]};for(var i=0;i<Date.dayNames.length;i++){var d=Date.dayNames[i];I.cn.push(D(d.substring(0,3).toLowerCase()));
23 }I.cn[0].cls+=' fc-first';I.cn[0].cn[0].style='min-height:90px';I.cn[6].cls+=' fc-last';H.push(I);}H[0].cls+=' fc-first';H[4].cls+=' fc-prev-last';H[5].cls+=' fc-last';return H;};var F={tag:'table',cls:'fc-border-separate',style:'width:100%',cellspacing:0,cn:[{tag:'thead',cn:[{tag:'tr',cls:'fc-first fc-last',cn:C()}
24 ]},{tag:'tbody',cn:E()}]};var G={cls:'fc fc-ltr',cn:[B,{cls:'fc-content',style:"position: relative;",cn:[{cls:'fc-view fc-view-month fc-grid',style:'position: relative',unselectable:'on',cn:[{cls:'fc-event-container',style:'position:absolute;z-index:8;top:0;left:0;'}
25 ,F]}]}]};return G;},initEvents:function(){if(!this.store){throw "can not find store for calendar";}var A={tag:"div",cls:"x-dlg-mask",style:"text-align:center",cn:[{tag:"div",style:"background-color:white;width:50%;margin:250 auto",cn:[{tag:"img",src:Roo.rootURL+'/images/ux/lightbox/loading.gif'}
26 ,{tag:"span",html:"Loading"}]}]};this.maskEl=Roo.DomHelper.append(this.el.select('.fc-content',true).first(),A,true);var B=this.el.select('.fc-content',true).first().getSize();this.maskEl.setSize(B.width,B.height);this.maskEl.enableDisplayMode("block");if(!this.loadMask){this.maskEl.hide();
27 }this.store=Roo.factory(this.store,Roo.data);this.store.on('load',this.onLoad,this);this.store.on('beforeload',this.onBeforeLoad,this);this.resize();this.cells=this.el.select('.fc-day',true);this.textNodes=this.el.query('.fc-day-number');this.cells.addClassOnOver('fc-state-hover');
28 this.el.select('.fc-button-prev',true).on('click',this.showPrevMonth,this);this.el.select('.fc-button-next',true).on('click',this.showNextMonth,this);this.el.select('.fc-button-today',true).on('click',this.showToday,this);this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
29 this.on('monthchange',this.onMonthChange,this);this.update(new Date().clearTime());},resize:function(){var sz=this.el.getSize();this.el.select('.fc-day-header',true).setWidth(sz.width/7);this.el.select('.fc-day-content div',true).setHeight(34);},showPrevMonth:function(e){this.update(this.activeDate.add("mo",-1));
30 },showToday:function(e){this.update(new Date().clearTime());},showNextMonth:function(e){this.update(this.activeDate.add("mo",1));},showPrevYear:function(){this.update(this.activeDate.add("y",-1));},showNextYear:function(){this.update(this.activeDate.add("y",1));
31 },update:function(A){var vd=this.activeDate;this.activeDate=A;var B=A.getDaysInMonth();var C=A.getFirstDateOfMonth();var D=C.getDay()-this.startDay;if(D<this.startDay){D+=7;}var pm=A.add(Date.MONTH,-1);var E=pm.getDaysInMonth()-D;this.cells=this.el.select('.fc-day',true);
32 this.textNodes=this.el.query('.fc-day-number');this.cells.addClassOnOver('fc-state-hover');var F=this.cells.elements;var G=this.textNodes;Roo.each(F,function(V){V.removeClass(['fc-past','fc-other-month','fc-future','fc-state-highlight','fc-state-disabled']);
33 });B+=D;var H=86400000;var d=(new Date(pm.getFullYear(),pm.getMonth(),E)).clearTime();var I=new Date().clearTime().getTime();var J=A.clearTime().getTime();var K=this.minDate?this.minDate.clearTime():Number.NEGATIVE_INFINITY;var L=this.maxDate?this.maxDate.clearTime():Number.POSITIVE_INFINITY;
34 var M=this.disabledDatesRE;var N=this.disabledDatesText;var O=this.disabledDays?this.disabledDays.join(""):false;var P=this.disabledDaysText;var Q=this.format;var R=function(V,W){W.row=0;W.events=[];W.more=[];W.title="";var t=d.getTime();W.dateValue=t;if(t==I){W.className+=" fc-today";
35 W.className+=" fc-state-highlight";W.title=V.todayText;}if(t==J){}if(t<K){W.className=" fc-state-disabled";W.title=V.minText;return;}if(t>L){W.className=" fc-state-disabled";W.title=V.maxText;return;}if(O){if(O.indexOf(d.getDay())!=-1){W.title=P;W.className=" fc-state-disabled";
36 }}if(M&&Q){var X=d.dateFormat(Q);if(M.test(X)){W.title=N.replace("%0",X);W.className=" fc-state-disabled";}}if(!W.initialClassName){W.initialClassName=W.dom.className;}W.dom.className=W.initialClassName+' '+W.className;};var i=0;for(;i<D;i++){G[i].innerHTML=(++E);
37 d.setDate(d.getDate()+1);F[i].className="fc-past fc-other-month";R(this,F[i]);}var S=0;for(;i<B;i++){S=i-D+1;G[i].innerHTML=(S);d.setDate(d.getDate()+1);F[i].className='';R(this,F[i]);}var T=0;for(;i<42;i++){G[i].innerHTML=(++T);d.setDate(d.getDate()+1);F[i].className="fc-future fc-other-month";
38 R(this,F[i]);}this.el.select('.fc-header-title h2',true).update(Date.monthNames[A.getMonth()]+" "+A.getFullYear());var U=Math.ceil((A.getDaysInMonth()+A.getFirstDateOfMonth().getDay())/7);this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
39 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();if(U!=6){this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');}this.fireEvent('monthchange',this,A);
40 },findCell:function(dt){dt=dt.clearTime().getTime();var A=false;this.cells.each(function(c){if(c.dateValue==dt){A=c;return false;}return true;});return A;},findCells:function(ev){var s=ev.start.clone().clearTime().getTime();var e=ev.end.clone().clearTime().getTime();
41 var A=[];this.cells.each(function(c){if(c.dateValue>e){return;}if(c.dateValue<s){return;}A.push(c);});return A;},addItem:function(ev){var A=this.findCells(ev);var B=false;var C=[];for(var i=0;i<A.length;i++){A[i].row=A[0].row;if(i==0){A[i].row=A[i].row+1;
42 }if(!B){B={start:A[i],end:A[i]};continue;}if(B.start.getY()==A[i].getY()){B.end=A[i];continue;}C.push(B);B={start:A[i],end:A[i]};}C.push(B);ev.els=[];ev.rows=C;ev.cells=A;A[0].events.push(ev);this.calevents.push(ev);},clearEvents:function(){if(!this.calevents){return;
43 }Roo.each(this.cells.elements,function(c){c.row=0;c.events=[];c.more=[];});Roo.each(this.calevents,function(e){Roo.each(e.els,function(el){el.un('mouseenter',this.onEventEnter,this);el.un('mouseleave',this.onEventLeave,this);el.remove();},this);},this);Roo.each(Roo.select('.fc-more-event',true).elements,function(e){e.remove();
44 });},renderEvents:function(){var A=this;this.cells.each(function(c){if(c.row<5){return;}var ev=c.events;var r=4;if(c.row!=c.events.length){r=4-(4-(c.row-c.events.length));}c.events=ev.slice(0,r);c.more=ev.slice(r);if(c.more.length&&c.more.length==1){c.events.push(c.more.pop());
45 }c.row=(c.row-ev.length)+c.events.length+((c.more.length)?1:0);});this.cells.each(function(c){c.select('.fc-day-content div',true).first().setHeight(Math.max(34,c.row*20));for(var e=0;e<c.events.length;e++){var ev=c.events[e];var B=ev.rows;for(var i=0;i<B.length;
46 i++){var C={cls:'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',style:'position: absolute',unselectable:"on",cn:[{cls:'fc-event-inner',cn:[{tag:'span',cls:'fc-event-title',html:String.format('{0}',ev.title)}]},{cls:'ui-resizable-handle ui-resizable-e',html:'&nbsp;&nbsp;&nbsp'}
47 ]};if(i==0){C.cls+=' fc-event-start';}if((i+1)==B.length){C.cls+=' fc-event-end';}var D=A.el.select('.fc-event-container',true).first();var cg=D.createChild(C);var E=B[i].start.select('.fc-day-content',true).first().getBox();var F=B[i].end.select('.fc-day-content',true).first().getBox();
48 var r=(c.more.length)?1:0;cg.setXY([E.x+2,E.y+((c.row-c.events.length-r+e)*20)]);cg.setWidth(F.right-E.x-2);cg.on('mouseenter',A.onEventEnter,A,ev);cg.on('mouseleave',A.onEventLeave,A,ev);cg.on('click',A.onEventClick,A,ev);ev.els.push(cg);}}if(c.more.length){var C={cls:'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',style:'position: absolute',unselectable:"on",cn:[{cls:'fc-event-inner',cn:[{tag:'span',cls:'fc-event-title',html:'More'}
49 ]},{cls:'ui-resizable-handle ui-resizable-e',html:'&nbsp;&nbsp;&nbsp'}]};var D=A.el.select('.fc-event-container',true).first();var cg=D.createChild(C);var E=c.select('.fc-day-content',true).first().getBox();var F=c.select('.fc-day-content',true).first().getBox();
50 cg.setXY([E.x+2,E.y+((c.row-1)*20)]);cg.setWidth(F.right-E.x-2);cg.on('click',A.onMoreEventClick,A,c.more);}});},onEventEnter:function(e,el,A,d){this.fireEvent('evententer',this,el,A);},onEventLeave:function(e,el,A,d){this.fireEvent('eventleave',this,el,A);
51 },onEventClick:function(e,el,A,d){this.fireEvent('eventclick',this,el,A);},onMonthChange:function(){this.store.load();},onMoreEventClick:function(e,el,A){var B=this;this.calpopover.placement='right';this.calpopover.setTitle('More');this.calpopover.setContent('');
52 var C=this.calpopover.el.select('.popover-content',true).first();Roo.each(A,function(m){var D={cls:'fc-event-hori fc-event-draggable',html:m.title};var cg=C.createChild(D);cg.on('click',B.onEventClick,B,m);});this.calpopover.show(el);},onLoad:function(){this.calevents=[];
53 var A=this;if(this.store.getCount()>0){this.store.data.each(function(d){A.addItem({id:d.data.id,start:(typeof(d.data.start_dt)==='string')?new Date.parseDate(d.data.start_dt,'Y-m-d H:i:s'):d.data.start_dt,end:(typeof(d.data.end_dt)==='string')?new Date.parseDate(d.data.end_dt,'Y-m-d H:i:s'):d.data.end_dt,time:d.data.start_time,title:d.data.title,description:d.data.description,venue:d.data.venue}
54 );});}this.renderEvents();if(this.calevents.length&&this.loadMask){this.maskEl.hide();}},onBeforeLoad:function(){this.clearEvents();if(this.loadMask){this.maskEl.show();}}});
55 // Roo/CalendarPanel.js
56 Roo.CalendarPanel=function(A){Roo.log("cal panel ctr");this.wrapper=Roo.DomHelper.append(document.body,{tag:"div",cls:"x-layout-grid-wrapper x-layout-inactive-content"},true);Roo.CalendarPanel.superclass.constructor.call(this,this.wrapper,A);Roo.log(this.el);
57 if(this.toolbar){this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);}if(this.footer&&!this.footer.el&&this.footer.xtype){}this.view=new Roo.calendar.View(Roo.apply({skipNavHeader:true,skipMonthHeader:false},A));this.on('activate',function(){Roo.log('activate');
58 this.render();},this);this.addEvents({'select':true,'monthchange':true,'evententer':true,'eventleave':true,'eventclick':true,'rendered':true});this.relayEvents(this.view,["select","monthchange","evententer","eventleave","rendered"]);};Roo.extend(Roo.CalendarPanel,Roo.ContentPanel,{render:function(){var ct=this.el.appendChild(document.createElement("div"));
59 this.onRender(this.el,false)},onRender:function(ct,A){if(this.rendered){return;}this.rendered=true;Roo.log("render calendar");var B=Roo.apply({},this.view.getAutoCreate());B.id=Roo.id();if(this.xattr&&typeof(this.xattr)=='object'){for(var i in this.xattr){B[i]=this.xattr[i];
60 }}if(this.dataId){B.dataId=this.dataId;}if(this.cls){B.cls=(typeof(B.cls)=='undefined')?this.cls:B.cls+' '+this.cls;}if(this.style){B.style=this.style;}if(this.name){B.name=this.name;}this.view.el=ct.createChild(B,A);this.view.initEvents();this.fireEvent('rendered');
61 }});