2011-07-29 18:48:43 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
2011-05-16 10:49:48 +00:00
|
|
|
/*@
|
|
|
|
Ox.DateTimeInput <f:Ox.Element> DateTimeInput Element
|
|
|
|
() -> <f> DateTimeInput Element
|
|
|
|
(options) -> <f> DateTimeInput Element
|
|
|
|
(options, self) -> <f> DateTimeInput Element
|
|
|
|
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-06-19 17:48:32 +00:00
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
ampm: false,
|
|
|
|
format: 'short',
|
|
|
|
seconds: false,
|
|
|
|
value: Ox.formatDate(new Date(), '%F %T'),
|
|
|
|
weekday: false
|
|
|
|
})
|
|
|
|
.options(options || {});
|
|
|
|
|
|
|
|
self.values = self.options.value.split(' ');
|
2011-11-04 15:54:28 +00:00
|
|
|
//Ox.Log('Form', self.values)
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
that = Ox.InputGroup({
|
2011-04-22 22:03:10 +00:00
|
|
|
inputs: [
|
2011-06-19 17:48:32 +00:00
|
|
|
Ox.DateInput({
|
2011-04-22 22:03:10 +00:00
|
|
|
format: self.options.format,
|
|
|
|
id: 'date',
|
|
|
|
value: self.values[0],
|
|
|
|
weekday: self.options.weekday
|
|
|
|
}),
|
2011-06-19 17:48:32 +00:00
|
|
|
Ox.TimeInput({
|
2011-04-22 22:03:10 +00:00
|
|
|
ampm: self.options.ampm,
|
|
|
|
id: 'time',
|
|
|
|
value: self.values[1],
|
|
|
|
seconds: self.options.seconds
|
|
|
|
})
|
|
|
|
],
|
|
|
|
separators: [
|
|
|
|
{title: '', width: 8}
|
|
|
|
],
|
|
|
|
value: self.options.value
|
|
|
|
})
|
|
|
|
.bindEvent('change', setValue);
|
|
|
|
|
|
|
|
function setValue() {
|
|
|
|
self.options.value = [
|
|
|
|
self.options('inputs')[0].options('value'),
|
|
|
|
self.options('inputs')[1].options('value')
|
|
|
|
].join(' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|