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

Commit 7f4b40e

Browse files
committed
feat(datepicker): add datepicker-mode, init-date & today hint
* Add two-way binded `datepicker-mode`. * Add optional `init-date` when no model value is specified. * Add hint for current date. * Use isolated scope for popup directive. * Use optional binding for `isOpen`. * Split each mode into it's own directive. Closes #1599 BREAKING CHANGE: `show-weeks` is no longer a watched attribute `*-format` attributes have been renamed to `format-*` `min` attribute has been renamed to `min-date` `max` attribute has been renamed to `max-date`
1 parent e8d5fef commit 7f4b40e

File tree

10 files changed

+690
-739
lines changed

10 files changed

+690
-739
lines changed

src/datepicker/datepicker.js

+312-310
Large diffs are not rendered by default.

src/datepicker/docs/demo.html

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33

44
<h4>Inline</h4>
55
<div style="display:inline-block; min-height:290px;">
6-
<div class="well well-sm" ng-model="dt">
7-
<datepicker min="minDate" show-weeks="showWeeks"></datepicker>
8-
</div>
6+
<datepicker ng-model="dt" min-date="minDate" show-weeks="true" class="well well-sm"></datepicker>
97
</div>
108

119
<h4>Popup</h4>
1210
<div class="row">
1311
<div class="col-md-6">
1412
<p class="input-group">
15-
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min="minDate" max="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
13+
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min-date="minDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="Close" />
1614
<span class="input-group-btn">
1715
<button class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
1816
</span>
@@ -28,7 +26,6 @@ <h4>Popup</h4>
2826
<hr />
2927
<button class="btn btn-sm btn-info" ng-click="today()">Today</button>
3028
<button class="btn btn-sm btn-default" ng-click="dt = '2009-08-24'">2009-08-24</button>
31-
<button class="btn btn-sm btn-success" ng-click="toggleWeeks()" tooltip="For inline datepicker">Toggle Weeks</button>
3229
<button class="btn btn-sm btn-danger" ng-click="clear()">Clear</button>
3330
<button class="btn btn-sm btn-default" ng-click="toggleMin()" tooltip="After today restriction">Min date</button>
3431
</div>

src/datepicker/docs/demo.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ var DatepickerDemoCtrl = function ($scope) {
44
};
55
$scope.today();
66

7-
$scope.showWeeks = true;
8-
$scope.toggleWeeks = function () {
9-
$scope.showWeeks = ! $scope.showWeeks;
10-
};
11-
127
$scope.clear = function () {
138
$scope.dt = null;
149
};
@@ -19,7 +14,7 @@ var DatepickerDemoCtrl = function ($scope) {
1914
};
2015

2116
$scope.toggleMin = function() {
22-
$scope.minDate = ( $scope.minDate ) ? null : new Date();
17+
$scope.minDate = $scope.minDate ? null : new Date();
2318
};
2419
$scope.toggleMin();
2520

@@ -31,10 +26,11 @@ var DatepickerDemoCtrl = function ($scope) {
3126
};
3227

3328
$scope.dateOptions = {
34-
'year-format': '\'yy\'',
35-
'starting-day': 1
29+
formatYear: 'yy',
30+
startingDay: 1
3631
};
3732

33+
$scope.initDate = new Date('2016-15-20');
3834
$scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'shortDate'];
3935
$scope.format = $scope.formats[0];
4036
};

src/datepicker/docs/readme.md

+35-23
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,70 @@ All settings can be provided as attributes in the `<datepicker>` or globally con
1313
:
1414
The date object.
1515

16-
* `show-weeks` <i class="glyphicon glyphicon-eye-open"></i>
17-
_(Defaults: true)_ :
18-
Whether to display week numbers.
16+
* `datepicker-mode` <i class="glyphicon glyphicon-eye-open"></i>
17+
_(Defaults: 'day')_ :
18+
Current mode of the datepicker _(day|month|year)_. Can be used to initialize datepicker to specific mode.
1919

20-
* `starting-day`
21-
_(Defaults: 0)_ :
22-
Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday).
23-
24-
* `min` <i class="glyphicon glyphicon-eye-open"></i>
20+
* `min-date` <i class="glyphicon glyphicon-eye-open"></i>
2521
_(Default: null)_ :
2622
Defines the minimum available date.
2723

28-
* `max` <i class="glyphicon glyphicon-eye-open"></i>
24+
* `max-date` <i class="glyphicon glyphicon-eye-open"></i>
2925
_(Default: null)_ :
3026
Defines the maximum available date.
3127

3228
* `date-disabled (date, mode)`
3329
_(Default: null)_ :
3430
An optional expression to disable visible options based on passing date and current mode _(day|month|year)_.
3531

36-
* `day-format`
32+
* `show-weeks`
33+
_(Defaults: true)_ :
34+
Whether to display week numbers.
35+
36+
* `starting-day`
37+
_(Defaults: 0)_ :
38+
Starting day of the week from 0-6 (0=Sunday, ..., 6=Saturday).
39+
40+
* `init-date`
41+
:
42+
The initial date view when no model value is not specified.
43+
44+
* `min-mode`
45+
_(Defaults: 'day')_ :
46+
Set a lower limit for mode.
47+
48+
* `max-mode`
49+
_(Defaults: 'year')_ :
50+
Set an upper limit for mode.
51+
52+
* `format-day`
3753
_(Default: 'dd')_ :
3854
Format of day in month.
3955

40-
* `month-format`
56+
* `format-month`
4157
_(Default: 'MMMM')_ :
4258
Format of month in year.
4359

44-
* `year-format`
60+
* `format-year`
4561
_(Default: 'yyyy')_ :
4662
Format of year in year range.
4763

48-
* `year-range`
49-
_(Default: 20)_ :
50-
Number of years displayed in year selection.
51-
52-
* `day-header-format`
64+
* `format-day-header`
5365
_(Default: 'EEE')_ :
5466
Format of day in week header.
5567

56-
* `day-title-format`
68+
* `format-day-title-`
5769
_(Default: 'MMMM yyyy')_ :
5870
Format of title when selecting day.
5971

60-
* `month-title-format`
72+
* `format-month-title`
6173
_(Default: 'yyyy')_ :
6274
Format of title when selecting month.
6375

76+
* `year-range`
77+
_(Default: 20)_ :
78+
Number of years displayed in year selection.
79+
6480

6581
### Popup Settings ###
6682

@@ -79,10 +95,6 @@ Specific settings for the `datepicker-popup`, that can globally configured throu
7995
_(Default: 'Today')_ :
8096
The text to display for the current day button.
8197

82-
* `toggle-weeks-text`
83-
_(Default: 'Weeks')_ :
84-
The text to display for the toggling week numbers button.
85-
8698
* `clear-text`
8799
_(Default: 'Clear')_ :
88100
The text to display for the clear button.

0 commit comments

Comments
 (0)