diff --git a/js/bootstrap-datepicker.js b/js/bootstrap-datepicker.js index d04dc62..51f0f1b 100644 --- a/js/bootstrap-datepicker.js +++ b/js/bootstrap-datepicker.js @@ -1154,10 +1154,6 @@ nextIsDisabled, factor = 1; switch (this.viewMode){ - case 0: - prevIsDisabled = year <= startYear && month <= startMonth; - nextIsDisabled = year >= endYear && month >= endMonth; - break; case 4: factor *= 10; /* falls through */ @@ -1168,8 +1164,12 @@ factor *= 10; /* falls through */ case 1: - prevIsDisabled = Math.floor(year / factor) * factor <= startYear; - nextIsDisabled = Math.floor(year / factor) * factor + factor >= endYear; + prevIsDisabled = Math.floor(year / factor) * factor < startYear; + nextIsDisabled = Math.floor(year / factor) * factor + factor > endYear; + break; + case 0: + prevIsDisabled = year <= startYear && month < startMonth; + nextIsDisabled = year >= endYear && month > endMonth; break; } diff --git a/tests/suites/options.js b/tests/suites/options.js index 2c90f77..5a22c9f 100644 --- a/tests/suites/options.js +++ b/tests/suites/options.js @@ -1626,13 +1626,13 @@ test('Nav arrow html templates .prev click', function () { equal(target.text(), '2011'); }); -test('Visibility of the prev and next arrows for decade/century/millenium views with startDate and endDate', function(){ +test('Visibility of the prev and next arrows for year/decade/century/millenium views with startDate and endDate', function(){ var input = $('') .appendTo('#qunit-fixture') .val('01/01/2015') .datepicker({ format: 'dd/mm/yyyy', - startView: 2, + startView: 1, startDate: '01/12/2014', endDate: '01/12/2016' }), @@ -1642,6 +1642,12 @@ test('Visibility of the prev and next arrows for decade/century/millenium views input.focus(); + target = picker.find('.datepicker-months thead th.prev'); + ok(!target.hasClass('disabled'), 'Prev switcher is not hidden'); + target = picker.find('.datepicker-months thead th.next'); + ok(!target.hasClass('disabled'), 'Next switcher is not hidden'); + + picker.find('.datepicker-months thead th.datepicker-switch').click(); target = picker.find('.datepicker-years thead th.prev'); ok(target.hasClass('disabled'), 'Prev switcher is hidden'); target = picker.find('.datepicker-years thead th.next'); diff --git a/tests/tests.html b/tests/tests.html index 2f4c6da..27fd150 100644 --- a/tests/tests.html +++ b/tests/tests.html @@ -2,7 +2,7 @@
- +