Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 1fdc7ae

Browse files
committed
feat(datepicker): add monthColumns to DatepickerConfig
1 parent 2f85948 commit 1fdc7ae

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

Diff for: src/datepicker/datepicker.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
1616
maxMode: 'year',
1717
minDate: null,
1818
minMode: 'day',
19+
monthColumns: 3,
1920
ngModelOptions: {},
2021
shortcutPropagation: false,
2122
showWeeks: true,
22-
monthColumns: 3,
2323
yearColumns: 5,
2424
yearRows: 4
2525
})
@@ -53,10 +53,10 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
5353
'maxMode',
5454
'minDate',
5555
'minMode',
56+
'monthColumns',
5657
'showWeeks',
5758
'shortcutPropagation',
5859
'startingDay',
59-
'monthColumns',
6060
'yearColumns',
6161
'yearRows'
6262
].forEach(function(key) {
@@ -79,9 +79,9 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
7979
$interpolate($scope.datepickerOptions[key])($scope.$parent) :
8080
datepickerConfig[key];
8181
break;
82+
case 'monthColumns':
8283
case 'showWeeks':
8384
case 'shortcutPropagation':
84-
case 'monthColumns':
8585
case 'yearColumns':
8686
case 'yearRows':
8787
self[key] = angular.isDefined($scope.datepickerOptions[key]) ?
@@ -461,13 +461,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
461461
}])
462462

463463
.controller('UibMonthpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
464-
var columns;
465464
this.step = { years: 1 };
466465
this.element = $element;
467466

468467
this.init = function(ctrl) {
469468
angular.extend(ctrl, this);
470-
columns = ctrl.monthColumns;
471469
ctrl.refreshView();
472470
};
473471

@@ -485,8 +483,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
485483
}
486484

487485
scope.title = dateFilter(this.activeDate, this.formatMonthTitle);
488-
scope.rows = this.split(months, columns);
489-
scope.yearHeaderColspan = columns > 3 ? columns - 2 : 1;
486+
scope.rows = this.split(months, this.monthColumns);
487+
scope.yearHeaderColspan = this.monthColumns > 3 ? this.monthColumns - 2 : 1;
490488
};
491489

492490
this.compare = function(date1, date2) {
@@ -503,11 +501,11 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
503501
if (key === 'left') {
504502
date = date - 1;
505503
} else if (key === 'up') {
506-
date = date - columns;
504+
date = date - this.monthColumns;
507505
} else if (key === 'right') {
508506
date = date + 1;
509507
} else if (key === 'down') {
510-
date = date + columns;
508+
date = date + this.monthColumns;
511509
} else if (key === 'pageup' || key === 'pagedown') {
512510
var year = this.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);
513511
this.activeDate.setFullYear(year);

Diff for: src/datepicker/docs/readme.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ Apart from the previous settings, to configure the uib-datepicker you need to cr
104104
_(Default: `day`)_ -
105105
Sets a lower limit for mode.
106106

107+
* `monthColumns`
108+
<small class="badge">C</small>
109+
_(Default: `3`)_ -
110+
Number of columns displayed in month selection.
111+
107112
* `ngModelOptions`
108113
<small class="badge">C</small>
109114
_(Default: `null`)_ -
@@ -124,11 +129,6 @@ Apart from the previous settings, to configure the uib-datepicker you need to cr
124129
*(Default: `$locale.DATETIME_FORMATS.FIRSTDAYOFWEEK`)* -
125130
Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday).
126131

127-
* `monthColumns`
128-
<small class="badge">C</small>
129-
_(Default: `3`)_ -
130-
Number of columns displayed in month selection.
131-
132132
* `yearRows`
133133
<small class="badge">C</small>
134134
_(Default: `4`)_ -

Diff for: src/datepicker/test/datepicker.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ describe('datepicker', function() {
13571357
]);
13581358
});
13591359

1360-
it('changes colspan of yearbutton in month selector to have colspan', function() {
1360+
it('shows title year button to expand to fill width in `month` mode', function() {
13611361
clickTitleButton();
13621362
expect(getTitleCell().attr('colspan')).toBe('2');
13631363
});

0 commit comments

Comments
 (0)