Skip to content

Commit

Permalink
Take input val into account, update on keystroke.
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbert committed May 1, 2012
1 parent b32dade commit 6512b2e
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions js/bootstrap-timepicker.js
Expand Up @@ -40,8 +40,9 @@
, listen: function () {
this.$element
.on('click', $.proxy(this.show, this))
.on('blur', $.proxy(this.blur, this));

.on('blur', $.proxy(this.blur, this))
.on('keyup', $.proxy(this.updateFromElementVal, this))
;
this.$widget.on('click', $.proxy(this.click, this));
}

Expand All @@ -56,6 +57,8 @@
, left: pos.left
})

this.updateFromElementVal();

this.$widget.show();
this.shown = true;
this.$element.trigger('shown');
Expand Down Expand Up @@ -118,19 +121,32 @@
return hour + ':' + minute + ' ' + meridian;
}

, setTime: function(input) {
, getTime: function() {
return this.formatTime(this.hour, this.minute, this.meridian);
}

, updateElement: function(input) {
this.$element.val(input);
}

, updateWidget: function(input) {
$('.bootstrap-timepicker td#timepickerHour').text(this.hour);
$('.bootstrap-timepicker td#timepickerMinute').text(this.minute < 10 ? '0' + this.minute : this.minute);
$('.bootstrap-timepicker td#timepickerMeridian').text(this.meridian);
}

, getTime: function() {
return this.formatTime(this.hour, this.minute, this.meridian);
, update: function() {
var time = this.getTime();
this.updateElement(time);
this.updateWidget(time);
}

, update: function() {
this.setTime(this.getTime());
, updateFromElementVal: function () {
var elemVal = this.$element.val();
if (elemVal) {
this.setValues(elemVal);
this.updateWidget();
}
}

, click: function(e) {
Expand Down

0 comments on commit 6512b2e

Please sign in to comment.