Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jquery.timepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
38 changes: 30 additions & 8 deletions jquery.timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},

/**
Expand Down Expand Up @@ -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);
},
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
},
Expand All @@ -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;
},

Expand Down Expand Up @@ -643,6 +663,8 @@
dropdown: true,
scrollbar: false,
// callbacks
open: function(/*time*/) {},
close: function(/*time*/) {},
change: function(/*time*/) {}
};

Expand Down