Skip to content

Commit

Permalink
Add alwaysShowCalendars option
Browse files Browse the repository at this point in the history
  • Loading branch information
dangrossman committed Feb 22, 2016
1 parent 7010187 commit 2b46f6c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
9 changes: 7 additions & 2 deletions daterangepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
this.timePickerSeconds = false;
this.linkedCalendars = true;
this.autoUpdateInput = true;
this.alwaysShowCalendars = false;
this.ranges = {};

this.opens = 'right';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -1185,7 +1189,8 @@
this.endDate.endOf('day');
}

this.hideCalendars();
if (!this.alwaysShowCalendars)
this.hideCalendars();
this.clickApply();
}
},
Expand Down
9 changes: 9 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ <h1 style="margin: 0 0 20px 0">Configuration Builder</h1>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="alwaysShowCalendars"> alwaysShowCalendars
</label>
</div>

</div>
<div class="col-md-4">

Expand Down Expand Up @@ -292,6 +298,9 @@ <h4>Configuration</h4>
if (!$('#autoUpdateInput').is(':checked'))
options.autoUpdateInput = false;

if ($('#alwaysShowCalendars').is(':checked'))
options.alwaysShowCalendars = true;

if ($('#parentEl').val().length)
options.parentEl = $('#parentEl').val();

Expand Down
10 changes: 10 additions & 0 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ <h2>Configuration Generator</h2>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" id="alwaysShowCalendars"> alwaysShowCalendars
</label>
</div>

</div>
<div class="col-md-4">

Expand Down Expand Up @@ -645,6 +651,10 @@ <h2>Options</h2>
automatically update the value of an <code>&lt;input&gt;</code> element it's attached to
at initialization and when the selected dates change.
</li>
<li>
<code>alwaysShowCalendars</code>: (boolean) Normally, if you use the <code>ranges</code>
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.
</li>
</ul>

</div>
Expand Down
3 changes: 3 additions & 0 deletions website/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 2b46f6c

Please sign in to comment.