From 6bdf96fe6b385b00f7043c565f52ed2cb32b1d1f Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 14 Jun 2012 15:50:00 +0200 Subject: [PATCH] DateInput/TimeInput/DateTimeInput: don't fail when options are undefined --- source/Ox.UI/js/Form/DateInput.js | 6 +++--- source/Ox.UI/js/Form/DateTimeInput.js | 11 +++++------ source/Ox.UI/js/Form/TimeInput.js | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/source/Ox.UI/js/Form/DateInput.js b/source/Ox.UI/js/Form/DateInput.js index a0198cf5..ca95edf1 100644 --- a/source/Ox.UI/js/Form/DateInput.js +++ b/source/Ox.UI/js/Form/DateInput.js @@ -25,8 +25,9 @@ Ox.DateInput = function(options, self) { weekday: false, width: { day: 32, - month: options.format == 'long' ? 80 : (options.format == 'medium' ? 40 : 32), - weekday: options.format == 'long' ? 80 : 40, + month: options && options.format == 'long' ? 80 + : options && options.format == 'medium' ? 40 : 32, + weekday: options && options.format == 'long' ? 80 : 40, year: 48 } }, options || {}) @@ -108,7 +109,6 @@ Ox.DateInput = function(options, self) { {title: '', width: 8}, {title: ',', width: 8} ]), split: split, - value: self.options.value, width: 0 }), self); diff --git a/source/Ox.UI/js/Form/DateTimeInput.js b/source/Ox.UI/js/Form/DateTimeInput.js index 1cf80eee..9069e1e1 100644 --- a/source/Ox.UI/js/Form/DateTimeInput.js +++ b/source/Ox.UI/js/Form/DateTimeInput.js @@ -26,8 +26,8 @@ Ox.DateTimeInput = function(options, self) { var date = new Date(); return Ox.formatDate( date, - '%F ' + (options.seconds || options.milliseconds ? '%T' : '%H:%M') - ) + (options.milliseconds ? '.' + Ox.pad(date % 1000, 3) : ''); + '%F ' + (options && (options.seconds || options.milliseconds) ? '%T' : '%H:%M') + ) + (options && options.milliseconds ? '.' + Ox.pad(date % 1000, 3) : ''); }()), weekday: false }, options || {}) @@ -35,7 +35,7 @@ Ox.DateTimeInput = function(options, self) { self.options.seconds = self.options.seconds || self.options.milliseconds; - that = Ox.InputGroup({ + that = Ox.InputGroup(Ox.extend(self.options, { inputs: [ Ox.DateInput({ format: self.options.format, @@ -52,9 +52,8 @@ Ox.DateTimeInput = function(options, self) { separators: [ {title: '', width: 8} ], - split: split, - value: self.options.value - }, self); + split: split + }), self); function join() { return that.options('inputs').map(function($input) { diff --git a/source/Ox.UI/js/Form/TimeInput.js b/source/Ox.UI/js/Form/TimeInput.js index 88714df8..46db6824 100644 --- a/source/Ox.UI/js/Form/TimeInput.js +++ b/source/Ox.UI/js/Form/TimeInput.js @@ -24,8 +24,8 @@ Ox.TimeInput = function(options, self) { var date = new Date(); return Ox.formatDate( date, - options.seconds || options.milliseconds ? '%T' : '%H:%M' - ) + (options.milliseconds ? '.' + Ox.pad(date % 1000, 3) : ''); + options && (options.seconds || options.milliseconds) ? '%T' : '%H:%M' + ) + (options && options.milliseconds ? '.' + Ox.pad(date % 1000, 3) : ''); }()), width: { hours: 32,