diff --git a/src/combodate.js b/src/combodate.js
index df0a8d4..e133b6d 100644
--- a/src/combodate.js
+++ b/src/combodate.js
@@ -23,26 +23,26 @@
var Combodate = function (element, options) {
this.$element = $(element);
- if(!this.$element.is('input')) {
+ if (!this.$element.is('input')) {
$.error('Combodate should be applied to INPUT element');
return;
}
this.options = $.extend({}, $.fn.combodate.defaults, options, this.$element.data());
this.init();
- };
+ };
Combodate.prototype = {
constructor: Combodate,
init: function () {
this.map = {
//key regexp moment.method
- day: ['D', 'date'],
- month: ['M', 'month'],
- year: ['Y', 'year'],
- hour: ['[Hh]', 'hours'],
- minute: ['m', 'minutes'],
- second: ['s', 'seconds'],
- ampm: ['[Aa]', '']
+ day: ['D', 'date'],
+ month: ['M', 'month'],
+ year: ['Y', 'year'],
+ hour: ['[Hh]', 'hours'],
+ minute: ['m', 'minutes'],
+ second: ['s', 'seconds'],
+ ampm: ['[Aa]', '']
};
this.$widget = $('').html(this.getTemplate());
@@ -53,7 +53,7 @@
this.datetime = null;
//update original input on change
- this.$widget.on('change', 'select', $.proxy(function(e) {
+ this.$widget.on('change', 'select', $.proxy(function (e) {
this.$element.val(this.getValue()).change();
// update days count if month or year changes
if (this.options.smartDays) {
@@ -66,7 +66,22 @@
this.$widget.find('select').css('width', 'auto');
// hide original input and insert widget
- this.$element.hide().after(this.$widget);
+ this.$element
+ .on('focus', $.proxy(function () {
+ this.$widget.find('select:first-child:not(:disabled)').focus();
+ }, this))
+ .css({
+ position: 'absolute',
+ width: '1px',
+ height: '1px',
+ padding: 0,
+ margin: '-1px',
+ overflow: 'hidden',
+ clip: 'rect(0,0,0,0)',
+ border: 0
+ })
+ .attr('tabindex', -1)
+ .after(this.$widget);
// set initial value
this.setValue(this.$element.val() || this.options.value);
@@ -75,30 +90,30 @@
/*
Replace tokens in template with