DateInput/TimeInput/DateTimeInput: don't fail when options are undefined

This commit is contained in:
rolux 2012-06-14 15:50:00 +02:00
parent 91ee1419aa
commit 6bdf96fe6b
3 changed files with 10 additions and 11 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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,