[Rt-commit] rt branch, 4.4/reset-datetimepicker-time, created. rt-4.4.4-6-g26bf392d8

? sunnavy sunnavy at bestpractical.com
Wed Mar 13 15:03:04 EDT 2019


The branch, 4.4/reset-datetimepicker-time has been created
        at  26bf392d817288ec5231894acce4af9929ae807d (commit)

- Log -----------------------------------------------------------------
commit 26bf392d817288ec5231894acce4af9929ae807d
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 14 02:47:20 2019 +0800

    Reset time part after date input is cleared
    
    Once a date input is cleared, the datetimepicker UI reset the date part,
    but sadly not the time part.  This commit resets the time part too, via
    an official callback(beforeShow) so we don't need to touch original js.
    
    Once the js lib fixes this issue, we can revert this commit.

diff --git a/share/static/js/util.js b/share/static/js/util.js
index d5bf84562..d41844fc5 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -251,7 +251,17 @@ jQuery(function() {
         hourGrid: 6,
         minuteGrid: 15,
         showSecond: false,
-        timeFormat: 'HH:mm:ss'
+        timeFormat: 'HH:mm:ss',
+        // datetimepicker doesn't reset time part when input value is cleared,
+        // so we reset it here
+        beforeShow: function(input, dp, tp) {
+            if ( jQuery(this).val() == '' ) {
+                tp.hour = tp._defaults.hour || 0;
+                tp.minute = tp._defaults.minute || 0;
+                tp.second = tp._defaults.second || 0;
+                tp.millisec = tp._defaults.millisec || 0;
+            }
+        }
     }) ).each(function(index, el) {
         var tp = jQuery.datepicker._get( jQuery.datepicker._getInst(el), 'timepicker');
         if (!tp) return;

-----------------------------------------------------------------------


More information about the rt-commit mailing list