Fix navigation disabled states (#2277)

This commit is contained in:
Vasilii Artemchuk 2017-10-09 17:56:29 +03:00 committed by GitHub
parent ab62864e2f
commit fefb59cd1d
3 changed files with 15 additions and 9 deletions

View File

@ -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;
}

View File

@ -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 = $('<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');

View File

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="assets/qunit.css" />
<link rel="stylesheet" href="assets/qunit.css">
<script src="assets/qunit.js"></script>
<!-- console.log for test failures: enable locally if you need extra debug info-->
<!--<script src="assets/qunit-logging.js"></script>-->