Timepicker: fix highlight minutes & parse hour

- fix highlight minutes when typing in the hour, fixes #1928
- parse hour when a column gets typed
This commit is contained in:
Felix Niklas 2018-04-12 12:18:23 +02:00
parent ec905e160f
commit d0202d73d3

View file

@ -238,16 +238,29 @@
this.update(); this.update();
break; break;
case 8: // backspace - ignore case 8: // backspace - ignore
this.highlightedUnit = null;
break;
case 186: // colon
// value is "5" or "10" and a ":" was typed -> turn into 05:00 or 10:00 with 00 selected
if(this.$element.val().length <= 2){
this.setTime(this.$element.val(), undefined, true);
this.$element.val(this.getTime());
this.highlightMinute();
e.preventDefault();
}
if(this.highlightedUnit == 'hour'){
setTimeout($.proxy(this.highlightNextUnit, this), 0);
e.preventDefault();
}
break; break;
default: default:
// all other keys // all other keys
// if cursor position is at the end of hour, jump to minute // if cursor position is at the end of hour, jump to minute
switch (this.getCursorPosition()) { switch (this.getCursorPosition()) {
case 1: case 1:
this.highlightMinute(); // highlight minutes but async because the newly typed character is not yet stored in the value (happens after this event)
setTimeout($.proxy(this.highlightMinute, this), 0);
break; break;
case 3:
} }
} }
}, },