Skip to content

Commit

Permalink
Improved selection of grayed-out values, now they change the current …
Browse files Browse the repository at this point in the history
…month and select the corresponding day
  • Loading branch information
biohzrdmx committed Sep 29, 2014
1 parent 4906a21 commit 43394a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions js/jquery.datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,29 @@
e.preventDefault();
var el = $(this),
calendar = el.closest('.calendar');
if ( el.hasClass('blank') || el.hasClass('grayed') ) {
if ( el.hasClass('blank') ) {
return;
}
//
calendar.find('.selected').removeClass('selected');
el.addClass('selected');
//
selected.day = parseInt( el.text() ) || 1;
if ( el.hasClass('grayed') ) {
if ( el.hasClass('prev') ) {
selected.year -= selected.month == 0 ? 1 : 0;
selected.month = selected.month > 0 ? selected.month - 1 : 11;
} else if ( el.hasClass('next') ) {
selected.year += selected.month == 11 ? 1 : 0;
selected.month = selected.month < 11 ? selected.month + 1 : 0;
}
}
date.setDate(selected.day);
date.setMonth(selected.month);
date.setYear(selected.year);
var formatted = opts.formatDate(date);
$(opts.element).val(formatted);
if (opts.closeOnPick) {
if ( opts.closeOnPick && !el.hasClass('grayed') ) {
$.datePicker.hide();
}
});
Expand Down
Loading

0 comments on commit 43394a6

Please sign in to comment.