From 70438ed936090beba3367994f987e482bbaca393 Mon Sep 17 00:00:00 2001 From: leon Date: Thu, 23 Feb 2023 15:56:23 +0800 Subject: [PATCH] Roo/bootstrap/form/TimeField.js roojs-bootstrap.js roojs-bootstrap-debug.js --- Roo/bootstrap/form/TimeField.js | 2 ++ roojs-bootstrap-debug.js | 9 ++++----- roojs-bootstrap.js | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Roo/bootstrap/form/TimeField.js b/Roo/bootstrap/form/TimeField.js index 8c392744a3..93d87f9d0c 100644 --- a/Roo/bootstrap/form/TimeField.js +++ b/Roo/bootstrap/form/TimeField.js @@ -283,7 +283,9 @@ Roo.extend(Roo.bootstrap.form.TimeField, Roo.bootstrap.form.Input, { if(typeof(this.time) === 'undefined') { this.time = new Date(); + Roo.log(this.time); this.time = this.time.add(Date.MINUTE, Math.round(parseInt(this.time.format('i')) / this.minuteStep) * this.minuteStep - parseInt(this.time.format('i'))); + Roo.log(this.time); } this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 6a464503f4..be333a5d79 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -24212,11 +24212,10 @@ Roo.extend(Roo.bootstrap.form.TimeField, Roo.bootstrap.form.Input, { { if(typeof(this.time) === 'undefined') { - var now = new Date(); - var oldMinute = parseInt(now.format('i')); - var newMinute = Math.round(parseInt(now.format('i')) / this.minuteStep) * this.minuteStep; - Roo.log(oldMinute); - Roo.log(newMinute); + this.time = new Date(); + Roo.log(this.time); + this.time = this.time.add(Date.MINUTE, Math.round(parseInt(this.time.format('i')) / this.minuteStep) * this.minuteStep - parseInt(this.time.format('i'))); + Roo.log(this.time); } this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 0b7226719b..c1363ee8c4 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1026,10 +1026,10 @@ this.pop.select('.minutes-down',true).first().on('click',this.onDecrementMinutes e.preventDefault();},picker:function(){return this.pickerEl;},fillTime:function(){var A=this.pop.select('tbody',true).first();A.dom.innerHTML='';A.createChild({tag:'tr',cn:[{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'i',cls:'hours-up fa fas fa-chevron-up'} ]}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'i',cls:'minutes-up fa fas fa-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',html:'AM'}]}]});A.createChild({tag:'tr',cn:[{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'hours-down fa fas fa-chevron-down'} -]}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'minutes-down fa fas fa-chevron-down'}]}]},{tag:'td',cls:'separator'}]});},update:function(){if(typeof(this.time)==='undefined'){var A=new Date();var B=parseInt(A.format('i')); -var C=Math.round(parseInt(A.format('i'))/this.minuteStep)*this.minuteStep;Roo.log(B);Roo.log(C);}this.time=(typeof(this.time)==='undefined')?new Date():this.time;this.fill();},fill:function(){var A=this.time.getHours();var B=this.time.getMinutes();var C='AM'; -if(A>11){C='PM';}if(A==0){A=12;}if(A>12){A=A-12;}if(A<10){A='0'+A;}if(B<10){B='0'+B;}this.pop.select('.timepicker-hour',true).first().dom.innerHTML=A;this.pop.select('.timepicker-minute',true).first().dom.innerHTML=B;this.pop.select('button',true).first().dom.innerHTML=C; -},place:function(){this.picker().removeClass(['bottom-left','bottom-right','top-left','top-right']);var A=['bottom'];if((Roo.lib.Dom.getViewHeight()+Roo.get(document.body).getScroll().top)-(this.inputEl().getBottom()+this.picker().getHeight())<0){A.pop(); +]}]},{tag:'td',cls:'separator'},{tag:'td',cn:[{tag:'a',href:'#',cls:'btn',cn:[{tag:'span',cls:'minutes-down fa fas fa-chevron-down'}]}]},{tag:'td',cls:'separator'}]});},update:function(){if(typeof(this.time)==='undefined'){this.time=new Date();Roo.log(this.time); +this.time=this.time.add(Date.MINUTE,Math.round(parseInt(this.time.format('i'))/this.minuteStep)*this.minuteStep-parseInt(this.time.format('i')));Roo.log(this.time);}this.time=(typeof(this.time)==='undefined')?new Date():this.time;this.fill();},fill:function(){var A=this.time.getHours(); +var B=this.time.getMinutes();var C='AM';if(A>11){C='PM';}if(A==0){A=12;}if(A>12){A=A-12;}if(A<10){A='0'+A;}if(B<10){B='0'+B;}this.pop.select('.timepicker-hour',true).first().dom.innerHTML=A;this.pop.select('.timepicker-minute',true).first().dom.innerHTML=B; +this.pop.select('button',true).first().dom.innerHTML=C;},place:function(){this.picker().removeClass(['bottom-left','bottom-right','top-left','top-right']);var A=['bottom'];if((Roo.lib.Dom.getViewHeight()+Roo.get(document.body).getScroll().top)-(this.inputEl().getBottom()+this.picker().getHeight())<0){A.pop(); A.push('top');}A.push('right');if((Roo.lib.Dom.getViewWidth()+Roo.get(document.body).getScroll().left)-(this.inputEl().getLeft()+this.picker().getWidth())<0){A.pop();A.push('left');}this.picker().addClass(A.join('-'));var B=this;Roo.each(A,function(c){if(c=='bottom'){(function(){} ).defer(200);B.picker().alignTo(B.inputEl(),"tr-br",[0,10],false);return;}if(c=='top'){B.picker().alignTo(B.inputEl(),"br-tr",[0,10],false);return;}});},onFocus:function(){Roo.bootstrap.form.TimeField.superclass.onFocus.call(this);this.show();},onBlur:function(){Roo.bootstrap.form.TimeField.superclass.onBlur.call(this); this.hide();},show:function(){this.picker().show();this.pop.show();this.update();this.place();this.fireEvent('show',this,this.date);},hide:function(){this.picker().hide();this.pop.hide();this.fireEvent('hide',this,this.date);},setTime:function(){this.hide(); -- 2.39.2