diff --git a/jquery.timepicker.css b/jquery.timepicker.css index 6dc1066..04593ec 100644 --- a/jquery.timepicker.css +++ b/jquery.timepicker.css @@ -59,6 +59,12 @@ font-weight: normal; color: #212121; } +.ui-timepicker-standard .ui-state-active { + /* overwrites .ui-state-active */ + background: #03a9f4; + color: #fff; + font-weight: normal; +} .ui-timepicker-standard .ui-menu-item { /* overwrites .ui-menu and .ui-menu-item */ /*clear: left; diff --git a/jquery.timepicker.js b/jquery.timepicker.js index fedcafe..df0203d 100644 --- a/jquery.timepicker.js +++ b/jquery.timepicker.js @@ -160,7 +160,7 @@ _hasScroll: function() { // fix for jQuery 1.6 new prop method var m = typeof this.ui.prop !== 'undefined' ? 'prop' : 'attr'; - return this.ui.height() < this.ui[m]('scrollHeight'); + return this.ui.height() < this.viewport[m]('scrollHeight'); }, /** @@ -281,6 +281,8 @@ select: function(i, item) { var widget = this, instance = i === false ? widget.instance : i; + item.parent().find('a.ui-state-active').removeClass('ui-state-active'); // Clear select class from all + item.children('a').addClass('ui-state-active'); // Set select class widget.setTime(instance, $.fn.timepicker.parseTime(item.children('a').text())); widget.close(instance, true); }, @@ -294,20 +296,20 @@ widget.deactivate(); } - if (widget._hasScroll()) { + /* if (widget._hasScroll()) { var offset = item.offset().top - widget.ui.offset().top, - scroll = widget.ui.scrollTop(), - height = widget.ui.height(); + scroll = 0, //widget.ui.scrollTop(), + height = widget.ui.height()/2; if (offset < 0) { - widget.ui.scrollTop(scroll + offset); + widget.viewport.scrollTop(scroll + offset); } else if (offset >= height) { - widget.ui.scrollTop(scroll + offset - height + item.height()); + widget.viewport.scrollTop(scroll + offset - height + item.height()); } - } + } */ widget.active = item.eq(0).children('a').addClass('ui-state-hover') .attr('id', 'ui-active-item') - .end(); + .end(); }, deactivate: function() { @@ -488,7 +490,17 @@ } if (time.getTime() === selectedTime.getTime()) { + //widget.select(i, item); + item.children('a').addClass('ui-state-active'); widget.activate(i, item); + + if (i.options.dynamic == false && widget._hasScroll()) { + var offset = item.offset().top - widget.viewport.offset().top, + scroll = widget.viewport.scrollTop(), + height = (widget.viewport.height() - item.height())/2; + widget.viewport.scrollTop(scroll + offset - height); + } + return false; } return true; @@ -497,6 +509,10 @@ widget.deactivate(i); } + if ($.isFunction(i.options.open)) { + i.options.open.apply(i.element); + } + // don't break the chain return i.element; }, @@ -512,6 +528,10 @@ $(document).unbind('click.timepicker-' + i.element.data('timepicker-event-namespace')); + if ($.isFunction(i.options.close)) { + i.options.close.apply(i.element); + } + return i.element; }, @@ -643,6 +663,8 @@ dropdown: true, scrollbar: false, // callbacks + open: function(/*time*/) {}, + close: function(/*time*/) {}, change: function(/*time*/) {} };