Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 02, 2012
@dnerdy Fixed the calulation of max when yearRange is given
The old method, new Date(2013, 1, -1), results in "Wed Jan 30 2013 00:00:00 GMT-0800 (PST)", for
example, when we really want new Date(2012, 11, 31), which is "Mon Dec 31 2012 00:00:00 GMT-0800 (PST)"
484b67c
@dnerdy Fixed monthSelector and yearSelector change event handlers
When setValue is called with year as a string (which just contains a year and not a full date) it
is erroneously parsed. .val() returns a string, so the value  must be cast to an integer before calling
setValue.
6f13a80
@dnerdy Fixed the yearSelector options to include the last year allowed by ye…
…arRange

The loop termination condition was off by 1
8256c99
@dnerdy Fixed pm (previous month) and nm (next month) so that they are only d…
…isabled when min or max

occurs in the current month being shown.
d66d211
Showing with 17 additions and 8 deletions.
  1. +17 −8 src/dateinput/dateinput.js
View
25 src/dateinput/dateinput.js
@@ -198,7 +198,7 @@
value = parseDate(value) || now;
min = parseDate(min || new Date(yearNow + conf.yearRange[0], 1, 1));
- max = parseDate(max || new Date( yearNow + conf.yearRange[1]+ 1, 1, -1));
+ max = parseDate(max || new Date(yearNow + conf.yearRange[1], 11, 31));
// check that language exists
@@ -420,12 +420,12 @@
// month selector
monthSelector.unbind("change").change(function() {
- self.setValue(yearSelector.val(), $(this).val());
+ self.setValue(parseInt(yearSelector.val()), parseInt($(this).val()));
});
// year selector
yearSelector.unbind("change").change(function() {
- self.setValue($(this).val(), monthSelector.val());
+ self.setValue(parseInt($(this).val()), parseInt(monthSelector.val()));
});
// prev / next month
@@ -531,7 +531,7 @@
yearSelector.empty();
var yearNow = now.getFullYear();
- for (var i = yearNow + conf.yearRange[0]; i < yearNow + conf.yearRange[1]; i++) {
+ for (var i = yearNow + conf.yearRange[0]; i < yearNow + conf.yearRange[1] + 1; i++) {
if (min < new Date(i + 1, 0, 1) && max > new Date(i, 0, 0)) {
yearSelector.append($("<option/>").text(i));
}
@@ -580,16 +580,25 @@
// today
} else if (isSameDay(now, date)) {
a.attr("id", css.today);
- }
+ }
+
+ // disabled
+ if (min && date < min) {
+ pm.addClass(css.disabled);
+ }
+
+ if (max && date > max) {
+ nm.addClass(css.disabled);
+ }
}
-
+
// disabled
if (min && date < min) {
- a.add(pm).addClass(css.disabled);
+ a.addClass(css.disabled);
}
if (max && date > max) {
- a.add(nm).addClass(css.disabled);
+ a.addClass(css.disabled);
}
a.attr("href", "#" + num).text(num).data("date", date);

No commit comments for this range

Something went wrong with that request. Please try again.