flatpickr
Advanced tools
Comparing version 1.7.3 to 1.7.5
@@ -0,0 +0,0 @@ !function(){var r=null; |
@@ -0,0 +0,0 @@ var table = document.querySelector(".c-r div"), |
@@ -0,0 +0,0 @@ { |
@@ -1,1 +0,1 @@ | ||
"use strict";var flatpickr=function e(t,n){var a,r,i,c=[];if(e.prototype=e.init.prototype,r=function(t){return t._flatpickr&&t._flatpickr.destroy(),t._flatpickr=new e.init(t,n),t._flatpickr},t.nodeName)return r(t);if(/^\#[a-zA-Z0-9\-\_]*$/.test(t))return r(document.getElementById(t.slice(1)));for(a=/^\.[a-zA-Z0-9\-\_]*$/.test(t)?document.getElementsByClassName(t.slice(1)):document.querySelectorAll(t),i=0;i<a.length;i++)c.push(r(a[i]));return{calendars:c,byID:function(e){for(var t=0;t<this.calendars.length;t++)if(this.calendars[t].element.id===e)return this.calendars[t]}}};flatpickr.init=function(e,t){var n,a,r,i,c,l,o,u,d,s,f,p,m,g,h,v,D,M,b,y,L,E,k,O,w,C,j,I,T,N=this,H=document.createElement("div"),S=document.createElement("span"),F=document.createElement("div"),Y=document.createElement("span"),A=document.createElement("span"),x=document.createElement("table"),_=document.createElement("tbody"),q=new Date,J=document.createElement("div");return L=function(){H.className="flatpickr-calendar",S.className="flatpickr-current-month",t=t||{},N.config={},N.element=e,N.destroy=y;for(var r in N.defaultConfig)N.config[r]=t[r]||N.element.dataset[r.toLowerCase()]||N.defaultConfig[r];N.input=N.config.wrap?e.querySelector("[data-input]"):e,N.config.defaultDate&&(N.config.defaultDate=a(N.config.defaultDate)),(N.input.value||N.config.defaultDate)&&(N.selectedDateObj=a(N.config.defaultDate||N.input.value)),N.config.minDate=a("today"===N.config.minDate?new Date:N.config.minDate,!0),N.config.maxDate=a(N.config.maxDate,!0),w(N.selectedDateObj||N.config.minDate||q),n(),M(),b(),N.config.noCalendar||p()},a=function(e,t){return t=t||!1,"string"==typeof e&&(e=new Date(e.replace(/(\d*)[\-\.](\d*)[\-\.](\d*)/g,"$1/$2/$3"))),t&&e&&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(){J.className="flatpickr-wrapper",N.element.parentNode.insertBefore(J,N.element),J.appendChild(N.element),N.config.inline&&J.classList.add("inline"),N.config.altInput&&(N.altInput=document.createElement(N.input.nodeName),N.altInput.placeholder=N.input.placeholder,N.altInput.type=N.input.type||"text",N.input.type="hidden",J.appendChild(N.altInput))},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},p=function(){if(N.selectedDateObj&&N.config.enableTime){var e=parseInt(C.value),t=(60+parseInt(j.value))%60;N.config.time_24hr||(e=e%12+12*("PM"===I.innerHTML)),N.selectedDateObj.setHours(e,t),C.value=i(N.config.time_24hr?e:(12+e)%12+12*(e%12===0)),j.value=i(t)}N.altInput&&N.selectedDateObj&&(N.altInput.value=c(N.config.altFormat)),N.selectedDateObj&&(N.input.value=c(N.config.dateFormat)),E()},i=function(e){return("0"+e).slice(-2)},c=function(e){N.config.noCalendar&&(e=""),N.config.enableTime&&(e+=" "+N.config.timeFormat);for(var t="",n={D:function(){return N.l10n.weekdays.shorthand[n.w()]},F:function(){return l(n.n()-1,!1)},H:function(){return i(N.selectedDateObj.getHours())},K:function(){return N.selectedDateObj.getHours()>11?"PM":"AM"},M:function(){return l(n.n()-1,!0)},U:function(){return N.selectedDateObj.getTime()/1e3},Y:function(){return N.selectedDateObj.getFullYear()},d:function(){return i(n.j())},h:function(){return N.selectedDateObj.getHours()%12?N.selectedDateObj.getHours()%12:12},i:function(){return i(N.selectedDateObj.getMinutes())},j:function(){return N.selectedDateObj.getDate()},l:function(){return N.l10n.weekdays.longhand[n.w()]},m:function(){return i(n.n())},n:function(){return N.selectedDateObj.getMonth()+1},w:function(){return N.selectedDateObj.getDay()},y:function(){return String(n.Y()).substring(2)}},a=e.split(""),r=0;r<a.length;r++)n[a[r]]&&"\\"!==a[r-1]?t+=n[a[r]]():"\\"!==a[r]&&(t+=a[r]);return t},l=function(e,t){return t?N.l10n.months.shorthand[e]:N.l10n.months.longhand[e]},o=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},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)},m=function(){S.innerHTML="<span>"+l(N.currentMonth,N.config.shorthandCurrentMonth)+"</span> "+N.currentYear},h=function(){(N.currentMonth<0||N.currentMonth>11)&&(N.currentYear+=N.currentMonth%11,N.currentMonth=(N.currentMonth+12)%12)},v=function(e){J.classList.contains("open")&&!J.contains(e.target)&&N.close()},k=function(e){N.currentMonth+=e,h(),m(),d()},D=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),p(),d(),N.config.inline||N.config.enableTime||N.close())},M=function(){N.config.noCalendar||(g(),u(),d(),x.appendChild(_),H.appendChild(x)),J.appendChild(H),N.config.enableTime&&s()},g=function(){F.className="flatpickr-months",Y.className="flatpickr-prev-month",Y.innerHTML=N.config.prevArrow,A.className="flatpickr-next-month",A.innerHTML=N.config.nextArrow,F.appendChild(Y),F.appendChild(S),F.appendChild(A),m(),H.appendChild(F)},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>",x.appendChild(e)},d=function(){for(var e=(new Date(N.currentYear,N.currentMonth,1).getDay()-N.l10n.firstDayOfWeek+7)%7,t=O(),n=(N.currentMonth-1+12)%12,a=O(n),i=document.createDocumentFragment(),c=document.createElement("tr"),l=a+1-e,u=void 0,d=void 0,s=void 0,f=void 0;a>=l;l++)c.innerHTML+='<td class="disabled"><span class="flatpickr-day">'+l+"</span></td>";for(_.innerHTML="",l=1;42-e>=l;l++)t>=l&&(d=new Date(N.currentYear,N.currentMonth,l)),(l+e-1)%7===0&&(i.appendChild(c),c=document.createElement("tr")),f=N.config.minDate&&d<N.config.minDate||N.config.maxDate&&d>N.config.maxDate,s=l>t||f||o(d),u=s?"disabled":"slot",s||N.selectedDateObj||!r(d,q)||(u+=" today"),!s&&N.selectedDateObj&&r(d,N.selectedDateObj)&&(u+=" selected"),c.innerHTML+='<td class="'+u+'"><span class="flatpickr-day">'+(l>t?l%t:l)+"</span></td>";i.appendChild(c),_.appendChild(i)},s=function(){var e=document.createElement("div"),t=document.createElement("span");e.className="flatpickr-time",C=document.createElement("input"),j=document.createElement("input"),t.className="flatpickr-time-separator",t.innerHTML=":",C.className="flatpickr-hour",C.type=j.type="number",j.className="flatpickr-minute",C.value=N.selectedDateObj?i(N.selectedDateObj.getHours()):12,j.value=N.selectedDateObj?i(N.selectedDateObj.getMinutes()):"00",C.step=N.config.hourIncrement,j.step=N.config.minuteIncrement,C.min=+!N.config.time_24hr,C.max=N.config.time_24hr?23:12,j.min=0,j.max=59,C.title=j.title="Scroll to increment",e.appendChild(C),e.appendChild(t),e.appendChild(j),N.config.time_24hr||(I=document.createElement("span"),I.className="flatpickr-am-pm",I.innerHTML=["AM","PM"][C.value>11|0],I.title="Click to toggle",e.appendChild(I)),N.config.noCalendar&&(N.selectedDateObj=new Date),H.appendChild(e)},b=function(){function e(e){e.preventDefault(),I.innerHTML=["AM","PM"]["AM"===I.innerHTML|0]}"true"===String(N.config.clickOpens)&&(N.input.addEventListener("focus",N.open),N.altInput&&N.altInput.addEventListener("focus",N.open)),N.config.wrap&&N.element.querySelector("[data-open]")&&N.element.querySelector("[data-open]").addEventListener("click",N.open),N.config.wrap&&N.element.querySelector("[data-close]")&&N.element.querySelector("[data-close]").addEventListener("click",N.close),N.config.wrap&&N.element.querySelector("[data-toggle]")&&N.element.querySelector("[data-toggle]").addEventListener("click",N.toggle),N.config.wrap&&N.element.querySelector("[data-clear]")&&N.element.querySelector("[data-clear]").addEventListener("click",N.clear),Y.addEventListener("click",function(){k(-1)}),A.addEventListener("click",function(){k(1)}),x.addEventListener("click",D),document.addEventListener("click",v,!0),N.config.enableTime&&(C.addEventListener("mousewheel",f),C.addEventListener("DOMMouseScroll",f),j.addEventListener("mousewheel",f),j.addEventListener("DOMMouseScroll",f),C.addEventListener("mouseout",p),j.addEventListener("mouseout",p),C.addEventListener("change",p),j.addEventListener("change",p),C.addEventListener("click",function(){return C.select()}),j.addEventListener("click",function(){return j.select()}),N.config.time_24hr||(I.addEventListener("focus",function(){return I.blur()}),I.addEventListener("click",e),I.addEventListener("mousewheel",e),I.addEventListener("DOMMouseScroll",e),I.addEventListener("mouseout",p))),"undefined"!=typeof MouseEvent&&(T=new MouseEvent("click",{bubbles:!0,cancelable:!0}))},N.open=function(){N.input.disabled||N.config.inline||(N.input.blur(),N.input.classList.add("active"),N.altInput&&(N.altInput.blur(),N.altInput.classList.add("active")),N.element.parentNode.classList.add("open"))},N.toggle=function(){N.input.disabled||(N.element.parentNode.classList.toggle("open"),N.altInput&&N.altInput.classList.toggle("active"),N.input.classList.toggle("active"))},N.close=function(){N.element.parentNode.classList.remove("open"),N.input.classList.remove("active"),N.altInput&&N.altInput.classList.remove("active"),N.config.onClose()},N.clear=function(){N.input.value="",N.selectedDateObj=null,w(),N.redraw()},E=function(){T?N.input.dispatchEvent(T):N.input.fireEvent("onchange"),N.config.onChange(N.selectedDateObj,N.input.value)},y=function(){var e=N.element.parentNode,t=e.removeChild(N.element);document.removeEventListener("click",v,!1),e.removeChild(H),e.parentNode.replaceChild(t,e)},w=function(e){e=a(e||N.selectedDateObj||N.config.defaultDate||N.config.minDate||q),N.currentYear=e.getFullYear(),N.currentMonth=e.getMonth()},N.redraw=function(){m(),d()},N.jumpToDate=function(e){w(a(e)||new Date),N.redraw()},N.setDate=function(e,t){N.selectedDateObj=a(e),N.jumpToDate(N.selectedDateObj),p(),t=t||!1,t&&E()},N.set=function(e,t){e in N.config&&(N.config[e]=t,w(),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,wrap:!1,clickOpens:!0,dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"<",nextArrow:">",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,t){},onClose:function(){}}},Date.prototype.fp_incr=function(e){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+parseInt(e,10))},"undefined"!=typeof module&&(module.exports=flatpickr); | ||
"use strict";var flatpickr=function e(t,n){var a,r,i,c=[];if(e.prototype=e.init.prototype,r=function(t){return t._flatpickr&&t._flatpickr.destroy(),t._flatpickr=new e.init(t,n),t._flatpickr},t.nodeName)return r(t);if(/^\#[a-zA-Z0-9\-\_]*$/.test(t))return r(document.getElementById(t.slice(1)));for(a=/^\.[a-zA-Z0-9\-\_]*$/.test(t)?document.getElementsByClassName(t.slice(1)):document.querySelectorAll(t),i=0;i<a.length;i++)c.push(r(a[i]));return{calendars:c,byID:function(e){var t=!0,n=!1,a=void 0;try{for(var r,i=this.calendars[Symbol.iterator]();!(t=(r=i.next()).done);t=!0){var c=r.value;if(c.element.id===e)return c}}catch(l){n=!0,a=l}finally{try{!t&&i["return"]&&i["return"]()}finally{if(n)throw a}}}}};flatpickr.init=function(e,t){var n,a,r,i,c,l,o,u,d,s,f,p,m,g,h,v,D,y,M,b,E,L,k,w,O,j,C,I,T=this,N=document.createElement("div"),S=document.createElement("span"),H=document.createElement("div"),x=document.createElement("span"),F=document.createElement("span"),Y=document.createElement("div"),A=new Date,_=document.createElement("div");return E=function(){N.className="flatpickr-calendar",S.className="flatpickr-current-month",t=t||{},T.config={},T.element=e,T.destroy=b;for(var r in T.defaultConfig)T.config[r]=t[r]||T.element.dataset&&T.element.dataset[r.toLowerCase()]||T.defaultConfig[r];T.input=T.config.wrap?e.querySelector("[data-input]"):e,T.config.defaultDate&&(T.config.defaultDate=a(T.config.defaultDate)),(T.input.value||T.config.defaultDate)&&(T.selectedDateObj=a(T.config.defaultDate||T.input.value)),T.config.minDate=a("today"===T.config.minDate?new Date:T.config.minDate,!0),T.config.maxDate=a(T.config.maxDate,!0),T.jumpToDate(T.selectedDateObj||T.config.minDate||A),n(),y(),M(),T.config.noCalendar||p()},a=function(e,t){return t=t||!1,"string"==typeof e&&(e=new Date(e.replace(/(\d*)[\-\.](\d*)[\-\.](\d*)/g,"$1/$2/$3"))),t&&e&&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(){_.className="flatpickr-wrapper",T.element.parentNode.insertBefore(_,T.element),_.appendChild(T.element),T.config.inline&&_.classList.add("inline"),T.config.altInput&&(T.altInput=document.createElement(T.input.nodeName),T.altInput.placeholder=T.input.placeholder,T.altInput.type=T.input.type||"text",T.input.type="hidden",_.appendChild(T.altInput))},w=function(e){var t=T.currentYear,n=e||T.currentMonth;return 1===n&&t%4===0&&t%100!==0||t%400===0?29:T.l10n.daysInMonth[n]},p=function(){if(T.selectedDateObj&&T.config.enableTime){var e=parseInt(O.value),t=(60+parseInt(j.value))%60;T.config.time_24hr||(e=e%12+12*("PM"===C.innerHTML)),T.selectedDateObj.setHours(e,t),O.value=i(T.config.time_24hr?e:(12+e)%12+12*(e%12===0)),j.value=i(t)}T.altInput&&T.selectedDateObj&&(T.altInput.value=c(T.config.altFormat)),T.selectedDateObj&&(T.input.value=c(T.config.dateFormat)),L()},i=function(e){return("0"+e).slice(-2)},c=function(e){T.config.noCalendar&&(e=""),T.config.enableTime&&(e+=" "+T.config.timeFormat);for(var t="",n={D:function(){return T.l10n.weekdays.shorthand[n.w()]},F:function(){return l(n.n()-1,!1)},H:function(){return i(T.selectedDateObj.getHours())},K:function(){return T.selectedDateObj.getHours()>11?"PM":"AM"},M:function(){return l(n.n()-1,!0)},U:function(){return T.selectedDateObj.getTime()/1e3},Y:function(){return T.selectedDateObj.getFullYear()},d:function(){return i(n.j())},h:function(){return T.selectedDateObj.getHours()%12?T.selectedDateObj.getHours()%12:12},i:function(){return i(T.selectedDateObj.getMinutes())},j:function(){return T.selectedDateObj.getDate()},l:function(){return T.l10n.weekdays.longhand[n.w()]},m:function(){return i(n.n())},n:function(){return T.selectedDateObj.getMonth()+1},w:function(){return T.selectedDateObj.getDay()},y:function(){return String(n.Y()).substring(2)}},a=e.split(""),r=0;r<a.length;r++)n[a[r]]&&"\\"!==a[r-1]?t+=n[a[r]]():"\\"!==a[r]&&(t+=a[r]);return t},l=function(e,t){return t=t||T.config.shorthandCurrentMonth,t?T.l10n.months.shorthand[e]:T.l10n.months.longhand[e]},o=function(e){var t=!0,n=!1,r=void 0;try{for(var i,c=T.config.disable[Symbol.iterator]();!(t=(i=c.next()).done);t=!0){var l=i.value;if(e>=a(l.from)&&e<=a(l.to))return!0}}catch(o){n=!0,r=o}finally{try{!t&&c["return"]&&c["return"]()}finally{if(n)throw r}}return!1},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)},m=function(){S.innerHTML="\n <span>"+l(T.currentMonth)+"</span> "+T.currentYear},h=function(){(T.currentMonth<0||T.currentMonth>11)&&(T.currentYear+=T.currentMonth%11,T.currentMonth=(T.currentMonth+12)%12)},v=function(e){_.classList.contains("open")&&!_.contains(e.target)&&T.close()},k=function(e){T.currentMonth+=e,h(),m(),d()},D=function(e){e.preventDefault();var t=e.target;t.classList.contains("slot")&&(T.selectedDateObj=new Date(T.currentYear,T.currentMonth,t.childNodes[0].innerHTML||t.innerHTML),p(),d(),T.config.inline||T.config.enableTime||T.close())},y=function(){T.config.noCalendar||(g(),u(),d(),N.appendChild(Y)),_.appendChild(N),T.config.enableTime&&s()},g=function(){H.className="flatpickr-month",x.className="flatpickr-prev-month",x.innerHTML=T.config.prevArrow,F.className="flatpickr-next-month",F.innerHTML=T.config.nextArrow,H.appendChild(x),H.appendChild(S),H.appendChild(F),m(),N.appendChild(H)},u=function(){var e=document.createElement("div"),t=T.l10n.firstDayOfWeek,n=T.l10n.weekdays.shorthand.slice();e.className="flatpickr-weekdays",t>0&&t<n.length&&(n=[].concat(n.splice(t,n.length),n.splice(0,t))),e.innerHTML="<span>"+n.join("</span><span>")+"</span>",N.appendChild(e)},d=function(){var e=(new Date(T.currentYear,T.currentMonth,1).getDay()-T.l10n.firstDayOfWeek+7)%7,t=w(),n=(T.currentMonth-1+12)%12,a=w(n),i=(document.createElement("div"),a+1-e),c=void 0,l=void 0,u=void 0,d=void 0;for(Y.className="flatpickr-days",Y.innerHTML="";a>=i;i++){var s=document.createElement("span");s.className="disabled flatpickr-day",s.innerText=i,Y.appendChild(s)}for(i=1;42-e>=i;i++){t>=i&&(l=new Date(T.currentYear,T.currentMonth,i)),d=T.config.minDate&&l<T.config.minDate||T.config.maxDate&&l>T.config.maxDate,u=i>t||d||o(l),c=u?"disabled flatpickr-day":"slot flatpickr-day",u||T.selectedDateObj||!r(l,A)||(c+=" today"),!u&&T.selectedDateObj&&r(l,T.selectedDateObj)&&(c+=" selected");var f=document.createElement("span");f.className=c,f.innerText=i>t?i%t:i,Y.appendChild(f)}},s=function(){var e=document.createElement("div"),t=document.createElement("span");e.className="flatpickr-time",O=document.createElement("input"),j=document.createElement("input"),t.className="flatpickr-time-separator",t.innerHTML=":",O.className="flatpickr-hour",O.type=j.type="number",j.className="flatpickr-minute",O.value=T.selectedDateObj?i(T.selectedDateObj.getHours()):12,j.value=T.selectedDateObj?i(T.selectedDateObj.getMinutes()):"00",O.step=T.config.hourIncrement,j.step=T.config.minuteIncrement,O.min=+!T.config.time_24hr,O.max=T.config.time_24hr?23:12,j.min=0,j.max=59,O.title=j.title="Scroll to increment",e.appendChild(O),e.appendChild(t),e.appendChild(j),T.config.time_24hr||(C=document.createElement("span"),C.className="flatpickr-am-pm",C.innerHTML=["AM","PM"][O.value>11|0],C.title="Click to toggle",e.appendChild(C)),T.config.noCalendar&&(T.selectedDateObj=new Date),N.appendChild(e)},M=function(){function e(e){e.preventDefault(),C.innerHTML=["AM","PM"]["AM"===C.innerHTML|0]}"true"===String(T.config.clickOpens)&&(T.input.addEventListener("focus",T.open),T.altInput&&T.altInput.addEventListener("focus",T.open)),T.config.wrap&&T.element.querySelector("[data-open]")&&T.element.querySelector("[data-open]").addEventListener("click",T.open),T.config.wrap&&T.element.querySelector("[data-close]")&&T.element.querySelector("[data-close]").addEventListener("click",T.close),T.config.wrap&&T.element.querySelector("[data-toggle]")&&T.element.querySelector("[data-toggle]").addEventListener("click",T.toggle),T.config.wrap&&T.element.querySelector("[data-clear]")&&T.element.querySelector("[data-clear]").addEventListener("click",T.clear),x.addEventListener("click",function(){k(-1)}),F.addEventListener("click",function(){k(1)}),Y.addEventListener("click",D),document.addEventListener("click",v,!0),T.config.enableTime&&(O.addEventListener("mousewheel",f),O.addEventListener("DOMMouseScroll",f),j.addEventListener("mousewheel",f),j.addEventListener("DOMMouseScroll",f),O.addEventListener("mouseout",p),j.addEventListener("mouseout",p),O.addEventListener("change",p),j.addEventListener("change",p),O.addEventListener("click",function(){return O.select()}),j.addEventListener("click",function(){return j.select()}),T.config.time_24hr||(C.addEventListener("focus",function(){return C.blur()}),C.addEventListener("click",e),C.addEventListener("mousewheel",e),C.addEventListener("DOMMouseScroll",e),C.addEventListener("mouseout",p))),document.createEvent?(I=document.createEvent("MouseEvent"),I.initMouseEvent("click",!0,!0,window)):I=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0})},T.open=function(){T.input.disabled||T.config.inline||(T.input.blur(),T.input.classList.add("active"),T.altInput&&(T.altInput.blur(),T.altInput.classList.add("active")),T.element.parentNode.classList.add("open"))},T.toggle=function(){T.input.disabled||(T.element.parentNode.classList.toggle("open"),T.altInput&&T.altInput.classList.toggle("active"),T.input.classList.toggle("active"))},T.close=function(){T.element.parentNode.classList.remove("open"),T.input.classList.remove("active"),T.altInput&&T.altInput.classList.remove("active"),T.config.onClose()},T.clear=function(){T.input.value="",T.selectedDateObj=null,T.jumpToDate()},L=function(){I?T.input.dispatchEvent(I):T.input.fireEvent("onchange"),T.config.onChange(T.selectedDateObj,T.input.value)},b=function(){var e=T.element.parentNode,t=e.removeChild(T.element);document.removeEventListener("click",v,!1),e.removeChild(N),e.parentNode.replaceChild(t,e)},T.redraw=function(){m(),d()},T.jumpToDate=function(e){e=a(e||T.selectedDateObj||T.config.defaultDate||T.config.minDate||A),T.currentYear=e.getFullYear(),T.currentMonth=e.getMonth(),T.redraw()},T.setDate=function(e,t){T.selectedDateObj=a(e),T.jumpToDate(T.selectedDateObj),p(),t=t||!1,t&&L()},T.set=function(e,t){e in T.config&&(T.config[e]=t,T.jumpToDate())},E(),T},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,wrap:!1,clickOpens:!0,dateFormat:"Y-m-d",altInput:!1,altFormat:"F j, Y",defaultDate:null,minDate:null,maxDate:null,disable:[],shorthandCurrentMonth:!1,inline:!1,prevArrow:"<",nextArrow:">",enableTime:!1,timeFormat:"h:i K",time_24hr:!1,hourIncrement:1,minuteIncrement:5,onChange:function(e,t){},onClose:function(){}}},Date.prototype.fp_incr=function(e){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+parseInt(e,10))},"undefined"!=typeof module&&(module.exports=flatpickr); |
@@ -5,2 +5,3 @@ import gulp from "gulp" | ||
import cssmin from "gulp-cssmin" | ||
import lint from "gulp-jshint" | ||
import uglify from "gulp-uglify" | ||
@@ -17,2 +18,6 @@ import rename from "gulp-rename" | ||
return gulp.src(paths.script) | ||
.pipe(lint({ | ||
'esversion': 6 | ||
})) | ||
.pipe(lint.reporter('default')) | ||
.pipe(babel({presets: ['es2015']})) | ||
@@ -41,8 +46,6 @@ .pipe(uglify()).on('error', errorHandler) | ||
export function watch() { | ||
gulp.watch('./src/style/*.styl', style); | ||
gulp.watch('./src/style/themes/*.styl', themes); | ||
gulp.watch('./src/style/**/*.styl', gulp.parallel(style, themes)); | ||
gulp.watch(paths.script, script); | ||
}; | ||
// Handle the error | ||
@@ -55,2 +58,3 @@ function errorHandler (error) { | ||
export {build} | ||
export default build; |
@@ -0,0 +0,0 @@ The MIT License (MIT) |
{ | ||
"name": "flatpickr", | ||
"version": "1.7.3", | ||
"version": "1.7.5", | ||
"description": "A lightweight, powerful datetimepicker", | ||
@@ -13,6 +13,8 @@ "dependencies": {}, | ||
"gulp-cssmin": "^0.1.7", | ||
"gulp-jshint": "^2.0.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-sass": "^2.2.0", | ||
"gulp-stylus": "^2.3.1", | ||
"gulp-uglify": "^1.5.3" | ||
"gulp-uglify": "^1.5.3", | ||
"jshint": "^2.9.1" | ||
}, | ||
@@ -19,0 +21,0 @@ "main": "dist/flatpickr.min.js", |
[![npm version](https://badge.fury.io/js/flatpickr.svg)](https://www.npmjs.com/package/flatpickr) | ||
![Bower version](https://badge.fury.io/bo/flatpickr-calendar.svg) | ||
![blue](https://cloud.githubusercontent.com/assets/11352152/14549371/3cbb65da-028d-11e6-976d-a6f63f32061f.PNG) | ||
![green](https://cloud.githubusercontent.com/assets/11352152/14549373/3cbe975a-028d-11e6-9192-43975f0146da.PNG) | ||
![confetti](https://cloud.githubusercontent.com/assets/11352152/14549440/de9bf55e-028d-11e6-9271-46782a99efea.PNG) | ||
![red](https://cloud.githubusercontent.com/assets/11352152/14549374/3cc01102-028d-11e6-9ff4-0cf208a310c4.PNG) | ||
![default](https://cloud.githubusercontent.com/assets/11352152/14549370/3cadb750-028d-11e6-818d-c6a1bc6349fc.PNG) | ||
![dark](https://cloud.githubusercontent.com/assets/11352152/14549372/3cbc8514-028d-11e6-8daf-ec1ba01c9d7e.PNG) | ||
## Preamble | ||
![wew](https://cloud.githubusercontent.com/assets/11352152/14397836/d02d2f7c-fdad-11e5-9658-bedfb997ff52.png) | ||
Almost every large SPA or project involves date and time input. There are limited options, however, if you also prefer to keep your projects lean and consequently stay away from heavy frameworks such as [jQuery](https://jsperf.com/jquery-vs-javascript-performance-comparison/22), or even Bootstrap. | ||
@@ -14,8 +25,4 @@ | ||
## Screenshots | ||
![wew](https://cloud.githubusercontent.com/assets/11352152/14397836/d02d2f7c-fdad-11e5-9658-bedfb997ff52.png) | ||
![light datetimepicker](https://cloud.githubusercontent.com/assets/11352152/14218528/b80adb0a-f822-11e5-9e89-0020345fa80d.PNG) | ||
![dark datetimepicker](https://cloud.githubusercontent.com/assets/11352152/12774092/8574034c-ca0f-11e5-9656-14711e806479.png) | ||
## Install & Use | ||
@@ -22,0 +29,0 @@ Along with demos and documentation: http://chmln.github.io/flatpickr |
@@ -41,5 +41,5 @@ var flatpickr = function (selector, config) { | ||
byID: function(id){ | ||
for (var i = 0; i < this.calendars.length; i++) { | ||
if (this.calendars[i].element.id === id) | ||
return this.calendars[i]; | ||
for (let calendar of this.calendars) { | ||
if (calendar.element.id === id) | ||
return calendar; | ||
} | ||
@@ -92,4 +92,3 @@ } | ||
nextMonthNav = document.createElement('span'), | ||
calendar = document.createElement('table'), | ||
calendarBody = document.createElement('tbody'), | ||
calendar = document.createElement('div'), | ||
currentDate = new Date(), | ||
@@ -116,3 +115,3 @@ wrapperElement = document.createElement('div'), | ||
instanceConfig[config] || | ||
self.element.dataset[config.toLowerCase()] || | ||
self.element.dataset&&self.element.dataset[config.toLowerCase()] || | ||
self.defaultConfig[config]; | ||
@@ -135,3 +134,3 @@ | ||
jumpToDate(self.selectedDateObj||self.config.minDate||currentDate); | ||
self.jumpToDate(self.selectedDateObj||self.config.minDate||currentDate); | ||
@@ -154,6 +153,7 @@ wrap(); | ||
timeless && date && ( date.setHours(0,0,0,0) ); | ||
if(timeless && date) | ||
date.setHours(0,0,0,0); | ||
return date; | ||
} | ||
}; | ||
@@ -165,3 +165,3 @@ equalDates = function(date1, date2){ | ||
} | ||
}; | ||
@@ -192,9 +192,10 @@ wrap = function () { | ||
let yr = self.currentYear, month = givenMonth || self.currentMonth; | ||
let yr = self.currentYear, | ||
month = givenMonth||self.currentMonth; | ||
if (month === 1 && ( !( (yr % 4) || (!(yr % 100) && (yr % 400))) ) ) | ||
if (month === 1 && ((yr % 4 === 0) && (yr % 100 !== 0)) || (yr % 400 === 0) ) | ||
return 29; | ||
return self.l10n.daysInMonth[month]; | ||
} | ||
}; | ||
@@ -229,3 +230,3 @@ updateValue = function(){ | ||
} | ||
}; | ||
@@ -276,3 +277,3 @@ pad = num =>("0" + num).slice(-2); | ||
monthToStr = function (date, shorthand) { | ||
shorthand=shorthand||self.config.shorthandCurrentMonth; | ||
return shorthand ? self.l10n.months.shorthand[date] : self.l10n.months.longhand[date]; | ||
@@ -285,5 +286,5 @@ | ||
for (var i = 0; i < self.config.disable.length; i++) | ||
if ( date >= uDate( self.config.disable[i]['from'] ) && date <= uDate( self.config.disable[i]['to'] ) ) | ||
return true; | ||
for (let range of self.config.disable) | ||
if ( date >= uDate(range.from) && date <= uDate(range.to) ) | ||
return true; | ||
@@ -301,4 +302,3 @@ return false; | ||
var min = parseInt(e.target.min), | ||
max = parseInt(e.target.max), | ||
let min = parseInt(e.target.min), max = parseInt(e.target.max), | ||
step = parseInt(e.target.step), | ||
@@ -308,6 +308,8 @@ delta = step * ( Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))) ), | ||
newValue < min && ( newValue = max+(min===0) - step*(min===0) ); | ||
if (newValue < min) | ||
newValue = max + (min === 0) - step*(min === 0); | ||
e.target.value = pad( newValue ); | ||
} | ||
}; | ||
@@ -317,7 +319,4 @@ | ||
navigationCurrentMonth.innerHTML = | ||
'<span>' + | ||
monthToStr(self.currentMonth, self.config.shorthandCurrentMonth) + | ||
'</span> ' | ||
+ self.currentYear; | ||
navigationCurrentMonth.innerHTML = ` | ||
<span>${monthToStr(self.currentMonth)}</span> ${self.currentYear}`; | ||
@@ -349,3 +348,3 @@ }; | ||
buildDays(); | ||
} | ||
}; | ||
@@ -356,5 +355,5 @@ calendarClick = function (event) { | ||
var targetDate = event.target; | ||
let targetDate = event.target; | ||
if ( targetDate.classList.contains('slot') || targetDate.parentNode.classList.contains('slot') ) | ||
if ( targetDate.classList.contains('slot') ) | ||
{ | ||
@@ -383,3 +382,2 @@ | ||
buildDays(); | ||
calendar.appendChild(calendarBody); | ||
calendarContainer.appendChild(calendar); | ||
@@ -389,4 +387,6 @@ } | ||
wrapperElement.appendChild(calendarContainer); | ||
self.config.enableTime && ( buildTime() ); | ||
if(self.config.enableTime) | ||
buildTime(); | ||
}; | ||
@@ -396,3 +396,3 @@ | ||
monthsNav.className = 'flatpickr-months'; | ||
monthsNav.className = 'flatpickr-month'; | ||
@@ -415,6 +415,8 @@ prevMonthNav.className = "flatpickr-prev-month"; | ||
let weekdayContainer = document.createElement('thead'), | ||
let weekdayContainer = document.createElement('div'), | ||
firstDayOfWeek = self.l10n.firstDayOfWeek, | ||
weekdays = self.l10n.weekdays.shorthand.slice(); | ||
weekdayContainer.className = "flatpickr-weekdays"; | ||
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) { | ||
@@ -424,4 +426,5 @@ weekdays = [].concat(weekdays.splice(firstDayOfWeek, weekdays.length), weekdays.splice(0, firstDayOfWeek)); | ||
weekdayContainer.innerHTML = '<tr><th>' + weekdays.join('</th><th>') + '</th></tr>'; | ||
calendar.appendChild(weekdayContainer); | ||
weekdayContainer.innerHTML = '<span>' + weekdays.join('</span><span>') + '</span>'; | ||
calendarContainer.appendChild(weekdayContainer); | ||
}; | ||
@@ -435,4 +438,3 @@ | ||
prevMonthDays = getDaysinMonth( prevMonth ), | ||
calendarFragment = document.createDocumentFragment(), | ||
row = document.createElement('tr'), | ||
calendarBody = document.createElement('div'), | ||
dayNumber = prevMonthDays + 1 - firstOfMonth, | ||
@@ -444,13 +446,13 @@ className, | ||
calendar.className = "flatpickr-days"; | ||
calendar.innerHTML = ''; | ||
// prepend days from the ending of previous month | ||
for( ; dayNumber <= prevMonthDays; dayNumber++ ) | ||
row.innerHTML += | ||
'<td class="disabled">' | ||
+ '<span class="flatpickr-day">' | ||
+ (dayNumber ) | ||
+ '</span>' + | ||
'</td>'; | ||
for( ; dayNumber <= prevMonthDays; dayNumber++ ){ | ||
let d = document.createElement("span"); | ||
d.className="disabled flatpickr-day"; | ||
d.innerText=dayNumber; | ||
calendar.appendChild(d); | ||
} | ||
calendarBody.innerHTML = ''; | ||
// Start at 1 since there is no 0th day | ||
@@ -462,15 +464,9 @@ for (dayNumber = 1; dayNumber <= 42 - firstOfMonth; dayNumber++) { | ||
// we have reached the end of a week, wrap to the next line | ||
if ( (dayNumber + firstOfMonth - 1) % 7 === 0) { | ||
calendarFragment.appendChild(row); | ||
row = document.createElement('tr'); | ||
} | ||
date_outside_minmax = | ||
(self.config.minDate && cur_date < self.config.minDate ) || | ||
(self.config.maxDate && cur_date > self.config.maxDate); | ||
date_outside_minmax = (self.config.minDate && cur_date < self.config.minDate ) | ||
|| (self.config.maxDate && cur_date > self.config.maxDate); | ||
date_is_disabled = dayNumber > numDays || date_outside_minmax || isDisabled( cur_date ); | ||
className = date_is_disabled ? "disabled" : "slot"; | ||
className = date_is_disabled ? "disabled flatpickr-day" : "slot flatpickr-day"; | ||
@@ -483,14 +479,10 @@ if (!date_is_disabled && !self.selectedDateObj && equalDates(cur_date, currentDate) ) | ||
let cell = document.createElement("span"); | ||
row.innerHTML += | ||
'<td class="' + className + '">'+ | ||
'<span class="flatpickr-day">'+ | ||
(dayNumber > numDays ? dayNumber % numDays : dayNumber)+ | ||
'</span></td>'; | ||
cell.className = className; | ||
cell.innerText = (dayNumber > numDays ? dayNumber % numDays : dayNumber); | ||
calendar.appendChild(cell); | ||
} | ||
calendarFragment.appendChild(row); | ||
calendarBody.appendChild(calendarFragment); | ||
}; | ||
@@ -552,3 +544,3 @@ | ||
} | ||
}; | ||
@@ -582,4 +574,4 @@ bind = function () { | ||
prevMonthNav.addEventListener('click', function(){ changeMonth(-1) }); | ||
nextMonthNav.addEventListener('click', function(){ changeMonth(1) }); | ||
prevMonthNav.addEventListener('click', () => { changeMonth(-1); }); | ||
nextMonthNav.addEventListener('click', () => { changeMonth(1); }); | ||
@@ -615,4 +607,13 @@ calendar.addEventListener('click', calendarClick); | ||
} | ||
if(typeof MouseEvent !== "undefined") | ||
clickEvt = new MouseEvent("click", {bubbles: true, cancelable: true}) | ||
if(document.createEvent){ | ||
clickEvt = document.createEvent("MouseEvent"); | ||
clickEvt.initMouseEvent("click",true,true,window); | ||
} | ||
else | ||
clickEvt = new MouseEvent('click', { | ||
'view': window, | ||
'bubbles': true, | ||
'cancelable': true | ||
}); | ||
@@ -660,5 +661,4 @@ }; | ||
self.selectedDateObj = null; | ||
jumpToDate(); | ||
self.redraw(); | ||
} | ||
self.jumpToDate(); | ||
}; | ||
@@ -668,3 +668,3 @@ triggerChange = function(){ | ||
if (clickEvt) | ||
self.input.dispatchEvent(clickEvt) | ||
self.input.dispatchEvent(clickEvt); | ||
else // IE | ||
@@ -675,3 +675,3 @@ self.input.fireEvent("onchange"); | ||
} | ||
}; | ||
@@ -688,12 +688,3 @@ destroy = function () { | ||
jumpToDate = function(jumpDate) { | ||
jumpDate = uDate( | ||
jumpDate|| | ||
self.selectedDateObj||self.config.defaultDate||self.config.minDate|| | ||
currentDate | ||
); | ||
self.currentYear = jumpDate.getFullYear(); | ||
self.currentMonth = jumpDate.getMonth(); | ||
}; | ||
@@ -705,10 +696,15 @@ self.redraw = function(){ | ||
} | ||
}; | ||
self.jumpToDate = function(date){ | ||
jumpToDate(uDate(date)||new Date()); | ||
self.jumpToDate = function(jumpDate){ | ||
jumpDate = uDate( | ||
jumpDate|| | ||
self.selectedDateObj||self.config.defaultDate||self.config.minDate|| | ||
currentDate | ||
); | ||
self.currentYear = jumpDate.getFullYear(); | ||
self.currentMonth = jumpDate.getMonth(); | ||
self.redraw(); | ||
} | ||
}; | ||
@@ -722,5 +718,6 @@ self.setDate = function(date, triggerChangeEvent){ | ||
triggerChangeEvent = triggerChangeEvent||false; | ||
triggerChangeEvent && (triggerChange()); | ||
if(triggerChangeEvent) | ||
triggerChange(); | ||
} | ||
}; | ||
@@ -731,7 +728,6 @@ self.set = function(key, value){ | ||
self.config[key] = value; | ||
jumpToDate(); | ||
self.redraw(); | ||
self.jumpToDate(); | ||
} | ||
} | ||
}; | ||
@@ -738,0 +734,0 @@ init(); |
@@ -0,0 +0,0 @@ // syntax for importing node modules below may differ depending on the tools you use |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
621544
38
2356
37
12