X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-calendar.js;h=e39e85fc612772df05d26da20e555984f1208d98;hp=b4a6d202c5cd2e53679ec98117a8a79462e71e29;hb=61bc45258e16a779856dd2ad0862630b489e4583;hpb=de1ce34b7bef96ff8347b45598e4daceb4a3ede0 diff --git a/roojs-calendar.js b/roojs-calendar.js index b4a6d202c5..e39e85fc61 100644 --- a/roojs-calendar.js +++ b/roojs-calendar.js @@ -6,11 +6,11 @@ Roo.log('skipping render');return cn;}var J=false;while(true){var I=H?H.child('> J=this.addxtypeChild(Roo.apply({},A),B);}return J;},addxtypeChild:function(A,B){var cn=this;B=typeof(B=='undefined')?'getChildContainer':B;var C=(typeof(A['flexy:if'])!='undefined')||(typeof(A['flexy:foreach'])!='undefined');if(A.xtype!='Body'){var D=Roo.factory(A);cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;var E=Roo.XComponent.build_from_html;if(Roo.get(document.body).attr('xtype')=='Roo.bootstrap.Body'){var F=Roo.get(this[B]());var G=F?F.child('>*[xtype]'):false;if(G&&G.attr('xtype').split('.').pop()==cn.xtype){cn.el=G;}else {Roo.log("MISSING "+cn.xtype+" on child of "+(this.el?this.el.attr('xbuilderid'):'no parent'));}}if(E&&C&&!cn.el&&cn.can_build_overlaid){Roo.log('skipping render');}else {cn.render(this[B]());}}var H=[];if(typeof(A.menu)!='undefined'){A.menu.parentType=cn.xtype;A.menu.triggerEl=cn.el;H.push(cn.addxtype(Roo.apply({},A.menu)));}if(!A.items||!A.items.length){cn.items=H;return cn;}var I=A.items;delete A.items;for(var i=0;i'+J+'',unselectable:'on'});};var A={tag:'table',cls:'fc-header',style:'width:100%',cn:[{tag:'tr',cn:[{tag:'td',cls:'fc-header-left',cn:[fc_button('prev','left','arrow','‹'),fc_button('next','right','arrow','›'),{tag:'span',cls:'fc-header-space'},fc_button('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:[]}]}]};var B=function(){var G=[];for(var i=0;iL){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";}}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;} +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,{startDay:0,getAutoCreate:function(){var A=function(H,I,J,K){return Roo.apply({},{tag:'span',cls:'fc-button fc-button-'+H+' fc-state-default '+(I.length?'fc-corner-'+I.split(' ').join(' fc-corner-'):''),html:''+K+'',unselectable:'on'});};var B={tag:'table',cls:'fc-header',style:'width:100%',cn:[{tag:'tr',cn:[{tag:'td',cls:'fc-header-left',cn:[A('prev','left','arrow','‹'),A('next','right','arrow','›'),{tag:'span',cls:'fc-header-space'},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:[]}]}]};var C=function(){var H=[];for(var i=0;iL){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";}}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(;ie){return;}if(c.dateValue1?'':ev.time},{tag:'span',cls:'fc-event-title',html:String.format('{0}',ev.title)}]},{cls:'ui-resizable-handle ui-resizable-e',html:'   '}]};if(i==0){C.cls+=' fc-event-start';}if((i+1)==B.length){C.cls+=' fc-event-end';}var D=this.el.select('.fc-event-container',true).first();var cg=D.createChild(C);cg.on('mouseenter',this.onEventEnter,this,ev);cg.on('mouseleave',this.onEventLeave,this,ev);cg.on('click',this.onEventClick,this,ev);ev.els.push(cg);var E=B[i].start.select('.fc-day-content',true).first().getBox();var F=B[i].end.select('.fc-day-content',true).first().getBox();cg.setXY([E.x+2,E.y+(ev.row*20)]);cg.setWidth(F.right-E.x-2);}}},onEventEnter:function(e,el,A,d){this.fireEvent('evententer',this,el,A);},onEventLeave:function(e,el,A,d){this.fireEvent('eventleave',this,el,A);},onEventClick:function(e,el,A,d){this.fireEvent('eventclick',this,el,A);},onMonthChange:function(){this.store.load();},onLoad:function(){this.clearEvents();Roo.log('calendar onload');this.calevents=[];var A=this;if(this.store.getCount()>0){this.store.data.each(function(d){A.addItem({id:d.data.id,start:new Date(d.data.start_dt),end:new Date(d.data.end_dt),time:d.data.start_time,title:d.data.title,description:d.data.description,venue:d.data.venue});});} +Roo.each(this.cells.elements,function(c){c.rows=0;});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);},renderEvents:function(){this.cells.each(function(c){c.select('.fc-day-content div',true).first().setHeight(Math.max(34,c.rows*20));});for(var e=0;e1?'':ev.time},{tag:'span',cls:'fc-event-title',html:String.format('{0}',ev.title)}]},{cls:'ui-resizable-handle ui-resizable-e',html:'   '}]};if(i==0){C.cls+=' fc-event-start';}if((i+1)==B.length){C.cls+=' fc-event-end';}var D=this.el.select('.fc-event-container',true).first();var cg=D.createChild(C);cg.on('mouseenter',this.onEventEnter,this,ev);cg.on('mouseleave',this.onEventLeave,this,ev);cg.on('click',this.onEventClick,this,ev);ev.els.push(cg);var E=B[i].start.select('.fc-day-content',true).first().getBox();var F=B[i].end.select('.fc-day-content',true).first().getBox();cg.setXY([E.x+2,E.y+(ev.row*20)]);cg.setWidth(F.right-E.x-2);}}},onEventEnter:function(e,el,A,d){this.fireEvent('evententer',this,el,A);},onEventLeave:function(e,el,A,d){this.fireEvent('eventleave',this,el,A);},onEventClick:function(e,el,A,d){this.fireEvent('eventclick',this,el,A);},onMonthChange:function(){this.store.load();},onLoad:function(){this.clearEvents();this.calevents=[];var A=this;if(this.store.getCount()>0){this.store.data.each(function(d){A.addItem({id:d.data.id,start:new Date(d.data.start_dt),end:new Date(d.data.end_dt),time:d.data.start_time,title:d.data.title,description:d.data.description,venue:d.data.venue});});} this.renderEvents();}}); //Roo/CalendarPanel.js 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);if(this.toolbar){this.toolbar.el.insertBefore(this.wrapper.dom.firstChild);}if(this.footer&&!this.footer.el&&this.footer.xtype){} -this.on('activate',function(){Roo.log('activate');this.render();},this);this.addEvents({'select':true,'monthchange':true,'evententer':true,'eventleave':true,'eventclick':true});};Roo.extend(Roo.CalendarPanel,Roo.ContentPanel,{getId:function(){return this.id;},destroy:function(){Roo.GridPanel.superclass.destroy.call(this);},render:function(){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.getAutoCreate());B.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;}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.el=ct.createChild(B,A);if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);} -this.initEvents();},getAutoCreate:Roo.bootstrap.Calendar.prototype.getAutoCreate,initEvents:Roo.bootstrap.Calendar.prototype.initEvents});Roo.each(['getAutoCreate','initEvents','resize','showPrevMonth','showToday','showNextMonth','showPrevYear','showNextYear','update','findCell','findCells','findBestRow','addItem','clearEvents','renderEvents','onEventEnter','onEventLeave','onEventClick','onMonthChange','onLoad'],function(p){Roo.log('add'+p);Roo.CalendarPanel.prototype[p]=Roo.bootstrap.Calendar.prototype[p];}); +this.view=new Roo.calendar.View(Roo.apply({skipNavHeader:true,skipMonthHeader:false},A));this.on('activate',function(){Roo.log('activate');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"));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];}}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');}});