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);
45 this.picker().on('click', this.onClick, this);
47 this.picker().addClass('datepicker-dropdown');
52 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
53 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
54 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
55 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
56 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
57 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
62 Roo.log('Fire Key !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
64 if (!this.picker().isVisible()){
65 if (e.keyCode == 27) // allow escape to hide and re-show picker
88 onClick: function(e) {
95 return this.el.select('.datepicker', true).first();
100 var time = this.pop.select('tbody', true).first();
102 time.dom.innerHTML = '';
117 cls: 'hours-up glyphicon glyphicon-chevron-up'
137 cls: 'minutes-up glyphicon glyphicon-chevron-up'
158 cls: 'timepicker-hour',
173 cls: 'timepicker-minute',
188 cls: 'btn btn-primary period',
210 cls: 'hours-down glyphicon glyphicon-chevron-down'
230 cls: 'minutes-down glyphicon glyphicon-chevron-down'
248 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
255 var hours = this.time.getHours();
256 var minutes = this.time.getMinutes();
277 minutes = '0' + minutes;
280 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
281 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
282 this.pop.select('button', true).first().dom.innerHTML = period;
288 this.picker().removeClass(['bottom', 'top']);
290 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
292 * place to the top of element!
296 this.picker().addClass('top');
297 this.picker().setTop(0 - this.picker().getHeight()).setLeft(this.inputEl().getLeft() - this.el.getLeft());
302 this.picker().addClass('bottom');
304 this.picker().setTop(this.inputEl().getHeight()).setLeft(this.inputEl().getLeft() - this.el.getLeft());
309 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
315 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
321 this.picker().show();
329 this.picker().hide();
337 this.setValue(this.time.format(this.format));
340 onMousedown: function(e){
345 onIncrementHours: function()
347 Roo.log('onIncrementHours');
348 this.time = this.time.add(Date.HOUR, 1);
353 onDecrementHours: function()
355 Roo.log('onDecrementHours');
356 this.time = this.time.add(Date.HOUR, -1);
360 onIncrementMinutes: function()
362 Roo.log('onIncrementMinutes');
363 this.time = this.time.add(Date.MINUTE, 1);
367 onDecrementMinutes: function()
369 Roo.log('onDecrementMinutes');
370 this.time = this.time.add(Date.MINUTE, -1);
374 onTogglePeriod: function()
376 Roo.log('onTogglePeriod');
377 this.time = this.time.add(Date.HOUR, 12);
384 Roo.apply(Roo.bootstrap.TimeField, {
414 cls: 'btn btn-info ok',
426 Roo.apply(Roo.bootstrap.TimeField, {
430 cls: 'datepicker dropdown-menu',
434 cls: 'datepicker-time',
438 cls: 'table-condensed',
440 Roo.bootstrap.TimeField.content,
441 Roo.bootstrap.TimeField.footer