Roo/bootstrap/DateField.js
authorEdward <edward@roojs.com>
Mon, 26 May 2014 11:15:14 +0000 (19:15 +0800)
committerEdward <edward@roojs.com>
Mon, 26 May 2014 11:15:14 +0000 (19:15 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/DateField.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index f8759e6..66a3a1a 100644 (file)
@@ -212,12 +212,12 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
             
             var period = this.picker().select('>.datepicker-time button.period-btn', true).first();
             
-            hours_up.on('click', this.onIncrementHours, hours_up);
-            hours_down.on('click', this.onDecrementHours, hours_down);
-            minutes_up.on('click', this.onIncrementMinutes, minutes_up);
-            minutes_down.on('click', this.onDecrementMinutes, minutes_down);
+            hours_up.on('click', this.onIncrementHours, this);
+            hours_down.on('click', this.onDecrementHours, this);
+            minutes_up.on('click', this.onIncrementMinutes, this);
+            minutes_down.on('click', this.onDecrementMinutes, this);
             
-            period.on('click', this.onTogglePeriod, period);
+            period.on('click', this.onTogglePeriod, this);
             
             this.updateTime();
             
index 6b04738..72bc7cb 100644 (file)
@@ -11037,12 +11037,12 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
             
             var period = this.picker().select('>.datepicker-time button.period-btn', true).first();
             
-            hours_up.on('click', this.onIncrementHours, hours_up);
-            hours_down.on('click', this.onDecrementHours, hours_down);
-            minutes_up.on('click', this.onIncrementMinutes, minutes_up);
-            minutes_down.on('click', this.onDecrementMinutes, minutes_down);
+            hours_up.on('click', this.onIncrementHours, this);
+            hours_down.on('click', this.onDecrementHours, this);
+            minutes_up.on('click', this.onIncrementMinutes, this);
+            minutes_down.on('click', this.onDecrementMinutes, this);
             
-            period.on('click', this.onTogglePeriod, period);
+            period.on('click', this.onTogglePeriod, this);
             
             this.updateTime();
             
@@ -11884,8 +11884,6 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
     
     onTogglePeriod: function()
     {
-        Roo.log('this!!!!!!!!!!!!!!!!!!!');
-        Roo.log(this);
         var h = 12;
         if(this.time.format('A') === 'PM'){
             h = -12;
index 7272676..b9476fa 100644 (file)
@@ -252,7 +252,7 @@ Roo.bootstrap.ProgressBar=function(A){Roo.bootstrap.ProgressBar.superclass.const
 Roo.bootstrap.TabPanel=function(A){Roo.bootstrap.TabPanel.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.TabPanel,Roo.bootstrap.Component,{active:false,html:false,tabId:false,getAutoCreate:function(){var A={tag:'div',cls:'tab-pane',html:this.html||''};if(this.active){A.cls+=' active';}if(this.tabId){A.tabId=this.tabId;}return A;}});
 //Roo/bootstrap/DateField.js
 Roo.bootstrap.DateField=function(A){Roo.bootstrap.DateField.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.DateField,Roo.bootstrap.Input,{format:"m/d/y",altFormats:false,weekStart:0,viewMode:'day',minViewMode:'',todayHighlight:false,todayBtn:false,language:'en',keyboardNavigation:true,calendarWeeks:false,startDate:-Infinity,endDate:Infinity,daysOfWeekDisabled:[],showTime:true,UTCDate:function(){return new Date(Date.UTC.apply(Date,arguments));},UTCTime:function(){return new Date(Date.UTC.apply(Date,arguments));},UTCToday:function(){var A=new Date();return this.UTCDate(A.getUTCFullYear(),A.getUTCMonth(),A.getUTCDate());},UTCTodayTime:function(){var A=new Date();return this.UTCTime(A.getUTCFullYear(),A.getUTCMonth(),A.getUTCDate(),A.getUTCHours(),A.getUTCMinutes());},getDate:function(){var d=this.getUTCDate();return new Date(d.getTime()+(d.getTimezoneOffset()*60000));},getUTCDate:function(){return this.date;},setDate:function(d){this.setUTCDate(new Date(d.getTime()-(d.getTimezoneOffset()*60000)));},setUTCDate:function(d){this.date=d;this.setValue(this.formatDate(this.date));},onRender:function(ct,A){Roo.bootstrap.DateField.superclass.onRender.call(this,ct,A);this.language=this.language||'en';this.language=this.language in Roo.bootstrap.DateField.dates?this.language:this.language.split('-')[0];this.language=this.language in Roo.bootstrap.DateField.dates?this.language:"en";this.isRTL=Roo.bootstrap.DateField.dates[this.language].rtl||false;this.format=this.format||'m/d/y';this.isInline=false;this.isInput=true;this.component=this.el.select('.add-on',true).first()||false;this.component=(this.component&&this.component.length===0)?false:this.component;this.hasInput=this.component&&this.inputEL().length;if(typeof(this.minViewMode==='string')){switch(this.minViewMode){case 'months':this.minViewMode=2;break;case 'years':this.minViewMode=3;break;case 'day':this.minViewMode=1;break;default:this.minViewMode=0;break;}}if(typeof(this.viewMode==='string')){switch(this.viewMode){case 'months':this.viewMode=2;break;case 'years':this.viewMode=2;break;case 'day':this.viewMode=1;break;default:this.viewMode=0;break;}}
-this.el.select('>.input-group',true).first().createChild(Roo.bootstrap.DateField.template);this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';this.picker().on('mousedown',this.onMousedown,this);this.picker().on('click',this.onClick,this);this.picker().addClass('datepicker-dropdown');this.startViewMode=this.viewMode;this.weekEnd=this.weekStart===0?6:this.weekStart-1;this.setStartDate(this.startDate);this.setEndDate(this.endDate);this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);this.fillDow();this.fillMonths();this.fillTime();this.update();this.showMode();if(this.showTime){var B=this.picker().select('>.datepicker-days tfoot th',true).first();var C=this.picker().select('>.datepicker-time tfoot th',true).first();var D=this.picker().select('>.datepicker-days tfoot span.picker-switch-icon',true).first();var E=this.picker().select('>.datepicker-time tfoot span.picker-switch-icon',true).first();C.addClass('switch-calendar');B.addClass('switch-time');E.addClass('switch-calendar');E.addClass('glyphicon-calendar');D.addClass('switch-time');D.addClass('glyphicon-time');var F=this.picker().select('>.datepicker-time span.hours-up',true).first();var G=this.picker().select('>.datepicker-time span.hours-down',true).first();var H=this.picker().select('>.datepicker-time span.minutes-up',true).first();var I=this.picker().select('>.datepicker-time span.minutes-down',true).first();var J=this.picker().select('>.datepicker-time button.period-btn',true).first();F.on('click',this.onIncrementHours,F);G.on('click',this.onDecrementHours,G);H.on('click',this.onIncrementMinutes,H);I.on('click',this.onDecrementMinutes,I);J.on('click',this.onTogglePeriod,J);this.updateTime();}else {Roo.each(this.picker().select('tfoot th',true).elements,function(v){v.remove();});}if(this.isInline){this.show();}},picker:function(){return this.el.select('.datepicker',true).first();},fillDow:function(){var A=this.weekStart;var B={tag:'tr',cn:[]};if(this.calendarWeeks){B.cn.push({tag:'th',cls:'cw',html:'&nbsp;'})}while(A<this.weekStart+7){B.cn.push({tag:'th',cls:'dow',html:Roo.bootstrap.DateField.dates[this.language].daysMin[(A++)%7]});}
+this.el.select('>.input-group',true).first().createChild(Roo.bootstrap.DateField.template);this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';this.picker().on('mousedown',this.onMousedown,this);this.picker().on('click',this.onClick,this);this.picker().addClass('datepicker-dropdown');this.startViewMode=this.viewMode;this.weekEnd=this.weekStart===0?6:this.weekStart-1;this.setStartDate(this.startDate);this.setEndDate(this.endDate);this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);this.fillDow();this.fillMonths();this.fillTime();this.update();this.showMode();if(this.showTime){var B=this.picker().select('>.datepicker-days tfoot th',true).first();var C=this.picker().select('>.datepicker-time tfoot th',true).first();var D=this.picker().select('>.datepicker-days tfoot span.picker-switch-icon',true).first();var E=this.picker().select('>.datepicker-time tfoot span.picker-switch-icon',true).first();C.addClass('switch-calendar');B.addClass('switch-time');E.addClass('switch-calendar');E.addClass('glyphicon-calendar');D.addClass('switch-time');D.addClass('glyphicon-time');var F=this.picker().select('>.datepicker-time span.hours-up',true).first();var G=this.picker().select('>.datepicker-time span.hours-down',true).first();var H=this.picker().select('>.datepicker-time span.minutes-up',true).first();var I=this.picker().select('>.datepicker-time span.minutes-down',true).first();var J=this.picker().select('>.datepicker-time button.period-btn',true).first();F.on('click',this.onIncrementHours,this);G.on('click',this.onDecrementHours,this);H.on('click',this.onIncrementMinutes,this);I.on('click',this.onDecrementMinutes,this);J.on('click',this.onTogglePeriod,this);this.updateTime();}else {Roo.each(this.picker().select('tfoot th',true).elements,function(v){v.remove();});}if(this.isInline){this.show();}},picker:function(){return this.el.select('.datepicker',true).first();},fillDow:function(){var A=this.weekStart;var B={tag:'tr',cn:[]};if(this.calendarWeeks){B.cn.push({tag:'th',cls:'cw',html:'&nbsp;'})}while(A<this.weekStart+7){B.cn.push({tag:'th',cls:'dow',html:Roo.bootstrap.DateField.dates[this.language].daysMin[(A++)%7]});}
 this.picker().select('>.datepicker-days thead',true).first().createChild(B);},fillMonths:function(){var i=0var months=this.picker().select('>.datepicker-months td',true).first();months.dom.innerHTML='';while(i<12){var A={tag:'span',cls:'month',html:Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]}
 months.createChild(A);}},fillTime:function(){var A=this.picker().select('>.datepicker-time tbody',true).first();A.dom.innerHTML='';A.createChild({tag:'tr',cn:[{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'hours-up glyphicon glyphicon-chevron-up'}]}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'minutes-up glyphicon glyphicon-chevron-up'}]}]},{tag:'td',cls:'separator'}]});A.createChild({tag:'tr',cn:[{tag:'td',cn:[{tag:'span',cls:'timepicker-hour',html:'00'}]},{tag:'td',cls:'separator',html:':'},{tag:'td',cn:[{tag:'span',cls:'timepicker-minute',html:'00'}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'button',type:'button',cls:'btn btn-primary period-btn',html:'AM'}]}]});A.createChild({tag:'tr',cn:[{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'hours-down glyphicon glyphicon-chevron-down'}]}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'minutes-down glyphicon glyphicon-chevron-down'}]}]},{tag:'td',cls:'separator'}]});},update:function(){this.date=(typeof(this.date)==='undefined')?this.UTCToday():(typeof(this.date)==='string')?this.parseDate(this.date):this.date;if(this.date<this.startDate){this.viewDate=new Date(this.startDate);}else if(this.date>this.endDate){this.viewDate=new Date(this.endDate);}else {this.viewDate=new Date(this.date);}
 this.fill();},fill:function(){var d=new Date(this.viewDate),A=d.getUTCFullYear(),B=d.getUTCMonth(),C=this.startDate!==-Infinity?this.startDate.getUTCFullYear():-Infinity,D=this.startDate!==-Infinity?this.startDate.getUTCMonth():-Infinity,E=this.endDate!==Infinity?this.endDate.getUTCFullYear():Infinity,F=this.endDate!==Infinity?this.endDate.getUTCMonth():Infinity,G=this.date&&this.date.valueOf(),H=this.UTCToday();this.picker().select('>.datepicker-days thead th.switch',true).first().dom.innerHTML=Roo.bootstrap.DateField.dates[this.language].months[B]+' '+A;this.updateNavArrows();this.fillMonths();var I=this.UTCDate(A,B-1,28,0,0,0,0),J=I.getDaysInMonth(I.getUTCFullYear(),I.getUTCMonth());I.setUTCDate(J);I.setUTCDate(J-(I.getUTCDay()-this.weekStart+7)%7);var K=new Date(I);K.setUTCDate(K.getUTCDate()+42);K=K.valueOf();var L=false;this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML='';while(I.valueOf()<K){var M='';if(I.getUTCDay()===this.weekStart){if(L){this.picker().select('>.datepicker-days tbody',true).first().createChild(L);}
@@ -268,7 +268,7 @@ this.showMode(-1);this.fill();}break;case 'td':if(C.indexOf('day')!==-1&&C.index
 this.date=this.UTCDate(G,I,H,0,0,0,0);this.viewDate=this.UTCDate(G,I,Math.min(28,H),0,0,0,0);this.fill();this.setValue(this.formatDate(this.date));this.hide();}break;}},setStartDate:function(A){this.startDate=A||-Infinity;if(this.startDate!==-Infinity){this.startDate=this.parseDate(this.startDate);}
 this.update();this.updateNavArrows();},setEndDate:function(A){this.endDate=A||Infinity;if(this.endDate!==Infinity){this.endDate=this.parseDate(this.endDate);}
 this.update();this.updateNavArrows();},setDaysOfWeekDisabled:function(A){this.daysOfWeekDisabled=A||[];if(typeof(this.daysOfWeekDisabled)!=='object'){this.daysOfWeekDisabled=this.daysOfWeekDisabled.split(/,\s*/);}
-this.daysOfWeekDisabled=this.daysOfWeekDisabled.map(function(d){return parseInt(d,10);});this.update();this.updateNavArrows();},updateNavArrows:function(){var d=new Date(this.viewDate),A=d.getUTCFullYear(),B=d.getUTCMonth();Roo.each(this.picker().select('.prev',true).elements,function(v){v.show();switch(this.viewMode){case 0:if(this.startDate!==-Infinity&&A<=this.startDate.getUTCFullYear()&&B<=this.startDate.getUTCMonth()){v.hide();}break;case 1:case 2:if(this.startDate!==-Infinity&&A<=this.startDate.getUTCFullYear()){v.hide();}break;}});Roo.each(this.picker().select('.next',true).elements,function(v){v.show();switch(this.viewMode){case 0:if(this.endDate!==Infinity&&A>=this.endDate.getUTCFullYear()&&B>=this.endDate.getUTCMonth()){v.hide();}break;case 1:case 2:if(this.endDate!==Infinity&&A>=this.endDate.getUTCFullYear()){v.hide();}break;}})},moveMonth:function(A,B){if(!B)return A;var C=new Date(A.valueOf()),D=C.getUTCDate(),E=C.getUTCMonth(),F=Math.abs(B),G,H;B=B>0?1:-1;if(F==1){H=B==-1?function(){return C.getUTCMonth()==E;}:function(){return C.getUTCMonth()!=G;};G=E+B;C.setUTCMonth(G);if(G<0||G>11)G=(G+12)%12;}else {for(var i=0;i<F;i++)C=this.moveMonth(C,B);G=C.getUTCMonth();C.setUTCDate(D);H=function(){return G!=C.getUTCMonth();};}while(H()){C.setUTCDate(--D);C.setUTCMonth(G);}return C;},moveYear:function(A,B){return this.moveMonth(A,B*12);},dateWithinRange:function(A){return A>=this.startDate&&A<=this.endDate;},remove:function(){this.picker().remove();},onIncrementHours:function(){this.time.add(Date.HOUR,1);this.updateTime();},onDecrementHours:function(){this.time.add(Date.HOUR,-1);this.updateTime();},onIncrementMinutes:function(){this.time.add(Date.MINUTE,1);this.updateTime();},onDecrementMinutes:function(){this.time.add(Date.MINUTE,-1);this.updateTime();},onTogglePeriod:function(){Roo.log('this!!!!!!!!!!!!!!!!!!!');Roo.log(this);var h=12;if(this.time.format('A')==='PM'){h=-12;}
+this.daysOfWeekDisabled=this.daysOfWeekDisabled.map(function(d){return parseInt(d,10);});this.update();this.updateNavArrows();},updateNavArrows:function(){var d=new Date(this.viewDate),A=d.getUTCFullYear(),B=d.getUTCMonth();Roo.each(this.picker().select('.prev',true).elements,function(v){v.show();switch(this.viewMode){case 0:if(this.startDate!==-Infinity&&A<=this.startDate.getUTCFullYear()&&B<=this.startDate.getUTCMonth()){v.hide();}break;case 1:case 2:if(this.startDate!==-Infinity&&A<=this.startDate.getUTCFullYear()){v.hide();}break;}});Roo.each(this.picker().select('.next',true).elements,function(v){v.show();switch(this.viewMode){case 0:if(this.endDate!==Infinity&&A>=this.endDate.getUTCFullYear()&&B>=this.endDate.getUTCMonth()){v.hide();}break;case 1:case 2:if(this.endDate!==Infinity&&A>=this.endDate.getUTCFullYear()){v.hide();}break;}})},moveMonth:function(A,B){if(!B)return A;var C=new Date(A.valueOf()),D=C.getUTCDate(),E=C.getUTCMonth(),F=Math.abs(B),G,H;B=B>0?1:-1;if(F==1){H=B==-1?function(){return C.getUTCMonth()==E;}:function(){return C.getUTCMonth()!=G;};G=E+B;C.setUTCMonth(G);if(G<0||G>11)G=(G+12)%12;}else {for(var i=0;i<F;i++)C=this.moveMonth(C,B);G=C.getUTCMonth();C.setUTCDate(D);H=function(){return G!=C.getUTCMonth();};}while(H()){C.setUTCDate(--D);C.setUTCMonth(G);}return C;},moveYear:function(A,B){return this.moveMonth(A,B*12);},dateWithinRange:function(A){return A>=this.startDate&&A<=this.endDate;},remove:function(){this.picker().remove();},onIncrementHours:function(){this.time.add(Date.HOUR,1);this.updateTime();},onDecrementHours:function(){this.time.add(Date.HOUR,-1);this.updateTime();},onIncrementMinutes:function(){this.time.add(Date.MINUTE,1);this.updateTime();},onDecrementMinutes:function(){this.time.add(Date.MINUTE,-1);this.updateTime();},onTogglePeriod:function(){var h=12;if(this.time.format('A')==='PM'){h=-12;}
 this.time.add(Date.HOUR,h);this.updateTime();}});Roo.apply(Roo.bootstrap.DateField,{head:{tag:'thead',cn:[{tag:'tr',cn:[{tag:'th',cls:'prev',html:'<i class="icon-arrow-left"/>'},{tag:'th',cls:'switch',colspan:'5'},{tag:'th',cls:'next',html:'<i class="icon-arrow-right"/>'}]}]},content:{tag:'tbody',cn:[{tag:'tr',cn:[{tag:'td',colspan:'7'}]}]},footer:{tag:'tfoot',cn:[{tag:'tr',cn:[{tag:'th',colspan:'7',cls:'',cn:[{tag:'span',cls:'picker-switch-icon glyphicon'}]}]}]},dates:{en:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],today:"Today"}},modes:[{clsName:'time',navFnc:'Time',navStep:0},{clsName:'days',navFnc:'Month',navStep:1},{clsName:'months',navFnc:'FullYear',navStep:1},{clsName:'years',navFnc:'FullYear',navStep:10}]});Roo.apply(Roo.bootstrap.DateField,{template:{tag:'div',cls:'datepicker dropdown-menu',cn:[{tag:'div',cls:'datepicker-days',cn:[{tag:'table',cls:'table-condensed',cn:[Roo.bootstrap.DateField.head,{tag:'tbody'},Roo.bootstrap.DateField.footer]}]},{tag:'div',cls:'datepicker-months',cn:[{tag:'table',cls:'table-condensed',cn:[Roo.bootstrap.DateField.head,Roo.bootstrap.DateField.content]}]},{tag:'div',cls:'datepicker-years',cn:[{tag:'table',cls:'table-condensed',cn:[Roo.bootstrap.DateField.head,Roo.bootstrap.DateField.content]}]},{tag:'div',cls:'datepicker-time',cn:[{tag:'table',cls:'table-condensed',cn:[Roo.bootstrap.DateField.content,Roo.bootstrap.DateField.footer]}]}]}});
 //Roo/bootstrap/CheckBox.js
 Roo.bootstrap.CheckBox=function(A){Roo.bootstrap.CheckBox.superclass.constructor.call(this,A);this.addEvents({check:true});};Roo.extend(Roo.bootstrap.CheckBox,Roo.bootstrap.Input,{inputType:'checkbox',value:1,valueOff:0,boxLabel:false,checked:false,getAutoCreate:function(){var A=(!this.labelAlign)?this.parentLabelAlign():this.labelAlign;var id=Roo.id();var B={};B.cls='form-group'var C={tag:'input',id:id,type:this.inputType,value:(!this.checked)?this.valueOff:this.value,cls:'form-box',placeholder:this.placeholder||''};if(this.disabled){C.disabled=true;}if(this.checked){C.checked=this.checked;}if(this.name){C.name=this.name;}if(this.size){C.cls+=' input-'+this.size;}var D=this;['xs','sm','md','lg'].map(function(F){if(D[F]){B.cls+=' col-'+F+'-'+D[F];}});var E=C;if(this.before||this.after){E={cls:'input-group',cn:[]};if(this.before){E.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}