[Lada-commits] [PATCH] Changed numberfield to spinner in datepicker to allow leading zeros

Wald Commits scm-commit at wald.intevation.org
Wed Mar 18 14:43:26 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1426686259 -3600
# Node ID f4fef1d3a2cee39bb996a9e89ec9df01c27011c0
# Parent  67963fcb7739e0a0b4a5af1f3dfb817a7d1c44a7
Changed numberfield to spinner in datepicker to allow leading zeros.

diff -r 67963fcb7739 -r f4fef1d3a2ce app/view/widget/base/DateTimePicker.js
--- a/app/view/widget/base/DateTimePicker.js	Wed Mar 18 13:55:14 2015 +0100
+++ b/app/view/widget/base/DateTimePicker.js	Wed Mar 18 14:44:19 2015 +0100
@@ -94,26 +94,72 @@
 
     beforeRender: function () {
         var me = this;
-        me.hourField = new Ext.form.field.Number({
+        me.hourField = new Ext.form.field.Spinner({
             ownerCt: me,
             ownerLayout: me.getComponentLayout(),
             value: 0,
-            increment: 1,
-            minValue: 0,
-            maxValue: 23,
+            onSpinUp: function() {
+                var value = parseInt(this.getValue());
+                if (value === 23) {
+                    return;
+                }
+                var newValue = value + 1;
+                if (newValue < 10) {
+                    this.setValue('0' + newValue);
+                }
+                else {
+                    this.setValue(newValue);
+                }
+            },
+            onSpinDown: function() {
+                var value = parseInt(this.getValue());
+                if (value === 0) {
+                    return;
+                }
+                var newValue = value - 1;
+                if (newValue < 10) {
+                    this.setValue('0' + newValue);
+                }
+                else {
+                    this.setValue(newValue);
+                }
+            },
             listeners: {
                 change: me.changeTimeValue,
                 scope: me
             }
         });
 
-        me.minuteField = new Ext.form.field.Number({
+        me.minuteField = new Ext.form.field.Spinner({
             ownerCt: me,
             ownerLayout: me.getComponentLayout(),
             value: 0,
-            increment: 1,
-            minValue: 0,
-            maxValue: 59,
+            onSpinUp: function() {
+                var value = parseInt(this.getValue());
+                if (value === 59) {
+                    return;
+                }
+                var newValue = value + 1;
+                if (newValue < 10) {
+                    this.setValue('0' + newValue);
+                }
+                else {
+                    this.setValue(newValue);
+                }
+            },
+            onSpinDown: function() {
+                var value = parseInt(this.getValue());
+                if (value === 0) {
+                    return;
+                }
+                var newValue = value - 1;
+                if (newValue < 10) {
+                    this.setValue('0' + newValue);
+                }
+                else {
+                    this.setValue(newValue);
+                }
+            },
             listeners: {
                 change: me.changeTimeValue,
                 scope: me


More information about the Lada-commits mailing list