From 2b46f6c1248adfc379f2696a3298fffbc70226f6 Mon Sep 17 00:00:00 2001 From: Dan Grossman Date: Mon, 22 Feb 2016 15:50:44 -0500 Subject: [PATCH] Add alwaysShowCalendars option --- daterangepicker.js | 9 +++++++-- demo.html | 9 +++++++++ website/index.html | 10 ++++++++++ website/website.js | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/daterangepicker.js b/daterangepicker.js index 7eab933b..f66dae98 100644 --- a/daterangepicker.js +++ b/daterangepicker.js @@ -54,6 +54,7 @@ this.timePickerSeconds = false; this.linkedCalendars = true; this.autoUpdateInput = true; + this.alwaysShowCalendars = false; this.ranges = {}; this.opens = 'right'; @@ -255,6 +256,9 @@ if (typeof options.isInvalidDate === 'function') this.isInvalidDate = options.isInvalidDate; + if (typeof options.alwaysShowCalendars === 'boolean') + this.alwaysShowCalendars = options.alwaysShowCalendars; + // update day names order to firstDay if (this.locale.firstDay != 0) { var iterator = this.locale.firstDay; @@ -365,7 +369,7 @@ } } - if (typeof options.ranges === 'undefined' && !this.singleDatePicker) { + if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) { this.container.addClass('show-calendar'); } @@ -1185,7 +1189,8 @@ this.endDate.endOf('day'); } - this.hideCalendars(); + if (!this.alwaysShowCalendars) + this.hideCalendars(); this.clickApply(); } }, diff --git a/demo.html b/demo.html index 5fe5dfce..4d6439dd 100644 --- a/demo.html +++ b/demo.html @@ -134,6 +134,12 @@

Configuration Builder

+
+ +
+
@@ -292,6 +298,9 @@

Configuration

if (!$('#autoUpdateInput').is(':checked')) options.autoUpdateInput = false; + if ($('#alwaysShowCalendars').is(':checked')) + options.alwaysShowCalendars = true; + if ($('#parentEl').val().length) options.parentEl = $('#parentEl').val(); diff --git a/website/index.html b/website/index.html index f34d0819..34411b85 100644 --- a/website/index.html +++ b/website/index.html @@ -502,6 +502,12 @@

Configuration Generator

+
+ +
+
@@ -645,6 +651,10 @@

Options

automatically update the value of an <input> element it's attached to at initialization and when the selected dates change. +
  • + alwaysShowCalendars: (boolean) Normally, if you use the ranges + option to specify pre-defined date ranges, calendars for choosing a custom date range are not shown until the user clicks "Custom Range". When this option is set to true, the calendars for choosing a custom date range are always shown instead. +
  • diff --git a/website/website.js b/website/website.js index 2e010c49..4baab5e6 100644 --- a/website/website.js +++ b/website/website.js @@ -86,6 +86,9 @@ $(document).ready(function() { if (!$('#autoUpdateInput').is(':checked')) options.autoUpdateInput = false; + if ($('#alwaysShowCalendars').is(':checked')) + options.alwaysShowCalendars = true; + if ($('#parentEl').val().length) options.parentEl = $('#parentEl').val();