Skip to content

Commit 541ff02

Browse files
committed
fix logbon72#105 weekDays param
1 parent 9348856 commit 541ff02

7 files changed

+54
-27
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Originally designed for Bootstrap Material, this has been modified to work with
88
- Configurable first day of the week
99
- Support 24-hour format display
1010
- Can disable dates, not selectable by user
11+
- Highlight Week days (Business Days)
1112
- Can disable minutes view
1213
- 1 to 59 minute steps (normally 1, 5, 10, 15)
1314
- Compatible with right-to-left direction
@@ -17,6 +18,7 @@ Originally designed for Bootstrap Material, this has been modified to work with
1718

1819
| Date | Author | Description |
1920
| ---------- | -------- | ------------------------------------------------------ |
21+
| 2017-07-30 | hexadecy | Highlight only week-days (business days) |
2022
| 2017-07-22 | hexadecy | Mouse or touch move to select time, minute steps param |
2123
| 2017-04-26 | hexadecy | New 24-hour clock face |
2224
| 2017-04-17 | hexadecy | Single click to select |
@@ -118,6 +120,7 @@ The directive accepts several attributes which are described below:
118120
| **ok-text** | String | Text for the OK button (default: OK) |
119121
| **week-start** | Number | First day of the week (default: 0 => Sunday) |
120122
| **disable-dates** | Date[] | Dates to be disabled or not selectable by user. |
123+
| **week-days** | Boolean | true => Highlight only week-days (default: false) |
121124
| **show-todays-date** | Attribute | Show today's date (default: undefined) |
122125
| **disable-parent-scroll** | Boolean | true => Disable scrolling while the dialog is open (default : false) |
123126
| **auto-ok** | Boolean | true => Single click (default: false) |
@@ -170,6 +173,7 @@ The `mdcDateTimeDialog.show` accepts the same options as the directive.
170173
amText: {string} ='AM',
171174
pmText: {string} ='PM',
172175
disableDates: {date[]} =[],
176+
weekDays: {boolean} =false,
173177
disableParentScroll: {boolean} = false,
174178
autoOk: {boolean} =false,
175179
editInput: {boolean} =false,

dist/angular-material-datetimepicker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-material-datetimepicker.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
<meta name="viewport" content="width=device-width, initial-scale=1">
99
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet" type="text/css">
1010
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
11-
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" rel="stylesheet">
11+
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
1212
<link href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.css" rel="stylesheet" type="text/css"/>
1313
<link rel="stylesheet" href="./css/material-datetimepicker.css" type="text/css"/>
1414

15-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular.min.js"></script>
16-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-animate.min.js"></script>
17-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-aria.min.js"></script>
15+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-animate.min.js"></script>
17+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-aria.min.js"></script>
1818
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.js"></script>
19-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.1/angular-translate.min.js"></script>
20-
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-sanitize.js"></script>
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.2/angular-translate.min.js"></script>
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-sanitize.js"></script>
2121
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>
22-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.4/angular-locale_fr.min.js"></script>
23-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.4/angular-locale_en.min.js"></script>
24-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
22+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.5/angular-locale_fr.min.js"></script>
23+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.5/angular-locale_en.min.js"></script>
24+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
2525
<script type="text/javascript" src="./beautifier.js"></script>
2626
<script type="text/javascript" src="./js/angular-material-datetimepicker.js"></script>
2727
<script type="text/javascript" src="./js/demo.js"></script>
@@ -175,6 +175,15 @@ <h2>Datetime Pickers</h2>
175175
<div flex-gt-md="grow" ex-source-code target="input"></div>
176176
</div>
177177

178+
<div layout-gt-md="row" layout="column" layout-align-gt-md="center center">
179+
<md-input-container flex-gt-md="30">
180+
<label>Highlight Weekdays Only</label>
181+
<input time="false" date="true" mdc-datetime-picker type="text" id="weekdaysdate"
182+
placeholder="Date" ng-model="date" min-date="minDate" max-date="maxDate" week-days="true">
183+
</md-input-container>
184+
<div flex-gt-md="grow" ex-source-code target="input"></div>
185+
</div>
186+
178187
<div layout-gt-md="row" layout="column" layout-align-gt-md="center center">
179188
<div flex-gt-md="30">
180189
<p>mdcDateTimeDialog Service</p>

