changeset 651:f4fef1d3a2ce

Changed numberfield to spinner in datepicker to allow leading zeros.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 18 Mar 2015 14:44:19 +0100
parents 67963fcb7739
children 05e4ad93d021
files app/view/widget/base/DateTimePicker.js
diffstat 1 files changed, 54 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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

http://lada.wald.intevation.org