Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatpickr

Package Overview
Dependencies
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatpickr - npm Package Compare versions

Comparing version 1.6.7 to 1.6.8

2

dist/flatpickr.min.js

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

var flatpickr=function(e,t){"use strict";var n,a,r,i=[];if(flatpickr.prototype=flatpickr.init.prototype,a=function(e){return e._flatpickr&&e._flatpickr.destroy(),e._flatpickr=new flatpickr.init(e,t),e._flatpickr},e.nodeName)return a(e);if(n=document.querySelectorAll(e),1===n.length)return a(n[0]);for(var r=0;r<n.length;r++)i.push(a(n[r]));return i};flatpickr.init=function(e,t){"use strict";var n,a,r,i,c,o,l,u,d,s,f,m,p,h,g,D,v,M,b,E,L,k,y,O,j,C,w,T,H,N=this,F=document.createElement("div"),I=document.createElement("span"),Y=document.createElement("div"),x=document.createElement("span"),A=document.createElement("span"),S=document.createElement("table"),_=document.createElement("tbody"),J=new Date,W=document.createElement("div");return L=function(){F.className="flatpickr-calendar",I.className="flatpickr-current-month",t=t||{},N.config={},N.element=e,N.destroy=E;for(var r in N.defaultConfig)N.config[r]=t[r]||N.element.dataset[r.toLowerCase()]||N.defaultConfig[r];N.config.defaultDate&&(N.config.defaultDate=a(N.config.defaultDate)),(N.element.value||N.config.defaultDate)&&(N.selectedDateObj=a(N.config.defaultDate||N.element.value)),N.config.minDate&&(N.config.minDate=a("today"===N.config.minDate?new Date:N.config.minDate,!0)),N.config.maxDate&&(N.config.maxDate=a(N.config.maxDate,!0)),j(N.selectedDateObj||N.config.minDate||J),n(),M(),b(),m()},a=function(e,t){return t=t||!1,"string"==typeof e&&(e=new Date(e.replace(/-/g,"/"))),t&&e.setHours(0,0,0,0),e},r=function(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()},n=function(){W.className="flatpickr-wrapper",N.element.parentNode.insertBefore(W,N.element),W.appendChild(N.element),N.config.inline&&W.classList.add("inline"),N.config.altInput&&(C=document.createElement(N.element.nodeName),C.className=N.element.className,N.element.type="hidden",W.appendChild(C))},O=function(e){var t=N.currentYear,n=e||N.currentMonth;return 1!==n||t%4||!(t%100)&&t%400?N.l10n.daysInMonth[n]:29},m=function(){if(N.selectedDateObj&&N.config.enableTime){var e=parseInt(w.value),t=(60+parseInt(T.value))%60;N.config.time_24hr||(e=e%12+12*("PM"===H.innerHTML)),N.selectedDateObj.setHours(e,t),w.value=i(N.config.time_24hr?e:(12+e)%12+12*(e%12===0)),T.value=i(t)}N.selectedDateObj&&(N.element.value=c(N.config.dateFormat)),N.config.altInput&&N.selectedDateObj&&(C.value=c(N.config.altFormat)),k()},i=function(e){return("0"+e).slice(-2)},c=function(e){N.config.enableTime&&(e+=" "+N.config.timeFormat);var t="",n={d:function(){return i(n.j())},D:function(){return N.l10n.weekdays.shorthand[n.w()]},j:function(){return N.selectedDateObj.getDate()},l:function(){return N.l10n.weekdays.longhand[n.w()]},w:function(){return N.selectedDateObj.getDay()},F:function(){return o(n.n()-1,!1)},m:function(){return i(n.n())},M:function(){return o(n.n()-1,!0)},n:function(){return N.selectedDateObj.getMonth()+1},U:function(){return N.selectedDateObj.getTime()/1e3},y:function(){return String(n.Y()).substring(2)},Y:function(){return N.selectedDateObj.getFullYear()},h:function(){return N.selectedDateObj.getHours()%12?N.selectedDateObj.getHours()%12:12},H:function(){return i(N.selectedDateObj.getHours())},i:function(){return i(N.selectedDateObj.getMinutes())},K:function(){return N.selectedDateObj.getHours()>11?"PM":"AM"}},a=e.split("");return[].forEach.call(a,function(e,r){n[e]&&"\\"!==a[r-1]?t+=n[e]():"\\"!==e&&(t+=e)}),t},o=function(e,t){return t?N.l10n.months.shorthand[e]:N.l10n.months.longhand[e]},u=function(){var e=document.createElement("thead"),t=N.l10n.firstDayOfWeek,n=N.l10n.weekdays.shorthand.slice();t>0&&t<n.length&&(n=[].concat(n.splice(t,n.length),n.splice(0,t))),e.innerHTML="<tr><th>"+n.join("</th><th>")+"</th></tr>",S.appendChild(e)},l=function(e){for(var t=0;t<N.config.disable.length;t++)if(e>=a(N.config.disable[t].from)&&e<=a(N.config.disable[t].to))return!0;return!1},s=function(){var e=document.createElement("div"),t=document.createElement("span");e.className="flatpickr-time",w=document.createElement("input"),T=document.createElement("input"),t.className="flatpickr-time-separator",t.innerHTML=":",w.className="flatpickr-hour",w.type=T.type="number",T.className="flatpickr-minute",w.value=N.selectedDateObj?i(N.selectedDateObj.getHours()):12,T.value=N.selectedDateObj?i(N.selectedDateObj.getMinutes()):"00",w.step=N.config.hourIncrement,T.step=N.config.minuteIncrement,w.min=N.config.time_24hr?0:1,w.max=N.config.time_24hr?23:12,T.min=0,T.max=59,e.appendChild(w),e.appendChild(t),e.appendChild(T),N.config.time_24hr||(H=document.createElement("span"),H.className="flatpickr-am-pm",H.innerHTML=["AM","PM"][0|(N.selectedDateObj&&w.value>11)],e.appendChild(H)),F.appendChild(e)},f=function(e){e.preventDefault();var t=parseInt(e.target.min),n=parseInt(e.target.max),a=parseInt(e.target.step),r=a*Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),c=(parseInt(e.target.value)+r)%(n+(0===t));t>c&&(c=n+(0===t)-a*(0===t)),e.target.value=i(c)},d=function(){var e,t,n,a,i,c=(new Date(N.currentYear,N.currentMonth,1).getDay()-N.l10n.firstDayOfWeek+7)%7,o=O(),u=(N.currentMonth-1+12)%12,d=O(u),s=document.createDocumentFragment(),f=document.createElement("tr");for(e=d+1-c;d>=e;e++)f.innerHTML+='<td class="disabled"><span class="flatpickr-day">'+e+"</span></td>";for(_.innerHTML="",e=1;42-c>=e;e++)o>=e&&(n=new Date(N.currentYear,N.currentMonth,e)),(e+c-1)%7===0&&(s.appendChild(f),f=document.createElement("tr")),i=N.config.minDate&&n<N.config.minDate||N.config.maxDate&&n>N.config.maxDate,a=e>o||i||l(n),t=a?"disabled":"slot",a||N.selectedDateObj||!r(n,J)||(t+=" today"),!a&&N.selectedDateObj&&r(n,N.selectedDateObj)&&(t+=" selected"),f.innerHTML+='<td class="'+t+'"><span class="flatpickr-day">'+(e>o?e%o:e)+"</span></td>";s.appendChild(f),_.appendChild(s)},p=function(){I.innerHTML="<span>"+o(N.currentMonth,N.config.shorthandCurrentMonth)+"</span> "+N.currentYear},h=function(){Y.className="flatpickr-months",x.className="flatpickr-prev-month",x.innerHTML=N.config.prevArrow,A.className="flatpickr-next-month",A.innerHTML=N.config.nextArrow,Y.appendChild(x),Y.appendChild(I),Y.appendChild(A),p(),F.appendChild(Y)},g=function(){(N.currentMonth<0||N.currentMonth>11)&&(N.currentYear+=N.currentMonth%11,N.currentMonth=(N.currentMonth+12)%12)},D=function(e){W.classList.contains("open")&&!W.contains(e.target)&&N.close()},y=function(e){N.currentMonth+=e,g(),p(),d()},v=function(e){e.preventDefault();var t=e.target;(t.classList.contains("slot")||t.parentNode.classList.contains("slot"))&&(N.selectedDateObj=new Date(N.currentYear,N.currentMonth,t.childNodes[0].innerHTML||t.innerHTML),m(),d(),N.config.inline||N.config.enableTime||N.close())},M=function(){h(),u(),d(),S.appendChild(_),F.appendChild(S),W.appendChild(F),N.config.enableTime&&s()},b=function(){function e(e){e.preventDefault(),H.innerHTML=["AM","PM"]["AM"===H.innerHTML|0]}N.element.addEventListener("focus",N.open),N.config.altInput&&C.addEventListener("focus",N.open),x.addEventListener("click",function(){y(-1)}),A.addEventListener("click",function(){y(1)}),S.addEventListener("click",v),document.addEventListener("click",D,!0),N.config.enableTime&&(w.addEventListener("mousewheel",f),w.addEventListener("DOMMouseScroll",f),T.addEventListener("mousewheel",f),T.addEventListener("DOMMouseScroll",f),w.addEventListener("mouseout",m),T.addEventListener("mouseout",m),w.addEventListener("change",m),T.addEventListener("change",m),w.addEventListener("click",function(){w.select()}),T.addEventListener("click",function(){T.select()}),N.config.time_24hr||(H.addEventListener("focus",function(){H.blur()}),H.addEventListener("click",e),H.addEventListener("mousewheel",e),H.addEventListener("DOMMouseScroll",e),H.addEventListener("mouseout",m)))},N.open=function(){N.element.blur(),C&&C.blur(),!N.config.inline&&W.classList.add("open")},N.close=function(){W.classList.remove("open")},k=function(){if("createEvent"in document){var t=document.createEvent("Event");t.initEvent("change",!0,!0),e.dispatchEvent(t)}else e.fireEvent("onchange");N.config.onChange(N.selectedDateObj,N.element.value)},E=function(){var e,t;document.removeEventListener("click",D,!1),N.element.removeEventListener("focus",N.open,!1),N.element.removeEventListener("click",N.open,!1),e=N.element.parentNode,e.removeChild(F),t=e.removeChild(N.element),e.parentNode.replaceChild(t,e)},j=function(e){e=e||N.selectedDateObj||N.config.minDate||J,N.currentYear=e.getFullYear(),N.currentMonth=e.getMonth()},N.redraw=function(){p(),d()},N.jumpToDate=function(e){j(a(e)||new Date),N.redraw()},N.setDate=function(e,t){N.selectedDateObj=a(e),N.jumpToDate(N.selectedDateObj),t=t||!1,t&&k()},N.set=function(e,t){e in N.config&&(N.config[e]=t,j(),N.redraw())},L(),N},flatpickr.init.prototype={l10n:{weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0},defaultConfig:{dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"&lt;",nextArrow:"&gt;",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,t){}}},"undefined"!=typeof module&&(module.exports=flatpickr);
var flatpickr=function(e,n){"use strict";var t,a,r,i=[];if(flatpickr.prototype=flatpickr.init.prototype,a=function(e){return e._flatpickr&&e._flatpickr.destroy(),e._flatpickr=new flatpickr.init(e,n),e._flatpickr},e.nodeName)return a(e);if(t=document.querySelectorAll(e),1===t.length)return a(t[0]);for(var r=0;r<t.length;r++)i.push(a(t[r]));return i};flatpickr.init=function(e,n){"use strict";var t,a,r,i,c,o,l,u,d,s,f,m,p,h,g,D,v,M,b,E,L,k,y,O,j,C,w,T,H,N=this,F=document.createElement("div"),I=document.createElement("span"),Y=document.createElement("div"),x=document.createElement("span"),A=document.createElement("span"),S=document.createElement("table"),_=document.createElement("tbody"),J=new Date,W=document.createElement("div");return L=function(){F.className="flatpickr-calendar",I.className="flatpickr-current-month",n=n||{},N.config={},N.element=e,N.destroy=E;for(var r in N.defaultConfig)N.config[r]=n[r]||N.element.dataset[r.toLowerCase()]||N.defaultConfig[r];N.config.defaultDate&&(N.config.defaultDate=a(N.config.defaultDate)),(N.element.value||N.config.defaultDate)&&(N.selectedDateObj=a(N.config.defaultDate||N.element.value)),N.config.minDate&&(N.config.minDate=a("today"===N.config.minDate?new Date:N.config.minDate,!0)),N.config.maxDate&&(N.config.maxDate=a(N.config.maxDate,!0)),j(N.selectedDateObj||N.config.minDate||J),t(),M(),b(),N.config.noCalendar||m()},a=function(e,n){return n=n||!1,"string"==typeof e&&(e=new Date(e.replace(/-/g,"/"))),n&&e.setHours(0,0,0,0),e},r=function(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},t=function(){W.className="flatpickr-wrapper",N.element.parentNode.insertBefore(W,N.element),W.appendChild(N.element),N.config.inline&&W.classList.add("inline"),N.config.altInput&&(C=document.createElement(N.element.nodeName),C.className=N.element.className,N.element.type="hidden",W.appendChild(C))},O=function(e){var n=N.currentYear,t=e||N.currentMonth;return 1!==t||n%4||!(n%100)&&n%400?N.l10n.daysInMonth[t]:29},m=function(){if(N.selectedDateObj&&N.config.enableTime){var e=parseInt(w.value),n=(60+parseInt(T.value))%60;N.config.time_24hr||(e=e%12+12*("PM"===H.innerHTML)),N.selectedDateObj.setHours(e,n),w.value=i(N.config.time_24hr?e:(12+e)%12+12*(e%12===0)),T.value=i(n)}N.selectedDateObj&&(N.element.value=c(N.config.dateFormat)),N.config.altInput&&N.selectedDateObj&&(C.value=c(N.config.altFormat)),k()},i=function(e){return("0"+e).slice(-2)},c=function(e){N.config.noCalendar&&(e=""),N.config.enableTime&&(e+=" "+N.config.timeFormat);var n="",t={d:function(){return i(t.j())},D:function(){return N.l10n.weekdays.shorthand[t.w()]},j:function(){return N.selectedDateObj.getDate()},l:function(){return N.l10n.weekdays.longhand[t.w()]},w:function(){return N.selectedDateObj.getDay()},F:function(){return o(t.n()-1,!1)},m:function(){return i(t.n())},M:function(){return o(t.n()-1,!0)},n:function(){return N.selectedDateObj.getMonth()+1},U:function(){return N.selectedDateObj.getTime()/1e3},y:function(){return String(t.Y()).substring(2)},Y:function(){return N.selectedDateObj.getFullYear()},h:function(){return N.selectedDateObj.getHours()%12?N.selectedDateObj.getHours()%12:12},H:function(){return i(N.selectedDateObj.getHours())},i:function(){return i(N.selectedDateObj.getMinutes())},K:function(){return N.selectedDateObj.getHours()>11?"PM":"AM"}},a=e.split("");return[].forEach.call(a,function(e,r){t[e]&&"\\"!==a[r-1]?n+=t[e]():"\\"!==e&&(n+=e)}),n},o=function(e,n){return n?N.l10n.months.shorthand[e]:N.l10n.months.longhand[e]},l=function(e){for(var n=0;n<N.config.disable.length;n++)if(e>=a(N.config.disable[n].from)&&e<=a(N.config.disable[n].to))return!0;return!1},f=function(e){e.preventDefault();var n=parseInt(e.target.min),t=parseInt(e.target.max),a=parseInt(e.target.step),r=a*Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),c=(parseInt(e.target.value)+r)%(t+(0===n));n>c&&(c=t+(0===n)-a*(0===n)),e.target.value=i(c)},p=function(){I.innerHTML="<span>"+o(N.currentMonth,N.config.shorthandCurrentMonth)+"</span> "+N.currentYear},g=function(){(N.currentMonth<0||N.currentMonth>11)&&(N.currentYear+=N.currentMonth%11,N.currentMonth=(N.currentMonth+12)%12)},D=function(e){W.classList.contains("open")&&!W.contains(e.target)&&N.close()},y=function(e){N.currentMonth+=e,g(),p(),d()},v=function(e){e.preventDefault();var n=e.target;(n.classList.contains("slot")||n.parentNode.classList.contains("slot"))&&(N.selectedDateObj=new Date(N.currentYear,N.currentMonth,n.childNodes[0].innerHTML||n.innerHTML),m(),d(),N.config.inline||N.config.enableTime||N.close())},M=function(){N.config.noCalendar||(h(),u(),d(),S.appendChild(_),F.appendChild(S)),W.appendChild(F),N.config.enableTime&&s()},h=function(){Y.className="flatpickr-months",x.className="flatpickr-prev-month",x.innerHTML=N.config.prevArrow,A.className="flatpickr-next-month",A.innerHTML=N.config.nextArrow,Y.appendChild(x),Y.appendChild(I),Y.appendChild(A),p(),F.appendChild(Y)},u=function(){var e=document.createElement("thead"),n=N.l10n.firstDayOfWeek,t=N.l10n.weekdays.shorthand.slice();n>0&&n<t.length&&(t=[].concat(t.splice(n,t.length),t.splice(0,n))),e.innerHTML="<tr><th>"+t.join("</th><th>")+"</th></tr>",S.appendChild(e)},d=function(){var e,n,t,a,i,c=(new Date(N.currentYear,N.currentMonth,1).getDay()-N.l10n.firstDayOfWeek+7)%7,o=O(),u=(N.currentMonth-1+12)%12,d=O(u),s=document.createDocumentFragment(),f=document.createElement("tr");for(e=d+1-c;d>=e;e++)f.innerHTML+='<td class="disabled"><span class="flatpickr-day">'+e+"</span></td>";for(_.innerHTML="",e=1;42-c>=e;e++)o>=e&&(t=new Date(N.currentYear,N.currentMonth,e)),(e+c-1)%7===0&&(s.appendChild(f),f=document.createElement("tr")),i=N.config.minDate&&t<N.config.minDate||N.config.maxDate&&t>N.config.maxDate,a=e>o||i||l(t),n=a?"disabled":"slot",a||N.selectedDateObj||!r(t,J)||(n+=" today"),!a&&N.selectedDateObj&&r(t,N.selectedDateObj)&&(n+=" selected"),f.innerHTML+='<td class="'+n+'"><span class="flatpickr-day">'+(e>o?e%o:e)+"</span></td>";s.appendChild(f),_.appendChild(s)},s=function(){var e=document.createElement("div"),n=document.createElement("span");e.className="flatpickr-time",w=document.createElement("input"),T=document.createElement("input"),n.className="flatpickr-time-separator",n.innerHTML=":",w.className="flatpickr-hour",w.type=T.type="number",T.className="flatpickr-minute",w.value=N.selectedDateObj?i(N.selectedDateObj.getHours()):12,T.value=N.selectedDateObj?i(N.selectedDateObj.getMinutes()):"00",w.step=N.config.hourIncrement,T.step=N.config.minuteIncrement,w.min=+!N.config.time_24hr,w.max=N.config.time_24hr?23:12,T.min=0,T.max=59,e.appendChild(w),e.appendChild(n),e.appendChild(T),N.config.time_24hr||(H=document.createElement("span"),H.className="flatpickr-am-pm",H.innerHTML=["AM","PM"][w.value>11|0],e.appendChild(H)),N.config.noCalendar&&(N.selectedDateObj=new Date),F.appendChild(e)},b=function(){function e(e){e.preventDefault(),H.innerHTML=["AM","PM"]["AM"===H.innerHTML|0]}N.element.addEventListener("focus",N.open),N.config.altInput&&C.addEventListener("focus",N.open),x.addEventListener("click",function(){y(-1)}),A.addEventListener("click",function(){y(1)}),S.addEventListener("click",v),document.addEventListener("click",D,!0),N.config.enableTime&&(w.addEventListener("mousewheel",f),w.addEventListener("DOMMouseScroll",f),T.addEventListener("mousewheel",f),T.addEventListener("DOMMouseScroll",f),w.addEventListener("mouseout",m),T.addEventListener("mouseout",m),w.addEventListener("change",m),T.addEventListener("change",m),w.addEventListener("click",function(){w.select()}),T.addEventListener("click",function(){T.select()}),N.config.time_24hr||(H.addEventListener("focus",function(){H.blur()}),H.addEventListener("click",e),H.addEventListener("mousewheel",e),H.addEventListener("DOMMouseScroll",e),H.addEventListener("mouseout",m)))},N.open=function(){N.element.blur(),C&&C.blur(),!N.config.inline&&W.classList.add("open")},N.close=function(){W.classList.remove("open")},k=function(){if("createEvent"in document){var n=document.createEvent("Event");n.initEvent("change",!0,!0),e.dispatchEvent(n)}else e.fireEvent("onchange");N.config.onChange(N.selectedDateObj,N.element.value)},E=function(){var e,n;document.removeEventListener("click",D,!1),N.element.removeEventListener("focus",N.open,!1),N.element.removeEventListener("click",N.open,!1),e=N.element.parentNode,e.removeChild(F),n=e.removeChild(N.element),e.parentNode.replaceChild(n,e)},j=function(e){e=e||N.selectedDateObj||N.config.minDate||J,N.currentYear=e.getFullYear(),N.currentMonth=e.getMonth()},N.redraw=function(){p(),d()},N.jumpToDate=function(e){j(a(e)||new Date),N.redraw()},N.setDate=function(e,n){N.selectedDateObj=a(e),N.jumpToDate(N.selectedDateObj),n=n||!1,n&&k()},N.set=function(e,n){e in N.config&&(N.config[e]=n,j(),N.redraw())},L(),N},flatpickr.init.prototype={l10n:{weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0},defaultConfig:{noCalendar:!1,dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"&lt;",nextArrow:"&gt;",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,n){}}},"undefined"!=typeof module&&(module.exports=flatpickr);
{
"name": "flatpickr",
"version": "1.6.7",
"version": "1.6.8",
"description": "A fast, feature-rich, and elegant javascript date picker (vanilla/no dependencies)",

@@ -5,0 +5,0 @@ "dependencies": {},

@@ -116,9 +116,9 @@ var flatpickr = function (selector, config) {

jumpToDate(self.selectedDateObj||self.config.minDate||currentDate);
wrap();
wrap();
buildCalendar();
bind();
updateValue();
if (!self.config.noCalendar)
updateValue();
};

@@ -213,2 +213,4 @@

if (self.config.noCalendar)
dateFormat = "";
self.config.enableTime && ( dateFormat+= " " + self.config.timeFormat);

@@ -294,16 +296,2 @@

buildWeekdays = function () {
var weekdayContainer = document.createElement('thead'),
firstDayOfWeek = self.l10n.firstDayOfWeek,
weekdays = self.l10n.weekdays.shorthand.slice();
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
weekdays = [].concat(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
}
weekdayContainer.innerHTML = '<tr><th>' + weekdays.join('</th><th>') + '</th></tr>';
calendar.appendChild(weekdayContainer);
};
isDisabled = function(date){

@@ -319,69 +307,135 @@

buildTime = function(){
var timeContainer = document.createElement("div"),
separator = document.createElement("span");
timeContainer.className = "flatpickr-time";
timeWrapper = function (e){
hourElement = document.createElement("input");
minuteElement = document.createElement("input");
e.preventDefault();
separator.className = "flatpickr-time-separator";
separator.innerHTML = ":";
var min = parseInt(e.target.min),
max = parseInt(e.target.max),
step = parseInt(e.target.step),
delta = step * ( Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))) ),
newValue = ( parseInt(e.target.value) + delta )%(max+(min===0));
hourElement.className = "flatpickr-hour";
hourElement.type = minuteElement.type = "number";
minuteElement.className = "flatpickr-minute";
newValue < min && ( newValue = max+(min===0) - step*(min===0) );
e.target.value = pad( newValue );
}
hourElement.value =
self.selectedDateObj ? pad(self.selectedDateObj.getHours()) : 12;
minuteElement.value =
self.selectedDateObj ? pad(self.selectedDateObj.getMinutes()) : "00";
updateNavigationCurrentMonth = function () {
hourElement.step = self.config.hourIncrement;
minuteElement.step = self.config.minuteIncrement;
navigationCurrentMonth.innerHTML =
'<span>' +
monthToStr(self.currentMonth, self.config.shorthandCurrentMonth) +
'</span> '
+ self.currentYear;
hourElement.min = self.config.time_24hr ? 0 : 1;
hourElement.max = self.config.time_24hr ? 23 : 12;
};
minuteElement.min = 0;
minuteElement.max = 59;
handleYearChange = function () {
timeContainer.appendChild(hourElement);
timeContainer.appendChild(separator);
timeContainer.appendChild(minuteElement);
if (self.currentMonth < 0 || self.currentMonth > 11) {
if (!self.config.time_24hr){ // add am_pm if appropriate
am_pm = document.createElement("span");
am_pm.className = "flatpickr-am-pm";
am_pm.innerHTML = ["AM","PM"][(self.selectedDateObj && hourElement.value > 11)|0];
timeContainer.appendChild(am_pm);
self.currentYear += self.currentMonth % 11;
self.currentMonth = (self.currentMonth + 12) % 12;
}
calendarContainer.appendChild(timeContainer);
};
documentClick = function (event) {
if (wrapperElement.classList.contains("open") && !wrapperElement.contains(event.target))
self.close();
};
changeMonth = function(offset)
{
self.currentMonth += offset;
handleYearChange();
updateNavigationCurrentMonth();
buildDays();
}
calendarClick = function (event) {
timeWrapper = function (e){
event.preventDefault();
e.preventDefault();
var targetDate = event.target;
var min = parseInt(e.target.min),
max = parseInt(e.target.max),
step = parseInt(e.target.step),
delta = step * ( Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))) ),
newValue = ( parseInt(e.target.value) + delta )%(max+(min===0));
if ( targetDate.classList.contains('slot') || targetDate.parentNode.classList.contains('slot') )
{
newValue < min && ( newValue = max+(min===0) - step*(min===0) );
e.target.value = pad( newValue );
self.selectedDateObj = new Date(
self.currentYear, self.currentMonth,
targetDate.childNodes[0].innerHTML||targetDate.innerHTML
);
}
updateValue();
buildDays();
if ( !self.config.inline && !self.config.enableTime )
self.close();
}
};
buildCalendar = function () {
if ( !self.config.noCalendar) {
buildMonthNavigation();
buildWeekdays();
buildDays();
calendar.appendChild(calendarBody);
calendarContainer.appendChild(calendar);
}
wrapperElement.appendChild(calendarContainer);
self.config.enableTime && ( buildTime() );
};
buildMonthNavigation = function () {
monthsNav.className = 'flatpickr-months';
prevMonthNav.className = "flatpickr-prev-month";
prevMonthNav.innerHTML = self.config.prevArrow;
nextMonthNav.className = "flatpickr-next-month";
nextMonthNav.innerHTML = self.config.nextArrow;
monthsNav.appendChild(prevMonthNav);
monthsNav.appendChild(navigationCurrentMonth);
monthsNav.appendChild(nextMonthNav);
updateNavigationCurrentMonth();
calendarContainer.appendChild(monthsNav);
};
buildWeekdays = function () {
var weekdayContainer = document.createElement('thead'),
firstDayOfWeek = self.l10n.firstDayOfWeek,
weekdays = self.l10n.weekdays.shorthand.slice();
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
weekdays = [].concat(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek));
}
weekdayContainer.innerHTML = '<tr><th>' + weekdays.join('</th><th>') + '</th></tr>';
calendar.appendChild(weekdayContainer);
};
buildDays = function () {

@@ -457,96 +511,56 @@

updateNavigationCurrentMonth = function () {
buildTime = function(){
navigationCurrentMonth.innerHTML =
'<span>' +
monthToStr(self.currentMonth, self.config.shorthandCurrentMonth) +
'</span> '
+ self.currentYear;
var timeContainer = document.createElement("div"),
separator = document.createElement("span");
};
timeContainer.className = "flatpickr-time";
buildMonthNavigation = function () {
hourElement = document.createElement("input");
minuteElement = document.createElement("input");
monthsNav.className = 'flatpickr-months';
separator.className = "flatpickr-time-separator";
separator.innerHTML = ":";
prevMonthNav.className = "flatpickr-prev-month";
prevMonthNav.innerHTML = self.config.prevArrow;
hourElement.className = "flatpickr-hour";
hourElement.type = minuteElement.type = "number";
minuteElement.className = "flatpickr-minute";
nextMonthNav.className = "flatpickr-next-month";
nextMonthNav.innerHTML = self.config.nextArrow;
monthsNav.appendChild(prevMonthNav);
monthsNav.appendChild(navigationCurrentMonth);
monthsNav.appendChild(nextMonthNav);
hourElement.value =
self.selectedDateObj ? pad(self.selectedDateObj.getHours()) : 12;
minuteElement.value =
self.selectedDateObj ? pad(self.selectedDateObj.getMinutes()) : "00";
updateNavigationCurrentMonth();
calendarContainer.appendChild(monthsNav);
};
handleYearChange = function () {
hourElement.step = self.config.hourIncrement;
minuteElement.step = self.config.minuteIncrement;
if (self.currentMonth < 0 || self.currentMonth > 11) {
hourElement.min = +!self.config.time_24hr; // 0 in 24hr mode, 1 in 12hr mode
hourElement.max = self.config.time_24hr ? 23 : 12;
self.currentYear += self.currentMonth % 11;
self.currentMonth = (self.currentMonth + 12) % 12;
minuteElement.min = 0;
minuteElement.max = 59;
timeContainer.appendChild(hourElement);
timeContainer.appendChild(separator);
timeContainer.appendChild(minuteElement);
if (!self.config.time_24hr){ // add am_pm if appropriate
am_pm = document.createElement("span");
am_pm.className = "flatpickr-am-pm";
am_pm.innerHTML = ["AM","PM"][(hourElement.value > 11)|0];
timeContainer.appendChild(am_pm);
}
};
// picking time only
if (self.config.noCalendar)
self.selectedDateObj = new Date();
documentClick = function (event) {
if (wrapperElement.classList.contains("open") && !wrapperElement.contains(event.target))
self.close();
calendarContainer.appendChild(timeContainer);
};
changeMonth = function(offset)
{
self.currentMonth += offset;
handleYearChange();
updateNavigationCurrentMonth();
buildDays();
}
calendarClick = function (event) {
event.preventDefault();
var targetDate = event.target;
if ( targetDate.classList.contains('slot') || targetDate.parentNode.classList.contains('slot') )
{
self.selectedDateObj = new Date(
self.currentYear, self.currentMonth,
targetDate.childNodes[0].innerHTML||targetDate.innerHTML
);
updateValue();
buildDays();
if ( !self.config.inline && !self.config.enableTime )
self.close();
}
};
buildCalendar = function () {
buildMonthNavigation();
buildWeekdays();
buildDays();
calendar.appendChild(calendarBody);
calendarContainer.appendChild(calendar);
wrapperElement.appendChild(calendarContainer);
self.config.enableTime && ( buildTime() );
};
bind = function () {

@@ -708,2 +722,3 @@

defaultConfig : {
noCalendar: false,
dateFormat: 'Y-m-d',

@@ -710,0 +725,0 @@ altInput: false,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc