Socket
Socket
Sign inDemoInstall

hotel-datepicker

Package Overview
Dependencies
1
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.1 to 4.0.2

2

build.js

@@ -8,3 +8,3 @@ const rollup = require('rollup');

const banner = `/*! ${packageInfo.name} ${packageInfo.version} - Copyright 2020 ${packageInfo.author} - ${packageInfo.homepage} - ${packageInfo.license} */`;
const banner = `/*! ${packageInfo.name} ${packageInfo.version} - Copyright 2021 ${packageInfo.author} - ${packageInfo.homepage} - ${packageInfo.license} */`;

@@ -11,0 +11,0 @@ rollup.rollup({

@@ -1,2 +0,2 @@

/*! hotel-datepicker 4.0.1 - Copyright 2020 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
/*! hotel-datepicker 4.0.2 - Copyright 2021 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
var HotelDatepicker = (function () {

@@ -375,2 +375,4 @@ 'use strict';

HotelDatepicker.prototype.showMonth = function showMonth (date, month) {
date.setHours(0, 0, 0, 0);
// Show month table and create the necessary HTML code

@@ -377,0 +379,0 @@ var name = this.getMonthName(date.getMonth());

@@ -1,2 +0,2 @@

/*! hotel-datepicker 4.0.1 - Copyright 2020 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
var HotelDatepicker=function(){"use strict";var t=0,e=function t(e,s){this._boundedEventHandlers={},this.id=t.getNewId();var a=s||{};this.format=a.format||"YYYY-MM-DD",this.infoFormat=a.infoFormat||this.format,this.separator=a.separator||" - ",this.startOfWeek=a.startOfWeek||"sunday",this.startDate=a.startDate||new Date,this.endDate=a.endDate||!1,this.minNights=a.minNights||1,this.maxNights=a.maxNights||0,this.selectForward=a.selectForward||!1,this.disabledDates=a.disabledDates||[],this.noCheckInDates=a.noCheckInDates||[],this.noCheckOutDates=a.noCheckOutDates||[],this.disabledDaysOfWeek=a.disabledDaysOfWeek||[],this.enableCheckout=a.enableCheckout||!1,this.preventContainerClose=a.preventContainerClose||!1,this.container=a.container||"",this.animationSpeed=a.animationSpeed||".5s",this.hoveringTooltip=a.hoveringTooltip||!0,this.autoClose=void 0===a.autoClose||a.autoClose,this.showTopbar=void 0===a.showTopbar||a.showTopbar,this.moveBothMonths=a.moveBothMonths||!1,this.i18n=a.i18n||{selected:"Your stay:",night:"Night",nights:"Nights",button:"Close","checkin-disabled":"Check-in disabled","checkout-disabled":"Check-out disabled","day-names-short":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day-names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"month-names-short":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month-names":["January","February","March","April","May","June","July","August","September","October","November","December"],"error-more":"Date range should not be more than 1 night","error-more-plural":"Date range should not be more than %d nights","error-less":"Date range should not be less than 1 night","error-less-plural":"Date range should not be less than %d nights","info-more":"Please select a date range of at least 1 night","info-more-plural":"Please select a date range of at least %d nights","info-range":"Please select a date range between %d and %d nights","info-default":"Please select a date range"},this.getValue=a.getValue||function(){return e.value},this.setValue=a.setValue||function(t){e.value=t},this.onDayClick=void 0!==a.onDayClick&&a.onDayClick,this.onOpenDatepicker=void 0!==a.onOpenDatepicker&&a.onOpenDatepicker,this.onSelectRange=void 0!==a.onSelectRange&&a.onSelectRange,this.input=e,this.init()};return e.prototype.addBoundedListener=function(t,e,s,a){t in this._boundedEventHandlers||(this._boundedEventHandlers[t]={}),e in this._boundedEventHandlers[t]||(this._boundedEventHandlers[t][e]=[]);var i=s.bind(this);this._boundedEventHandlers[t][e].push([i,a]),t.addEventListener(e,i,a)},e.prototype.removeAllBoundedListeners=function(t,e){if(t in this._boundedEventHandlers){var s=this._boundedEventHandlers[t];if(e in s)for(var a=s[e],i=a.length;i--;){var n=a[i];t.removeEventListener(e,n[0],n[1])}}},e.getNewId=function(){return++t},e.prototype.setFechaI18n=function(){fecha.setGlobalDateI18n({dayNamesShort:this.i18n["day-names-short"],dayNames:this.i18n["day-names"],monthNamesShort:this.i18n["month-names-short"],monthNames:this.i18n["month-names"]})},e.prototype.getWeekDayNames=function(){var t="";if("monday"===this.startOfWeek){for(var e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[(1+e)%7]+"</th>";return t}for(var s=0;s<7;s++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[s]+"</th>";return t},e.prototype.getMonthDom=function(t){return document.getElementById(this.getMonthTableId(t))},e.prototype.getMonthName=function(t){return this.lang("month-names")[t]},e.prototype.getDatepickerId=function(){return"datepicker-"+this.generateId()},e.prototype.getMonthTableId=function(t){return"month-"+t+"-"+this.generateId()},e.prototype.getCloseButtonId=function(){return"close-"+this.generateId()},e.prototype.getTooltipId=function(){return"tooltip-"+this.generateId()},e.prototype.getNextMonth=function(t){var e=new Date(t.valueOf());return new Date(e.setMonth(e.getMonth()+1,1))},e.prototype.getPrevMonth=function(t){var e=new Date(t.valueOf());return new Date(e.setMonth(e.getMonth()-1,1))},e.prototype.getDateString=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.format(t,e)},e.prototype.parseDate=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.parse(t,e)},e.prototype.init=function(){this.parent=this.container?this.container:this.input.parentElement,this.start=!1,this.end=!1,this.minDays=1<this.minNights?this.minNights+1:2,this.maxDays=0<this.maxNights?this.maxNights+1:0,this.startDate&&"string"==typeof this.startDate&&(this.startDate=this.parseDate(this.startDate)),this.endDate&&"string"==typeof this.endDate&&(this.endDate=this.parseDate(this.endDate)),this.isTouchDevice()&&(this.hoveringTooltip=!1),this.isOpen=!1,this.changed=!1,this.createDom();var t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=new Date(this.startDate.getTime())),this.endDate&&0<this.compareMonth(this.getNextMonth(t),this.endDate)&&(t=new Date(this.getPrevMonth(this.endDate.getTime()))),0<this.disabledDates.length&&this.parseDisabledDates(),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.topBarDefaultText(),this.addListeners(),this.isFirstDisabledDate=0,this.lastDisabledDate=!1},e.prototype.addListeners=function(){for(var e=this,t=this.datepicker.getElementsByClassName("datepicker__month-button--next"),s=0;s<t.length;s++)t[s].addEventListener("click",function(t){return e.goToNextMonth(t)});for(var a=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),i=0;i<a.length;i++)a[i].addEventListener("click",function(t){return e.goToPreviousMonth(t)});this.addBoundedListener(this.input,"click",function(t){return e.openDatepicker(t)}),this.showTopbar&&document.getElementById(this.getCloseButtonId()).addEventListener("click",function(t){return e.closeDatepicker(t)}),this.datepicker.addEventListener("mouseover",function(t){return e.datepickerHover(t)}),this.datepicker.addEventListener("mouseout",function(t){return e.datepickerMouseOut(t)}),this.addBoundedListener(this.input,"change",function(){return e.checkAndSetDefaultValue()})},e.prototype.generateId=function(){return this.input.id?this.input.id:this.id},e.prototype.createDom=function(){var t=this.createDatepickerDomString();this.parent.insertAdjacentHTML("beforeend",t),this.datepicker=document.getElementById(this.getDatepickerId())},e.prototype.createDatepickerDomString=function(){var t='<div id="'+this.getDatepickerId()+'" style="display:none" class="datepicker datepicker--closed">';t+='<div class="datepicker__inner">',this.showTopbar&&(t+='<div class="datepicker__topbar"><div class="datepicker__info datepicker__info--selected"><span class="datepicker__info datepicker__info--selected-label">'+this.lang("selected")+' </span> <strong class="datepicker__info-text datepicker__info-text--start-day">...</strong> <span class="datepicker__info-text datepicker__info--separator">'+this.separator+'</span> <strong class="datepicker__info-text datepicker__info-text--end-day">...</strong> <em class="datepicker__info-text datepicker__info-text--selected-days">(<span></span>)</em></div><div class="datepicker__info datepicker__info--feedback"></div><button type="button" id="'+this.getCloseButtonId()+'" class="datepicker__close-button">'+this.lang("button")+"</button></div>"),t+='<div class="datepicker__months">';for(var e=1;e<=2;e++)t+='<table id="'+this.getMonthTableId(e)+'" class="datepicker__month datepicker__month--month'+e+'"><thead><tr class="datepicker__month-caption"><th><span class="datepicker__month-button datepicker__month-button--prev" month="'+e+'">&lt;</span></th><th colspan="5" class="datepicker__month-name"></th><th><span class="datepicker__month-button datepicker__month-button--next" month="'+e+'">&gt;</span></th></tr><tr class="datepicker__week-days">'+this.getWeekDayNames(e)+"</tr></thead><tbody></tbody></table>";return t+="</div>",t+='<div style="display:none" id="'+this.getTooltipId()+'" class="datepicker__tooltip"></div>',t+="</div>",t+="</div>"},e.prototype.showMonth=function(t,e){var s=this.getMonthName(t.getMonth()),a=this.getMonthDom(e),i=a.getElementsByClassName("datepicker__month-name")[0],n=a.getElementsByTagName("tbody")[0];i.textContent=s+" "+t.getFullYear(),this.emptyElement(n),n.insertAdjacentHTML("beforeend",this.createMonthDomString(t)),this.updateSelectableRange(),this["month"+e]=t},e.prototype.createMonthDomString=function(t){var e,s=this,a=[],i="";t.setDate(1);var n=t.getDay(),o=t.getMonth();if(0===n&&"monday"===this.startOfWeek&&(n=7),0<n)for(var r=n;0<r;r--){var h=new Date(t.getTime()-864e5*r);e=s.isValidDate(h.getTime()),(s.startDate&&s.compareDay(h,s.startDate)<0||s.endDate&&0<s.compareDay(h,s.endDate))&&(e=!1),a.push({date:h,type:"lastMonth",day:h.getDate(),time:h.getTime(),valid:e})}for(var d=0;d<40;d++){var l=s.addDays(t,d);e=s.isValidDate(l.getTime()),(s.startDate&&s.compareDay(l,s.startDate)<0||s.endDate&&0<s.compareDay(l,s.endDate))&&(e=!1),a.push({date:l,type:l.getMonth()===o?"visibleMonth":"nextMonth",day:l.getDate(),time:l.getTime(),valid:e})}for(var c=0;c<6&&"nextMonth"!==a[7*c].type;c++){i+='<tr class="datepicker__week-row">';for(var p=0;p<7;p++){var m="monday"===s.startOfWeek?p+1:p;m=a[7*c+m];var g=s.getDateString(m.time)===s.getDateString(new Date),u=s.getDateString(m.time)===s.getDateString(s.startDate),y=!1,D=!1,f=!1,v=!1,k=!1,_=!1;if(m.valid||"visibleMonth"===m.type){var b=s.getDateString(m.time,"YYYY-MM-DD");if(0<s.disabledDates.length){var C=s.getClosestDates(m.date);if(C[0]&&C[1]&&s.compareDay(m.date,C[0])&&0<s.countDays(C[0],C[1])-2){var M=s.countDays(C[1],m.date)-1,T=s.countDays(m.date,C[0])-1;s.selectForward&&M<s.minDays?m.valid=!1:!s.selectForward&&M<s.minDays&&T<s.minDays&&(m.valid=!1),!m.valid&&s.enableCheckout&&2===M&&(_=!0)}-1<s.disabledDates.indexOf(b)?(y=!(m.valid=!1),s.isFirstDisabledDate++,s.lastDisabledDate=m.date):s.isFirstDisabledDate=0,m.valid&&s.lastDisabledDate&&0<s.compareDay(m.date,s.lastDisabledDate)&&2===s.countDays(m.date,s.lastDisabledDate)&&(k=!0)}0<s.disabledDaysOfWeek.length&&-1<s.disabledDaysOfWeek.indexOf(fecha.format(m.time,"dddd"))&&(v=!(m.valid=!1)),0<s.noCheckInDates.length&&-1<s.noCheckInDates.indexOf(b)&&(k=!(D=!0)),0<s.noCheckOutDates.length&&-1<s.noCheckOutDates.indexOf(b)&&(f=!0)}var w=["datepicker__month-day--"+m.type,"datepicker__month-day--"+(m.valid?"valid":"invalid"),g?"datepicker__month-day--today":"",y?"datepicker__month-day--disabled":"",y&&s.enableCheckout&&1===s.isFirstDisabledDate?"datepicker__month-day--checkout-enabled":"",_?"datepicker__month-day--before-disabled-date":"",u||k?"datepicker__month-day--checkin-only":"",D?"datepicker__month-day--no-checkin":"",f?"datepicker__month-day--no-checkout":"",v?"datepicker__month-day--day-of-week-disabled":""],S="";D&&(S=s.i18n["checkin-disabled"]),f&&(S&&(S+=". "),S+=s.i18n["checkout-disabled"]);var N={time:m.time,class:w.join(" ")};S&&(N.title=S),i+='<td class="datepicker__month-day '+N.class+'" '+s.printAttributes(N)+">"+m.day+"</td>"}i+="</tr>"}return i},e.prototype.openDatepicker=function(){var e=this;this.isOpen||(this.removeClass(this.datepicker,"datepicker--closed"),this.addClass(this.datepicker,"datepicker--open"),this.checkAndSetDefaultValue(),this.slideDown(this.datepicker,this.animationSpeed),this.isOpen=!0,this.showSelectedDays(),this.disableNextPrevButtons(),this.addBoundedListener(document,"click",function(t){return e.documentClick(t)}),this.onOpenDatepicker&&this.onOpenDatepicker())},e.prototype.closeDatepicker=function(){if(this.isOpen){this.removeClass(this.datepicker,"datepicker--open"),this.addClass(this.datepicker,"datepicker--closed"),this.slideUp(this.datepicker,this.animationSpeed),this.isOpen=!1;var t=document.createEvent("Event");t.initEvent("afterClose",!0,!0),this.input.dispatchEvent(t),this.removeAllBoundedListeners(document,"click")}},e.prototype.autoclose=function(){this.autoClose&&this.changed&&this.isOpen&&this.start&&this.end&&this.closeDatepicker()},e.prototype.documentClick=function(t){this.parent.contains(t.target)||t.target===this.input?"td"===t.target.tagName.toLowerCase()&&this.dayClicked(t.target):this.preventContainerClose||this.closeDatepicker()},e.prototype.datepickerHover=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&this.dayHovering(t.target)},e.prototype.datepickerMouseOut=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&(document.getElementById(this.getTooltipId()).style.display="none")},e.prototype.checkAndSetDefaultValue=function(){var t=this.getValue(),e=t?t.split(this.separator):"";if(e&&2<=e.length){var s=this.format;this.changed=!1,this.setDateRange(this.parseDate(e[0],s),this.parseDate(e[1],s)),this.changed=!0}else if(this.showTopbar){this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none"}},e.prototype.setDateRange=function(t,e){if(t.getTime()>e.getTime()){var s=e;e=t,t=s,s=null}var a=!0;if((this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(e,this.endDate))&&(a=!1),!a)return this.showMonth(this.startDate,1),this.showMonth(this.getNextMonth(this.startDate),2),this.showSelectedDays(),void this.disableNextPrevButtons();t.setTime(t.getTime()+432e5),e.setTime(e.getTime()+432e5),this.start=t.getTime(),this.end=e.getTime(),0<this.compareDay(t,e)&&0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),this.showMonth(t,1),this.showMonth(e,2),this.showSelectedDays(),this.disableNextPrevButtons(),this.checkSelection(),this.showSelectedInfo(),this.autoclose()},e.prototype.showSelectedDays=function(){var t=this;if(this.start||this.end)for(var e=this.datepicker.getElementsByTagName("td"),s=0;s<e.length;s++){var a=parseInt(e[s].getAttribute("time"),10);t.start&&t.end&&t.end>=a&&t.start<=a||t.start&&!t.end&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--selected"):t.removeClass(e[s],"datepicker__month-day--selected"),t.start&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--first-day-selected"):t.removeClass(e[s],"datepicker__month-day--first-day-selected"),t.end&&t.getDateString(t.end,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--last-day-selected"):t.removeClass(e[s],"datepicker__month-day--last-day-selected")}},e.prototype.showSelectedInfo=function(){if(this.showTopbar){var t=this.datepicker.getElementsByClassName("datepicker__info--selected")[0],e=t.getElementsByClassName("datepicker__info-text--start-day")[0],s=t.getElementsByClassName("datepicker__info-text--end-day")[0],a=t.getElementsByClassName("datepicker__info-text--selected-days")[0],i=document.getElementById(this.getCloseButtonId());if(e.textContent="...",s.textContent="...",a.style.display="none",this.start&&(t.style.display="",e.textContent=this.getDateString(new Date(parseInt(this.start,10)),this.infoFormat)),this.end&&(s.textContent=this.getDateString(new Date(parseInt(this.end,10)),this.infoFormat)),this.start&&this.end){var n=this.countDays(this.end,this.start)-1,o=1===n?n+" "+this.lang("night"):n+" "+this.lang("nights"),r=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end));a.style.display="",a.firstElementChild.textContent=o,i.disabled=!1,this.setValue(r,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0}else i.disabled=!0}else if(this.start&&this.end){var h=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end));this.setValue(h,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0}},e.prototype.dayClicked=function(t){if(!this.hasClass(t,"datepicker__month-day--invalid")){var e=this.start&&this.end||!this.start&&!this.end;if(e){if(this.hasClass(t,"datepicker__month-day--no-checkin"))return}else if(this.start&&this.hasClass(t,"datepicker__month-day--no-checkout"))return;var s=parseInt(t.getAttribute("time"),10);if(this.addClass(t,"datepicker__month-day--selected"),e?(this.start=s,this.end=!1):this.start&&(this.end=s),this.start&&this.end&&this.start>this.end){var a=this.end;this.end=this.start,this.start=a}this.start=parseInt(this.start,10),this.end=parseInt(this.end,10),this.clearHovering(),this.start&&!this.end&&this.dayHovering(t),this.updateSelectableRange(),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays(),this.autoclose(),this.onDayClick&&this.onDayClick(),this.end&&this.onSelectRange&&this.onSelectRange()}},e.prototype.isValidDate=function(t){if(t=parseInt(t,10),this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(t,this.endDate))return!1;if(this.start&&!this.end){if(0<this.maxDays&&this.countDays(t,this.start)>this.maxDays||0<this.minDays&&1<this.countDays(t,this.start)&&this.countDays(t,this.start)<this.minDays)return!1;if(this.selectForward&&t<this.start)return!1;if(0<this.disabledDates.length){var e=this.getClosestDates(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&0<=this.compareDay(t,e[1]))return!1}}return!0},e.prototype.checkSelection=function(){var t=this,e=this.countDays(this.end,this.start),s=!!this.showTopbar&&this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];if(this.maxDays&&e>this.maxDays){this.start=!1,this.end=!1;for(var a=this.datepicker.getElementsByTagName("td"),i=0;i<a.length;i++)t.removeClass(a[i],"datepicker__month-day--selected"),t.removeClass(a[i],"datepicker__month-day--first-day-selected"),t.removeClass(a[i],"datepicker__month-day--last-day-selected");if(this.showTopbar){var n=this.maxDays-1;this.topBarErrorText(s,"error-more",n)}}else if(this.minDays&&e<this.minDays){this.start=!1,this.end=!1;for(var o=this.datepicker.getElementsByTagName("td"),r=0;r<o.length;r++)t.removeClass(o[r],"datepicker__month-day--selected"),t.removeClass(o[r],"datepicker__month-day--first-day-selected"),t.removeClass(o[r],"datepicker__month-day--last-day-selected");if(this.showTopbar){var h=this.minDays-1;this.topBarErrorText(s,"error-less",h)}}else this.start||this.end?this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.removeClass(s,"datepicker__info--help")):this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.addClass(s,"datepicker__info--help"))},e.prototype.addDays=function(t,e){var s=new Date(t);return s.setDate(s.getDate()+e),s},e.prototype.countDays=function(t,e){return Math.abs(this.daysFrom1970(t)-this.daysFrom1970(e))+1},e.prototype.compareDay=function(t,e){var s=parseInt(this.getDateString(t,"YYYYMMDD"),10)-parseInt(this.getDateString(e,"YYYYMMDD"),10);return 0<s?1:0===s?0:-1},e.prototype.compareMonth=function(t,e){var s=parseInt(this.getDateString(t,"YYYYMM"),10)-parseInt(this.getDateString(e,"YYYYMM"),10);return 0<s?1:0===s?0:-1},e.prototype.daysFrom1970=function(t){return Math.floor(this.toLocalTimestamp(t)/864e5)},e.prototype.toLocalTimestamp=function(t){return"object"==typeof t&&t.getTime&&(t=t.getTime()),"string"!=typeof t||t.match(/\d{13}/)||(t=this.parseDate(t).getTime()),t=parseInt(t,10)-60*(new Date).getTimezoneOffset()*1e3},e.prototype.printAttributes=function(t){var e=t,s="";for(var a in t)Object.prototype.hasOwnProperty.call(e,a)&&(s+=a+'="'+e[a]+'" ');return s},e.prototype.goToNextMonth=function(t){var e=t.target.getAttribute("month"),s=1<e,a=s?this.month2:this.month1;a=this.getNextMonth(a),!this.isSingleMonth()&&!s&&0<=this.compareMonth(a,this.month2)||this.isMonthOutOfRange(a)||(this.moveBothMonths&&s&&this.showMonth(this.month2,1),this.showMonth(a,e),this.showSelectedDays(),this.disableNextPrevButtons())},e.prototype.goToPreviousMonth=function(t){var e=t.target.getAttribute("month"),s=1<e,a=s?this.month2:this.month1;a=this.getPrevMonth(a),s&&this.compareMonth(a,this.month1)<=0||this.isMonthOutOfRange(a)||(this.moveBothMonths&&!s&&this.showMonth(this.month1,2),this.showMonth(a,e),this.showSelectedDays(),this.disableNextPrevButtons())},e.prototype.isSingleMonth=function(){return!this.isVisible(this.getMonthDom(2))},e.prototype.isMonthOutOfRange=function(t){var e=new Date(t.valueOf());return!!(this.startDate&&new Date(e.getFullYear(),e.getMonth()+1,0,23,59,59)<this.startDate||this.endDate&&new Date(e.getFullYear(),e.getMonth(),1)>this.endDate)},e.prototype.disableNextPrevButtons=function(){if(!this.isSingleMonth()){var t=parseInt(this.getDateString(this.month1,"YYYYMM"),10),e=parseInt(this.getDateString(this.month2,"YYYYMM"),10),s=Math.abs(t-e),a=this.datepicker.getElementsByClassName("datepicker__month-button--next"),i=this.datepicker.getElementsByClassName("datepicker__month-button--prev");1<s&&89!==s?(this.removeClass(a[0],"datepicker__month-button--disabled"),this.removeClass(i[1],"datepicker__month-button--disabled")):(this.addClass(a[0],"datepicker__month-button--disabled"),this.addClass(i[1],"datepicker__month-button--disabled")),this.isMonthOutOfRange(this.getPrevMonth(this.month1))?this.addClass(i[0],"datepicker__month-button--disabled"):this.removeClass(i[0],"datepicker__month-button--disabled"),this.isMonthOutOfRange(this.getNextMonth(this.month2))?this.addClass(a[1],"datepicker__month-button--disabled"):this.removeClass(a[1],"datepicker__month-button--disabled")}},e.prototype.topBarDefaultText=function(){if(this.showTopbar){var t="";t=this.minDays&&this.maxDays?this.lang("info-range"):this.minDays&&2<this.minDays?this.lang("info-more-plural"):this.minDays?this.lang("info-more"):this.lang("info-default");var e=this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];t=t.replace(/%d/,this.minDays-1).replace(/%d/,this.maxDays-1),this.addClass(e,"datepicker__info--help"),this.removeClass(e,"datepicker__info--error"),e.textContent=t}},e.prototype.topBarErrorText=function(t,e,s){this.showTopbar&&(this.addClass(t,"datepicker__info--error"),this.removeClass(t,"datepicker__info--help"),1<s?(e=(e=this.lang(e+"-plural")).replace("%d",s),t.textContent=e):e=this.lang(e),this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none")},e.prototype.updateSelectableRange=function(){for(var t=this,e=this.datepicker.getElementsByTagName("td"),s=this.start&&!this.end,a=0;a<e.length;a++)if(t.hasClass(e[a],"datepicker__month-day--invalid")&&t.hasClass(e[a],"datepicker__month-day--tmp")&&(t.removeClass(e[a],"datepicker__month-day--tmp"),t.hasClass(e[a],"datepicker__month-day--tmpinvalid")?t.removeClass(e[a],"datepicker__month-day--tmpinvalid"):(t.removeClass(e[a],"datepicker__month-day--invalid"),t.addClass(e[a],"datepicker__month-day--valid"))),s){if(t.hasClass(e[a],"datepicker__month-day--visibleMonth")&&(t.hasClass(e[a],"datepicker__month-day--valid")||t.hasClass(e[a],"datepicker__month-day--disabled")||t.hasClass(e[a],"datepicker__month-day--before-disabled-date"))){var i=parseInt(e[a].getAttribute("time"),10);t.isValidDate(i)?(t.addClass(e[a],"datepicker__month-day--valid"),t.addClass(e[a],"datepicker__month-day--tmp"),t.removeClass(e[a],"datepicker__month-day--invalid"),t.removeClass(e[a],"datepicker__month-day--disabled")):(t.hasClass(e[a],"datepicker__month-day--invalid")&&t.addClass(e[a],"datepicker__month-day--tmpinvalid"),t.addClass(e[a],"datepicker__month-day--invalid"),t.addClass(e[a],"datepicker__month-day--tmp"),t.removeClass(e[a],"datepicker__month-day--valid"))}}else(t.hasClass(e[a],"datepicker__month-day--checkout-enabled")||t.hasClass(e[a],"datepicker__month-day--before-disabled-date"))&&(t.addClass(e[a],"datepicker__month-day--invalid"),t.removeClass(e[a],"datepicker__month-day--valid"),t.hasClass(e[a],"datepicker__month-day--before-disabled-date")||t.addClass(e[a],"datepicker__month-day--disabled"));return!0},e.prototype.dayHovering=function(t){var e=this,s=parseInt(t.getAttribute("time"),10),a="";if(!this.hasClass(t,"datepicker__month-day--invalid")){for(var i=this.datepicker.getElementsByTagName("td"),n=0;n<i.length;n++){var o=parseInt(i[n].getAttribute("time"),10);o===s?e.addClass(i[n],"datepicker__month-day--hovering"):e.removeClass(i[n],"datepicker__month-day--hovering"),e.start&&!e.end&&(e.start<o&&o<=s||e.start>o&&s<=o)?e.addClass(i[n],"datepicker__month-day--hovering"):e.removeClass(i[n],"datepicker__month-day--hovering")}if(this.start&&!this.end){var r=this.countDays(s,this.start)-1;if(this.hoveringTooltip)if("function"==typeof this.hoveringTooltip)a=this.hoveringTooltip(r,this.start,s);else if(!0===this.hoveringTooltip&&0<r){a=r+" "+(1===r?this.lang("night"):this.lang("nights"))}}}if(a){var h=t.getBoundingClientRect(),d=this.datepicker.getBoundingClientRect(),l=h.left-d.left,c=h.top-d.top;l+=h.width/2;var p=document.getElementById(this.getTooltipId());p.style.display="",p.textContent=a;var m=p.getBoundingClientRect().width,g=p.getBoundingClientRect().height;l-=m/2,c-=g,setTimeout(function(){p.style.left=l+"px",p.style.top=c+"px"},10)}else{document.getElementById(this.getTooltipId()).style.display="none"}},e.prototype.clearHovering=function(){for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--hovering");document.getElementById(this.getTooltipId()).style.display="none"},e.prototype.clearSelection=function(){this.start=!1,this.end=!1;for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays()},e.prototype.parseDisabledDates=function(){var t=[];this.setFechaI18n();for(var e=0;e<this.disabledDates.length;e++)t[e]=fecha.parse(this.disabledDates[e],"YYYY-MM-DD");t.sort(function(t,e){return t-e}),this.disabledDatesTime=t},e.prototype.getClosestDates=function(t){var e=[!1,!1];if(t<this.disabledDatesTime[0])e=this.enableCheckout?[!1,this.addDays(this.disabledDatesTime[0],1)]:[!1,this.disabledDatesTime[0]];else if(t>this.disabledDatesTime[this.disabledDatesTime.length-1])e=[this.disabledDatesTime[this.disabledDatesTime.length-1],!1];else{var s,a=this.disabledDatesTime.length,i=this.disabledDatesTime.length,n=Math.abs(new Date(0,0,0).valueOf()),o=n,r=-n,h=0;for(s=0;s<this.disabledDatesTime.length;++s)(h=t-this.disabledDatesTime[s])<0&&r<h&&(i=s,r=h),0<h&&h<o&&(a=s,o=h);this.disabledDatesTime[a]&&(e[0]=this.disabledDatesTime[a]),void 0===this.disabledDatesTime[a]?e[1]=!1:this.enableCheckout?e[1]=this.addDays(this.disabledDatesTime[i],1):e[1]=this.disabledDatesTime[i]}return e},e.prototype.lang=function(t){return t in this.i18n?this.i18n[t]:""},e.prototype.emptyElement=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},e.prototype.classRegex=function(t){return new RegExp("(^|\\s+)"+t+"(\\s+|$)")},e.prototype.hasClass=function(t,e){return this.classRegex(e).test(t.className)},e.prototype.addClass=function(t,e){this.hasClass(t,e)||(t.className=t.className+" "+e)},e.prototype.removeClass=function(t,e){t.className=t.className.replace(this.classRegex(e)," ")},e.prototype.isVisible=function(t){return t.offsetWidth||t.offsetHeight||t.getClientRects().length},e.prototype.slideDown=function(t,e){t.style.display="";var s=t.getBoundingClientRect().height;t.style.height=0,this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=s+"px",t.addEventListener("transitionend",function(){t.style.height=t.style.transition=t.style.display=""})},e.prototype.slideUp=function(t,e){var s=t.getBoundingClientRect().height;t.style.height=s+"px",this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=0,t.addEventListener("transitionend",function(){t.style.display="none"})},e.prototype.recalc=function(t){return t.offsetHeight},e.prototype.isTouchDevice=function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch},e.prototype.open=function(){this.openDatepicker()},e.prototype.close=function(){this.closeDatepicker()},e.prototype.getDatePicker=function(){return this.datepicker},e.prototype.setRange=function(t,e){"string"==typeof t&&"string"==typeof e&&(t=this.parseDate(t),e=this.parseDate(e)),this.setDateRange(t,e)},e.prototype.clear=function(){this.clearSelection()},e.prototype.getNights=function(){var t=0;if(this.start&&this.end)t=this.countDays(this.end,this.start)-1;else{var e=this.getValue(),s=e?e.split(this.separator):"";if(s&&2<=s.length){var a=this.format;t=this.countDays(this.parseDate(s[0],a),this.parseDate(s[1],a))-1}}return t},e.prototype.destroy=function(){document.getElementById(this.getDatepickerId())&&(this.removeAllBoundedListeners(this.input,"click"),this.removeAllBoundedListeners(document,"click"),this.removeAllBoundedListeners(this.input,"change"),this.datepicker.parentNode.removeChild(this.datepicker))},e}();
/*! hotel-datepicker 4.0.2 - Copyright 2021 Benito Lopez (http://lopezb.com) - https://github.com/benitolopez/hotel-datepicker - MIT */
var HotelDatepicker=function(){"use strict";function s(e,t){this._boundedEventHandlers={},this.id=s.getNewId(),t=t||{},this.format=t.format||"YYYY-MM-DD",this.infoFormat=t.infoFormat||this.format,this.separator=t.separator||" - ",this.startOfWeek=t.startOfWeek||"sunday",this.startDate=t.startDate||new Date,this.endDate=t.endDate||!1,this.minNights=t.minNights||1,this.maxNights=t.maxNights||0,this.selectForward=t.selectForward||!1,this.disabledDates=t.disabledDates||[],this.noCheckInDates=t.noCheckInDates||[],this.noCheckOutDates=t.noCheckOutDates||[],this.disabledDaysOfWeek=t.disabledDaysOfWeek||[],this.enableCheckout=t.enableCheckout||!1,this.preventContainerClose=t.preventContainerClose||!1,this.container=t.container||"",this.animationSpeed=t.animationSpeed||".5s",this.hoveringTooltip=t.hoveringTooltip||!0,this.autoClose=void 0===t.autoClose||t.autoClose,this.showTopbar=void 0===t.showTopbar||t.showTopbar,this.moveBothMonths=t.moveBothMonths||!1,this.i18n=t.i18n||{selected:"Your stay:",night:"Night",nights:"Nights",button:"Close","checkin-disabled":"Check-in disabled","checkout-disabled":"Check-out disabled","day-names-short":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"day-names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"month-names-short":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"month-names":["January","February","March","April","May","June","July","August","September","October","November","December"],"error-more":"Date range should not be more than 1 night","error-more-plural":"Date range should not be more than %d nights","error-less":"Date range should not be less than 1 night","error-less-plural":"Date range should not be less than %d nights","info-more":"Please select a date range of at least 1 night","info-more-plural":"Please select a date range of at least %d nights","info-range":"Please select a date range between %d and %d nights","info-default":"Please select a date range"},this.getValue=t.getValue||function(){return e.value},this.setValue=t.setValue||function(t){e.value=t},this.onDayClick=void 0!==t.onDayClick&&t.onDayClick,this.onOpenDatepicker=void 0!==t.onOpenDatepicker&&t.onOpenDatepicker,this.onSelectRange=void 0!==t.onSelectRange&&t.onSelectRange,this.input=e,this.init()}var t=0;return s.prototype.addBoundedListener=function(t,e,s,a){t in this._boundedEventHandlers||(this._boundedEventHandlers[t]={}),e in this._boundedEventHandlers[t]||(this._boundedEventHandlers[t][e]=[]);s=s.bind(this);this._boundedEventHandlers[t][e].push([s,a]),t.addEventListener(e,s,a)},s.prototype.removeAllBoundedListeners=function(t,e){if(t in this._boundedEventHandlers){var s=this._boundedEventHandlers[t];if(e in s)for(var a=s[e],i=a.length;i--;){var n=a[i];t.removeEventListener(e,n[0],n[1])}}},s.getNewId=function(){return++t},s.prototype.setFechaI18n=function(){fecha.setGlobalDateI18n({dayNamesShort:this.i18n["day-names-short"],dayNames:this.i18n["day-names"],monthNamesShort:this.i18n["month-names-short"],monthNames:this.i18n["month-names"]})},s.prototype.getWeekDayNames=function(){var t="";if("monday"===this.startOfWeek){for(var e=0;e<7;e++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[(1+e)%7]+"</th>";return t}for(var s=0;s<7;s++)t+='<th class="datepicker__week-name">'+this.lang("day-names-short")[s]+"</th>";return t},s.prototype.getMonthDom=function(t){return document.getElementById(this.getMonthTableId(t))},s.prototype.getMonthName=function(t){return this.lang("month-names")[t]},s.prototype.getDatepickerId=function(){return"datepicker-"+this.generateId()},s.prototype.getMonthTableId=function(t){return"month-"+t+"-"+this.generateId()},s.prototype.getCloseButtonId=function(){return"close-"+this.generateId()},s.prototype.getTooltipId=function(){return"tooltip-"+this.generateId()},s.prototype.getNextMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()+1,1))},s.prototype.getPrevMonth=function(t){t=new Date(t.valueOf());return new Date(t.setMonth(t.getMonth()-1,1))},s.prototype.getDateString=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.format(t,e)},s.prototype.parseDate=function(t,e){return void 0===e&&(e=this.format),this.setFechaI18n(),fecha.parse(t,e)},s.prototype.init=function(){this.parent=this.container||this.input.parentElement,this.start=!1,this.end=!1,this.minDays=1<this.minNights?this.minNights+1:2,this.maxDays=0<this.maxNights?this.maxNights+1:0,this.startDate&&"string"==typeof this.startDate&&(this.startDate=this.parseDate(this.startDate)),this.endDate&&"string"==typeof this.endDate&&(this.endDate=this.parseDate(this.endDate)),this.isTouchDevice()&&(this.hoveringTooltip=!1),this.isOpen=!1,this.changed=!1,this.createDom();var t=new Date;this.startDate&&this.compareMonth(t,this.startDate)<0&&(t=new Date(this.startDate.getTime())),this.endDate&&0<this.compareMonth(this.getNextMonth(t),this.endDate)&&(t=new Date(this.getPrevMonth(this.endDate.getTime()))),0<this.disabledDates.length&&this.parseDisabledDates(),this.showMonth(t,1),this.showMonth(this.getNextMonth(t),2),this.topBarDefaultText(),this.addListeners(),this.isFirstDisabledDate=0,this.lastDisabledDate=!1},s.prototype.addListeners=function(){for(var e=this,t=this.datepicker.getElementsByClassName("datepicker__month-button--next"),s=0;s<t.length;s++)t[s].addEventListener("click",function(t){return e.goToNextMonth(t)});for(var a=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),i=0;i<a.length;i++)a[i].addEventListener("click",function(t){return e.goToPreviousMonth(t)});this.addBoundedListener(this.input,"click",function(t){return e.openDatepicker(t)}),this.showTopbar&&document.getElementById(this.getCloseButtonId()).addEventListener("click",function(t){return e.closeDatepicker(t)}),this.datepicker.addEventListener("mouseover",function(t){return e.datepickerHover(t)}),this.datepicker.addEventListener("mouseout",function(t){return e.datepickerMouseOut(t)}),this.addBoundedListener(this.input,"change",function(){return e.checkAndSetDefaultValue()})},s.prototype.generateId=function(){return this.input.id||this.id},s.prototype.createDom=function(){var t=this.createDatepickerDomString();this.parent.insertAdjacentHTML("beforeend",t),this.datepicker=document.getElementById(this.getDatepickerId())},s.prototype.createDatepickerDomString=function(){var t='<div id="'+this.getDatepickerId()+'" style="display:none" class="datepicker datepicker--closed">';t+='<div class="datepicker__inner">',this.showTopbar&&(t+='<div class="datepicker__topbar"><div class="datepicker__info datepicker__info--selected"><span class="datepicker__info datepicker__info--selected-label">'+this.lang("selected")+' </span> <strong class="datepicker__info-text datepicker__info-text--start-day">...</strong> <span class="datepicker__info-text datepicker__info--separator">'+this.separator+'</span> <strong class="datepicker__info-text datepicker__info-text--end-day">...</strong> <em class="datepicker__info-text datepicker__info-text--selected-days">(<span></span>)</em></div><div class="datepicker__info datepicker__info--feedback"></div><button type="button" id="'+this.getCloseButtonId()+'" class="datepicker__close-button">'+this.lang("button")+"</button></div>"),t+='<div class="datepicker__months">';for(var e=1;e<=2;e++)t+='<table id="'+this.getMonthTableId(e)+'" class="datepicker__month datepicker__month--month'+e+'"><thead><tr class="datepicker__month-caption"><th><span class="datepicker__month-button datepicker__month-button--prev" month="'+e+'">&lt;</span></th><th colspan="5" class="datepicker__month-name"></th><th><span class="datepicker__month-button datepicker__month-button--next" month="'+e+'">&gt;</span></th></tr><tr class="datepicker__week-days">'+this.getWeekDayNames(e)+"</tr></thead><tbody></tbody></table>";return t+="</div>",t+='<div style="display:none" id="'+this.getTooltipId()+'" class="datepicker__tooltip"></div>',t+="</div>",t+="</div>"},s.prototype.showMonth=function(t,e){t.setHours(0,0,0,0);var s=this.getMonthName(t.getMonth()),a=this.getMonthDom(e),i=a.getElementsByClassName("datepicker__month-name")[0],a=a.getElementsByTagName("tbody")[0];i.textContent=s+" "+t.getFullYear(),this.emptyElement(a),a.insertAdjacentHTML("beforeend",this.createMonthDomString(t)),this.updateSelectableRange(),this["month"+e]=t},s.prototype.createMonthDomString=function(t){var e=this,s=[],a="";t.setDate(1);var i=t.getDay(),n=t.getMonth();if(0<(i=0===i&&"monday"===this.startOfWeek?7:i))for(var o=i;0<o;o--){var r=new Date(t.getTime()-864e5*o),h=e.isValidDate(r.getTime());(e.startDate&&e.compareDay(r,e.startDate)<0||e.endDate&&0<e.compareDay(r,e.endDate))&&(h=!1),s.push({date:r,type:"lastMonth",day:r.getDate(),time:r.getTime(),valid:h})}for(var d=0;d<40;d++){var l=e.addDays(t,d);h=e.isValidDate(l.getTime()),(e.startDate&&e.compareDay(l,e.startDate)<0||e.endDate&&0<e.compareDay(l,e.endDate))&&(h=!1),s.push({date:l,type:l.getMonth()===n?"visibleMonth":"nextMonth",day:l.getDate(),time:l.getTime(),valid:h})}for(var c=0;c<6&&"nextMonth"!==s[7*c].type;c++){a+='<tr class="datepicker__week-row">';for(var p=0;p<7;p++){var m,g,u,y=s[7*c+(y="monday"===e.startOfWeek?p+1:p)],D=e.getDateString(y.time)===e.getDateString(new Date),f=e.getDateString(y.time)===e.getDateString(e.startDate),k=!1,_=!1,v=!1,b=!1,C=!1,M=!1;!y.valid&&"visibleMonth"!==y.type||(m=e.getDateString(y.time,"YYYY-MM-DD"),0<e.disabledDates.length&&((u=e.getClosestDates(y.date))[0]&&u[1]&&e.compareDay(y.date,u[0])&&0<e.countDays(u[0],u[1])-2&&(g=e.countDays(u[1],y.date)-1,u=e.countDays(y.date,u[0])-1,(e.selectForward&&g<e.minDays||!e.selectForward&&g<e.minDays&&u<e.minDays)&&(y.valid=!1),!y.valid&&e.enableCheckout&&2==g&&(M=!0)),-1<e.disabledDates.indexOf(m)?(k=!(y.valid=!1),e.isFirstDisabledDate++,e.lastDisabledDate=y.date):e.isFirstDisabledDate=0,y.valid&&e.lastDisabledDate&&0<e.compareDay(y.date,e.lastDisabledDate)&&2===e.countDays(y.date,e.lastDisabledDate)&&(C=!0)),0<e.disabledDaysOfWeek.length&&-1<e.disabledDaysOfWeek.indexOf(fecha.format(y.time,"dddd"))&&(b=!(y.valid=!1)),0<e.noCheckInDates.length&&-1<e.noCheckInDates.indexOf(m)&&(C=!(_=!0)),0<e.noCheckOutDates.length&&-1<e.noCheckOutDates.indexOf(m)&&(v=!0));C=["datepicker__month-day--"+y.type,"datepicker__month-day--"+(y.valid?"valid":"invalid"),D?"datepicker__month-day--today":"",k?"datepicker__month-day--disabled":"",k&&e.enableCheckout&&1===e.isFirstDisabledDate?"datepicker__month-day--checkout-enabled":"",M?"datepicker__month-day--before-disabled-date":"",f||C?"datepicker__month-day--checkin-only":"",_?"datepicker__month-day--no-checkin":"",v?"datepicker__month-day--no-checkout":"",b?"datepicker__month-day--day-of-week-disabled":""],b="";_&&(b=e.i18n["checkin-disabled"]),v&&(b&&(b+=". "),b+=e.i18n["checkout-disabled"]);C={time:y.time,class:C.join(" ")};b&&(C.title=b),a+='<td class="datepicker__month-day '+C.class+'" '+e.printAttributes(C)+">"+y.day+"</td>"}a+="</tr>"}return a},s.prototype.openDatepicker=function(){var e=this;this.isOpen||(this.removeClass(this.datepicker,"datepicker--closed"),this.addClass(this.datepicker,"datepicker--open"),this.checkAndSetDefaultValue(),this.slideDown(this.datepicker,this.animationSpeed),this.isOpen=!0,this.showSelectedDays(),this.disableNextPrevButtons(),this.addBoundedListener(document,"click",function(t){return e.documentClick(t)}),this.onOpenDatepicker&&this.onOpenDatepicker())},s.prototype.closeDatepicker=function(){var t;this.isOpen&&(this.removeClass(this.datepicker,"datepicker--open"),this.addClass(this.datepicker,"datepicker--closed"),this.slideUp(this.datepicker,this.animationSpeed),this.isOpen=!1,(t=document.createEvent("Event")).initEvent("afterClose",!0,!0),this.input.dispatchEvent(t),this.removeAllBoundedListeners(document,"click"))},s.prototype.autoclose=function(){this.autoClose&&this.changed&&this.isOpen&&this.start&&this.end&&this.closeDatepicker()},s.prototype.documentClick=function(t){this.parent.contains(t.target)||t.target===this.input?"td"===t.target.tagName.toLowerCase()&&this.dayClicked(t.target):this.preventContainerClose||this.closeDatepicker()},s.prototype.datepickerHover=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&this.dayHovering(t.target)},s.prototype.datepickerMouseOut=function(t){t.target.tagName&&"td"===t.target.tagName.toLowerCase()&&(document.getElementById(this.getTooltipId()).style.display="none")},s.prototype.checkAndSetDefaultValue=function(){var t=this.getValue(),e=t?t.split(this.separator):"";e&&2<=e.length?(t=this.format,this.changed=!1,this.setDateRange(this.parseDate(e[0],t),this.parseDate(e[1],t)),this.changed=!0):this.showTopbar&&(this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none")},s.prototype.setDateRange=function(t,e){t.getTime()>e.getTime()&&(s=e,e=t,t=s,s=null);var s=!0;if(!(s=this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(e,this.endDate)?!1:s))return this.showMonth(this.startDate,1),this.showMonth(this.getNextMonth(this.startDate),2),this.showSelectedDays(),void this.disableNextPrevButtons();t.setTime(t.getTime()+432e5),e.setTime(e.getTime()+432e5),this.start=t.getTime(),this.end=e.getTime(),0<this.compareDay(t,e)&&0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),0===this.compareMonth(t,e)&&(e=this.getNextMonth(t)),this.showMonth(t,1),this.showMonth(e,2),this.showSelectedDays(),this.disableNextPrevButtons(),this.checkSelection(),this.showSelectedInfo(),this.autoclose()},s.prototype.showSelectedDays=function(){var t=this;if(this.start||this.end)for(var e=this.datepicker.getElementsByTagName("td"),s=0;s<e.length;s++){var a=parseInt(e[s].getAttribute("time"),10);t.start&&t.end&&t.end>=a&&t.start<=a||t.start&&!t.end&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--selected"):t.removeClass(e[s],"datepicker__month-day--selected"),t.start&&t.getDateString(t.start,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--first-day-selected"):t.removeClass(e[s],"datepicker__month-day--first-day-selected"),t.end&&t.getDateString(t.end,"YYYY-MM-DD")===t.getDateString(a,"YYYY-MM-DD")?t.addClass(e[s],"datepicker__month-day--last-day-selected"):t.removeClass(e[s],"datepicker__month-day--last-day-selected")}},s.prototype.showSelectedInfo=function(){var t,e,s,a,i;this.showTopbar?(a=(t=this.datepicker.getElementsByClassName("datepicker__info--selected")[0]).getElementsByClassName("datepicker__info-text--start-day")[0],s=t.getElementsByClassName("datepicker__info-text--end-day")[0],e=t.getElementsByClassName("datepicker__info-text--selected-days")[0],i=document.getElementById(this.getCloseButtonId()),a.textContent="...",s.textContent="...",e.style.display="none",this.start&&(t.style.display="",a.textContent=this.getDateString(new Date(parseInt(this.start,10)),this.infoFormat)),this.end&&(s.textContent=this.getDateString(new Date(parseInt(this.end,10)),this.infoFormat)),this.start&&this.end?(s=1==(a=this.countDays(this.end,this.start)-1)?a+" "+this.lang("night"):a+" "+this.lang("nights"),a=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end)),e.style.display="",e.firstElementChild.textContent=s,i.disabled=!1,this.setValue(a,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0):i.disabled=!0):this.start&&this.end&&(i=this.getDateString(new Date(this.start))+this.separator+this.getDateString(new Date(this.end)),this.setValue(i,this.getDateString(new Date(this.start)),this.getDateString(new Date(this.end))),this.changed=!0)},s.prototype.dayClicked=function(t){if(!this.hasClass(t,"datepicker__month-day--invalid")){var e=this.start&&this.end||!this.start&&!this.end;if(e){if(this.hasClass(t,"datepicker__month-day--no-checkin"))return}else if(this.start&&this.hasClass(t,"datepicker__month-day--no-checkout"))return;var s=parseInt(t.getAttribute("time"),10);this.addClass(t,"datepicker__month-day--selected"),e?(this.start=s,this.end=!1):this.start&&(this.end=s),this.start&&this.end&&this.start>this.end&&(s=this.end,this.end=this.start,this.start=s),this.start=parseInt(this.start,10),this.end=parseInt(this.end,10),this.clearHovering(),this.start&&!this.end&&this.dayHovering(t),this.updateSelectableRange(),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays(),this.autoclose(),this.onDayClick&&this.onDayClick(),this.end&&this.onSelectRange&&this.onSelectRange()}},s.prototype.isValidDate=function(t){if(t=parseInt(t,10),this.startDate&&this.compareDay(t,this.startDate)<0||this.endDate&&0<this.compareDay(t,this.endDate))return!1;if(this.start&&!this.end){if(0<this.maxDays&&this.countDays(t,this.start)>this.maxDays||0<this.minDays&&1<this.countDays(t,this.start)&&this.countDays(t,this.start)<this.minDays)return!1;if(this.selectForward&&t<this.start)return!1;if(0<this.disabledDates.length){var e=this.getClosestDates(new Date(parseInt(this.start,10)));if(e[0]&&this.compareDay(t,e[0])<=0)return!1;if(e[1]&&0<=this.compareDay(t,e[1]))return!1}}return!0},s.prototype.checkSelection=function(){var t=this,e=this.countDays(this.end,this.start),s=!!this.showTopbar&&this.datepicker.getElementsByClassName("datepicker__info--feedback")[0];if(this.maxDays&&e>this.maxDays){this.start=!1,this.end=!1;for(var a,i=this.datepicker.getElementsByTagName("td"),n=0;n<i.length;n++)t.removeClass(i[n],"datepicker__month-day--selected"),t.removeClass(i[n],"datepicker__month-day--first-day-selected"),t.removeClass(i[n],"datepicker__month-day--last-day-selected");this.showTopbar&&(a=this.maxDays-1,this.topBarErrorText(s,"error-more",a))}else if(this.minDays&&e<this.minDays){this.start=!1,this.end=!1;for(var o=this.datepicker.getElementsByTagName("td"),r=0;r<o.length;r++)t.removeClass(o[r],"datepicker__month-day--selected"),t.removeClass(o[r],"datepicker__month-day--first-day-selected"),t.removeClass(o[r],"datepicker__month-day--last-day-selected");this.showTopbar&&(e=this.minDays-1,this.topBarErrorText(s,"error-less",e))}else this.start||this.end?this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.removeClass(s,"datepicker__info--help")):this.showTopbar&&(this.removeClass(s,"datepicker__info--error"),this.addClass(s,"datepicker__info--help"))},s.prototype.addDays=function(t,e){t=new Date(t);return t.setDate(t.getDate()+e),t},s.prototype.countDays=function(t,e){return Math.abs(this.daysFrom1970(t)-this.daysFrom1970(e))+1},s.prototype.compareDay=function(t,e){e=parseInt(this.getDateString(t,"YYYYMMDD"),10)-parseInt(this.getDateString(e,"YYYYMMDD"),10);return 0<e?1:0==e?0:-1},s.prototype.compareMonth=function(t,e){e=parseInt(this.getDateString(t,"YYYYMM"),10)-parseInt(this.getDateString(e,"YYYYMM"),10);return 0<e?1:0==e?0:-1},s.prototype.daysFrom1970=function(t){return Math.floor(this.toLocalTimestamp(t)/864e5)},s.prototype.toLocalTimestamp=function(t){return"string"!=typeof(t="object"==typeof t&&t.getTime?t.getTime():t)||t.match(/\d{13}/)||(t=this.parseDate(t).getTime()),t=parseInt(t,10)-60*(new Date).getTimezoneOffset()*1e3},s.prototype.printAttributes=function(t){var e,s=t,a="";for(e in t)Object.prototype.hasOwnProperty.call(s,e)&&(a+=e+'="'+s[e]+'" ');return a},s.prototype.goToNextMonth=function(t){var e=t.target.getAttribute("month"),s=1<e,t=s?this.month2:this.month1,t=this.getNextMonth(t);!this.isSingleMonth()&&!s&&0<=this.compareMonth(t,this.month2)||this.isMonthOutOfRange(t)||(this.moveBothMonths&&s&&this.showMonth(this.month2,1),this.showMonth(t,e),this.showSelectedDays(),this.disableNextPrevButtons())},s.prototype.goToPreviousMonth=function(t){var e=t.target.getAttribute("month"),s=1<e,t=s?this.month2:this.month1,t=this.getPrevMonth(t);s&&this.compareMonth(t,this.month1)<=0||this.isMonthOutOfRange(t)||(this.moveBothMonths&&!s&&this.showMonth(this.month1,2),this.showMonth(t,e),this.showSelectedDays(),this.disableNextPrevButtons())},s.prototype.isSingleMonth=function(){return!this.isVisible(this.getMonthDom(2))},s.prototype.isMonthOutOfRange=function(t){t=new Date(t.valueOf());return!!(this.startDate&&new Date(t.getFullYear(),t.getMonth()+1,0,23,59,59)<this.startDate||this.endDate&&new Date(t.getFullYear(),t.getMonth(),1)>this.endDate)},s.prototype.disableNextPrevButtons=function(){var t,e,s;this.isSingleMonth()||(e=parseInt(this.getDateString(this.month1,"YYYYMM"),10),s=parseInt(this.getDateString(this.month2,"YYYYMM"),10),t=Math.abs(e-s),e=this.datepicker.getElementsByClassName("datepicker__month-button--next"),s=this.datepicker.getElementsByClassName("datepicker__month-button--prev"),1<t&&89!==t?(this.removeClass(e[0],"datepicker__month-button--disabled"),this.removeClass(s[1],"datepicker__month-button--disabled")):(this.addClass(e[0],"datepicker__month-button--disabled"),this.addClass(s[1],"datepicker__month-button--disabled")),this.isMonthOutOfRange(this.getPrevMonth(this.month1))?this.addClass(s[0],"datepicker__month-button--disabled"):this.removeClass(s[0],"datepicker__month-button--disabled"),this.isMonthOutOfRange(this.getNextMonth(this.month2))?this.addClass(e[1],"datepicker__month-button--disabled"):this.removeClass(e[1],"datepicker__month-button--disabled"))},s.prototype.topBarDefaultText=function(){var t,e;this.showTopbar&&(t="",t=this.minDays&&this.maxDays?this.lang("info-range"):this.minDays&&2<this.minDays?this.lang("info-more-plural"):this.minDays?this.lang("info-more"):this.lang("info-default"),e=this.datepicker.getElementsByClassName("datepicker__info--feedback")[0],t=t.replace(/%d/,this.minDays-1).replace(/%d/,this.maxDays-1),this.addClass(e,"datepicker__info--help"),this.removeClass(e,"datepicker__info--error"),e.textContent=t)},s.prototype.topBarErrorText=function(t,e,s){this.showTopbar&&(this.addClass(t,"datepicker__info--error"),this.removeClass(t,"datepicker__info--help"),1<s?(e=(e=this.lang(e+"-plural")).replace("%d",s),t.textContent=e):e=this.lang(e),this.datepicker.getElementsByClassName("datepicker__info--selected")[0].style.display="none")},s.prototype.updateSelectableRange=function(){for(var t,e=this,s=this.datepicker.getElementsByTagName("td"),a=this.start&&!this.end,i=0;i<s.length;i++)e.hasClass(s[i],"datepicker__month-day--invalid")&&e.hasClass(s[i],"datepicker__month-day--tmp")&&(e.removeClass(s[i],"datepicker__month-day--tmp"),e.hasClass(s[i],"datepicker__month-day--tmpinvalid")?e.removeClass(s[i],"datepicker__month-day--tmpinvalid"):(e.removeClass(s[i],"datepicker__month-day--invalid"),e.addClass(s[i],"datepicker__month-day--valid"))),a?e.hasClass(s[i],"datepicker__month-day--visibleMonth")&&(e.hasClass(s[i],"datepicker__month-day--valid")||e.hasClass(s[i],"datepicker__month-day--disabled")||e.hasClass(s[i],"datepicker__month-day--before-disabled-date"))&&(t=parseInt(s[i].getAttribute("time"),10),e.isValidDate(t)?(e.addClass(s[i],"datepicker__month-day--valid"),e.addClass(s[i],"datepicker__month-day--tmp"),e.removeClass(s[i],"datepicker__month-day--invalid"),e.removeClass(s[i],"datepicker__month-day--disabled")):(e.hasClass(s[i],"datepicker__month-day--invalid")&&e.addClass(s[i],"datepicker__month-day--tmpinvalid"),e.addClass(s[i],"datepicker__month-day--invalid"),e.addClass(s[i],"datepicker__month-day--tmp"),e.removeClass(s[i],"datepicker__month-day--valid"))):(e.hasClass(s[i],"datepicker__month-day--checkout-enabled")||e.hasClass(s[i],"datepicker__month-day--before-disabled-date"))&&(e.addClass(s[i],"datepicker__month-day--invalid"),e.removeClass(s[i],"datepicker__month-day--valid"),e.hasClass(s[i],"datepicker__month-day--before-disabled-date")||e.addClass(s[i],"datepicker__month-day--disabled"));return!0},s.prototype.dayHovering=function(t){var e,s,a,i=this,n=parseInt(t.getAttribute("time"),10),o="";if(!this.hasClass(t,"datepicker__month-day--invalid")){for(var r,h=this.datepicker.getElementsByTagName("td"),d=0;d<h.length;d++){var l=parseInt(h[d].getAttribute("time"),10);l===n?i.addClass(h[d],"datepicker__month-day--hovering"):i.removeClass(h[d],"datepicker__month-day--hovering"),i.start&&!i.end&&(i.start<l&&l<=n||i.start>l&&n<=l)?i.addClass(h[d],"datepicker__month-day--hovering"):i.removeClass(h[d],"datepicker__month-day--hovering")}this.start&&!this.end&&(r=this.countDays(n,this.start)-1,this.hoveringTooltip&&("function"==typeof this.hoveringTooltip?o=this.hoveringTooltip(r,this.start,n):!0===this.hoveringTooltip&&0<r&&(o=r+" "+(1==r?this.lang("night"):this.lang("nights")))))}o?(r=t.getBoundingClientRect(),t=this.datepicker.getBoundingClientRect(),e=r.left-t.left,s=r.top-t.top,e+=r.width/2,(a=document.getElementById(this.getTooltipId())).style.display="",a.textContent=o,r=a.getBoundingClientRect().width,o=a.getBoundingClientRect().height,e-=r/2,s-=o,setTimeout(function(){a.style.left=e+"px",a.style.top=s+"px"},10)):document.getElementById(this.getTooltipId()).style.display="none"},s.prototype.clearHovering=function(){for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--hovering");document.getElementById(this.getTooltipId()).style.display="none"},s.prototype.clearSelection=function(){this.start=!1,this.end=!1;for(var t=this.datepicker.getElementsByTagName("td"),e=0;e<t.length;e++)this.removeClass(t[e],"datepicker__month-day--selected"),this.removeClass(t[e],"datepicker__month-day--first-day-selected"),this.removeClass(t[e],"datepicker__month-day--last-day-selected");this.setValue(""),this.checkSelection(),this.showSelectedInfo(),this.showSelectedDays()},s.prototype.parseDisabledDates=function(){var t=[];this.setFechaI18n();for(var e=0;e<this.disabledDates.length;e++)t[e]=fecha.parse(this.disabledDates[e],"YYYY-MM-DD");t.sort(function(t,e){return t-e}),this.disabledDatesTime=t},s.prototype.getClosestDates=function(t){var e=[!1,!1];if(t<this.disabledDatesTime[0])e=this.enableCheckout?[!1,this.addDays(this.disabledDatesTime[0],1)]:[!1,this.disabledDatesTime[0]];else if(t>this.disabledDatesTime[this.disabledDatesTime.length-1])e=[this.disabledDatesTime[this.disabledDatesTime.length-1],!1];else{for(var s,a=this.disabledDatesTime.length,i=this.disabledDatesTime.length,n=Math.abs(new Date(0,0,0).valueOf()),o=n,r=-n,h=0;h<this.disabledDatesTime.length;++h)(s=t-this.disabledDatesTime[h])<0&&r<s&&(i=h,r=s),0<s&&s<o&&(a=h,o=s);this.disabledDatesTime[a]&&(e[0]=this.disabledDatesTime[a]),void 0===this.disabledDatesTime[a]?e[1]=!1:this.enableCheckout?e[1]=this.addDays(this.disabledDatesTime[i],1):e[1]=this.disabledDatesTime[i]}return e},s.prototype.lang=function(t){return t in this.i18n?this.i18n[t]:""},s.prototype.emptyElement=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},s.prototype.classRegex=function(t){return new RegExp("(^|\\s+)"+t+"(\\s+|$)")},s.prototype.hasClass=function(t,e){return this.classRegex(e).test(t.className)},s.prototype.addClass=function(t,e){this.hasClass(t,e)||(t.className=t.className+" "+e)},s.prototype.removeClass=function(t,e){t.className=t.className.replace(this.classRegex(e)," ")},s.prototype.isVisible=function(t){return t.offsetWidth||t.offsetHeight||t.getClientRects().length},s.prototype.slideDown=function(t,e){t.style.display="";var s=t.getBoundingClientRect().height;t.style.height=0,this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=s+"px",t.addEventListener("transitionend",function(){t.style.height=t.style.transition=t.style.display=""})},s.prototype.slideUp=function(t,e){var s=t.getBoundingClientRect().height;t.style.height=s+"px",this.recalc(t.offsetHeight),t.style.transition="height "+e,t.style.height=0,t.addEventListener("transitionend",function(){t.style.display="none"})},s.prototype.recalc=function(t){return t.offsetHeight},s.prototype.isTouchDevice=function(){return"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch},s.prototype.open=function(){this.openDatepicker()},s.prototype.close=function(){this.closeDatepicker()},s.prototype.getDatePicker=function(){return this.datepicker},s.prototype.setRange=function(t,e){"string"==typeof t&&"string"==typeof e&&(t=this.parseDate(t),e=this.parseDate(e)),this.setDateRange(t,e)},s.prototype.clear=function(){this.clearSelection()},s.prototype.getNights=function(){var t,e,s=0;return this.start&&this.end?s=this.countDays(this.end,this.start)-1:(t=(e=this.getValue())?e.split(this.separator):"")&&2<=t.length&&(e=this.format,s=this.countDays(this.parseDate(t[0],e),this.parseDate(t[1],e))-1),s},s.prototype.destroy=function(){document.getElementById(this.getDatepickerId())&&(this.removeAllBoundedListeners(this.input,"click"),this.removeAllBoundedListeners(document,"click"),this.removeAllBoundedListeners(this.input,"change"),this.datepicker.parentNode.removeChild(this.datepicker))},s}();
{
"name": "hotel-datepicker",
"version": "4.0.1",
"version": "4.0.2",
"author": "Benito Lopez (http://lopezb.com)",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -363,2 +363,4 @@ 'use strict';

showMonth(date, month) {
date.setHours(0, 0, 0, 0);
// Show month table and create the necessary HTML code

@@ -365,0 +367,0 @@ const name = this.getMonthName(date.getMonth());

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc