diff --git a/daterangepicker.js b/daterangepicker.js index aa24d346..341f8949 100644 --- a/daterangepicker.js +++ b/daterangepicker.js @@ -257,6 +257,9 @@ if (typeof options.isInvalidDate === 'function') this.isInvalidDate = options.isInvalidDate; + if (typeof options.isCustomDate === 'function') + this.isCustomDate = options.isCustomDate; + if (typeof options.alwaysShowCalendars === 'boolean') this.alwaysShowCalendars = options.alwaysShowCalendars; @@ -509,6 +512,10 @@ return false; }, + isCustomDate: function() { + return false; + }, + updateView: function() { if (this.timePicker) { this.renderTimePicker('left'); @@ -806,6 +813,15 @@ if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate) classes.push('in-range'); + //apply custom classes for this date + var isCustom = this.isCustomDate(calendar[row][col]); + if (isCustom !== false) { + if (typeof isCustom === 'string') + classes.push(isCustom); + else + Array.prototype.push.apply(classes, isCustom); + } + var cname = '', disabled = false; for (var i = 0; i < classes.length; i++) { cname += classes[i] + ' '; diff --git a/website/index.html b/website/index.html index 3e01ce08..006dfced 100644 --- a/website/index.html +++ b/website/index.html @@ -655,6 +655,11 @@

Options

calendars before they are displayed, and may return true or false to indicate whether that date should be available for selection or not. +
  • + isCustomDate: (function) A function that is passed each date in the two + calendars before they are displayed, and may return a string or array of CSS class names + to apply to that date's calendar cell. +
  • autoUpdateInput: (boolean) Indicates whether the date range picker should automatically update the value of an <input> element it's attached to