diff --git a/public/v1/css/daterangepicker.css b/public/v1/css/daterangepicker.css index 5dd276bc2d..73f36b0cc9 100755 --- a/public/v1/css/daterangepicker.css +++ b/public/v1/css/daterangepicker.css @@ -1,418 +1,388 @@ .daterangepicker { - position: absolute; - color: inherit; - background-color: #fff; - border-radius: 4px; - width: 278px; - padding: 4px; - margin-top: 1px; - top: 100px; - left: 20px; - /* Calendars */ + position: absolute; + color: inherit; + background-color: #fff; + border-radius: 4px; + border: 1px solid #ddd; + width: 278px; + max-width: none; + padding: 0; + margin-top: 7px; + top: 100px; + left: 20px; + z-index: 3001; + display: none; + font-family: arial; + font-size: 15px; + line-height: 1em; } .daterangepicker:before, .daterangepicker:after { - position: absolute; - display: inline-block; - border-bottom-color: rgba(0, 0, 0, 0.2); - content: ''; + position: absolute; + display: inline-block; + border-bottom-color: rgba(0, 0, 0, 0.2); + content: ''; } .daterangepicker:before { - top: -7px; - border-right: 7px solid transparent; - border-left: 7px solid transparent; - border-bottom: 7px solid #ccc; + top: -7px; + border-right: 7px solid transparent; + border-left: 7px solid transparent; + border-bottom: 7px solid #ccc; } .daterangepicker:after { - top: -6px; - border-right: 6px solid transparent; - border-bottom: 6px solid #fff; - border-left: 6px solid transparent; + top: -6px; + border-right: 6px solid transparent; + border-bottom: 6px solid #fff; + border-left: 6px solid transparent; } .daterangepicker.opensleft:before { - right: 9px; + right: 9px; } .daterangepicker.opensleft:after { - right: 10px; + right: 10px; } .daterangepicker.openscenter:before { - left: 0; - right: 0; - width: 0; - margin-left: auto; - margin-right: auto; + left: 0; + right: 0; + width: 0; + margin-left: auto; + margin-right: auto; } .daterangepicker.openscenter:after { - left: 0; - right: 0; - width: 0; - margin-left: auto; - margin-right: auto; + left: 0; + right: 0; + width: 0; + margin-left: auto; + margin-right: auto; } .daterangepicker.opensright:before { - left: 9px; + left: 9px; } .daterangepicker.opensright:after { - left: 10px; + left: 10px; } -.daterangepicker.dropup { - margin-top: -5px; +.daterangepicker.drop-up { + margin-top: -7px; } -.daterangepicker.dropup:before { - top: initial; - bottom: -7px; - border-bottom: initial; - border-top: 7px solid #ccc; +.daterangepicker.drop-up:before { + top: initial; + bottom: -7px; + border-bottom: initial; + border-top: 7px solid #ccc; } -.daterangepicker.dropup:after { - top: initial; - bottom: -6px; - border-bottom: initial; - border-top: 6px solid #fff; +.daterangepicker.drop-up:after { + top: initial; + bottom: -6px; + border-bottom: initial; + border-top: 6px solid #fff; } -.daterangepicker.dropdown-menu { - max-width: none; - z-index: 3001; +.daterangepicker.single .daterangepicker .ranges, .daterangepicker.single .drp-calendar { + float: none; } -.daterangepicker.single .ranges, .daterangepicker.single .calendar { - float: none; +.daterangepicker.single .drp-selected { + display: none; } -.daterangepicker.show-calendar .calendar { - display: block; +.daterangepicker.show-calendar .drp-calendar { + display: block; } -.daterangepicker .calendar { - display: none; - max-width: 270px; - margin: 4px; +.daterangepicker.show-calendar .drp-buttons { + display: block; } -.daterangepicker .calendar.single .calendar-table { - border: none; +.daterangepicker.auto-apply .drp-buttons { + display: none; } -.daterangepicker .calendar th, .daterangepicker .calendar td { - white-space: nowrap; - text-align: center; - min-width: 32px; +.daterangepicker .drp-calendar { + display: none; + max-width: 270px; +} + +.daterangepicker .drp-calendar.left { + padding: 8px 0 8px 8px; +} + +.daterangepicker .drp-calendar.right { + padding: 8px; +} + +.daterangepicker .drp-calendar.single .calendar-table { + border: none; +} + +.daterangepicker .calendar-table .next span, .daterangepicker .calendar-table .prev span { + color: #fff; + border: solid black; + border-width: 0 2px 2px 0; + border-radius: 0; + display: inline-block; + padding: 3px; +} + +.daterangepicker .calendar-table .next span { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); +} + +.daterangepicker .calendar-table .prev span { + transform: rotate(135deg); + -webkit-transform: rotate(135deg); +} + +.daterangepicker .calendar-table th, .daterangepicker .calendar-table td { + white-space: nowrap; + text-align: center; + vertical-align: middle; + min-width: 32px; + width: 32px; + height: 24px; + line-height: 24px; + font-size: 12px; + border-radius: 4px; + border: 1px solid transparent; + white-space: nowrap; + cursor: pointer; } .daterangepicker .calendar-table { - border: 1px solid #fff; - padding: 4px; - border-radius: 4px; - background-color: #fff; + border: 1px solid #fff; + border-radius: 4px; + background-color: #fff; } -.daterangepicker table { - width: 100%; - margin: 0; -} - -.daterangepicker td, .daterangepicker th { - text-align: center; - width: 20px; - height: 20px; - border-radius: 4px; - border: 1px solid transparent; - white-space: nowrap; - cursor: pointer; +.daterangepicker .calendar-table table { + width: 100%; + margin: 0; + border-spacing: 0; + border-collapse: collapse; } .daterangepicker td.available:hover, .daterangepicker th.available:hover { - background-color: #eee; - border-color: transparent; - color: inherit; + background-color: #eee; + border-color: transparent; + color: inherit; } .daterangepicker td.week, .daterangepicker th.week { - font-size: 80%; - color: #ccc; + font-size: 80%; + color: #ccc; } .daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date { - background-color: #fff; - border-color: transparent; - color: #999; + background-color: #fff; + border-color: transparent; + color: #999; } .daterangepicker td.in-range { - background-color: #ebf4f8; - border-color: transparent; - color: #000; - border-radius: 0; + background-color: #ebf4f8; + border-color: transparent; + color: #000; + border-radius: 0; } .daterangepicker td.start-date { - border-radius: 4px 0 0 4px; + border-radius: 4px 0 0 4px; } .daterangepicker td.end-date { - border-radius: 0 4px 4px 0; + border-radius: 0 4px 4px 0; } .daterangepicker td.start-date.end-date { - border-radius: 4px; + border-radius: 4px; } .daterangepicker td.active, .daterangepicker td.active:hover { - background-color: #357ebd; - border-color: transparent; - color: #fff; + background-color: #357ebd; + border-color: transparent; + color: #fff; } .daterangepicker th.month { - width: auto; + width: auto; } .daterangepicker td.disabled, .daterangepicker option.disabled { - color: #999; - cursor: not-allowed; - text-decoration: line-through; + color: #999; + cursor: not-allowed; + text-decoration: line-through; } .daterangepicker select.monthselect, .daterangepicker select.yearselect { - font-size: 12px; - padding: 1px; - height: auto; - margin: 0; - cursor: default; + font-size: 12px; + padding: 1px; + height: auto; + margin: 0; + cursor: default; } .daterangepicker select.monthselect { - margin-right: 2%; - width: 56%; + margin-right: 2%; + width: 56%; } .daterangepicker select.yearselect { - width: 40%; + width: 40%; } .daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect { - width: 50px; - margin-bottom: 0; -} - -.daterangepicker .input-mini { - border: 1px solid #ccc; - border-radius: 4px; - color: #555; - height: 30px; - line-height: 30px; - display: block; - vertical-align: middle; - margin: 0 0 5px 0; - padding: 0 6px 0 28px; - width: 100%; -} - -.daterangepicker .input-mini.active { - border: 1px solid #08c; - border-radius: 4px; -} - -.daterangepicker .daterangepicker_input { - position: relative; -} - -.daterangepicker .daterangepicker_input i { - position: absolute; - left: 8px; - top: 8px; -} - -.daterangepicker.rtl .input-mini { - padding-right: 28px; - padding-left: 6px; -} - -.daterangepicker.rtl .daterangepicker_input i { - left: auto; - right: 8px; + width: 50px; + margin: 0 auto; + background: #eee; + border: 1px solid #eee; + padding: 2px; + outline: 0; + font-size: 12px; } .daterangepicker .calendar-time { - text-align: center; - margin: 5px auto; - line-height: 30px; - position: relative; - padding-left: 28px; + text-align: center; + margin: 4px auto 0 auto; + line-height: 30px; + position: relative; } .daterangepicker .calendar-time select.disabled { - color: #ccc; - cursor: not-allowed; + color: #ccc; + cursor: not-allowed; } -.ranges { - font-size: 11px; - float: none; - margin: 4px; - text-align: left; +.daterangepicker .drp-buttons { + clear: both; + text-align: right; + padding: 8px; + border-top: 1px solid #ddd; + display: none; + line-height: 12px; + vertical-align: middle; } -.ranges ul { - list-style: none; - margin: 0 auto; - padding: 0; - width: 100%; +.daterangepicker .drp-selected { + display: inline-block; + font-size: 12px; + padding-right: 8px; } -.ranges li { - font-size: 13px; - background-color: #f5f5f5; - border: 1px solid #f5f5f5; - border-radius: 4px; - color: #08c; - padding: 3px 12px; - margin-bottom: 8px; - cursor: pointer; +.daterangepicker .drp-buttons .btn { + margin-left: 8px; + font-size: 12px; + font-weight: bold; + padding: 4px 8px; } -.ranges li:hover { - background-color: #08c; - border: 1px solid #08c; - color: #fff; +.daterangepicker.show-ranges .drp-calendar.left { + border-left: 1px solid #ddd; } -.ranges li.active { - background-color: #08c; - border: 1px solid #08c; - color: #fff; +.daterangepicker .ranges { + float: none; + text-align: left; + margin: 0; +} + +.daterangepicker.show-calendar .ranges { + margin-top: 8px; +} + +.daterangepicker .ranges ul { + list-style: none; + margin: 0 auto; + padding: 0; + width: 100%; +} + +.daterangepicker .ranges li { + font-size: 12px; + padding: 8px 12px; + cursor: pointer; +} + +.daterangepicker .ranges li:hover { + background-color: #eee; +} + +.daterangepicker .ranges li.active { + background-color: #08c; + color: #fff; } /* Larger Screen Styling */ @media (min-width: 564px) { - .daterangepicker { - width: auto; - } - + .daterangepicker { + width: auto; } .daterangepicker .ranges ul { - width: 160px; - } - + width: 140px; } .daterangepicker.single .ranges ul { - width: 100%; - } - - .daterangepicker.single .calendar.left { - clear: none; - } - - .daterangepicker.single.ltr .ranges, .daterangepicker.single.ltr .calendar { - float: left; - } - - .daterangepicker.single.rtl .ranges, .daterangepicker.single.rtl .calendar { - float: right; - } - + width: 100%; } + .daterangepicker.single .drp-calendar.left { + clear: none; } + .daterangepicker.single.ltr .ranges, .daterangepicker.single.ltr .drp-calendar { + float: left; } + .daterangepicker.single.rtl .ranges, .daterangepicker.single.rtl .drp-calendar { + float: right; } .daterangepicker.ltr { - direction: ltr; - text-align: left; - } - - .daterangepicker.ltr .calendar.left { + direction: ltr; + text-align: left; } + .daterangepicker.ltr .drp-calendar.left { clear: left; - margin-right: 0; - } - - .daterangepicker.ltr .calendar.left .calendar-table { - border-right: none; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - - .daterangepicker.ltr .calendar.right { - margin-left: 0; - } - - .daterangepicker.ltr .calendar.right .calendar-table { - border-left: none; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - - .daterangepicker.ltr .left .daterangepicker_input { - padding-right: 12px; - } - - .daterangepicker.ltr .calendar.left .calendar-table { - padding-right: 12px; - } - - .daterangepicker.ltr .ranges, .daterangepicker.ltr .calendar { - float: left; - } - + margin-right: 0; } + .daterangepicker.ltr .drp-calendar.left .calendar-table { + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; } + .daterangepicker.ltr .drp-calendar.right { + margin-left: 0; } + .daterangepicker.ltr .drp-calendar.right .calendar-table { + border-left: none; + border-top-left-radius: 0; + border-bottom-left-radius: 0; } + .daterangepicker.ltr .drp-calendar.left .calendar-table { + padding-right: 8px; } + .daterangepicker.ltr .ranges, .daterangepicker.ltr .drp-calendar { + float: left; } .daterangepicker.rtl { - direction: rtl; - text-align: right; - } - - .daterangepicker.rtl .calendar.left { + direction: rtl; + text-align: right; } + .daterangepicker.rtl .drp-calendar.left { clear: right; - margin-left: 0; - } - - .daterangepicker.rtl .calendar.left .calendar-table { - border-left: none; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - - .daterangepicker.rtl .calendar.right { - margin-right: 0; - } - - .daterangepicker.rtl .calendar.right .calendar-table { - border-right: none; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - - .daterangepicker.rtl .left .daterangepicker_input { - padding-left: 12px; - } - - .daterangepicker.rtl .calendar.left .calendar-table { - padding-left: 12px; - } - - .daterangepicker.rtl .ranges, .daterangepicker.rtl .calendar { + margin-left: 0; } + .daterangepicker.rtl .drp-calendar.left .calendar-table { + border-left: none; + border-top-left-radius: 0; + border-bottom-left-radius: 0; } + .daterangepicker.rtl .drp-calendar.right { + margin-right: 0; } + .daterangepicker.rtl .drp-calendar.right .calendar-table { + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; } + .daterangepicker.rtl .drp-calendar.left .calendar-table { + padding-left: 12px; } + .daterangepicker.rtl .ranges, .daterangepicker.rtl .drp-calendar { text-align: right; - float: right; - } -} - + float: right; } } @media (min-width: 730px) { - .daterangepicker .ranges { - width: auto; - } - - .daterangepicker.ltr .ranges { - float: left; - } - - .daterangepicker.rtl .ranges { - float: right; - } - - .daterangepicker .calendar.left { - clear: none !important; - } -} + .daterangepicker .ranges { + width: auto; } + .daterangepicker.ltr .ranges { + float: left; } + .daterangepicker.rtl .ranges { + float: right; } + .daterangepicker .drp-calendar.left { + clear: none !important; } } diff --git a/public/v1/js/lib/daterangepicker.js b/public/v1/js/lib/daterangepicker.js index 822afc9a80..3657f481f0 100755 --- a/public/v1/js/lib/daterangepicker.js +++ b/public/v1/js/lib/daterangepicker.js @@ -1,16 +1,17 @@ /** - * @version: 2.1.30 - * @author: Dan Grossman http://www.dangrossman.info/ - * @copyright: Copyright (c) 2012-2017 Dan Grossman. All rights reserved. - * @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php - * @website: http://www.daterangepicker.com/ - */ -// Follow the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js +* @version: 3.0.3 +* @author: Dan Grossman http://www.dangrossman.info/ +* @copyright: Copyright (c) 2012-2018 Dan Grossman. All rights reserved. +* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php +* @website: http://www.daterangepicker.com/ +*/ +// Following the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Make globaly available as well define(['moment', 'jquery'], function (moment, jquery) { if (!jquery.fn) jquery.fn = {}; // webpack server rendering + if (typeof moment !== 'function' && moment.default) moment = moment.default return factory(moment, jquery); }); } else if (typeof module === 'object' && module.exports) { @@ -37,10 +38,12 @@ this.endDate = moment().endOf('day'); this.minDate = false; this.maxDate = false; - this.dateLimit = false; + this.maxSpan = false; this.autoApply = false; this.singleDatePicker = false; this.showDropdowns = false; + this.minYear = moment().subtract(100, 'year').format('YYYY'); + this.maxYear = moment().add(100, 'year').format('YYYY'); this.showWeekNumbers = false; this.showISOWeekNumbers = false; this.showCustomRangeLabel = true; @@ -62,8 +65,8 @@ this.drops = 'up'; this.buttonClasses = 'btn btn-sm'; - this.applyClass = 'btn-success'; - this.cancelClass = 'btn-default'; + this.applyButtonClasses = 'btn-primary'; + this.cancelButtonClasses = 'btn-default'; this.locale = { direction: 'ltr', @@ -95,36 +98,23 @@ //html template for the picker UI if (typeof options.template !== 'string' && !(options.template instanceof $)) - options.template = ''; + options.template = + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '' + + '' + + ' ' + + '
' + + '
'; this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl); this.container = $(options.template).appendTo(this.parentEl); @@ -148,19 +138,19 @@ this.locale.daysOfWeek = options.locale.daysOfWeek.slice(); if (typeof options.locale.monthNames === 'object') - this.locale.monthNames = options.locale.monthNames.slice(); + this.locale.monthNames = options.locale.monthNames.slice(); if (typeof options.locale.firstDay === 'number') - this.locale.firstDay = options.locale.firstDay; + this.locale.firstDay = options.locale.firstDay; if (typeof options.locale.applyLabel === 'string') - this.locale.applyLabel = options.locale.applyLabel; + this.locale.applyLabel = options.locale.applyLabel; if (typeof options.locale.cancelLabel === 'string') - this.locale.cancelLabel = options.locale.cancelLabel; + this.locale.cancelLabel = options.locale.cancelLabel; if (typeof options.locale.weekLabel === 'string') - this.locale.weekLabel = options.locale.weekLabel; + this.locale.weekLabel = options.locale.weekLabel; if (typeof options.locale.customRangeLabel === 'string'){ //Support unicode chars in the custom range name. @@ -204,14 +194,23 @@ if (this.maxDate && this.endDate.isAfter(this.maxDate)) this.endDate = this.maxDate.clone(); - if (typeof options.applyClass === 'string') - this.applyClass = options.applyClass; + if (typeof options.applyButtonClasses === 'string') + this.applyButtonClasses = options.applyButtonClasses; - if (typeof options.cancelClass === 'string') - this.cancelClass = options.cancelClass; + if (typeof options.applyClass === 'string') //backwards compat + this.applyButtonClasses = options.applyClass; - if (typeof options.dateLimit === 'object') - this.dateLimit = options.dateLimit; + if (typeof options.cancelButtonClasses === 'string') + this.cancelButtonClasses = options.cancelButtonClasses; + + if (typeof options.cancelClass === 'string') //backwards compat + this.cancelButtonClasses = options.cancelClass; + + if (typeof options.maxSpan === 'object') + this.maxSpan = options.maxSpan; + + if (typeof options.dateLimit === 'object') //backwards compat + this.maxSpan = options.dateLimit; if (typeof options.opens === 'string') this.opens = options.opens; @@ -234,6 +233,12 @@ if (typeof options.showDropdowns === 'boolean') this.showDropdowns = options.showDropdowns; + if (typeof options.minYear === 'number') + this.minYear = options.minYear; + + if (typeof options.maxYear === 'number') + this.maxYear = options.maxYear; + if (typeof options.showCustomRangeLabel === 'boolean') this.showCustomRangeLabel = options.showCustomRangeLabel; @@ -286,7 +291,7 @@ //if no start/end dates set, check if an input element contains initial values if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') { - if ($(this.element).is('input[type=text]')) { + if ($(this.element).is(':text')) { var val = $(this.element).val(), split = val.split(this.locale.separator); @@ -319,21 +324,21 @@ else end = moment(options.ranges[range][1]); - // If the start or end date exceed those allowed by the minDate or dateLimit + // If the start or end date exceed those allowed by the minDate or maxSpan // options, shorten the range to the allowable period. if (this.minDate && start.isBefore(this.minDate)) start = this.minDate.clone(); var maxDate = this.maxDate; - if (this.dateLimit && maxDate && start.clone().add(this.dateLimit).isAfter(maxDate)) - maxDate = start.clone().add(this.dateLimit); + if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate)) + maxDate = start.clone().add(this.maxSpan); if (maxDate && end.isAfter(maxDate)) end = maxDate.clone(); // If the end of the range is before the minimum or the start of the range is // after the maximum, don't display this range option at all. if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day')) - || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day'))) + || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day'))) continue; //Support unicode chars in the range names. @@ -369,22 +374,20 @@ if (this.timePicker && this.autoApply) this.autoApply = false; - if (this.autoApply && typeof options.ranges !== 'object') { - this.container.find('.ranges').hide(); - } else if (this.autoApply) { - this.container.find('.applyBtn, .cancelBtn').addClass('hide'); + if (this.autoApply) { + this.container.addClass('auto-apply'); } + if (typeof options.ranges === 'object') + this.container.addClass('show-ranges'); + if (this.singleDatePicker) { this.container.addClass('single'); - this.container.find('.calendar.left').addClass('single'); - this.container.find('.calendar.left').show(); - this.container.find('.calendar.right').hide(); - this.container.find('.daterangepicker_input input, .daterangepicker_input > i').hide(); - if (this.timePicker) { - this.container.find('.ranges ul').hide(); - } else { - this.container.find('.ranges').hide(); + this.container.find('.drp-calendar.left').addClass('single'); + this.container.find('.drp-calendar.left').show(); + this.container.find('.drp-calendar.right').hide(); + if (!this.timePicker) { + this.container.addClass('auto-apply'); } } @@ -394,17 +397,12 @@ this.container.addClass('opens' + this.opens); - //swap the position of the predefined ranges if opens right - if (typeof options.ranges !== 'undefined' && this.opens == 'right') { - this.container.find('.ranges').prependTo( this.container.find('.calendar.left').parent() ); - } - //apply CSS classes and labels to buttons this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses); - if (this.applyClass.length) - this.container.find('.applyBtn').addClass(this.applyClass); - if (this.cancelClass.length) - this.container.find('.cancelBtn').addClass(this.cancelClass); + if (this.applyButtonClasses.length) + this.container.find('.applyBtn').addClass(this.applyButtonClasses); + if (this.cancelButtonClasses.length) + this.container.find('.cancelBtn').addClass(this.cancelButtonClasses); this.container.find('.applyBtn').html(this.locale.applyLabel); this.container.find('.cancelBtn').html(this.locale.cancelLabel); @@ -412,35 +410,29 @@ // event listeners // - this.container.find('.calendar') + this.container.find('.drp-calendar') .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this)) .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this)) .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this)) .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this)) - .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this)) .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this)) .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this)) - .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this)) - .on('focus.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsFocused, this)) - .on('blur.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsBlurred, this)) - .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)) - .on('keydown.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsKeydown, this)); this.container.find('.ranges') + .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)) + + this.container.find('.drp-buttons') .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this)) .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this)) - .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)) - .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this)) - .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this)); if (this.element.is('input') || this.element.is('button')) { this.element.on({ - 'click.daterangepicker': $.proxy(this.show, this), - 'focus.daterangepicker': $.proxy(this.show, this), - 'keyup.daterangepicker': $.proxy(this.elementChanged, this), - 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility - }); + 'click.daterangepicker': $.proxy(this.show, this), + 'focus.daterangepicker': $.proxy(this.show, this), + 'keyup.daterangepicker': $.proxy(this.elementChanged, this), + 'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility + }); } else { this.element.on('click.daterangepicker', $.proxy(this.toggle, this)); this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this)); @@ -450,13 +442,7 @@ // if attached to a text input, set the initial value // - 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') && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format)); - this.element.trigger('change'); - } + this.updateElement(); }; @@ -514,11 +500,13 @@ if (this.maxDate && this.endDate.isAfter(this.maxDate)) this.endDate = this.maxDate.clone(); - if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate)) - this.endDate = this.startDate.clone().add(this.dateLimit); + if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate)) + this.endDate = this.startDate.clone().add(this.maxSpan); this.previousRightTime = this.endDate.clone(); + this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); + if (!this.isShowing) this.updateElement(); @@ -543,13 +531,8 @@ this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled'); } } - if (this.endDate) { - this.container.find('input[name="daterangepicker_end"]').removeClass('active'); - this.container.find('input[name="daterangepicker_start"]').addClass('active'); - } else { - this.container.find('input[name="daterangepicker_end"]').addClass('active'); - this.container.find('input[name="daterangepicker_start"]').removeClass('active'); - } + if (this.endDate) + this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); this.updateMonthsInView(); this.updateCalendars(); this.updateFormInputs(); @@ -563,7 +546,7 @@ (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; } @@ -581,8 +564,8 @@ } } if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) { - this.rightCalendar.month = this.maxDate.clone().date(2); - this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month'); + this.rightCalendar.month = this.maxDate.clone().date(2); + this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month'); } }, @@ -710,7 +693,7 @@ html += ''; if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) { - html += ''; + html += ''; } else { html += ''; } @@ -720,8 +703,8 @@ if (this.showDropdowns) { var currentMonth = calendar[1][1].month(); var currentYear = calendar[1][1].year(); - var maxYear = (maxDate && maxDate.year()) || (currentYear + 5); - var minYear = (minDate && minDate.year()) || (currentYear - 50); + var maxYear = (maxDate && maxDate.year()) || (this.maxYear); + var minYear = (minDate && minDate.year()) || (this.minYear); var inMinYear = currentYear == minYear; var inMaxYear = currentYear == maxYear; @@ -729,12 +712,12 @@ for (var m = 0; m < 12; m++) { if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) { monthHtml += ""; + (m === currentMonth ? " selected='selected'" : "") + + ">" + this.locale.monthNames[m] + ""; } else { monthHtml += ""; + (m === currentMonth ? " selected='selected'" : "") + + " disabled='disabled'>" + this.locale.monthNames[m] + ""; } } monthHtml += ""; @@ -742,8 +725,8 @@ var yearHtml = ''; @@ -752,7 +735,7 @@ html += '' + dateHtml + ''; if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) { - html += ''; + html += ''; } else { html += ''; } @@ -772,10 +755,10 @@ html += ''; html += ''; - //adjust maxDate to reflect the dateLimit setting in order to - //grey out end dates beyond the dateLimit - if (this.endDate == null && this.dateLimit) { - var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day'); + //adjust maxDate to reflect the maxSpan setting in order to + //grey out end dates beyond the maxSpan + if (this.endDate == null && this.maxSpan) { + var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day'); if (!maxDate || maxLimit.isBefore(maxDate)) { maxDate = maxLimit; } @@ -857,7 +840,7 @@ html += ''; html += ''; - this.container.find('.calendar.' + side + ' .calendar-table').html(html); + this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html); }, @@ -869,8 +852,8 @@ var html, selected, minDate, maxDate = this.maxDate; - if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate))) - maxDate = this.startDate.clone().add(this.dateLimit); + if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isAfter(this.maxDate))) + maxDate = this.startDate.clone().add(this.maxSpan); if (side == 'left') { selected = this.startDate.clone(); @@ -880,12 +863,12 @@ minDate = this.startDate; //Preserve the time already selected - var timeSelector = this.container.find('.calendar.right .calendar-time div'); + var timeSelector = this.container.find('.drp-calendar.right .calendar-time'); if (timeSelector.html() != '') { - selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour()); - selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute()); - selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second()); + selected.hour(selected.hour() || timeSelector.find('.hourselect option:selected').val()); + selected.minute(selected.minute() || timeSelector.find('.minuteselect option:selected').val()); + selected.second(selected.second() || timeSelector.find('.secondselect option:selected').val()); if (!this.timePicker24Hour) { var ampm = timeSelector.find('.ampmselect option:selected').val(); @@ -1018,20 +1001,12 @@ html += ''; } - this.container.find('.calendar.' + side + ' .calendar-time div').html(html); + this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html); }, updateFormInputs: function() { - //ignore mouse movements while an above-calendar text input has focus - if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - return; - - this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format)); - if (this.endDate) - this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format)); - if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) { this.container.find('button.applyBtn').removeAttr('disabled'); } else { @@ -1056,44 +1031,44 @@ containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; else containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; - this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup'); + this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up'); if (this.opens == 'left') { this.container.css({ - top: containerTop, - right: parentRightEdge - this.element.offset().left - this.element.outerWidth(), - left: 'auto' - }); + top: containerTop, + right: parentRightEdge - this.element.offset().left - this.element.outerWidth(), + left: 'auto' + }); if (this.container.offset().left < 0) { this.container.css({ - right: 'auto', - left: 9 - }); + right: 'auto', + left: 9 + }); } } else if (this.opens == 'center') { this.container.css({ - top: containerTop, - left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 - - this.container.outerWidth() / 2, - right: 'auto' - }); + top: containerTop, + left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 + - this.container.outerWidth() / 2, + right: 'auto' + }); if (this.container.offset().left < 0) { this.container.css({ - right: 'auto', - left: 9 - }); + right: 'auto', + left: 9 + }); } } else { this.container.css({ - top: containerTop, - left: this.element.offset().left - parentOffset.left, - right: 'auto' - }); + top: containerTop, + left: this.element.offset().left - parentOffset.left, + right: 'auto' + }); if (this.container.offset().left + this.container.outerWidth() > $(window).width()) { this.container.css({ - left: 'auto', - right: 0 - }); + left: 'auto', + right: 0 + }); } } }, @@ -1106,13 +1081,13 @@ // Bind global datepicker mousedown for hiding and $(document) - .on('mousedown.daterangepicker', this._outsideClickProxy) - // also support mobile devices - .on('touchend.daterangepicker', this._outsideClickProxy) - // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them - .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) - // and also close when focus changes to outside the picker (eg. tabbing between controls) - .on('focusin.daterangepicker', this._outsideClickProxy); + .on('mousedown.daterangepicker', this._outsideClickProxy) + // also support mobile devices + .on('touchend.daterangepicker', this._outsideClickProxy) + // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them + .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) + // and also close when focus changes to outside the picker (eg. tabbing between controls) + .on('focusin.daterangepicker', this._outsideClickProxy); // Reposition the picker if the window is resized while it's open $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this)); @@ -1139,7 +1114,7 @@ //if a new date range was selected, invoke the user callback function if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) - this.callback(this.startDate, this.endDate, this.chosenLabel); + this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel); //if picker is attached to a text input, update it this.updateElement(); @@ -1165,11 +1140,11 @@ // itself then call this.hide() if ( // ie modal dialog fix - e.type == "focusin" || - target.closest(this.element).length || - target.closest(this.container).length || - target.closest('.calendar-table').length - ) return; + e.type == "focusin" || + target.closest(this.element).length || + target.closest(this.container).length || + target.closest('.calendar-table').length + ) return; this.hide(); this.element.trigger('outsideClick.daterangepicker', this); }, @@ -1185,24 +1160,6 @@ this.element.trigger('hideCalendar.daterangepicker', this); }, - hoverRange: function(e) { - - //ignore mouse movements while an above-calendar text input has focus - if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - return; - - var label = e.target.getAttribute('data-range-key'); - - if (label == this.locale.customRangeLabel) { - this.updateView(); - } else { - var dates = this.ranges[label]; - this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format)); - this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format)); - } - - }, - clickRange: function(e) { var label = e.target.getAttribute('data-range-key'); this.chosenLabel = label; @@ -1225,7 +1182,7 @@ }, clickPrev: function(e) { - var cal = $(e.target).parents('.calendar'); + var cal = $(e.target).parents('.drp-calendar'); if (cal.hasClass('left')) { this.leftCalendar.month.subtract(1, 'month'); if (this.linkedCalendars) @@ -1237,7 +1194,7 @@ }, clickNext: function(e) { - var cal = $(e.target).parents('.calendar'); + var cal = $(e.target).parents('.drp-calendar'); if (cal.hasClass('left')) { this.leftCalendar.month.add(1, 'month'); } else { @@ -1250,32 +1207,21 @@ hoverDate: function(e) { - //ignore mouse movements while an above-calendar text input has focus - //if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - // return; - //ignore dates that can't be selected if (!$(e.target).hasClass('available')) return; - //have the text inputs above calendars reflect the date being hovered over var title = $(e.target).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); - var cal = $(e.target).parents('.calendar'); + var cal = $(e.target).parents('.drp-calendar'); var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; - if (this.endDate && !this.container.find('input[name=daterangepicker_start]').is(":focus")) { - this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format)); - } else if (!this.endDate && !this.container.find('input[name=daterangepicker_end]').is(":focus")) { - this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format)); - } - //highlight the dates between the start date and the date being hovered as a potential end date var leftCalendar = this.leftCalendar; var rightCalendar = this.rightCalendar; var startDate = this.startDate; if (!this.endDate) { - this.container.find('.calendar tbody td').each(function(index, el) { + this.container.find('.drp-calendar tbody td').each(function(index, el) { //skip week numbers, only look at dates if ($(el).hasClass('week')) return; @@ -1283,7 +1229,7 @@ var title = $(el).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); - var cal = $(el).parents('.calendar'); + var cal = $(el).parents('.drp-calendar'); var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col]; if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) { @@ -1304,7 +1250,7 @@ var title = $(e.target).attr('data-title'); var row = title.substr(1, 1); var col = title.substr(3, 1); - var cal = $(e.target).parents('.calendar'); + var cal = $(e.target).parents('.drp-calendar'); var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; // @@ -1352,8 +1298,8 @@ } this.setEndDate(date.clone()); if (this.autoApply) { - this.calculateChosenLabel(); - this.clickApply(); + this.calculateChosenLabel(); + this.clickApply(); } } @@ -1374,19 +1320,19 @@ var customRange = true; var i = 0; for (var range in this.ranges) { - if (this.timePicker) { - var format = this.timePickerSeconds ? "YYYY-MM-DD hh:mm:ss" : "YYYY-MM-DD hh:mm"; + if (this.timePicker) { + var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm"; //ignore times when comparing dates if time picker seconds is not enabled if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) { customRange = false; - this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html(); + this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; } } else { //ignore times when comparing dates if time picker is not enabled if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) { customRange = false; - this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html(); + this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key'); break; } } @@ -1394,7 +1340,7 @@ } if (customRange) { if (this.showCustomRangeLabel) { - this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html(); + this.chosenLabel = this.container.find('.ranges li:last').addClass('active').attr('data-range-key'); } else { this.chosenLabel = null; } @@ -1415,9 +1361,9 @@ }, monthOrYearChanged: function(e) { - var isLeft = $(e.target).closest('.calendar').hasClass('left'), + var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'), leftOrRight = isLeft ? 'left' : 'right', - cal = this.container.find('.calendar.'+leftOrRight); + cal = this.container.find('.drp-calendar.'+leftOrRight); // Month must be Number for new moment versions var month = parseInt(cal.find('.monthselect').val(), 10); @@ -1458,7 +1404,7 @@ timeChanged: function(e) { - var cal = $(e.target).closest('.calendar'), + var cal = $(e.target).closest('.drp-calendar'), isLeft = cal.hasClass('left'); var hour = parseInt(cal.find('.hourselect').val(), 10); @@ -1504,81 +1450,6 @@ }, - formInputsChanged: function(e) { - 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); - - if (start.isValid() && end.isValid()) { - - if (isRight && end.isBefore(start)) - start = end.clone(); - - this.setStartDate(start); - this.setEndDate(end); - - if (isRight) { - this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format)); - } else { - this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format)); - } - - } - - this.updateView(); - }, - - formInputsFocused: function(e) { - - // Highlight the focused input - this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass('active'); - $(e.target).addClass('active'); - - // Set the state such that if the user goes back to using a mouse, - // the calendars are aware we're selecting the end of the range, not - // the start. This allows someone to edit the end of a date range without - // re-selecting the beginning, by clicking on the end date input then - // using the calendar. - var isRight = $(e.target).closest('.calendar').hasClass('right'); - if (isRight) { - this.endDate = null; - this.setStartDate(this.startDate.clone()); - this.updateView(); - } - - }, - - formInputsBlurred: function(e) { - - // this function has one purpose right now: if you tab from the first - // text input to the second in the UI, the endDate is nulled so that - // you can click another, but if you tab out without clicking anything - // or changing the input value, the old endDate should be retained - - if (!this.endDate) { - var val = this.container.find('input[name="daterangepicker_end"]').val(); - var end = moment(val, this.locale.format); - if (end.isValid()) { - this.setEndDate(end); - this.updateView(); - } - } - - }, - - formInputsKeydown: function(e) { - // This function ensures that if the 'enter' key was pressed in the input, then the calendars - // are updated with the startDate and endDate. - // This behaviour is automatic in Chrome/Firefox/Edge but not in IE 11 hence why this exists. - // Other browsers and versions of IE are untested and the behaviour is unknown. - if (e.keyCode === 13) { - // Prevent the calendar from being updated twice on Chrome/Firefox/Edge - e.preventDefault(); - this.formInputsChanged(e); - } - }, - - elementChanged: function() { if (!this.element.is('input')) return; if (!this.element.val().length) return; @@ -1620,12 +1491,14 @@ }, updateElement: function() { - 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') && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format)); - this.element.trigger('change'); + if (this.element.is('input') && this.autoUpdateInput) { + var newValue = this.startDate.format(this.locale.format); + if (!this.singleDatePicker) { + newValue += this.locale.separator + this.endDate.format(this.locale.format); + } + if (newValue !== this.element.val()) { + this.element.val(newValue).trigger('change'); + } } }, @@ -1650,4 +1523,4 @@ return DateRangePicker; -})); \ No newline at end of file +}));