2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
2012-05-21 10:38:18 +00:00
|
|
|
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
2012-05-22 13:14:40 +00:00
|
|
|
Ox.DateTimeInput <f:Ox.InputGroup> DateTimeInput Element
|
|
|
|
([options[, self]]) -> <o> DateTimeInput Element
|
2011-05-16 10:49:48 +00:00
|
|
|
options <o> Options object
|
|
|
|
ampm <b|false> false is 24h true is am/pm
|
|
|
|
format <s|short> options are short, medium, long
|
|
|
|
seconds <b|false> show seconds
|
|
|
|
value <d> defautls to now
|
|
|
|
weekday <b|false> weekday
|
|
|
|
self <o> Shared private variable
|
2011-11-03 15:42:41 +00:00
|
|
|
change <!> triggered on change of value
|
2011-05-16 10:49:48 +00:00
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.DateTimeInput = function(options, self) {
|
|
|
|
|
2011-12-21 13:42:47 +00:00
|
|
|
var that;
|
|
|
|
self = Ox.extend(self || {}, {
|
|
|
|
options: Ox.extend({
|
|
|
|
ampm: false,
|
|
|
|
format: 'short',
|
|
|
|
milliseconds: false,
|
|
|
|
seconds: false,
|
|
|
|
value: (function() {
|
|
|
|
var date = new Date();
|
|
|
|
return Ox.formatDate(
|
|
|
|
date,
|
|
|
|
'%F ' + (options.seconds || options.milliseconds ? '%T' : '%H:%M')
|
|
|
|
) + (options.milliseconds ? '.' + Ox.pad(date % 1000, 3) : '');
|
|
|
|
}()),
|
|
|
|
weekday: false
|
|
|
|
}, options || {})
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-12-21 13:42:47 +00:00
|
|
|
self.options.seconds = self.options.seconds || self.options.milliseconds;
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
that = Ox.InputGroup({
|
2011-12-21 13:42:47 +00:00
|
|
|
inputs: [
|
|
|
|
Ox.DateInput({
|
|
|
|
format: self.options.format,
|
|
|
|
id: 'date',
|
|
|
|
weekday: self.options.weekday
|
|
|
|
}),
|
|
|
|
Ox.TimeInput({
|
|
|
|
ampm: self.options.ampm,
|
|
|
|
id: 'time',
|
|
|
|
seconds: self.options.seconds
|
|
|
|
})
|
|
|
|
],
|
|
|
|
join: join,
|
|
|
|
separators: [
|
|
|
|
{title: '', width: 8}
|
|
|
|
],
|
|
|
|
split: split,
|
|
|
|
value: self.options.value
|
|
|
|
}, self);
|
|
|
|
|
|
|
|
function join() {
|
|
|
|
return that.options('inputs').map(function($input) {
|
2011-12-21 15:33:52 +00:00
|
|
|
return $input.value();
|
2011-12-21 13:42:47 +00:00
|
|
|
}).join(' ');
|
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-12-21 13:42:47 +00:00
|
|
|
function split() {
|
|
|
|
return self.options.value.split(' ');
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|