-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blockWeekDays option to date field. #1079
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
To be able to block selection of some days of week (for example, weekends) I added blockWeekDays options to date field. It's array of week day numbers. (1 - monday, 2 - tuesday, 3 - wensday, 4 - thursday, 5 - friday, 6 - saturday, 0 - sunday)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,13 +239,14 @@ | |
|
||
case 'date': | ||
defaults = { | ||
format : w2utils.settings.dateFormat, // date format | ||
keyboard : true, | ||
silent : true, | ||
start : '', // string or jquery object | ||
end : '', // string or jquery object | ||
blocked : {}, // { '4/11/2011': 'yes' } | ||
colored : {} // { '4/11/2011': 'red:white' } | ||
format : w2utils.settings.dateFormat, // date format | ||
keyboard : true, | ||
silent : true, | ||
start : '', // string or jquery object | ||
end : '', // string or jquery object | ||
blocked : {}, // { '4/11/2011': 'yes' } | ||
colored : {}, // { '4/11/2011': 'red:white' } | ||
blockWeekDays : null // array of numbers of weekday to block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be empty array by default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I don't mind. Let in be an empty array. I thought it must work if this option was not specified (for backward compatibility), so I added this checks. But default empty array seems to be ok. |
||
}; | ||
this.options = $.extend(true, {}, defaults, options); | ||
options = this.options; // since object is re-created, need to re-assign | ||
|
@@ -1863,6 +1864,21 @@ | |
} | ||
// block predefined dates | ||
if (this.options.blocked && $.inArray(str, this.options.blocked) != -1) inRange = false; | ||
|
||
/* | ||
clockWeekDay - type: array or integers. every element - number of week day. | ||
number of weekday (1 - monday, 2 - tuesday, 3 - wensday, 4 - thursday, 5 - friday, 6 - saturday, 0 - sunday) | ||
for block in calendar (for example, block all sundays so user can't choose sunday in calendar) | ||
*/ | ||
if (this.options.blockWeekDays != null && this.options.blockWeekDays != undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (this.options.blockWeekDays != null) is the same as if (this.options.blockWeekDays != null && this.options.blockWeekDays != undefined) |
||
&& this.options.blockWeekDays.length != undefined){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think instead of this.options.blockWeekDays.length != undefined we should use Array.isArray(this.options.blockWeekDays) |
||
var l = this.options.blockWeekDays.length; | ||
for (var i=0; i<l; i++){ | ||
if (dt.getDay() == this.options.blockWeekDays[i]){ | ||
inRange = false; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (this.type == 'time') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should also be implemented for "datetime" type