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

datepicker: add yearRangeReverse property sort year in reverse order #6521

Open
wants to merge 2 commits into
base: v1-dev
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
8 changes: 7 additions & 1 deletion jade/page-contents/pickers_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ <h5>Options</h5>
<td>10</td>
<td>Number of years either side, or array of upper/lower range.</td>
</tr>
<tr>
<td>yearRangeReverse</td>
<td>Boolean</td>
<td>false</td>
<td>Sort year range in reverse order</td>
</tr>
<tr>
<td>isRTL</td>
<td>Boolean</td>
Expand Down Expand Up @@ -760,4 +766,4 @@ <h5 class="method-header">
</div>

</div>
</div>
</div>
7 changes: 4 additions & 3 deletions js/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,7 @@
}
return (
`<td data-day="${opts.day}" class="${arr.join(' ')}" aria-selected="${ariaSelected}">` +
`<button class="datepicker-day-button" type="button" data-year="${opts.year}" data-month="${
opts.month
}" data-day="${opts.day}">${opts.day}</button>` +
`<button class="datepicker-day-button" type="button" data-year="${opts.year}" data-month="${opts.month}" data-day="${opts.day}">${opts.day}</button>` +
'</td>'
);
}
Expand Down Expand Up @@ -609,6 +607,9 @@
arr.push(`<option value="${i}" ${i === year ? 'selected="selected"' : ''}>${i}</option>`);
}
}
if (opts.yearRangeReverse) {
arr.reverse();
}

yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join(
''
Expand Down