Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minDate parameter #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion css/datepicker/clean.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ tbody.datepickerDays td.datepickerSelected {
}

/* Grey out dates in the future */
div.datepicker td.datepickerFuture a {
div.datepicker td.datepickerFuture a, div.datepicker td.datepickerMinDate a{
color:#DDDDDD;
}

Expand Down
13 changes: 11 additions & 2 deletions js/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
* The day that starts the week, where 0: Sunday, 1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday. Defaults to Sunday
*/
starts: 0,
/**
* Specify a minimum date
*/
minDate :null,
/**
* Previous link text. Default '◀' (Unicode left arrow)
*/
Expand Down Expand Up @@ -343,6 +347,11 @@
if (today.getDate() == date.getDate() && today.getMonth() == date.getMonth() && today.getYear() == date.getYear()) {
data.weeks[indic].days[indic2].classname.push('datepickerToday');
}

if (date < options.minDate) {
data.weeks[indic].days[indic2].classname.push('datepickerMinDate');
}

if (date > today) {
// current month, date in future
data.weeks[indic].days[indic2].classname.push('datepickerFuture');
Expand Down Expand Up @@ -526,7 +535,7 @@
fillIt = true;
}

} else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
} else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled') && !parentEl.hasClass('datepickerMinDate') ) {
// clicking the calendar grid

if(tblEl.eq(0).hasClass('datepickerViewMonths')) {
Expand Down Expand Up @@ -1024,4 +1033,4 @@
return data ? fn( data ) : fn;
};

})(jQuery);
})(jQuery);