Skip to content

Commit

Permalink
fix logbon72#105 weekDays param
Browse files Browse the repository at this point in the history
  • Loading branch information
hexadecy committed Jul 31, 2017
1 parent 9348856 commit 541ff02
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Originally designed for Bootstrap Material, this has been modified to work with
- Configurable first day of the week
- Support 24-hour format display
- Can disable dates, not selectable by user
- Highlight Week days (Business Days)
- Can disable minutes view
- 1 to 59 minute steps (normally 1, 5, 10, 15)
- Compatible with right-to-left direction
Expand All @@ -17,6 +18,7 @@ Originally designed for Bootstrap Material, this has been modified to work with

| Date | Author | Description |
| ---------- | -------- | ------------------------------------------------------ |
| 2017-07-30 | hexadecy | Highlight only week-days (business days) |
| 2017-07-22 | hexadecy | Mouse or touch move to select time, minute steps param |
| 2017-04-26 | hexadecy | New 24-hour clock face |
| 2017-04-17 | hexadecy | Single click to select |
Expand Down Expand Up @@ -118,6 +120,7 @@ The directive accepts several attributes which are described below:
| **ok-text** | String | Text for the OK button (default: OK) |
| **week-start** | Number | First day of the week (default: 0 => Sunday) |
| **disable-dates** | Date[] | Dates to be disabled or not selectable by user. |
| **week-days** | Boolean | true => Highlight only week-days (default: false) |
| **show-todays-date** | Attribute | Show today's date (default: undefined) |
| **disable-parent-scroll** | Boolean | true => Disable scrolling while the dialog is open (default : false) |
| **auto-ok** | Boolean | true => Single click (default: false) |
Expand Down Expand Up @@ -170,6 +173,7 @@ The `mdcDateTimeDialog.show` accepts the same options as the directive.
amText: {string} ='AM',
pmText: {string} ='PM',
disableDates: {date[]} =[],
weekDays: {boolean} =false,
disableParentScroll: {boolean} = false,
autoOk: {boolean} =false,
editInput: {boolean} =false,
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-material-datetimepicker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-material-datetimepicker.min.js.map

Large diffs are not rendered by default.

27 changes: 18 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="./css/material-datetimepicker.css" type="text/css"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.4/angular-material.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.1/angular-translate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular-sanitize.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-translate/2.15.2/angular-translate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-sanitize.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.4/angular-locale_fr.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.4/angular-locale_en.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.5/angular-locale_fr.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.6.5/angular-locale_en.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script type="text/javascript" src="./beautifier.js"></script>
<script type="text/javascript" src="./js/angular-material-datetimepicker.js"></script>
<script type="text/javascript" src="./js/demo.js"></script>
Expand Down Expand Up @@ -175,6 +175,15 @@ <h2>Datetime Pickers</h2>
<div flex-gt-md="grow" ex-source-code target="input"></div>
</div>

<div layout-gt-md="row" layout="column" layout-align-gt-md="center center">
<md-input-container flex-gt-md="30">
<label>Highlight Weekdays Only</label>
<input time="false" date="true" mdc-datetime-picker type="text" id="weekdaysdate"
placeholder="Date" ng-model="date" min-date="minDate" max-date="maxDate" week-days="true">
</md-input-container>
<div flex-gt-md="grow" ex-source-code target="input"></div>
</div>

<div layout-gt-md="row" layout="column" layout-align-gt-md="center center">
<div flex-gt-md="30">
<p>mdcDateTimeDialog Service</p>
Expand Down
14 changes: 14 additions & 0 deletions js/angular-material-datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function ngMaterialDatePicker(moment) {
pmText: 'PM',
todayText: 'Today',
disableDates: [],
weekDays: false,
disableParentScroll: false,
autoOk: false,
editInput: false,
Expand All @@ -121,6 +122,7 @@ function ngMaterialDatePicker(moment) {
minDate: '=',
maxDate: '=',
disableDates: '=',
weekDays: '=',
shortTime: '=',
weekStart: '=',
format: '@',
Expand Down Expand Up @@ -253,6 +255,7 @@ function ngMaterialDatePicker(moment) {
amText: {string} ='AM',
pmText: {string} ='PM',
disableDates: {date[]} =[],
weekDays: {boolean} =false,
disableParentScroll: {boolean} =false,
autoOk: {boolean} =false,
editInput: {boolean} =false,
Expand Down Expand Up @@ -374,6 +377,7 @@ function ngMaterialDatePicker(moment) {
return moment(x).format('MMMM Do YYYY');
});
this.selectDate(this.currentDate);
this.weekDays = this.params.weekDays;
},
initDate: function () {
this.currentView = VIEW_STATES.DATE;
Expand Down Expand Up @@ -457,6 +461,15 @@ function ngMaterialDatePicker(moment) {
}
return true;
},
isWeekDay: function(date) {
if (this.weekDays) {
if (date.isoWeekday() <= 5) {
return true;
}
return false;
}
return true;
},
selectDate: function (date) {
if (date) {
this.currentDate = moment(date);
Expand Down Expand Up @@ -766,6 +779,7 @@ function ngMaterialDatePicker(moment) {
calendar.isInRange = function (date) {
return picker.isAfterMinDate(moment(date), false, false) &&
picker.isBeforeMaxDate(moment(date), false, false) &&
picker.isWeekDay(moment(date)) &&
picker.isInDisableDates(moment(date));
};

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"homepage": "https://beenote.github.io/angular-material-datetimepicker/",
"main": "js/angular-material-datetimepicker.js",
"dependencies": {
"angular": "^1.6.4",
"angular-animate": "^1.6.4",
"angular-aria": "^1.6.4",
"angular": "^1.6.5",
"angular-animate": "^1.6.5",
"angular-aria": "^1.6.5",
"angular-material": "^1.1.4",
"moment": "^2.18.1"
},
Expand All @@ -38,7 +38,7 @@
"gulp-tag-version": "^1.3.0",
"gulp-uglify": "^3.0.0",
"pump": "^1.0.2",
"run-sequence": "^2.0.0",
"run-sequence": "^2.1.0",
"yargs": "^8.0.2"
}
}
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"

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

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

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

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

ansi-cyan@^0.1.1:
version "0.1.1"
Expand Down Expand Up @@ -1742,9 +1742,9 @@ resolve@^1.1.6, resolve@^1.1.7:
version "1.2.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.0.tgz#9589c3f2f6149d1417a40becc1663db6ec6bc26c"

run-sequence@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/run-sequence/-/run-sequence-2.0.0.tgz#6ab754fe53cd771d47dbdee63c254882344d5896"
run-sequence@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/run-sequence/-/run-sequence-2.1.0.tgz#149da012516f21dcf79db6dc99a2a95603631b21"
dependencies:
chalk "^1.1.3"
gulp-util "^3.0.8"
Expand Down

0 comments on commit 541ff02

Please sign in to comment.