js/angular-material-datetimepicker.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function ngMaterialDatePicker(moment) {
9898
pmText: 'PM',
9999
todayText: 'Today',
100100
disableDates: [],
101+
weekDays: false,
101102
disableParentScroll: false,
102103
autoOk: false,
103104
editInput: false,
@@ -121,6 +122,7 @@ function ngMaterialDatePicker(moment) {
121122
minDate: '=',
122123
maxDate: '=',
123124
disableDates: '=',
125+
weekDays: '=',
124126
shortTime: '=',
125127
weekStart: '=',
126128
format: '@',
@@ -253,6 +255,7 @@ function ngMaterialDatePicker(moment) {
253255
amText: {string} ='AM',
254256
pmText: {string} ='PM',
255257
disableDates: {date[]} =[],
258+
weekDays: {boolean} =false,
256259
disableParentScroll: {boolean} =false,
257260
autoOk: {boolean} =false,
258261
editInput: {boolean} =false,
@@ -374,6 +377,7 @@ function ngMaterialDatePicker(moment) {
374377
return moment(x).format('MMMM Do YYYY');
375378
});
376379
this.selectDate(this.currentDate);
380+
this.weekDays = this.params.weekDays;
377381
},
378382
initDate: function () {
379383
this.currentView = VIEW_STATES.DATE;
@@ -457,6 +461,15 @@ function ngMaterialDatePicker(moment) {
457461
}
458462
return true;
459463
},
464+
isWeekDay: function(date) {
465+
if (this.weekDays) {
466+
if (date.isoWeekday() <= 5) {
467+
return true;
468+
}
469+
return false;
470+
}
471+
return true;
472+
},
460473
selectDate: function (date) {
461474
if (date) {
462475
this.currentDate = moment(date);
@@ -766,6 +779,7 @@ function ngMaterialDatePicker(moment) {
766779
calendar.isInRange = function (date) {
767780
return picker.isAfterMinDate(moment(date), false, false) &&
768781
picker.isBeforeMaxDate(moment(date), false, false) &&
782+
picker.isWeekDay(moment(date)) &&
769783
picker.isInDisableDates(moment(date));
770784
};
771785

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
"homepage": "https://beenote.github.io/angular-material-datetimepicker/",
1717
"main": "js/angular-material-datetimepicker.js",
1818
"dependencies": {
19-
"angular": "^1.6.4",
20-
"angular-animate": "^1.6.4",
21-
"angular-aria": "^1.6.4",
19+
"angular": "^1.6.5",
20+
"angular-animate": "^1.6.5",
21+
"angular-aria": "^1.6.5",
2222
"angular-material": "^1.1.4",
2323
"moment": "^2.18.1"
2424
},
@@ -38,7 +38,7 @@
3838
"gulp-tag-version": "^1.3.0",
3939
"gulp-uglify": "^3.0.0",
4040
"pump": "^1.0.2",
41-
"run-sequence": "^2.0.0",
41+
"run-sequence": "^2.1.0",
4242
"yargs": "^8.0.2"
4343
}
4444
}

yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ amdefine@>=0.0.4:
3131
version "1.0.1"
3232
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
3333

34-
angular-animate@^1.6.4:
35-
version "1.6.4"
36-
resolved "https://registry.yarnpkg.com/angular-animate/-/angular-animate-1.6.4.tgz#d3eb906d39834f2dfbdd982e6b8d7a3b4d9001d2"
34+
angular-animate@^1.6.5:
35+
version "1.6.5"
36+
resolved "https://registry.yarnpkg.com/angular-animate/-/angular-animate-1.6.5.tgz#3817c75880d05fc899a6c8d4b09d1cc62a71e93a"
3737

38-
angular-aria@^1.6.4:
39-
version "1.6.4"
40-
resolved "https://registry.yarnpkg.com/angular-aria/-/angular-aria-1.6.4.tgz#c8683666ace196668f68e7220811bdcfc9e106e4"
38+
angular-aria@^1.6.5:
39+
version "1.6.5"
40+
resolved "https://registry.yarnpkg.com/angular-aria/-/angular-aria-1.6.5.tgz#37d9d35349df57934968dc7e1679d97ea96f863c"
4141

4242
angular-material@^1.1.4:
4343
version "1.1.4"
4444
resolved "https://registry.yarnpkg.com/angular-material/-/angular-material-1.1.4.tgz#27de35646f54ccd320080af0c708e1b438af87f6"
4545

46-
angular@^1.6.4:
47-
version "1.6.4"
48-
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.4.tgz#03b7b15c01a0802d7e2cf593240e604054dc77fb"
46+
angular@^1.6.5:
47+
version "1.6.5"
48+
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.5.tgz#37f788eebec5ce2e3fa02b17bbcb2a231576a0d6"
4949

5050
ansi-cyan@^0.1.1:
5151
version "0.1.1"
@@ -1742,9 +1742,9 @@ resolve@^1.1.6, resolve@^1.1.7:
17421742
version "1.2.0"
17431743
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c"
17441744

1745-
run-sequence@^2.0.0:
1746-
version "2.0.0"
1747-
resolved "https://registry.yarnpkg.com/run-sequence/-/run-sequence-2.0.0.tgz#6ab754fe53cd771d47dbdee63c254882344d5896"
1745+
run-sequence@^2.1.0:
1746+
version "2.1.0"
1747+
resolved "https://registry.yarnpkg.com/run-sequence/-/run-sequence-2.1.0.tgz#149da012516f21dcf79db6dc99a2a95603631b21"
17481748
dependencies:
17491749
chalk "^1.1.3"
17501750
gulp-util "^3.0.8"

0 commit comments

Comments
 (0)