bootstrap-daterangepicker
Advanced tools
Comparing version 2.0.6 to 2.0.9
@@ -0,0 +0,0 @@ { |
/** | ||
* @version: 2.0.6 | ||
* @version: 2.0.9 | ||
* @author: Dan Grossman http://www.dangrossman.info/ | ||
@@ -55,2 +55,4 @@ * @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved. | ||
this.timePickerSeconds = false; | ||
this.linkedCalendars = true; | ||
this.autoUpdateInput = true; | ||
this.ranges = {}; | ||
@@ -248,2 +250,11 @@ | ||
if (typeof options.autoUpdateInput === 'boolean') | ||
this.autoUpdateInput = options.autoUpdateInput; | ||
if (typeof options.linkedCalendars === 'boolean') | ||
this.linkedCalendars = options.linkedCalendars; | ||
if (typeof options.isInvalidDate === 'function') | ||
this.isInvalidDate = options.isInvalidDate; | ||
// update day names order to firstDay | ||
@@ -397,4 +408,4 @@ if (this.locale.firstDay != 0) { | ||
.on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this)) | ||
.on('keyup.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)) | ||
.on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.updateFormInputs, this)); | ||
//.on('keyup.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)) | ||
.on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)); | ||
@@ -423,6 +434,6 @@ this.container.find('.ranges') | ||
if (this.element.is('input') && !this.singleDatePicker) { | ||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) { | ||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); | ||
this.element.trigger('change'); | ||
} else if (this.element.is('input')) { | ||
} else if (this.element.is('input') && this.autoUpdateInput) { | ||
this.element.val(this.startDate.format(this.locale.format)); | ||
@@ -485,2 +496,6 @@ this.element.trigger('change'); | ||
isInvalidDate: function() { | ||
return false; | ||
}, | ||
updateView: function() { | ||
@@ -510,4 +525,14 @@ if (this.timePicker) { | ||
if (this.endDate) { | ||
//if both dates are visible already, do nothing | ||
if (this.leftCalendar.month && this.rightCalendar.month && | ||
(this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) | ||
&& | ||
(this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) | ||
) { | ||
return; | ||
} | ||
this.leftCalendar.month = this.startDate.clone().date(2); | ||
if (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year()) { | ||
if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) { | ||
this.rightCalendar.month = this.endDate.clone().date(2); | ||
@@ -517,2 +542,3 @@ } else { | ||
} | ||
} else { | ||
@@ -628,3 +654,3 @@ if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) { | ||
// Possible patch for issue #626 https://github.com/dangrossman/bootstrap-daterangepicker/issues/626 | ||
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]); // .utcOffset(this.timeZone); | ||
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]).utcOffset(this.timeZone); // .utcOffset(this.timeZone); | ||
@@ -673,3 +699,3 @@ var col, row; | ||
if (!minDate || minDate.isBefore(calendar.firstDay)) { | ||
if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) { | ||
html += '<th class="prev available"><i class="fa fa-chevron-left glyphicon glyphicon-chevron-left"></i></th>'; | ||
@@ -696,2 +722,6 @@ } else { | ||
">" + this.locale.monthNames[m] + "</option>"; | ||
} else { | ||
monthHtml += "<option value='" + m + "'" + | ||
(m === currentMonth ? " selected='selected'" : "") + | ||
" disabled='disabled'>" + this.locale.monthNames[m] + "</option>"; | ||
} | ||
@@ -713,3 +743,3 @@ } | ||
html += '<th colspan="5" class="month">' + dateHtml + '</th>'; | ||
if (!maxDate || maxDate.isAfter(calendar.lastDay)) { | ||
if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) { | ||
html += '<th class="next available"><i class="fa fa-chevron-right glyphicon glyphicon-chevron-right"></i></th>'; | ||
@@ -775,2 +805,6 @@ } else { | ||
//don't allow selection of date if a custom function decides it's invalid | ||
if (this.isInvalidDate(calendar[row][col])) | ||
classes.push('off', 'disabled'); | ||
//highlight the currently selected start date | ||
@@ -1051,6 +1085,6 @@ if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD')) | ||
//if picker is attached to a text input, update it | ||
if (this.element.is('input') && !this.singleDatePicker) { | ||
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) { | ||
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); | ||
this.element.trigger('change'); | ||
} else if (this.element.is('input')) { | ||
} else if (this.element.is('input') && this.autoUpdateInput) { | ||
this.element.val(this.startDate.format(this.locale.format)); | ||
@@ -1134,2 +1168,4 @@ this.element.trigger('change'); | ||
this.leftCalendar.month.subtract(1, 'month'); | ||
if (this.linkedCalendars) | ||
this.rightCalendar.month.subtract(1, 'month'); | ||
} else { | ||
@@ -1147,2 +1183,4 @@ this.rightCalendar.month.subtract(1, 'month'); | ||
this.rightCalendar.month.add(1, 'month'); | ||
if (this.linkedCalendars) | ||
this.leftCalendar.month.add(1, 'month'); | ||
} | ||
@@ -1176,2 +1214,6 @@ this.updateCalendars(); | ||
this.container.find('.calendar td').each(function(index, el) { | ||
//skip week numbers, only look at dates | ||
if ($(el).hasClass('week')) return; | ||
var title = $(el).attr('data-title'); | ||
@@ -1182,2 +1224,3 @@ var row = title.substr(1, 1); | ||
var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col]; | ||
if (dt.isAfter(startDate) && dt.isBefore(date)) { | ||
@@ -1188,2 +1231,3 @@ $(el).addClass('in-range'); | ||
} | ||
}); | ||
@@ -1299,3 +1343,11 @@ } | ||
this[leftOrRight+'Calendar'].month.month(month).year(year); | ||
if (isLeft) { | ||
this.leftCalendar.month.month(month).year(year); | ||
if (this.linkedCalendars) | ||
this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month'); | ||
} else { | ||
this.rightCalendar.month.month(month).year(year); | ||
if (this.linkedCalendars) | ||
this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month'); | ||
} | ||
this.updateCalendars(); | ||
@@ -1351,4 +1403,4 @@ }, | ||
var isRight = $(e.target).closest('.calendar').hasClass('right'); | ||
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format); | ||
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format); | ||
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format).utcOffset(this.timeZone); | ||
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format).utcOffset(this.timeZone); | ||
@@ -1355,0 +1407,0 @@ if (start.isValid() && end.isValid()) { |
@@ -0,0 +0,0 @@ //! moment.js |
Package.describe({ | ||
name: 'dangrossman:bootstrap-daterangepicker', | ||
version: '2.0.6', | ||
version: '2.0.9', | ||
summary: 'Date range picker component for Bootstrap', | ||
@@ -5,0 +5,0 @@ git: 'https://github.com/dangrossman/bootstrap-daterangepicker', |
{ | ||
"name": "bootstrap-daterangepicker", | ||
"version": "2.0.6", | ||
"version": "2.0.9", | ||
"description": "Date range picker component for Bootstrap", | ||
@@ -5,0 +5,0 @@ "main": "daterangepicker.js", |
@@ -0,0 +0,0 @@ # Date Range Picker for Bootstrap |
$(document).ready(function() { | ||
$('.configurator input').change(function() { | ||
updateConfig(); | ||
}); | ||
@@ -10,2 +6,6 @@ $('#config-text').keyup(function() { | ||
}); | ||
$('.configurator input, .configurator select').change(function() { | ||
updateConfig(); | ||
}); | ||
@@ -16,2 +16,12 @@ $('.demo i').click(function() { | ||
$('#startDate').daterangepicker({ | ||
singleDatePicker: true, | ||
startDate: moment().subtract(6, 'days') | ||
}); | ||
$('#endDate').daterangepicker({ | ||
singleDatePicker: true, | ||
startDate: moment() | ||
}); | ||
updateConfig(); | ||
@@ -37,3 +47,3 @@ | ||
if ($('#timePickerIncrement').val().length) | ||
if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1) | ||
options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10); | ||
@@ -52,2 +62,4 @@ | ||
options.ranges = { | ||
'Today': [moment(), moment()], | ||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], | ||
'Last 7 Days': [moment().subtract(6, 'days'), moment()], | ||
@@ -75,2 +87,8 @@ 'Last 30 Days': [moment().subtract(29, 'days'), moment()], | ||
if (!$('#linkedCalendars').is(':checked')) | ||
options.linkedCalendars = false; | ||
if (!$('#autoUpdateInput').is(':checked')) | ||
options.autoUpdateInput = false; | ||
if ($('#parentEl').val().length) | ||
@@ -91,18 +109,18 @@ options.parentEl = $('#parentEl').val(); | ||
if ($('#opens').val().length) | ||
if ($('#opens').val().length && $('#opens').val() != 'right') | ||
options.opens = $('#opens').val(); | ||
if ($('#drops').val().length) | ||
if ($('#drops').val().length && $('#drops').val() != 'down') | ||
options.drops = $('#drops').val(); | ||
if ($('#buttonClasses').val().length) | ||
if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm') | ||
options.buttonClasses = $('#buttonClasses').val(); | ||
if ($('#applyClass').val().length) | ||
if ($('#applyClass').val().length && $('#applyClass').val() != 'btn-success') | ||
options.applyClass = $('#applyClass').val(); | ||
if ($('#cancelClass').val().length) | ||
if ($('#cancelClass').val().length && $('#cancelClass').val() != 'btn-default') | ||
options.cancelClass = $('#cancelClass').val(); | ||
$('#config-text').val("$('#config-demo').daterangepicker(" + JSON.stringify(options, null, ' ') + ", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});"); | ||
$('#config-text').val("$('#demo').daterangepicker(" + JSON.stringify(options, null, ' ') + ", function(start, end, label) {\n console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});"); | ||
@@ -109,0 +127,0 @@ $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
322085
4413