Added support for min/max date range
authorAlexander Ebert <ebert@woltlab.com>
Fri, 15 Jul 2016 13:49:28 +0000 (15:49 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 16 Jul 2016 11:42:56 +0000 (13:42 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js

index 928f4b118a5bfd7ecaa5b54c11d3081a22922d8e..772d942acaa24aff45804672ada3571c54e41bb5 100644 (file)
@@ -77,6 +77,10 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                                        elData(element, 'min-date', '100');
                                        elData(element, 'max-date', 'now');
                                }
+                               else {
+                                       if (element.min) elData(element, 'min-date', element.min);
+                                       if (element.max) elData(element, 'max-date', element.max);
+                               }
                                
                                this._initDateRange(element, now, true);
                                this._initDateRange(element, now, false);
@@ -199,6 +203,9 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment
                                        throw new Error("Reference date picker identified by '" + value + "' does not exists (element id: '" + element.id + "').");
                                }
                        }
+                       else if (/^\d{4}\-\d{2}\-\d{2}T/.test(value)) {
+                               value = new Date(value).getTime();
+                       }
                        else {
                                value = new Date((isMinDate ? 1970 : 2038), 0, 1).getTime();
                        }