9 * @class Roo.bootstrap.TimeField
10 * @extends Roo.bootstrap.Input
11 * Bootstrap DateField class
15 * Create a new TimeField
16 * @param {Object} config The config object
19 Roo.bootstrap.TimeField = function(config){
20 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
23 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
26 * @cfg {String} format
27 * The default time format string which can be overriden for localization support. The format must be
28 * valid according to {@link Date#parseDate} (defaults to 'H:i').
32 onRender: function(ct, position)
35 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
37 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
39 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
41 this.pop = this.picker().select('>.datepicker-time',true).first();
42 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block'
44 this.picker().on('mousedown', this.onMousedown, this);
46 this.picker().addClass('datepicker-dropdown');
51 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
52 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
53 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
54 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
55 this.pop.select('button', true).first().on('click', this.onTogglePeriod, this);
61 return this.el.select('.datepicker', true).first();
66 var time = this.pop.select('tbody', true).first();
68 time.dom.innerHTML = '';
83 cls: 'hours-up glyphicon glyphicon-chevron-up'
103 cls: 'minutes-up glyphicon glyphicon-chevron-up'
124 cls: 'timepicker-hour',
139 cls: 'timepicker-minute',
154 cls: 'btn btn-primary',
176 cls: 'hours-down glyphicon glyphicon-chevron-down'
196 cls: 'minutes-down glyphicon glyphicon-chevron-down'
214 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
221 var hours = this.time.getHours();
222 var minutes = this.time.getMinutes();
243 minutes = '0' + minutes;
246 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
247 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
248 this.pop.select('button', true).first().dom.innerHTML = period;
254 this.picker().removeClass(['bottom', 'top']);
256 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
258 * place to the top of element!
262 this.picker().addClass('top');
263 this.picker().setTop(0 - this.picker().getHeight()).setLeft(this.inputEl().getLeft() - this.el.getLeft());
268 this.picker().addClass('bottom');
270 this.picker().setTop(this.inputEl().getHeight()).setLeft(this.inputEl().getLeft() - this.el.getLeft());
275 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
281 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
287 this.picker().show();
295 this.picker().hide();
303 this.setValue(this.time.format(this.format));
306 onMousedown: function(e){
311 onIncrementHours: function()
313 Roo.log('onIncrementHours');
314 this.time = this.time.add(Date.HOUR, 1);
319 onDecrementHours: function()
321 Roo.log('onDecrementHours');
322 this.time = this.time.add(Date.HOUR, -1);
326 onIncrementMinutes: function()
328 Roo.log('onIncrementMinutes');
329 this.time = this.time.add(Date.MINUTE, 1);
333 onDecrementMinutes: function()
335 Roo.log('onDecrementMinutes');
336 this.time = this.time.add(Date.MINUTE, -1);
340 onTogglePeriod: function()
342 Roo.log('onTogglePeriod');
343 this.time = this.time.add(Date.HOUR, 12);
350 Roo.apply(Roo.bootstrap.TimeField, {
392 Roo.apply(Roo.bootstrap.TimeField, {
396 cls: 'datepicker dropdown-menu',
400 cls: 'datepicker-time',
404 cls: 'table-condensed',
406 Roo.bootstrap.TimeField.content,
407 Roo.bootstrap.TimeField.footer