';
+ 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');
+ if (!maxDate || maxLimit.isBefore(maxDate)) {
+ maxDate = maxLimit;
+ }
+ }
+
+ for (var row = 0; row < 6; row++) {
+ html += '
';
+
+ // add week number
+ if (this.showWeekNumbers)
+ html += '
' + calendar[row][0].week() + '
';
+ else if (this.showISOWeekNumbers)
+ html += '
' + calendar[row][0].isoWeek() + '
';
+
+ for (var col = 0; col < 7; col++) {
+
+ var classes = [];
+
+ //highlight today's date
+ if (calendar[row][col].isSame(new Date(), "day"))
+ classes.push('today');
+
+ //highlight weekends
+ if (calendar[row][col].isoWeekday() > 5)
+ classes.push('weekend');
+
+ //grey out the dates in other months displayed at beginning and end of this calendar
+ if (calendar[row][col].month() != calendar[1][1].month())
+ classes.push('off');
+
+ //don't allow selection of dates before the minimum date
+ if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
+ classes.push('off', 'disabled');
+
+ //don't allow selection of dates after the maximum date
+ if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
+ classes.push('off', 'disabled');
+
+ //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
+ if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
+ classes.push('active', 'start-date');
+
+ //highlight the currently selected end date
+ if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
+ classes.push('active', 'end-date');
+
+ //highlight dates in-between the selected dates
+ 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] + ' ';
+ if (classes[i] == 'disabled')
+ disabled = true;
+ }
+ if (!disabled)
+ cname += 'available';
+
+ html += '
' + calendar[row][col].date() + '
';
+
+ }
+ html += '
';
+ }
+
+ html += '';
+ html += '
';
+
+ this.container.find('.calendar.' + side + ' .calendar-table').html(html);
+
+ },
+
+ renderTimePicker: function(side) {
+
+ // Don't bother updating the time picker if it's currently disabled
+ // because an end date hasn't been clicked yet
+ if (side == 'right' && !this.endDate) return;
+
+ 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 (side == 'left') {
+ selected = this.startDate.clone();
+ minDate = this.minDate;
+ } else if (side == 'right') {
+ selected = this.endDate.clone();
+ minDate = this.startDate;
+
+ //Preserve the time already selected
+ var timeSelector = this.container.find('.calendar.right .calendar-time div');
+ 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());
+
+ if (!this.timePicker24Hour) {
+ var ampm = timeSelector.find('.ampmselect option:selected').val();
+ if (ampm === 'PM' && selected.hour() < 12)
+ selected.hour(selected.hour() + 12);
+ if (ampm === 'AM' && selected.hour() === 12)
+ selected.hour(0);
+ }
+
+ }
+
+ if (selected.isBefore(this.startDate))
+ selected = this.startDate.clone();
+
+ if (maxDate && selected.isAfter(maxDate))
+ selected = maxDate.clone();
+
+ }
+
+ //
+ // hours
+ //
+
+ html = ' ';
+
+ //
+ // minutes
+ //
+
+ html += ': ';
+
+ //
+ // seconds
+ //
+
+ if (this.timePickerSeconds) {
+ html += ': ';
+ }
+
+ //
+ // AM/PM
+ //
+
+ if (!this.timePicker24Hour) {
+ html += '';
+ }
+
+ this.container.find('.calendar.' + side + ' .calendar-time div').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 {
+ this.container.find('button.applyBtn').attr('disabled', 'disabled');
+ }
+
+ },
+
+ move: function() {
+ var parentOffset = { top: 0, left: 0 },
+ containerTop;
+ var parentRightEdge = $(window).width();
+ if (!this.parentEl.is('body')) {
+ parentOffset = {
+ top: this.parentEl.offset().top - this.parentEl.scrollTop(),
+ left: this.parentEl.offset().left - this.parentEl.scrollLeft()
+ };
+ parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
+ }
+
+ if (this.drops == 'up')
+ 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');
+
+ if (this.opens == 'left') {
+ this.container.css({
+ 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
+ });
+ }
+ } 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'
+ });
+ if (this.container.offset().left < 0) {
+ this.container.css({
+ right: 'auto',
+ left: 9
+ });
+ }
+ } else {
+ this.container.css({
+ 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
+ });
+ }
+ }
+ },
+
+ show: function(e) {
+ if (this.isShowing) return;
+
+ // Create a click proxy that is private to this instance of datepicker, for unbinding
+ this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
+
+ // 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);
+
+ // Reposition the picker if the window is resized while it's open
+ $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
+
+ this.oldStartDate = this.startDate.clone();
+ this.oldEndDate = this.endDate.clone();
+ this.previousRightTime = this.endDate.clone();
+
+ this.updateView();
+ this.container.show();
+ this.move();
+ this.element.trigger('show.daterangepicker', this);
+ this.isShowing = true;
+ },
+
+ hide: function(e) {
+ if (!this.isShowing) return;
+
+ //incomplete date selection, revert to last values
+ if (!this.endDate) {
+ this.startDate = this.oldStartDate.clone();
+ this.endDate = this.oldEndDate.clone();
+ }
+
+ //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);
+
+ //if picker is attached to a text input, update it
+ this.updateElement();
+
+ $(document).off('.daterangepicker');
+ $(window).off('.daterangepicker');
+ this.container.hide();
+ this.element.trigger('hide.daterangepicker', this);
+ this.isShowing = false;
+ },
+
+ toggle: function(e) {
+ if (this.isShowing) {
+ this.hide();
+ } else {
+ this.show();
+ }
+ },
+
+ outsideClick: function(e) {
+ var target = $(e.target);
+ // if the page is clicked anywhere except within the daterangerpicker/button
+ // 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;
+ this.hide();
+ this.element.trigger('outsideClick.daterangepicker', this);
+ },
+
+ showCalendars: function() {
+ this.container.addClass('show-calendar');
+ this.move();
+ this.element.trigger('showCalendar.daterangepicker', this);
+ },
+
+ hideCalendars: function() {
+ this.container.removeClass('show-calendar');
+ 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;
+ if (label == this.locale.customRangeLabel) {
+ this.showCalendars();
+ } else {
+ var dates = this.ranges[label];
+ this.startDate = dates[0];
+ this.endDate = dates[1];
+
+ if (!this.timePicker) {
+ this.startDate.startOf('day');
+ this.endDate.endOf('day');
+ }
+
+ if (!this.alwaysShowCalendars)
+ this.hideCalendars();
+ this.clickApply();
+ }
+ },
+
+ clickPrev: function(e) {
+ var cal = $(e.target).parents('.calendar');
+ if (cal.hasClass('left')) {
+ this.leftCalendar.month.subtract(1, 'month');
+ if (this.linkedCalendars)
+ this.rightCalendar.month.subtract(1, 'month');
+ } else {
+ this.rightCalendar.month.subtract(1, 'month');
+ }
+ this.updateCalendars();
+ },
+
+ clickNext: function(e) {
+ var cal = $(e.target).parents('.calendar');
+ if (cal.hasClass('left')) {
+ this.leftCalendar.month.add(1, 'month');
+ } else {
+ this.rightCalendar.month.add(1, 'month');
+ if (this.linkedCalendars)
+ this.leftCalendar.month.add(1, 'month');
+ }
+ this.updateCalendars();
+ },
+
+ 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 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) {
+
+ //skip week numbers, only look at dates
+ if ($(el).hasClass('week')) return;
+
+ var title = $(el).attr('data-title');
+ var row = title.substr(1, 1);
+ var col = title.substr(3, 1);
+ var cal = $(el).parents('.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')) {
+ $(el).addClass('in-range');
+ } else {
+ $(el).removeClass('in-range');
+ }
+
+ });
+ }
+
+ },
+
+ clickDate: function(e) {
+
+ if (!$(e.target).hasClass('available')) return;
+
+ 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 date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
+
+ //
+ // this function needs to do a few things:
+ // * alternate between selecting a start and end date for the range,
+ // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
+ // * if autoapply is enabled, and an end date was chosen, apply the selection
+ // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
+ // * if one of the inputs above the calendars was focused, cancel that manual input
+ //
+
+ if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
+ if (this.timePicker) {
+ var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
+ if (!this.timePicker24Hour) {
+ var ampm = this.container.find('.left .ampmselect').val();
+ if (ampm === 'PM' && hour < 12)
+ hour += 12;
+ if (ampm === 'AM' && hour === 12)
+ hour = 0;
+ }
+ var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
+ var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
+ date = date.clone().hour(hour).minute(minute).second(second);
+ }
+ this.endDate = null;
+ this.setStartDate(date.clone());
+ } else if (!this.endDate && date.isBefore(this.startDate)) {
+ //special case: clicking the same date for start/end,
+ //but the time of the end date is before the start date
+ this.setEndDate(this.startDate.clone());
+ } else { // picking end
+ if (this.timePicker) {
+ var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
+ if (!this.timePicker24Hour) {
+ var ampm = this.container.find('.right .ampmselect').val();
+ if (ampm === 'PM' && hour < 12)
+ hour += 12;
+ if (ampm === 'AM' && hour === 12)
+ hour = 0;
+ }
+ var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
+ var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
+ date = date.clone().hour(hour).minute(minute).second(second);
+ }
+ this.setEndDate(date.clone());
+ if (this.autoApply) {
+ this.calculateChosenLabel();
+ this.clickApply();
+ }
+ }
+
+ if (this.singleDatePicker) {
+ this.setEndDate(this.startDate);
+ if (!this.timePicker)
+ this.clickApply();
+ }
+
+ this.updateView();
+
+ //This is to cancel the blur event handler if the mouse was in one of the inputs
+ e.stopPropagation();
+
+ },
+
+ calculateChosenLabel: function () {
+ 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";
+ //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();
+ 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();
+ break;
+ }
+ }
+ i++;
+ }
+ if (customRange) {
+ if (this.showCustomRangeLabel) {
+ this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
+ } else {
+ this.chosenLabel = null;
+ }
+ this.showCalendars();
+ }
+ },
+
+ clickApply: function(e) {
+ this.hide();
+ this.element.trigger('apply.daterangepicker', this);
+ },
+
+ clickCancel: function(e) {
+ this.startDate = this.oldStartDate;
+ this.endDate = this.oldEndDate;
+ this.hide();
+ this.element.trigger('cancel.daterangepicker', this);
+ },
+
+ monthOrYearChanged: function(e) {
+ var isLeft = $(e.target).closest('.calendar').hasClass('left'),
+ leftOrRight = isLeft ? 'left' : 'right',
+ cal = this.container.find('.calendar.'+leftOrRight);
+
+ // Month must be Number for new moment versions
+ var month = parseInt(cal.find('.monthselect').val(), 10);
+ var year = cal.find('.yearselect').val();
+
+ if (!isLeft) {
+ if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
+ month = this.startDate.month();
+ year = this.startDate.year();
+ }
+ }
+
+ if (this.minDate) {
+ if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
+ month = this.minDate.month();
+ year = this.minDate.year();
+ }
+ }
+
+ if (this.maxDate) {
+ if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
+ month = this.maxDate.month();
+ year = this.maxDate.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();
+ },
+
+ timeChanged: function(e) {
+
+ var cal = $(e.target).closest('.calendar'),
+ isLeft = cal.hasClass('left');
+
+ var hour = parseInt(cal.find('.hourselect').val(), 10);
+ var minute = parseInt(cal.find('.minuteselect').val(), 10);
+ var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
+
+ if (!this.timePicker24Hour) {
+ var ampm = cal.find('.ampmselect').val();
+ if (ampm === 'PM' && hour < 12)
+ hour += 12;
+ if (ampm === 'AM' && hour === 12)
+ hour = 0;
+ }
+
+ if (isLeft) {
+ var start = this.startDate.clone();
+ start.hour(hour);
+ start.minute(minute);
+ start.second(second);
+ this.setStartDate(start);
+ if (this.singleDatePicker) {
+ this.endDate = this.startDate.clone();
+ } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
+ this.setEndDate(start.clone());
+ }
+ } else if (this.endDate) {
+ var end = this.endDate.clone();
+ end.hour(hour);
+ end.minute(minute);
+ end.second(second);
+ this.setEndDate(end);
+ }
+
+ //update the calendars so all clickable dates reflect the new time component
+ this.updateCalendars();
+
+ //update the form inputs above the calendars with the new time
+ this.updateFormInputs();
+
+ //re-render the time pickers because changing one selection can affect what's enabled in another
+ this.renderTimePicker('left');
+ this.renderTimePicker('right');
+
+ },
+
+ 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;
+
+ var dateString = this.element.val().split(this.locale.separator),
+ start = null,
+ end = null;
+
+ if (dateString.length === 2) {
+ start = moment(dateString[0], this.locale.format);
+ end = moment(dateString[1], this.locale.format);
+ }
+
+ if (this.singleDatePicker || start === null || end === null) {
+ start = moment(this.element.val(), this.locale.format);
+ end = start;
+ }
+
+ if (!start.isValid() || !end.isValid()) return;
+
+ this.setStartDate(start);
+ this.setEndDate(end);
+ this.updateView();
+ },
+
+ keydown: function(e) {
+ //hide on tab or enter
+ if ((e.keyCode === 9) || (e.keyCode === 13)) {
+ this.hide();
+ }
+
+ //hide on esc and prevent propagation
+ if (e.keyCode === 27) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.hide();
+ }
+ },
+
+ 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');
+ }
+ },
+
+ remove: function() {
+ this.container.remove();
+ this.element.off('.daterangepicker');
+ this.element.removeData();
+ }
+
+ };
+
+ $.fn.daterangepicker = function(options, callback) {
+ var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
+ this.each(function() {
+ var el = $(this);
+ if (el.data('daterangepicker'))
+ el.data('daterangepicker').remove();
+ el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
+ });
+ return this;
+ };
+
+ return DateRangePicker;
+
+}));
diff --git a/vendor/blobt/grid/ActionColumn.php b/vendor/blobt/grid/ActionColumn.php
new file mode 100644
index 0000000..863a6ff
--- /dev/null
+++ b/vendor/blobt/grid/ActionColumn.php
@@ -0,0 +1,203 @@
+ function ($url, $model, $key) {
+ * return $model->status === 'editable' ? Html::a('Update', $url) : '';
+ * },
+ * ],
+ *
+ */
+ public $buttons = [];
+
+ /** @var array 和上述$buttons功能类似,只是匿名函数返回布尔,只控制是否展示
+ * 匿名函数必须遵循以下申明方式:
+ *
+ * ```php
+ * function ($model, $key, $index) {
+ * return $model->status === 'editable';
+ * }
+ * ```
+ *
+ * 使用案例:
+ * ```php
+ * [
+ * 'update' => \Yii::$app->user->can('update'),
+ * ],
+ * ```
+ * @since 2.0.7
+ */
+ public $visibleButtons = [];
+
+ /**
+ * @var callable 匿名函数,用作控制按钮Url
+ *
+ * 匿名函数必须遵循以下申明方式:
+ * ```php
+ * function (string $action, mixed $model, mixed $key, integer $index, ActionColumn $this) {
+ * //return string;
+ * }
+ * ```
+ *
+ * 如果没有设置,默认使用本类的[[createUrl()]].
+ */
+ public $urlCreator;
+
+ /**
+ * @var array 按钮的html属性
+ */
+ public $buttonOptions = [];
+
+ /**
+ * {@inheritdoc}
+ */
+ public function init() {
+ parent::init();
+ $this->initDefaultButtons();
+ }
+
+ /**
+ * 初始化默认按钮
+ */
+ protected function initDefaultButtons() {
+ $this->initDefaultButton('view', 'eye-open');
+ $this->initDefaultButton('update', 'pencil');
+ $this->initDefaultButton('delete', 'trash', [
+ 'alertify-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?')
+ ]);
+ }
+
+ /**
+ * 初始化按钮
+ * @param string $name
+ * @param string $iconName
+ * @param array $additionalOptions 附加html属性
+ */
+ protected function initDefaultButton($name, $iconName, $additionalOptions = []) {
+ if (!isset($this->buttons[$name]) && strpos($this->template, '{' . $name . '}') !== false) {
+ $this->buttons[$name] = function ($url, $model, $key) use ($name, $iconName, $additionalOptions) {
+ switch ($name) {
+ case 'view':
+ $title = Yii::t('yii', 'View');
+ break;
+ case 'update':
+ $title = Yii::t('yii', 'Update');
+ break;
+ case 'delete':
+ $title = Yii::t('yii', 'Delete');
+ break;
+ default:
+ $title = ucfirst($name);
+ }
+ $options = array_merge([
+ 'title' => $title,
+ 'aria-label' => $title,
+ 'data-pjax' => '0',
+ ], $additionalOptions, $this->buttonOptions);
+ $icon = Html::tag('span', '', ['class' => "glyphicon glyphicon-$iconName"]);
+ return Html::a($icon, $url, $options);
+ };
+ }
+ }
+
+ /**
+ * 通过给定的action和model创建一个URL.
+ *
+ * @param string $action 按钮名
+ * @param \yii\db\ActiveRecordInterface $model 数据模型
+ * @param mixed $key 模型的ID
+ * @param int $index 行号
+ * @return string the created URL
+ */
+ public function createUrl($action, $model, $key, $index) {
+ if (is_callable($this->urlCreator)) {
+ return call_user_func($this->urlCreator, $action, $model, $key, $index, $this);
+ }
+
+ $params = is_array($key) ? $key : ['id' => (string) $key];
+ $params[0] = $this->controller ? $this->controller . '/' . $action : $action;
+
+ return Url::toRoute($params);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function renderDataCellContent($model, $key, $index) {
+ return preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) use ($model, $key, $index) {
+ $name = $matches[1];
+
+ if (isset($this->visibleButtons[$name])) {
+ $isVisible = $this->visibleButtons[$name] instanceof \Closure ? call_user_func($this->visibleButtons[$name], $model, $key, $index) : $this->visibleButtons[$name];
+ } else {
+ $isVisible = true;
+ }
+
+ if ($isVisible && isset($this->buttons[$name])) {
+ $url = $this->createUrl($name, $model, $key, $index);
+ return call_user_func($this->buttons[$name], $url, $model, $key);
+ }
+
+ return '';
+ }, $this->template);
+ }
+
+}
diff --git a/vendor/blobt/grid/CheckboxColumn.php b/vendor/blobt/grid/CheckboxColumn.php
new file mode 100644
index 0000000..0afefc6
--- /dev/null
+++ b/vendor/blobt/grid/CheckboxColumn.php
@@ -0,0 +1,162 @@
+ function ($model, $key, $index, $column) {
+ * return ['value' => $model->name];
+ * }
+ * ```
+ *
+ * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
+ */
+ public $checkboxOptions = [];
+
+ /**
+ * @var bool whether it is possible to select multiple rows. Defaults to `true`.
+ */
+ public $multiple = true;
+
+ /**
+ * @var string the css class that will be used to find the checkboxes.
+ * @since 2.0.9
+ */
+ public $cssClass;
+
+ /**
+ * {@inheritdoc}
+ * @throws \yii\base\InvalidConfigException if [[name]] is not set.
+ */
+ public function init() {
+ parent::init();
+ if (empty($this->name)) {
+ throw new InvalidConfigException('The "name" property must be set.');
+ }
+ if (substr_compare($this->name, '[]', -2, 2)) {
+ $this->name .= '[]';
+ }
+
+ $this->registerClientScript();
+ }
+
+ /**
+ * Renders the header cell content.
+ * The default implementation simply renders [[header]].
+ * This method may be overridden to customize the rendering of the header cell.
+ * @return string the rendering result
+ */
+ protected function renderHeaderCellContent() {
+ if ($this->header !== null || !$this->multiple) {
+ return parent::renderHeaderCellContent();
+ }
+
+ return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function renderDataCellContent($model, $key, $index) {
+ if ($this->content !== null) {
+ return parent::renderDataCellContent($model, $key, $index);
+ }
+
+ if ($this->checkboxOptions instanceof Closure) {
+ $options = call_user_func($this->checkboxOptions, $model, $key, $index, $this);
+ } else {
+ $options = $this->checkboxOptions;
+ }
+
+ if (!isset($options['value'])) {
+ $options['value'] = is_array($key) ? Json::encode($key) : $key;
+ }
+
+ if ($this->cssClass !== null) {
+ Html::addCssClass($options, $this->cssClass);
+ }
+
+ return Html::checkbox($this->name, !empty($options['checked']), $options);
+ }
+
+ /**
+ * Returns header checkbox name.
+ * @return string header checkbox name
+ * @since 2.0.8
+ */
+ protected function getHeaderCheckBoxName() {
+ $name = $this->name;
+ if (substr_compare($name, '[]', -2, 2) === 0) {
+ $name = substr($name, 0, -2);
+ }
+ if (substr_compare($name, ']', -1, 1) === 0) {
+ $name = substr($name, 0, -1) . '_all]';
+ } else {
+ $name .= '_all';
+ }
+
+ return $name;
+ }
+
+ /**
+ * Registers the needed JavaScript.
+ * @since 2.0.8
+ */
+ public function registerClientScript() {
+ $id = $this->grid->options['id'];
+ $options = Json::encode([
+ 'name' => $this->name,
+ 'class' => $this->cssClass,
+ 'multiple' => $this->multiple,
+ 'checkAll' => $this->grid->showHeader ? $this->getHeaderCheckBoxName() : null,
+ ]);
+ $this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
+ }
+
+}
diff --git a/vendor/blobt/grid/Column.php b/vendor/blobt/grid/Column.php
new file mode 100644
index 0000000..2fde27d
--- /dev/null
+++ b/vendor/blobt/grid/Column.php
@@ -0,0 +1,40 @@
+ 'box'];
+
+ /**
+ * @var array table的html属性
+ */
+ public $tableOptions = ['class' => 'table table-bordered table-hover dataTable'];
+
+ /**
+ * @var array 表格头部html属性
+ */
+ public $headerRowOptions = [];
+
+ /**
+ * @var array 表格脚部html属性
+ */
+ public $footerRowOptions = [];
+
+ /**
+ * @var array|Cloure 表格每一行的html属性
+ * 这个参数除了可以是一个options数组外,还可以是一个匿名函数,该函数必须返回一个options数组,
+ * 渲染每一行都会调用该函数
+ * 该函数必须遵循以下声明规则
+ * ```php
+ * function ($model, $key, $index, $grid)
+ * ```
+ *
+ * - `$model`: 每行的模型
+ * - `$key`: id值
+ * - `$index`: [[dataProvider]]提供的索引号
+ * - `$grid`: GridView 对象
+ */
+ public $rowOptions = [];
+
+ /**
+ * @var Closure an 一个匿名函数(结构和[[rowOptions]]一样),每行渲染前后都会被调用
+ */
+ public $beforeRow;
+ public $afterRow;
+
+ /**
+ * @var bool 是否显示表格头
+ */
+ public $showHeader = true;
+
+ /**
+ * @var bool 是否显示表格脚
+ */
+ public $showFooter = false;
+
+ /**
+ * @var bool 没有数据情况下是否显示
+ */
+ public $showOnEmpty = true;
+
+ /**
+ * @var array|Formatter 用来格式化输出属性值
+ */
+ public $formatter;
+
+ /**
+ * @var string 摘要的显示样式
+ *
+ *
+ * - `{begin}`: 开始条数
+ * - `{end}`: 结束条数
+ * - `{count}`: 显示条数
+ * - `{totalCount}`: 总记录条数
+ * - `{page}`: 显示分页
+ * - `{pageCount}`: 总分页数
+ * - `{select}`: 显示页数
+ */
+ public $summary = "{select} 显示{begin}~{end}条 共{totalCount}条";
+
+ /**
+ * @var array 摘要的html属性
+ */
+ public $summaryOptions = ['class' => 'summary'];
+
+ /**
+ * @var array 列配置数组. 数组每一项代表一个列,列数组可以包括class、attribute、format、label等。
+ * 例子:
+ * ```php
+ * [
+ * ['class' => SerialColumn::className()],
+ * [
+ * 'class' => DataColumn::className(), //渲染用到的类,没一列都默认使用[[DataColumn]]渲染,所以这里可以忽略
+ * 'attribute' => 'name', //代表每一行的数据原
+ * 'format' => 'text', //输出的格式
+ * 'label' => 'Name', //label
+ * '' => ''
+ * ],
+ * ['class' => CheckboxColumn::className()],
+ * ]
+ * ```
+ *
+ * 当然,也支持简写成这样:[[DataColumn::attribute|attribute]], [[DataColumn::format|format]],
+ * 或 [[DataColumn::label|label]] options: `"attribute:format:label"`.
+ * 所以上面例子的 "name" 列能简写成这样 : `"name:text:Name"`.
+ * 甚至"format"和"label"都是可以不制定的,因为它们都有默认值。
+ *
+ * 其实大多数情况下都可以使用简写:
+ *
+ * ```php
+ * [
+ * 'id',
+ * 'amount:currency:Total Amount',
+ * 'created_at:datetime',
+ * ]
+ * ```
+ *
+ * 当[[dataProvider]]提供active records, 且active record又和其它 active record建立了关联关系的,
+ * 例如 the `name` 属性是 和 `author` 关联,那么你可以这样制定数据:
+ *
+ * ```php
+ * // shortcut syntax
+ * 'author.name',
+ * // full syntax
+ * [
+ * 'attribute' => 'author.name',
+ * // ...
+ * ]
+ * ```
+ */
+ public $columns = [];
+
+ /**
+ * @var string 当单元格数据为空时候显示的内容。
+ */
+ public $emptyCell = ' ';
+
+ /**
+ * @var string TODO:这个目前用来做页数选择,具体原理没有研究清楚
+ */
+ public $filterSelector = 'select[name="per-page"]';
+
+ /**
+ * @var type
+ */
+ public $filter;
+
+ /**
+ * @var array 批量操作的选项
+ */
+ public $batch;
+
+ /**
+ * @var string 表格的layout:
+ *
+ * - `{summary}`: 摘要.
+ * - `{items}`: 表格项.
+ * - `{pager}`: 分页.
+ * - `{batch}`: 批量处理
+ */
+ public $layout = <<< HTML
+