PageSourceSearch

https://boatcharter.fo/wp-content/themes/wprentals/js/daterangepicker.js?ver=1.0

js boatcharter.fo collected 2026-10-08 21:27:58 UTC 72,821 bytes, 1,711 lines download raw bytes

vendor: 27,498 bytes, lines 1-656
1/**
2* @version: 3.0.5
3* @author: Dan Grossman http://www.dangrossman.info/
4* @copyright: Copyright (c) 2012-2019 Dan Grossman. All rights reserved.
5* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
6* @website: http://www.daterangepicker.com/
7*/
8// Following the UMD template https://github.com/umdjs/umd/blob/master/templates/returnExportsGlobal.js
9(function (root, factory) {
10    if (typeof define === 'function' && define.amd) {
11        // AMD. Make globaly available as well
12        define(['moment', 'jquery'], function (moment, jquery) {
13            if (!jquery.fn) jquery.fn = {}; // webpack server rendering
14            if (typeof moment !== 'function' && moment.default) moment = moment.default
15            return factory(moment, jquery);
16        });
17    } else if (typeof module === 'object' && module.exports) {
18        // Node / Browserify
19        //isomorphic issue
20        var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined;
21        if (!jQuery) {
22            jQuery = require('jquery');
23            if (!jQuery.fn) jQuery.fn = {};
24        }
25        var moment = (typeof window != 'undefined' && typeof window.moment != 'undefined') ? window.moment : require('moment');
26        module.exports = factory(moment, jQuery);
27    } else {
28        // Browser globals
29        root.daterangepicker = factory(root.moment, root.jQuery);
30    }
31}(this, function(moment, $) {
32    var DateRangePicker = function(element, options, cb) {
33
34        //default settings for options
35        this.parentEl = 'body';
36        this.element = $(element);
37        this.startDate = moment().startOf('day');
38        this.endDate = moment().endOf('day');
39        this.minDate = false;
40        this.minDateSpan=false;
41        this.maxDate = false;
42        this.maxSpan = false;
43        this.minSpan = false;
44        this.start_date_picked=0;
45        this.autoApply = false;
46        this.singleDatePicker = false;
47        this.showDropdowns = false;
48        this.minYear = moment().subtract(100, 'year').format('YYYY');
49        this.maxYear = moment().add(100, 'year').format('YYYY');
50        this.showWeekNumbers = false;
51        this.showISOWeekNumbers = false;
52        this.showCustomRangeLabel = true;
53        this.timePicker = false;
54        this.timePicker24Hour = false;
55        this.timePickerIncrement = 1;
56        this.timePickerSeconds = false;
57        this.linkedCalendars = true;
58        this.autoUpdateInput = true;
59        this.alwaysShowCalendars = false;
60        this.ranges = {};
61
62        this.opens = 'right';
63        if (this.element.hasClass('pull-right'))
64            this.opens = 'left';
65
66        this.drops = 'down';
67        if (this.element.hasClass('dropup'))
68            this.drops = 'up';
69
70        this.buttonClasses = 'btn btn-sm';
71        this.applyButtonClasses = 'btn-primary';
72        this.cancelButtonClasses = 'btn-default';
73
74        this.locale = {
75            direction: 'ltr',
76            format: moment.localeData().longDateFormat('L'),
77            separator: ' - ',
78            applyLabel: 'Apply',
79            cancelLabel: 'Cancel',
80            weekLabel: 'W',
81            customRangeLabel: 'Custom Range',
82            daysOfWeek: moment.weekdaysMin(),
83            monthNames: moment.monthsShort(),
84            firstDay: moment.localeData().firstDayOfWeek()
85        };
86
87        this.callback = function() { };
88
89        //some state information
90        this.isShowing = false;
91        this.leftCalendar = {};
92        this.rightCalendar = {};
93
94        //custom options from user
95        if (typeof options !== 'object' || options === null)
96            options = {};
97
98        //allow setting options with data attributes
99        //data-api options will be overwritten with custom javascript options
100        options = $.extend(this.element.data(), options);
101
102        if (typeof options.showPrice== 'boolean') {
103            this.showPrice = options.showPrice;
104        }
105
106
107
108        //html template for the picker UI
109        if (typeof options.template !== 'string' && !(options.template instanceof $))
110            options.template =
111            '<div class="daterangepicker">' +
112                '<div class="ranges"></div>' +
113                '<div class="drp-calendar left">' +
114                    '<div class="calendar-table"></div>' +
115                    '<div class="calendar-time"></div>' +
116                '</div>' +
117                '<div class="drp-calendar right">' +
118                    '<div class="calendar-table"></div>' +
119                    '<div class="calendar-time"></div>' +
120                '</div>' +
121                '<div class="drp-buttons">' +
122                    '<span class="drp-selected"></span>' +
123                    '<button class="cancelBtn" type="button"></button>' +
124                    '<button class="applyBtn" disabled="disabled" type="button"></button> ' +
125                '</div>';
126
127              
128                if(show_daterange_picker_custom_mess==='yes'){
129                    options.template =  options.template + 
130                    '<div class="wpestate_section">'+daterangepicker_vars.pls_select+
131                    ' <span class="wpestate_section_start">'+daterangepicker_vars.start_date+
132                    ' </span> '+daterangepicker_vars.to+
133                    ' <span class="wpestate_section_end">'+
134                    daterangepicker_vars.end_date+'</span></div>';
135          
136                }
137            options.template =  options.template +  '</div>';
138
139        this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
140        this.container = $(options.template).appendTo(this.parentEl);
141
142        //
143        // handle all the possible options overriding defaults
144        //
145
146        if (typeof options.locale === 'object') {
147
148            if (typeof options.locale.direction === 'string')
149                this.locale.direction = options.locale.direction;
150
151            if (typeof options.locale.format === 'string')
152                this.locale.format = options.locale.format;
153
154            if (typeof options.locale.separator === 'string')
155                this.locale.separator = options.locale.separator;
156
157            if (typeof options.locale.daysOfWeek === 'object')
158                this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
159
160            if (typeof options.locale.monthNames === 'object')
161              this.locale.monthNames = options.locale.monthNames.slice();
162
163            if (typeof options.locale.firstDay === 'number')
164              this.locale.firstDay = options.locale.firstDay;
165
166            if (typeof options.locale.applyLabel === 'string')
167              this.locale.applyLabel = options.locale.applyLabel;
168
169            if (typeof options.locale.cancelLabel === 'string')
170              this.locale.cancelLabel = options.locale.cancelLabel;
171
172            if (typeof options.locale.weekLabel === 'string')
173              this.locale.weekLabel = options.locale.weekLabel;
174
175            if (typeof options.locale.customRangeLabel === 'string'){
176                //Support unicode chars in the custom range name.
177                var elem = document.createElement('textarea');
178                elem.innerHTML = options.locale.customRangeLabel;
179                var rangeHtml = elem.value;
180                this.locale.customRangeLabel = rangeHtml;
181            }
182        }
183        this.container.addClass(this.locale.direction);
184
185        if (typeof options.startDate === 'string')
186            this.startDate = moment(options.startDate, this.locale.format);
187
188        if (typeof options.endDate === 'string')
189            this.endDate = moment(options.endDate, this.locale.format);
190
191        if (typeof options.minDate === 'string')
192            this.minDate = moment(options.minDate, this.locale.format);
193
194        if (typeof options.maxDate === 'string')
195            this.maxDate = moment(options.maxDate, this.locale.format);
196
197        if (typeof options.startDate === 'object')
198            this.startDate = moment(options.startDate);
199
200        if (typeof options.endDate === 'object')
201            this.endDate = moment(options.endDate);
202
203        if (typeof options.minDate === 'object')
204            this.minDate = moment(options.minDate);
205
206        if (typeof options.maxDate === 'object')
207            this.maxDate = moment(options.maxDate);
208
209        // sanity check for bad options
210        if (this.minDate && this.startDate.isBefore(this.minDate))
211            this.startDate = this.minDate.clone();
212
213        // sanity check for bad options
214        if (this.maxDate && this.endDate.isAfter(this.maxDate))
215            this.endDate = this.maxDate.clone();
216
217        if (typeof options.applyButtonClasses === 'string')
218            this.applyButtonClasses = options.applyButtonClasses;
219
220        if (typeof options.applyClass === 'string') //backwards compat
221            this.applyButtonClasses = options.applyClass;
222
223        if (typeof options.cancelButtonClasses === 'string')
224            this.cancelButtonClasses = options.cancelButtonClasses;
225
226        if (typeof options.cancelClass === 'string') //backwards compat
227            this.cancelButtonClasses = options.cancelClass;
228
229        if (typeof options.maxSpan === 'object')
230            this.maxSpan = options.maxSpan;
231
232        if (typeof options.minSpan === 'object'){
233            this.minSpan = options.minSpan;
234        }
235
236
237        if (typeof options.dateLimit === 'object') //backwards compat
238            this.maxSpan = options.dateLimit;
239
240        if (typeof options.opens === 'string')
241            this.opens = options.opens;
242
243        if (typeof options.drops === 'string')
244            this.drops = options.drops;
245
246        if (typeof options.showWeekNumbers === 'boolean')
247            this.showWeekNumbers = options.showWeekNumbers;
248
249        if (typeof options.showISOWeekNumbers === 'boolean')
250            this.showISOWeekNumbers = options.showISOWeekNumbers;
251
252        if (typeof options.buttonClasses === 'string')
253            this.buttonClasses = options.buttonClasses;
254
255        if (typeof options.buttonClasses === 'object')
256            this.buttonClasses = options.buttonClasses.join(' ');
257
258        if (typeof options.showDropdowns === 'boolean')
259            this.showDropdowns = options.showDropdowns;
260
261        if (typeof options.minYear === 'number')
262            this.minYear = options.minYear;
263
264        if (typeof options.maxYear === 'number')
265            this.maxYear = options.maxYear;
266
267        if (typeof options.showCustomRangeLabel === 'boolean')
268            this.showCustomRangeLabel = options.showCustomRangeLabel;
269
270        if (typeof options.singleDatePicker === 'boolean') {
271            this.singleDatePicker = options.singleDatePicker;
272            if (this.singleDatePicker)
273                this.endDate = this.startDate.clone();
274        }
275
276        if (typeof options.timePicker === 'boolean')
277            this.timePicker = options.timePicker;
278
279        if (typeof options.timePickerSeconds === 'boolean')
280            this.timePickerSeconds = options.timePickerSeconds;
281
282        if (typeof options.timePickerIncrement === 'number')
283            this.timePickerIncrement = options.timePickerIncrement;
284
285        if (typeof options.timePicker24Hour === 'boolean')
286            this.timePicker24Hour = options.timePicker24Hour;
287
288        if (typeof options.autoApply === 'boolean')
289            this.autoApply = options.autoApply;
290
291        if (typeof options.autoUpdateInput === 'boolean')
292            this.autoUpdateInput = options.autoUpdateInput;
293
294        if (typeof options.linkedCalendars === 'boolean')
295            this.linkedCalendars = options.linkedCalendars;
296
297        if (typeof options.isInvalidDate === 'function')
298            this.isInvalidDate = options.isInvalidDate;
299
300        if (typeof options.isCustomDate === 'function')
301            this.isCustomDate = options.isCustomDate;
302
303        if (typeof options.alwaysShowCalendars === 'boolean')
304            this.alwaysShowCalendars = options.alwaysShowCalendars;
305
306        // update day names order to firstDay
307        if (this.locale.firstDay != 0) {
308            var iterator = this.locale.firstDay;
309            while (iterator > 0) {
310                this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
311                iterator--;
312            }
313        }
314
315        var start, end, range;
316
317        //if no start/end dates set, check if an input element contains initial values
318        if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
319            if ($(this.element).is(':text')) {
320                var val = $(this.element).val(),
321                    split = val.split(this.locale.separator);
322
323                start = end = null;
324
325                if (split.length == 2) {
326                    start = moment(split[0], this.locale.format);
327                    end = moment(split[1], this.locale.format);
328                } else if (this.singleDatePicker && val !== "") {
329                    start = moment(val, this.locale.format);
330                    end = moment(val, this.locale.format);
331                }
332                if (start !== null && end !== null) {
333                    this.setStartDate(start);
334                    this.setEndDate(end);
335                }
336            }
337        }
338
339        if (typeof options.ranges === 'object') {
340            for (range in options.ranges) {
341
342                if (typeof options.ranges[range][0] === 'string')
343                    start = moment(options.ranges[range][0], this.locale.format);
344                else
345                    start = moment(options.ranges[range][0]);
346
347                if (typeof options.ranges[range][1] === 'string')
348                    end = moment(options.ranges[range][1], this.locale.format);
349                else
350                    end = moment(options.ranges[range][1]);
351
352                // If the start or end date exceed those allowed by the minDate or maxSpan
353                // options, shorten the range to the allowable period.
354                if (this.minDate && start.isBefore(this.minDate))
355                    start = this.minDate.clone();
356
357                var maxDate = this.maxDate;
358                if (this.maxSpan && maxDate && start.clone().add(this.maxSpan).isAfter(maxDate))
359                    maxDate = start.clone().add(this.maxSpan);
360                if (maxDate && end.isAfter(maxDate))
361                    end = maxDate.clone();
362
363                    
364                //wpestate   
365                if (this.minSpan ) {
366                    this.minDateSpan = start.clone().add(this.minSpan);
367                }
368
369
370                // If the end of the range is before the minimum or the start of the range is
371                // after the maximum, don't display this range option at all.
372                if ((this.minDate && end.isBefore(this.minDate, this.timepicker ? 'minute' : 'day'))
373                  || (maxDate && start.isAfter(maxDate, this.timepicker ? 'minute' : 'day')))
374                    continue;
375
376                //Support unicode chars in the range names.
377                var elem = document.createElement('textarea');
378                elem.innerHTML = range;
379                var rangeHtml = elem.value;
380
381                this.ranges[rangeHtml] = [start, end];
382            }
383
384            var list = '<ul>';
385            for (range in this.ranges) {
386                list += '<li data-range-key="' + range + '">' + range + '</li>';
387            }
388            if (this.showCustomRangeLabel) {
389                list += '<li data-range-key="' + this.locale.customRangeLabel + '">' + this.locale.customRangeLabel + '</li>';
390            }
391            list += '</ul>';
392            this.container.find('.ranges').prepend(list);
393        }
394
395        if (typeof cb === 'function') {
396            this.callback = cb;
397        }
398
399        if (!this.timePicker) {
400            this.startDate = this.startDate.startOf('day');
401            this.endDate = this.endDate.endOf('day');
402            this.container.find('.calendar-time').hide();
403        }
404
405        //can't be used together for now
406        if (this.timePicker && this.autoApply)
407            this.autoApply = false;
408
409        if (this.autoApply) {
410            this.container.addClass('auto-apply');
411        }
412
413        if (typeof options.ranges === 'object')
414            this.container.addClass('show-ranges');
415
416        if (this.singleDatePicker) {
417            this.container.addClass('single');
418            this.container.find('.drp-calendar.left').addClass('single');
419            this.container.find('.drp-calendar.left').show();
420            this.container.find('.drp-calendar.right').hide();
421            if (!this.timePicker) {
422                this.container.addClass('auto-apply');
423            }
424        }
425
426        if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
427            this.container.addClass('show-calendar');
428        }
429
430        this.container.addClass('opens' + this.opens);
431
432        //apply CSS classes and labels to buttons
433        this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
434        if (this.applyButtonClasses.length)
435            this.container.find('.applyBtn').addClass(this.applyButtonClasses);
436        if (this.cancelButtonClasses.length)
437            this.container.find('.cancelBtn').addClass(this.cancelButtonClasses);
438        this.container.find('.applyBtn').html(this.locale.applyLabel);
439        this.container.find('.cancelBtn').html(this.locale.cancelLabel);
440
441        //
442        // event listeners
443        //
444
445        this.container.find('.drp-calendar')
446            .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
447            .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
448            .on('mousedown.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
449            .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
450            .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
451            .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
452            .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
453
454        this.container.find('.ranges')
455            .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
456
457        this.container.find('.drp-buttons')
458            .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
459            .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
460
461        if (this.element.is('input') || this.element.is('button')) {
462            this.element.on({
463                'click.daterangepicker': $.proxy(this.show, this),
464                'focus.daterangepicker': $.proxy(this.show, this),
465                'keyup.daterangepicker': $.proxy(this.elementChanged, this),
466                'keydown.daterangepicker': $.proxy(this.keydown, this) //IE 11 compatibility
467            });
468        } else {
469            this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
470            this.element.on('keydown.daterangepicker', $.proxy(this.toggle, this));
471        }
472
473        //
474        // if attached to a text input, set the initial value
475        //
476
477        this.updateElement();
478
479    };
480
481    DateRangePicker.prototype = {
482
483        constructor: DateRangePicker,
484
485        setStartDate: function(startDate) {
486            if (typeof startDate === 'string')
487                this.startDate = moment(startDate, this.locale.format);
488
489            if (typeof startDate === 'object')
490                this.startDate = moment(startDate);
491
492            if (!this.timePicker)
493                this.startDate = this.startDate.startOf('day');
494
495            if (this.timePicker && this.timePickerIncrement)
496                this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
497
498            if (this.minDate && this.startDate.isBefore(this.minDate)) {
499                this.startDate = this.minDate.clone();
500                if (this.timePicker && this.timePickerIncrement)
501                    this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
502            }
503
504            if (this.maxDate && this.startDate.isAfter(this.maxDate)) {
505                this.startDate = this.maxDate.clone();
506                if (this.timePicker && this.timePickerIncrement)
507                    this.startDate.minute(Math.floor(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
508            }
509
510            if (!this.isShowing)
511                this.updateElement();
512
513            this.updateMonthsInView();
514        },
515
516        setEndDate: function(endDate) {
517            if (typeof endDate === 'string')
518                this.endDate = moment(endDate, this.locale.format);
519
520            if (typeof endDate === 'object')
521                this.endDate = moment(endDate);
522
523            if (!this.timePicker)
524                this.endDate = this.endDate.endOf('day');
525
526            if (this.timePicker && this.timePickerIncrement)
527                this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
528
529            if (this.endDate.isBefore(this.startDate))
530                this.endDate = this.startDate.clone();
531
532            if (this.maxDate && this.endDate.isAfter(this.maxDate))
533                this.endDate = this.maxDate.clone();
534
535            if (this.maxSpan && this.startDate.clone().add(this.maxSpan).isBefore(this.endDate))
536                this.endDate = this.startDate.clone().add(this.maxSpan);
537
538            this.previousRightTime = this.endDate.clone();
539
540            this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
541
542            if (!this.isShowing)
543                this.updateElement();
544
545            this.updateMonthsInView();
546        },
547
548        isInvalidDate: function() {
549            return false;
550        },
551
552        isCustomDate: function() {
553            return false;
554        },
555
556        updateView: function() {
557            if (this.timePicker) {
558                this.renderTimePicker('left');
559                this.renderTimePicker('right');
560                if (!this.endDate) {
561                    this.container.find('.right .calendar-time select').prop('disabled', true).addClass('disabled');
562                } else {
563                    this.container.find('.right .calendar-time select').prop('disabled', false).removeClass('disabled');
564                }
565            }
566            if (this.endDate)
567                this.container.find('.drp-selected').html(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
568            this.updateMonthsInView();
569            this.updateCalendars();
570            this.updateFormInputs();
571        },
572
573        updateMonthsInView: function() {
574            if (this.endDate) {
575
576                //if both dates are visible already, do nothing
577                if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
578                    (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
579                    &&
580                    (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
581                    ) {
582                    return;
583                }
584
585                this.leftCalendar.month = this.startDate.clone().date(2);
586                if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
587                    this.rightCalendar.month = this.endDate.clone().date(2);
588                } else {
589                    this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
590                }
591
592            } else {
593                if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
594                    this.leftCalendar.month = this.startDate.clone().date(2);
595                    this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
596                }
597            }
598            if (this.maxDate && this.linkedCalendars && !this.singleDatePicker && this.rightCalendar.month > this.maxDate) {
599              this.rightCalendar.month = this.maxDate.clone().date(2);
600              this.leftCalendar.month = this.maxDate.clone().date(2).subtract(1, 'month');
601            }
602        },
603
604        updateCalendars: function() {
605
606            if (this.timePicker) {
607                var hour, minute, second;
608                if (this.endDate) {
609                    hour = parseInt(this.container.find('.left .hourselect').val(), 10);
610                    minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
611                    if (isNaN(minute)) {
612                        minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
613                    }
614                    second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
615                    if (!this.timePicker24Hour) {
616                        var ampm = this.container.find('.left .ampmselect').val();
617                        if (ampm === 'PM' && hour < 12)
618                            hour += 12;
619                        if (ampm === 'AM' && hour === 12)
620                            hour = 0;
621                    }
622                } else {
623                    hour = parseInt(this.container.find('.right .hourselect').val(), 10);
624                    minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
625                    if (isNaN(minute)) {
626                        minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
627                    }
628                    second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
629                    if (!this.timePicker24Hour) {
630                        var ampm = this.container.find('.right .ampmselect').val();
631                        if (ampm === 'PM' && hour < 12)
632                            hour += 12;
633                        if (ampm === 'AM' && hour === 12)
634                            hour = 0;
635                    }
636                }
637                this.leftCalendar.month.hour(hour).minute(minute).second(second);
638                this.rightCalendar.month.hour(hour).minute(minute).second(second);
639            }
640
641            this.renderCalendar('left');
642            this.renderCalendar('right');
643
644            //highlight any predefined range matching the current start and end dates
645            this.container.find('.ranges li').removeClass('active');
646            if (this.endDate == null) return;
647
648            this.calculateChosenLabel();
649        },
650
651        renderCalendar: function(side) {
652
653            //
654            // Build the matrix of dates that will populate the calendar
655            //
656            var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
657            var month = calendar.month.month();
658            var year = calendar.month.year();
659            var hour = calendar.month.hour();
660            var minute = calendar.month.minute();
661            var second = calendar.month.second();
662            var daysInMonth = moment([year, month]).daysInMonth();
663            var firstDay = moment([year, month, 1]);
664            var lastDay = moment([year, month, daysInMonth]);
665            var lastMonth = moment(firstDay).subtract(1, 'month').month();
666            var lastYear = moment(firstDay).subtract(1, 'month').year();
667            var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
668            var dayOfWeek = firstDay.day();
669
670            //initialize a 6 rows x 7 columns array for the calendar
671            var calendar = [];
672            calendar.firstDay = firstDay;
673            calendar.lastDay = lastDay;
674
675            for (var i = 0; i < 6; i++) {
676                calendar[i] = [];
677            }
678
679            //populate the calendar with date objects
680            var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
681            if (startDay > daysInLastMonth)
682                startDay -= 7;
683
684            if (dayOfWeek == this.locale.firstDay)
685                startDay = daysInLastMonth - 6;
686
687            var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
688
689            var col, row;
690            for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
691                if (i > 0 && col % 7 === 0) {
692                    col = 0;
693                    row++;
694                }
695                calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
696                curDate.hour(12);
697
698                if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
699                    calendar[row][col] = this.minDate.clone();
700                }
701
702                if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
703                    calendar[row][col] = this.maxDate.clone();
704                }
705
706            }
707
708            //make the calendar object available to hoverDate/clickDate
709            if (side == 'left') {
710                this.leftCalendar.calendar = calendar;
711            } else {
712                this.rightCalendar.calendar = calendar;
713            }
714
715            //
716            // Display the calendar
717            //
718
719            var minDate = side == 'left' ? this.minDate : this.startDate;
720            var maxDate = this.maxDate;
721            var selected = side == 'left' ? this.startDate : this.endDate;
722            var arrow = this.locale.direction == 'ltr' ? {left: 'chevron-left', right: 'chevron-right'} : {left: 'chevron-right', right: 'chevron-left'};
723
724            var html = '<table class="table-condensed">';
725            html += '<thead>';
726            html += '<tr>';
727
728            // add empty cell for week number
729            if (this.showWeekNumbers || this.showISOWeekNumbers)
730                html += '<th></th>';
731
732            if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
733                html += '<th class="prev available"><span></span></th>';
734            } else {
735                html += '<th></th>';
736            }
737
738            var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
739
740            if (this.showDropdowns) {
741                var currentMonth = calendar[1][1].month();
742                var currentYear = calendar[1][1].year();
743                var maxYear = (maxDate && maxDate.year()) || (this.maxYear);
744                var minYear = (minDate && minDate.year()) || (this.minYear);
745                var inMinYear = currentYear == minYear;
746                var inMaxYear = currentYear == maxYear;
747
748                var monthHtml = '<select class="monthselect">';
749                for (var m = 0; m < 12; m++) {
750                    if ((!inMinYear || (minDate && m >= minDate.month())) && (!inMaxYear || (maxDate && m <= maxDate.month()))) {
751                        monthHtml += "<option value='" + m + "'" +
752                            (m === currentMonth ? " selected='selected'" : "") +
753                            ">" + this.locale.monthNames[m] + "</option>";
754                    } else {
755                        monthHtml += "<option value='" + m + "'" +
756                            (m === currentMonth ? " selected='selected'" : "") +
757                            " disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
758                    }
759                }
760                monthHtml += "</select>";
761
762                var yearHtml = '<select class="yearselect">';
763                for (var y = minYear; y <= maxYear; y++) {
764                    yearHtml += '<option value="' + y + '"' +
765                        (y === currentYear ? ' selected="selected"' : '') +
766                        '>' + y + '</option>';
767                }
768                yearHtml += '</select>';
769
770                dateHtml = monthHtml + yearHtml;
771            }
772
773            html += '<th colspan="5" class="month">' + dateHtml + '</th>';
774            if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
775                html += '<th class="next available"><span></span></th>';
776            } else {
777                html += '<th></th>';
778            }
779
780            html += '</tr>';
781            html += '<tr>';
782
783            // add week number label
784            if (this.showWeekNumbers || this.showISOWeekNumbers)
785                html += '<th class="week">' + this.locale.weekLabel + '</th>';
786
787            $.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
788                html += '<th>' + dayOfWeek + '</th>';
789            });
790
791            html += '</tr>';
792            html += '</thead>';
793            html += '<tbody>';
794
795            //adjust maxDate to reflect the maxSpan setting in order to
796            //grey out end dates beyond the maxSpan
797            if (this.endDate == null && this.maxSpan) {
798                var maxLimit = this.startDate.clone().add(this.maxSpan).endOf('day');
799                if (!maxDate || maxLimit.isBefore(maxDate)) {
800                    maxDate = maxLimit;
801                }
802            }
803             
804            if (this.endDate == null && this.minSpan) {
805                var minLimit = this.startDate.clone().add(this.minSpan).endOf('day');
806                if(!minDate || minLimit.isAfter(minDate)){
807                    this.minDateSpan = minLimit;
808                }
809            }
810            
811            
812
813            for (var row = 0; row < 6; row++) {
814                html += '<tr>';
815
816                // add week number
817                if (this.showWeekNumbers)
818                    html += '<td class="week">' + calendar[row][0].week() + '</td>';
819                else if (this.showISOWeekNumbers)
820                    html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
821
822                for (var col = 0; col < 7; col++) {
823
824                    var classes = [];
825
826                    //highlight today's date
827                    if (calendar[row][col].isSame(new Date(), "day"))
828                        classes.push('today');
829
830                    //highlight weekends
831                    if (calendar[row][col].isoWeekday() > 5)
832                        classes.push('weekend');
833
834                    //grey out the dates in other months displayed at beginning and end of this calendar
835                    if (calendar[row][col].month() != calendar[1][1].month())
836                        classes.push('off', 'ends');
837
838                    //don't allow selection of dates before the minimum date
839                    if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
840                        classes.push('off', 'disabled');
841
842                    //don't allow selection of dates after the maximum date
843                    if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
844                        classes.push('off', 'disabled');
845
846                    //minSpan  wpestate
847                     
848                    var infome=calendar[row][col].year()+"/"+(calendar[row][col].month()+1)+"/"+calendar[row][col].date();
849                
850                    var date_format     = control_vars.date_format.toUpperCase();
851                    var infome2= moment(infome, 'YYYY-M-DD').format(date_format);
852                    var infome_unix = moment(infome, 'YYYY-M-DD').valueOf(); 
853
854                  
855
856                   // wpestate added
857                   //|| this.element[0].id==='end_date'
858                    if(this.element[0].id==='start_date' ){
859                            // if is block by mandatory start/end date
860                            
861                            if(wpestate_booking_invalid_Date_new(infome_unix)==='is_block_check_in_check_out'){
862                                classes.push('check_in_block','disabled');
863                            } else if(wpestate_booking_invalid_Date_new(infome_unix)==='is_block_check_in'){
864                                classes.push('check_in_block_is_block_check_in','disabled');
865                            } 
866
867
868                            // if blocked by mandatory start date - the remove
869                            if( this.start_date_picked===1 && calendar[row][col].isAfter(this.startDate, 'day') ){     
870                         
871                                for( var i = 0; i < classes.length; i++){ 
872                                    if ( classes[i] === 'check_in_block_is_block_check_in'   ) {
873                                        classes.splice(i, 1); 
874                                    }
875                                }
876                                for( var i = 0; i < classes.length; i++){ 
877                                    if ( classes[i] === 'disabled'   ) {
878                                        classes.splice(i, 1); 
879                                    }
880                                }
881                            }
882
883
884                        
885                            
886                            // minimum days for mega details
887                            if( typeof(mega_details)==='object'){
888                              
889                                var minday_unix= moment(this.startDate).utc().add(moment(this.startDate).utcOffset(),'minutes').valueOf();
890                                var minday_unix=minday_unix/1000;
891
892
893
894                                if( mega_details[minday_unix] != undefined  ){
895                                    minim_days = parseFloat( mega_details[minday_unix]['period_min_days_booking'] ,10 );
896
897                                    var temp_min_span={
898                                        "days": minim_days
899                                    };
900                                    var minLimit = this.startDate.clone().add(temp_min_span).endOf('day');
901                                    this.minDateSpan = minLimit;
902                                }
903
904                               
905                                
906                                if(this.minDateSpan && this.startDate && calendar[row][col].isBefore(this.minDateSpan, 'day')  && calendar[row][col].isAfter(this.startDate, 'day')){
907                                
908                                    classes.push('wpestate_min_days_required', 'disabled');
909                                    classes.push('off', 'disabled');
910                                }
911
912                            }else{
913                           
914                                if(this.minDateSpan && this.startDate && calendar[row][col].isBefore(this.minDateSpan, 'day')  && calendar[row][col].isAfter(this.startDate, 'day')){
915                                  
916                                    classes.push('wpestate_min_days_required', 'disabled');
917                                    classes.push('off', 'disabled');
918                                }
919                            }
920                    }
921
922                    //don't allow selection of date if a custom function decides it's invalid
923                    if (this.isInvalidDate(calendar[row][col]))
924                        classes.push('off', 'disabled');
925
926                    //highlight the currently selected start date
927                    if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
928                        classes.push('active', 'start-date');
929
930                    //highlight the currently selected end date
931                    if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
932                        classes.push('active', 'end-date');
933
934                    //highlight dates in-between the selected dates
935                    if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
936                        classes.push('in-range');
937
938                    //apply custom classes for this date
vendor: 32,067 bytes, lines 939-1711
939                    var isCustom = this.isCustomDate(calendar[row][col]);
940                    if (isCustom !== false) {
941                        if (typeof isCustom === 'string')
942                            classes.push(isCustom);
943                        else
944                            Array.prototype.push.apply(classes, isCustom);
945                    }
946
947                    var cname = '', disabled = false;
948                    for (var i = 0; i < classes.length; i++) {
949                        cname += classes[i] + ' ';
950                        if (classes[i] == 'disabled')
951                            disabled = true;
952                    }
953                    if (!disabled)
954                        cname += 'available'; 
955                    //|| this.element[0].id==='end_date') 
956                        if (typeof wpestate_show_price_Daterangepicker === "function" && this.element[0].id==='start_date'  ){ 
957                            html += '<td class="infome_unix wpestate_booking_class ' + cname.replace(/^\s+|\s+$/g, '') + '"x2 data-custom="'+infome2+'" data-custom-mes="'+infome2+'" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '<div class="wpestate_show_price_calendar">'+wpestate_show_price_Daterangepicker(infome_unix)+'</div></td>';
958                        }else{
959                            html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '"x1 data-custom="'+infome+'" data-custom-mes="'+infome2+'" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
960
961                        }
962                }
963                html += '</tr>';
964            }
965
966            html += '</tbody>';
967            html += '</table>';
968
969            this.container.find('.drp-calendar.' + side + ' .calendar-table').html(html);
970
971        },
972
973        renderTimePicker: function(side) {
974
975            // Don't bother updating the time picker if it's currently disabled
976            // because an end date hasn't been clicked yet
977            if (side == 'right' && !this.endDate) return;
978
979            var html, selected, minDate, maxDate = this.maxDate;
980
981            if (this.maxSpan && (!this.maxDate || this.startDate.clone().add(this.maxSpan).isBefore(this.maxDate)))
982                maxDate = this.startDate.clone().add(this.maxSpan);
983
984            if (side == 'left') {
985                selected = this.startDate.clone();
986                minDate = this.minDate;
987            } else if (side == 'right') {
988                selected = this.endDate.clone();
989                minDate = this.startDate;
990
991                //Preserve the time already selected
992                var timeSelector = this.container.find('.drp-calendar.right .calendar-time');
993                if (timeSelector.html() != '') {
994
995                    selected.hour(!isNaN(selected.hour()) ? selected.hour() : timeSelector.find('.hourselect option:selected').val());
996                    selected.minute(!isNaN(selected.minute()) ? selected.minute() : timeSelector.find('.minuteselect option:selected').val());
997                    selected.second(!isNaN(selected.second()) ? selected.second() : timeSelector.find('.secondselect option:selected').val());
998
999                    if (!this.timePicker24Hour) {
1000                        var ampm = timeSelector.find('.ampmselect option:selected').val();
1001                        if (ampm === 'PM' && selected.hour() < 12)
1002                            selected.hour(selected.hour() + 12);
1003                        if (ampm === 'AM' && selected.hour() === 12)
1004                            selected.hour(0);
1005                    }
1006
1007                }
1008
1009                if (selected.isBefore(this.startDate))
1010                    selected = this.startDate.clone();
1011
1012                if (maxDate && selected.isAfter(maxDate))
1013                    selected = maxDate.clone();
1014
1015            }
1016
1017            //
1018            // hours
1019            //
1020
1021            html = '<select class="hourselect">';
1022
1023            var start = this.timePicker24Hour ? 0 : 1;
1024            var end = this.timePicker24Hour ? 23 : 12;
1025
1026            for (var i = start; i <= end; i++) {
1027                var i_in_24 = i;
1028                if (!this.timePicker24Hour)
1029                    i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
1030
1031                var time = selected.clone().hour(i_in_24);
1032                var disabled = false;
1033                if (minDate && time.minute(59).isBefore(minDate))
1034                    disabled = true;
1035                if (maxDate && time.minute(0).isAfter(maxDate))
1036                    disabled = true;
1037
1038                if (i_in_24 == selected.hour() && !disabled) {
1039                    html += '<option value="' + i + '" selected="selected">' + i + '</option>';
1040                } else if (disabled) {
1041                    html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
1042                } else {
1043                    html += '<option value="' + i + '">' + i + '</option>';
1044                }
1045            }
1046
1047            html += '</select> ';
1048
1049            //
1050            // minutes
1051            //
1052
1053            html += ': <select class="minuteselect">';
1054
1055            for (var i = 0; i < 60; i += this.timePickerIncrement) {
1056                var padded = i < 10 ? '0' + i : i;
1057                var time = selected.clone().minute(i);
1058
1059                var disabled = false;
1060                if (minDate && time.second(59).isBefore(minDate))
1061                    disabled = true;
1062                if (maxDate && time.second(0).isAfter(maxDate))
1063                    disabled = true;
1064
1065                if (selected.minute() == i && !disabled) {
1066                    html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
1067                } else if (disabled) {
1068                    html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
1069                } else {
1070                    html += '<option value="' + i + '">' + padded + '</option>';
1071                }
1072            }
1073
1074            html += '</select> ';
1075
1076            //
1077            // seconds
1078            //
1079
1080            if (this.timePickerSeconds) {
1081                html += ': <select class="secondselect">';
1082
1083                for (var i = 0; i < 60; i++) {
1084                    var padded = i < 10 ? '0' + i : i;
1085                    var time = selected.clone().second(i);
1086
1087                    var disabled = false;
1088                    if (minDate && time.isBefore(minDate))
1089                        disabled = true;
1090                    if (maxDate && time.isAfter(maxDate))
1091                        disabled = true;
1092
1093                    if (selected.second() == i && !disabled) {
1094                        html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
1095                    } else if (disabled) {
1096                        html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
1097                    } else {
1098                        html += '<option value="' + i + '">' + padded + '</option>';
1099                    }
1100                }
1101
1102                html += '</select> ';
1103            }
1104
1105            //
1106            // AM/PM
1107            //
1108
1109            if (!this.timePicker24Hour) {
1110                html += '<select class="ampmselect">';
1111
1112                var am_html = '';
1113                var pm_html = '';
1114
1115                if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
1116                    am_html = ' disabled="disabled" class="disabled"';
1117
1118                if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
1119                    pm_html = ' disabled="disabled" class="disabled"';
1120
1121                if (selected.hour() >= 12) {
1122                    html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
1123                } else {
1124                    html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
1125                }
1126
1127                html += '</select>';
1128            }
1129
1130            this.container.find('.drp-calendar.' + side + ' .calendar-time').html(html);
1131
1132        },
1133
1134        updateFormInputs: function() {
1135
1136            if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
1137                this.container.find('button.applyBtn').prop('disabled', false);
1138            } else {
1139                this.container.find('button.applyBtn').prop('disabled', true);
1140            }
1141
1142        },
1143
1144        move: function() {
1145            var parentOffset = { top: 0, left: 0 },
1146                containerTop;
1147            var parentRightEdge = $(window).width();
1148            if (!this.parentEl.is('body')) {
1149                parentOffset = {
1150                    top: this.parentEl.offset().top - this.parentEl.scrollTop(),
1151                    left: this.parentEl.offset().left - this.parentEl.scrollLeft()
1152                };
1153                parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
1154            }
1155
1156            if (this.drops == 'up')
1157                containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
1158            else
1159                containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
1160
1161            // Force the container to it's actual width
1162            this.container.css({
1163              top: 0,
1164              left: 0,
1165              right: 'auto'
1166            });
1167            var containerWidth = this.container.outerWidth();
1168
1169            this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('drop-up');
1170
1171            if (this.opens == 'left') {
1172                var containerRight = parentRightEdge - this.element.offset().left - this.element.outerWidth();
1173                if (containerWidth + containerRight > $(window).width()) {
1174                    this.container.css({
1175                        top: containerTop,
1176                        right: 'auto',
1177                        left: 9
1178                    });
1179                } else {
1180                    this.container.css({
1181                        top: containerTop,
1182                        right: containerRight,
1183                        left: 'auto'
1184                    });
1185                }
1186            } else if (this.opens == 'center') {
1187                var containerLeft = this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
1188                                        - containerWidth / 2;
1189                if (containerLeft < 0) {
1190                    this.container.css({
1191                        top: containerTop,
1192                        right: 'auto',
1193                        left: 9
1194                    });
1195                } else if (containerLeft + containerWidth > $(window).width()) {
1196                    this.container.css({
1197                        top: containerTop,
1198                        left: 'auto',
1199                        right: 0
1200                    });
1201                } else {
1202                    this.container.css({
1203                        top: containerTop,
1204                        left: containerLeft,
1205                        right: 'auto'
1206                    });
1207                }
1208            } else {
1209                var containerLeft = this.element.offset().left - parentOffset.left;
1210                if (containerLeft + containerWidth > $(window).width()) {
1211                    this.container.css({
1212                        top: containerTop,
1213                        left: 'auto',
1214                        right: 0
1215                    });
1216                } else {
1217                    this.container.css({
1218                        top: containerTop,
1219                        left: containerLeft,
1220                        right: 'auto'
1221                    });
1222                }
1223            }
1224        },
1225
1226        show: function(e) {
1227            if (this.isShowing) return;
1228
1229            // Create a click proxy that is private to this instance of datepicker, for unbinding
1230            this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
1231
1232            // Bind global datepicker mousedown for hiding and
1233            $(document)
1234              .on('mousedown.daterangepicker', this._outsideClickProxy)
1235              // also support mobile devices
1236              .on('touchend.daterangepicker', this._outsideClickProxy)
1237              // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
1238              .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
1239              // and also close when focus changes to outside the picker (eg. tabbing between controls)
1240              .on('focusin.daterangepicker', this._outsideClickProxy);
1241
1242            // Reposition the picker if the window is resized while it's open
1243            $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
1244
1245            this.oldStartDate = this.startDate.clone();
1246            this.oldEndDate = this.endDate.clone();
1247            this.previousRightTime = this.endDate.clone();
1248
1249            this.updateView();
1250            this.container.show();
1251            this.move();
1252            this.element.trigger('show.daterangepicker', this);
1253            this.isShowing = true;
1254        },
1255
1256        hide: function(e) {
1257            if (!this.isShowing) return;
1258
1259            //incomplete date selection, revert to last values
1260            if (!this.endDate) {
1261                this.startDate = this.oldStartDate.clone();
1262                this.endDate = this.oldEndDate.clone();
1263            }
1264
1265            //if a new date range was selected, invoke the user callback function
1266            if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
1267                this.callback(this.startDate.clone(), this.endDate.clone(), this.chosenLabel);
1268
1269            //if picker is attached to a text input, update it
1270            this.updateElement();
1271
1272            $(document).off('.daterangepicker');
1273            $(window).off('.daterangepicker');
1274            this.container.hide();
1275            this.element.trigger('hide.daterangepicker', this);
1276            this.isShowing = false;
1277        },
1278
1279        toggle: function(e) {
1280            if (this.isShowing) {
1281                this.hide();
1282            } else {
1283                this.show();
1284            }
1285        },
1286
1287        outsideClick: function(e) {
1288            
1289            var target = $(e.target);
1290            // if the page is clicked anywhere except within the daterangerpicker/button
1291            // itself then call this.hide()
1292            if (
1293                // ie modal dialog fix
1294                e.type == "focusin" ||
1295                target.closest(this.element).length ||
1296                target.closest(this.container).length ||
1297                target.closest('.calendar-table').length
1298                ) return;
1299            this.hide();
1300            this.element.trigger('outsideClick.daterangepicker', this);
1301        },
1302
1303        showCalendars: function() {
1304            this.container.addClass('show-calendar');
1305            this.move();
1306            this.element.trigger('showCalendar.daterangepicker', this);
1307        },
1308
1309        hideCalendars: function() {
1310            this.container.removeClass('show-calendar');
1311            this.element.trigger('hideCalendar.daterangepicker', this);
1312        },
1313
1314        clickRange: function(e) {
1315            var label = e.target.getAttribute('data-range-key');
1316            this.chosenLabel = label;
1317            if (label == this.locale.customRangeLabel) {
1318                this.showCalendars();
1319            } else {
1320                var dates = this.ranges[label];
1321                this.startDate = dates[0];
1322                this.endDate = dates[1];
1323
1324                if (!this.timePicker) {
1325                    this.startDate.startOf('day');
1326                    this.endDate.endOf('day');
1327                }
1328
1329                if (!this.alwaysShowCalendars)
1330                    this.hideCalendars();
1331                this.clickApply();
1332            }
1333        },
1334
1335        clickPrev: function(e) {
1336            var cal = $(e.target).parents('.drp-calendar');
1337            if (cal.hasClass('left')) {
1338                this.leftCalendar.month.subtract(1, 'month');
1339                if (this.linkedCalendars)
1340                    this.rightCalendar.month.subtract(1, 'month');
1341            } else {
1342                this.rightCalendar.month.subtract(1, 'month');
1343            }
1344            this.updateCalendars();
1345        },
1346
1347        clickNext: function(e) {
1348            var cal = $(e.target).parents('.drp-calendar');
1349            if (cal.hasClass('left')) {
1350                this.leftCalendar.month.add(1, 'month');
1351            } else {
1352                this.rightCalendar.month.add(1, 'month');
1353                if (this.linkedCalendars)
1354                    this.leftCalendar.month.add(1, 'month');
1355            }
1356            this.updateCalendars();
1357        },
1358
1359        hoverDate: function(e) {
1360
1361            //ignore dates that can't be selected
1362            if (!$(e.target).hasClass('available')) return;
1363
1364            var title = $(e.target).attr('data-title');
1365            var row = title.substr(1, 1);
1366            var col = title.substr(3, 1);
1367            var cal = $(e.target).parents('.drp-calendar');
1368            var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
1369
1370            //highlight the dates between the start date and the date being hovered as a potential end date
1371            var leftCalendar = this.leftCalendar;
1372            var rightCalendar = this.rightCalendar;
1373            var startDate = this.startDate;
1374            if (!this.endDate) {
1375                this.container.find('.drp-calendar tbody td').each(function(index, el) {
1376
1377                    //skip week numbers, only look at dates
1378                    if ($(el).hasClass('week')) return;
1379
1380                    var title = $(el).attr('data-title');
1381                    var row = title.substr(1, 1);
1382                    var col = title.substr(3, 1);
1383                    var cal = $(el).parents('.drp-calendar');
1384                    var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
1385
1386                    if ((dt.isAfter(startDate) && dt.isBefore(date)) || dt.isSame(date, 'day')) {
1387                        $(el).addClass('in-range');
1388                    } else {
1389                        $(el).removeClass('in-range');
1390                    }
1391
1392                });
1393            }
1394
1395        },
1396
1397        clickDate: function(e) {
1398        
1399            who_is=1;
1400            jQuery('.wpestate_calendar').removeClass('minim_days_reservation').removeClass('wpestate_min_days_required');
1401        
1402            if (!$(e.target).hasClass('available')) return;
1403            
1404            var title = $(e.target).attr('data-title');
1405            var row = title.substr(1, 1);
1406            var col = title.substr(3, 1);
1407            var cal = $(e.target).parents('.drp-calendar');
1408            var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
1409
1410            //
1411            // this function needs to do a few things:
1412            // * alternate between selecting a start and end date for the range,
1413            // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
1414            // * if autoapply is enabled, and an end date was chosen, apply the selection
1415            // * if single date picker mode, and time picker isn't enabled, apply the selection immediately
1416            // * if one of the inputs above the calendars was focused, cancel that manual input
1417            //
1418        
1419            if (this.endDate || date.isBefore(this.startDate, 'day')) { //picking start
1420                if (this.timePicker) {
1421                    var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
1422                    if (!this.timePicker24Hour) {
1423                        var ampm = this.container.find('.left .ampmselect').val();
1424                        if (ampm === 'PM' && hour < 12)
1425                            hour += 12;
1426                        if (ampm === 'AM' && hour === 12)
1427                            hour = 0;
1428                    }
1429                    var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
1430                    if (isNaN(minute)) {
1431                        minute = parseInt(this.container.find('.left .minuteselect option:last').val(), 10);
1432                    }
1433                    var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
1434                    date = date.clone().hour(hour).minute(minute).second(second);
1435                }
1436                this.endDate = null;
1437                this.setStartDate(date.clone());
1438                
1439                //wpestate SeT is start_Date_picked flag
1440                who_is=0;
1441             
1442                var input_val = $(e.target).attr("data-custom-mes");
1443                var input_val_mes = $(e.target).attr("data-custom-mes");
1444
1445                jQuery('.wpestate_section_start').html(input_val_mes);
1446                jQuery('.wpestate_section_end').html(daterangepicker_vars.end_date);
1447                this.element.val(input_val);
1448                this.start_date_picked=1;
1449                
1450                
1451            } else if (!this.endDate && date.isBefore(this.startDate)) {
1452                //special case: clicking the same date for start/end,
1453                //but the time of the end date is before the start date
1454                this.setEndDate(this.startDate.clone());
1455                who_is=1;
1456               
1457            } else { // picking end
1458                if (this.timePicker) {
1459                    var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
1460                    if (!this.timePicker24Hour) {
1461                        var ampm = this.container.find('.right .ampmselect').val();
1462                        if (ampm === 'PM' && hour < 12)
1463                            hour += 12;
1464                        if (ampm === 'AM' && hour === 12)
1465                            hour = 0;
1466                    }
1467                    var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
1468                    if (isNaN(minute)) {
1469                        minute = parseInt(this.container.find('.right .minuteselect option:last').val(), 10);
1470                    }
1471                    var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
1472                    date = date.clone().hour(hour).minute(minute).second(second);
1473                }
1474                this.setEndDate(date.clone());
1475                if (this.autoApply) {
1476                  this.calculateChosenLabel();
1477                  this.clickApply();
1478                }
1479                //wpestate reset is start_Date_picked flag
1480                this.start_date_picked=0; 
1481
1482                var input_val_end = $(e.target).attr("data-custom");
1483                var input_val_end_mes = $(e.target).attr("data-custom-mes");
1484
1485                jQuery('.wpestate_section_end').html(input_val_end_mes);
1486            }
1487
1488            if (this.singleDatePicker) {
1489                this.setEndDate(this.startDate);
1490                if (!this.timePicker)
1491                    this.clickApply();
1492            }
1493
1494            this.updateView();
1495
1496            //This is to cancel the blur event handler if the mouse was in one of the inputs
1497            e.stopPropagation();
1498
1499        },
1500
1501        calculateChosenLabel: function () {
1502            var customRange = true;
1503            var i = 0;
1504            for (var range in this.ranges) {
1505              if (this.timePicker) {
1506                    var format = this.timePickerSeconds ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD HH:mm";
1507                    //ignore times when comparing dates if time picker seconds is not enabled
1508                    if (this.startDate.format(format) == this.ranges[range][0].format(format) && this.endDate.format(format) == this.ranges[range][1].format(format)) {
1509                        customRange = false;
1510                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
1511                        break;
1512                    }
1513                } else {
1514                    //ignore times when comparing dates if time picker is not enabled
1515                    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')) {
1516                        customRange = false;
1517                        this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').attr('data-range-key');
1518                        break;
1519                    }
1520                }
1521                i++;
1522            }
1523            if (customRange) {
1524                if (this.showCustomRangeLabel) {
1525                    this.chosenLabel = this.container.find('.ranges li:last').addClass('active').attr('data-range-key');
1526                } else {
1527                    this.chosenLabel = null;
1528                }
1529                this.showCalendars();
1530            }
1531        },
1532
1533        clickApply: function(e) {
1534            this.hide();
1535            this.element.trigger('apply.daterangepicker', this);
1536        },
1537
1538        clickCancel: function(e) {
1539            this.startDate = this.oldStartDate;
1540            this.endDate = this.oldEndDate;
1541            this.hide();
1542            this.element.trigger('cancel.daterangepicker', this);
1543        },
1544
1545        monthOrYearChanged: function(e) {
1546            var isLeft = $(e.target).closest('.drp-calendar').hasClass('left'),
1547                leftOrRight = isLeft ? 'left' : 'right',
1548                cal = this.container.find('.drp-calendar.'+leftOrRight);
1549
1550            // Month must be Number for new moment versions
1551            var month = parseInt(cal.find('.monthselect').val(), 10);
1552            var year = cal.find('.yearselect').val();
1553
1554            if (!isLeft) {
1555                if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
1556                    month = this.startDate.month();
1557                    year = this.startDate.year();
1558                }
1559            }
1560
1561            if (this.minDate) {
1562                if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
1563                    month = this.minDate.month();
1564                    year = this.minDate.year();
1565                }
1566            }
1567
1568            if (this.maxDate) {
1569                if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
1570                    month = this.maxDate.month();
1571                    year = this.maxDate.year();
1572                }
1573            }
1574
1575            if (isLeft) {
1576                this.leftCalendar.month.month(month).year(year);
1577                if (this.linkedCalendars)
1578                    this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
1579            } else {
1580                this.rightCalendar.month.month(month).year(year);
1581                if (this.linkedCalendars)
1582                    this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
1583            }
1584            this.updateCalendars();
1585        },
1586
1587        timeChanged: function(e) {
1588
1589            var cal = $(e.target).closest('.drp-calendar'),
1590                isLeft = cal.hasClass('left');
1591
1592            var hour = parseInt(cal.find('.hourselect').val(), 10);
1593            var minute = parseInt(cal.find('.minuteselect').val(), 10);
1594            if (isNaN(minute)) {
1595                minute = parseInt(cal.find('.minuteselect option:last').val(), 10);
1596            }
1597            var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
1598
1599            if (!this.timePicker24Hour) {
1600                var ampm = cal.find('.ampmselect').val();
1601                if (ampm === 'PM' && hour < 12)
1602                    hour += 12;
1603                if (ampm === 'AM' && hour === 12)
1604                    hour = 0;
1605            }
1606
1607            if (isLeft) {
1608                var start = this.startDate.clone();
1609                start.hour(hour);
1610                start.minute(minute);
1611                start.second(second);
1612                this.setStartDate(start);
1613                if (this.singleDatePicker) {
1614                    this.endDate = this.startDate.clone();
1615                } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
1616                    this.setEndDate(start.clone());
1617                }
1618            } else if (this.endDate) {
1619                var end = this.endDate.clone();
1620                end.hour(hour);
1621                end.minute(minute);
1622                end.second(second);
1623                this.setEndDate(end);
1624            }
1625
1626            //update the calendars so all clickable dates reflect the new time component
1627            this.updateCalendars();
1628
1629            //update the form inputs above the calendars with the new time
1630            this.updateFormInputs();
1631
1632            //re-render the time pickers because changing one selection can affect what's enabled in another
1633            this.renderTimePicker('left');
1634            this.renderTimePicker('right');
1635
1636        },
1637
1638        elementChanged: function() {
1639            if (!this.element.is('input')) return;
1640            if (!this.element.val().length) return;
1641
1642            var dateString = this.element.val().split(this.locale.separator),
1643                start = null,
1644                end = null;
1645
1646            if (dateString.length === 2) {
1647                start = moment(dateString[0], this.locale.format);
1648                end = moment(dateString[1], this.locale.format);
1649            }
1650
1651            if (this.singleDatePicker || start === null || end === null) {
1652                start = moment(this.element.val(), this.locale.format);
1653                end = start;
1654            }
1655
1656            if (!start.isValid() || !end.isValid()) return;
1657
1658            this.setStartDate(start);
1659            this.setEndDate(end);
1660            this.updateView();
1661        },
1662
1663        keydown: function(e) {
1664            //hide on tab or enter
1665            if ((e.keyCode === 9) || (e.keyCode === 13)) {
1666                this.hide();
1667            }
1668
1669            //hide on esc and prevent propagation
1670            if (e.keyCode === 27) {
1671                e.preventDefault();
1672                e.stopPropagation();
1673
1674                this.hide();
1675            }
1676        },
1677
1678        updateElement: function() {
1679            if (this.element.is('input') && this.autoUpdateInput) {
1680                var newValue = this.startDate.format(this.locale.format);
1681                if (!this.singleDatePicker) {
1682                    newValue += this.locale.separator + this.endDate.format(this.locale.format);
1683                }
1684                if (newValue !== this.element.val()) {
1685                    this.element.val(newValue).trigger('change');
1686                }
1687            }
1688        },
1689
1690        remove: function() {
1691            this.container.remove();
1692            this.element.off('.daterangepicker');
1693            this.element.removeData();
1694        }
1695
1696    };
1697
1698    $.fn.daterangepicker = function(options, callback) {
1699        var implementOptions = $.extend(true, {}, $.fn.daterangepicker.defaultOptions, options);
1700        this.each(function() {
1701            var el = $(this);
1702            if (el.data('daterangepicker'))
1703                el.data('daterangepicker').remove();
1704            el.data('daterangepicker', new DateRangePicker(el, implementOptions, callback));
1705        });
1706        return this;
1707    };
1708
1709    return DateRangePicker;
1710
1711}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.