diff --git a/paper-calendar.html b/paper-calendar.html
index 25cea40..11d97d3 100644
--- a/paper-calendar.html
+++ b/paper-calendar.html
@@ -288,6 +288,22 @@
type: Date,
value: null
},
+ /**
+ *Array of selectable dates
+ * (whitelist)
+ */
+ validDates:{
+ type: Array,
+ value: []
+ },
+ /**
+ * Array of not selectable dates
+ * (blacklist)
+ */
+ invalidDates:{
+ type: Array,
+ value: []
+ },
/**
* The currently selected month (1-12)
*/
@@ -431,7 +447,7 @@
return cssClass;
},
_isDisabled: function(day, date) {
- return !day || !this._withinValidRange(date);
+ return !day || !this._withinValidRange(date) || ! this._confirmsToWhiteAndBlacklist(date);
},
_getMonthClass: function(name, month) {
return name + ' month-' + month.year + '-' + month.month;
@@ -628,6 +644,7 @@
console.warn('Date outside of valid range: ' + date);
this.date = date = oldValue;
}
+
this.currentYear = date.getFullYear();
this.currentMonth = date.getMonth() + 1;
// Only trigger a notification if there actually is a difference.
@@ -637,7 +654,7 @@
this._updateSelection();
},
_tapDay: function(event) {
- if (!this._withinValidRange(event.model.item.date)) {
+ if (!this._withinValidRange(event.model.item.date) || !this._confirmsToWhiteAndBlacklist(event.model.item.date)) {
return false;
}
var item = event.model.item;
@@ -652,7 +669,27 @@
},
_withinValidRange: function(date) {
if (this._isValidDate(date)) {
- return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
+ return (!this.minDate || date >= this.minDate) && (!this.maxDate || date <= this.maxDate);
+ }
+ return false;
+ },
+
+ _confirmsToWhiteAndBlacklist: function(date){
+ if(this._isValidDate(date)) {
+ var result = !this._isInBlacklist(date) && this._isInWhitelist(date);
+ return result;
+ }
+ return false;
+ },
+ _isInWhitelist: function(date){
+ if(this.validDates && this.validDates.length > 0 && this._isValidDate(date)) {
+ return this.validDates.indexOf(this.dateFormat(date,'YYYY-MM-DD')) >= 0;
+ }
+ return true;
+ },
+ _isInBlacklist: function(date){
+ if(this.invalidDates && this.invalidDates.length > 0 && this._isValidDate(date)) {
+ return this.invalidDates.indexOf(this.dateFormat(date,'YYYY-MM-DD')) >= 0;
}
return false;
},
diff --git a/paper-date-picker.html b/paper-date-picker.html
index fd0f4a1..a27a791 100644
--- a/paper-date-picker.html
+++ b/paper-date-picker.html
@@ -163,7 +163,7 @@
on-iron-select="_pageSelected">
+ min-date="{{minDate}}" max-date="{{maxDate}}" invalid-dates="{{invalidDates}}" valid-dates="{{validDates}}">
@@ -220,6 +220,24 @@
type: Date,
value: null
},
+ /**
+ * Array of selectable dates
+ * (whitelist)
+ * Format must be String YYYY-MM-DD
+ */
+ validDates:{
+ type: Array,
+ value: []
+ },
+ /**
+ * Array of not selectable dates
+ * (blacklist)
+ * Format must be String YYYY-MM-DD
+ */
+ invalidDates:{
+ type: Array,
+ value: []
+ },
/**
* Force narrow layout
*/