Skip to content

Commit 1ed1eae

Browse files
committed
Merge pull request uxsolutions#85 from addbrick/master
2 parents a8dfed7 + 520518d commit 1ed1eae

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ Number, String. Default: 0, 'month'
140140

141141
The view that the datepicker should show when it is opened. Accepts values of 0 or 'month' for month view (the default), 1 or 'year' for the 12-month overview, and 2 or 'decade' for the 10-year overview. Useful for date-of-birth datepickers.
142142

143+
### keyboardNavigation
144+
145+
Boolean. Default: true
146+
147+
Whether or not to allow date navigation by arrow keys.
148+
143149
### language
144150

145151
String. Default: 'en'

js/bootstrap-datepicker.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
} else if ('dateAutoclose' in this.element.data()) {
7272
this.autoclose = this.element.data('date-autoclose');
7373
}
74+
75+
this.keyboardNavigation = true;
76+
if ('keyboardNavigation' in options) {
77+
this.keyboardNavigation = options.keyboardNavigation;
78+
} else if ('dateKeyboardNavigation' in this.element.data()) {
79+
this.keyboardNavigation = this.element.data('date-keyboard-navigation');
80+
}
7481

7582
switch(options.startView || this.element.data('date-start-view')){
7683
case 2:
@@ -548,6 +555,7 @@
548555
break;
549556
case 37: // left
550557
case 39: // right
558+
if (!this.keyboardNavigation) break;
551559
dir = e.keyCode == 37 ? -1 : 1;
552560
if (e.ctrlKey){
553561
newDate = this.moveYear(this.date, dir);
@@ -572,6 +580,7 @@
572580
break;
573581
case 38: // up
574582
case 40: // down
583+
if (!this.keyboardNavigation) break;
575584
dir = e.keyCode == 38 ? -1 : 1;
576585
if (e.ctrlKey){
577586
newDate = this.moveYear(this.date, dir);

0 commit comments

Comments
 (0)