From 954cafca62ddc9264fe1cf54a4e87e372d091f1c Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Wed, 8 Apr 2015 14:02:58 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js --- roojs-bootstrap-debug.js | 24 +++++++++++++++++------- roojs-bootstrap.js | 6 +++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 2c7b50fd0d..7d88b7250f 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -14800,7 +14800,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { return value; } var v = Date.parseDate(value, this.format); - if (!v && this.useIso) { + if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) { v = Date.parseDate(value, 'Y-m-d'); } if(!v && this.altFormats){ @@ -14871,8 +14871,14 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { setValue: function(v) { - var d = new Date(v).clearTime(); + // v can be a string or a date.. + + + var d = new Date(this.parseDate(v) ).clearTime(); + + Roo.log(d); + Roo.log(d); if(isNaN(d.getTime())){ this.date = this.viewDate = ''; Roo.bootstrap.DateField.superclass.setValue.call(this, ''); @@ -14998,6 +15004,7 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { var nodeName = target.nodeName; var className = target.className; var html = target.innerHTML; + //Roo.log(nodeName); switch(nodeName.toLowerCase()) { case 'th': @@ -15030,9 +15037,9 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { } break; case 'span': - if (className.indexOf('disabled') === -1) { + if (className.indexOf('disabled') < 0) { this.viewDate.setUTCDate(1); - if (className.indexOf('month') !== -1) { + if (className.indexOf('month') > -1) { this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html)); } else { var year = parseInt(html, 10) || 0; @@ -15045,19 +15052,20 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { break; case 'td': - if (className.indexOf('day') !== -1 && className.indexOf('disabled') === -1){ + //Roo.log(className); + if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){ var day = parseInt(html, 10) || 1; var year = this.viewDate.getUTCFullYear(), month = this.viewDate.getUTCMonth(); - if (className.indexOf('old') !== -1) { + if (className.indexOf('old') > -1) { if(month === 0 ){ month = 11; year -= 1; }else{ month -= 1; } - } else if (className.indexOf('new') !== -1) { + } else if (className.indexOf('new') > -1) { if (month == 11) { month = 0; year += 1; @@ -15065,9 +15073,11 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, { month += 1; } } + //Roo.log([year,month,day]); this.date = this.UTCDate(year, month, day,0,0,0,0); this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0); // this.fill(); + //Roo.log(this.formatDate(this.date)); this.setValue(this.formatDate(this.date)); this.hide(); } diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index a435bd1ca9..f318d9722f 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -334,10 +334,10 @@ L.cn.push({tag:'td',cls:'day '+M,html:I.getDate()}) I.setDate(I.getDate()+1);}var P=this.date&&this.date.getUTCFullYear();var Q=this.date&&this.date.getUTCMonth();this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML=A;Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements,function(v,k){v.removeClass('active');if(P===A&&k===Q){v.addClass('active');}if(AE||(A==C&&kF)){v.addClass('disabled');}});A=parseInt(A/10,10)*10;this.picker().select('>.datepicker-years th.switch',true).first().dom.innerHTML=A+'-'+(A+9);this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML='';A-=1;for(var i=-1;i<11;i++){this.picker().select('>.datepicker-years tbody td',true).first().createChild({tag:'span',cls:'year'+(i===-1||i===10?' old':'')+(P===A?' active':'')+(AE?' disabled':''),html:A}) A+=1;}},showMode:function(A){if(A){this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+A));} Roo.each(this.picker().select('>div',true).elements,function(v){v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay='block';v.hide();});this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName,true).first().show();},place:function(){if(this.isInline)return;this.picker().removeClass(['bottom','top']);if((Roo.lib.Dom.getViewHeight()+Roo.get(document.body).getScroll().top)-(this.inputEl().getBottom()+this.picker().getHeight())<0){this.picker().addClass('top');this.picker().setTop(this.inputEl().getTop()-this.picker().getHeight()).setLeft(this.inputEl().getLeft());return;} -this.picker().addClass('bottom');this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());},parseDate:function(A){if(!A||A instanceof Date){return A;}var v=Date.parseDate(A,this.format);if(!v&&this.useIso){v=Date.parseDate(A,'Y-m-d');}if(!v&&this.altFormats){if(!this.altFormatsArray){this.altFormatsArray=this.altFormats.split("|");}for(var i=0,B=this.altFormatsArray.length;i-1){this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(D));}else {var G=parseInt(D,10)||0;this.viewDate.setUTCFullYear(G);} +this.showMode(-1);this.fill();}break;case 'td':if(C.indexOf('day')>-1&&C.indexOf('disabled')<0){var H=parseInt(D,10)||1;var G=this.viewDate.getUTCFullYear(),I=this.viewDate.getUTCMonth();if(C.indexOf('old')>-1){if(I===0){I=11;G-=1;}else {I-=1;}}else if(C.indexOf('new')>-1){if(I==11){I=0;G+=1;}else {I+=1;}} 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.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*/);} -- 2.39.2