mirror of
https://github.com/lubuntu-team/lubuntu.me.git
synced 2025-02-23 16:21:07 +00:00
1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
!function(e,t){"use strict";var n;if("object"==typeof exports){try{n=require("moment")}catch(e){}module.exports=t(n)}else"function"==typeof define&&define.amd?define(function(e){try{n=e("moment")}catch(e){}return t(n)}):e.Pikaday=t(e.moment)}(this,function(e){"use strict";var t="function"==typeof e,n=!!window.addEventListener,a=window.document,i=window.setTimeout,s=function(e,t,a,i){n?e.addEventListener(t,a,!!i):e.attachEvent("on"+t,a)},o=function(e,t,a,i){n?e.removeEventListener(t,a,!!i):e.detachEvent("on"+t,a)},r=function(e,t,n){var i;a.createEvent?(i=a.createEvent("HTMLEvents"),i.initEvent(t,!0,!1),i=_(i,n),e.dispatchEvent(i)):a.createEventObject&&(i=a.createEventObject(),i=_(i,n),e.fireEvent("on"+t,i))},h=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},l=function(e,t){return-1!==(" "+e.className+" ").indexOf(" "+t+" ")},d=function(e,t){l(e,t)||(e.className=""===e.className?t:e.className+" "+t)},u=function(e,t){e.className=h((" "+e.className+" ").replace(" "+t+" "," "))},c=function(e){return/Array/.test(Object.prototype.toString.call(e))},f=function(e){return/Date/.test(Object.prototype.toString.call(e))&&!isNaN(e.getTime())},m=function(e){var t=e.getDay();return 0===t||6===t},g=function(e){return e%4==0&&e%100!=0||e%400==0},p=function(e,t){return[31,g(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]},y=function(e){f(e)&&e.setHours(0,0,0,0)},D=function(e,t){return e.getTime()===t.getTime()},_=function(e,t,n){var a,i;for(a in t)i=void 0!==e[a],i&&"object"==typeof t[a]&&null!==t[a]&&void 0===t[a].nodeName?f(t[a])?n&&(e[a]=new Date(t[a].getTime())):c(t[a])?n&&(e[a]=t[a].slice(0)):e[a]=_({},t[a],n):!n&&i||(e[a]=t[a]);return e},b=function(e){return e.month<0&&(e.year-=Math.ceil(Math.abs(e.month)/12),e.month+=12),e.month>11&&(e.year+=Math.floor(Math.abs(e.month)/12),e.month-=12),e},v={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},theme:null,onSelect:null,onOpen:null,onClose:null,onDraw:null},w=function(e,t,n){for(t+=e.firstDay;t>=7;)t-=7;return n?e.i18n.weekdaysShort[t]:e.i18n.weekdays[t]},M=function(e){var t=[],n="false";if(e.isEmpty){if(!e.showDaysInNextAndPreviousMonths)return'<td class="is-empty"></td>';t.push("is-outside-current-month")}return e.isDisabled&&t.push("is-disabled"),e.isToday&&t.push("is-today"),e.isSelected&&(t.push("is-selected"),n="true"),e.isInRange&&t.push("is-inrange"),e.isStartRange&&t.push("is-startrange"),e.isEndRange&&t.push("is-endrange"),'<td data-day="'+e.day+'" class="'+t.join(" ")+'" aria-selected="'+n+'"><button class="pika-button pika-day" type="button" data-pika-year="'+e.year+'" data-pika-month="'+e.month+'" data-pika-day="'+e.day+'">'+e.day+"</button></td>"},k=function(e,t,n){var a=new Date(n,0,1);return'<td class="pika-week">'+Math.ceil(((new Date(n,t,e)-a)/864e5+a.getDay()+1)/7)+"</td>"},x=function(e,t){return"<tr>"+(t?e.reverse():e).join("")+"</tr>"},R=function(e){return"<tbody>"+e.join("")+"</tbody>"},N=function(e){var t,n=[];for(e.showWeekNumber&&n.push("<th></th>"),t=0;t<7;t++)n.push('<th scope="col"><abbr title="'+w(e,t)+'">'+w(e,t,!0)+"</abbr></th>");return"<thead><tr>"+(e.isRTL?n.reverse():n).join("")+"</tr></thead>"},C=function(e,t,n,a,i,s){var o,r,h,l,d,u=e._o,f=n===u.minYear,m=n===u.maxYear,g='<div id="'+s+'" class="pika-title" role="heading" aria-live="assertive">',p=!0,y=!0;for(h=[],o=0;o<12;o++)h.push('<option value="'+(n===i?o-t:12+o-t)+'"'+(o===a?' selected="selected"':"")+(f&&o<u.minMonth||m&&o>u.maxMonth?'disabled="disabled"':"")+">"+u.i18n.months[o]+"</option>");for(l='<div class="pika-label">'+u.i18n.months[a]+'<select class="pika-select pika-select-month" tabindex="-1">'+h.join("")+"</select></div>",c(u.yearRange)?(o=u.yearRange[0],r=u.yearRange[1]+1):(o=n-u.yearRange,r=1+n+u.yearRange),h=[];o<r&&o<=u.maxYear;o++)o>=u.minYear&&h.push('<option value="'+o+'"'+(o===n?' selected="selected"':"")+">"+o+"</option>");return d='<div class="pika-label">'+n+u.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+h.join("")+"</select></div>",u.showMonthAfterYear?g+=d+l:g+=l+d,f&&(0===a||u.minMonth>=a)&&(p=!1),m&&(11===a||u.maxMonth<=a)&&(y=!1),0===t&&(g+='<button class="pika-prev'+(p?"":" is-disabled")+'" type="button">'+u.i18n.previousMonth+"</button>"),t===e._o.numberOfMonths-1&&(g+='<button class="pika-next'+(y?"":" is-disabled")+'" type="button">'+u.i18n.nextMonth+"</button>"),g+="</div>"},T=function(e,t,n){return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+n+'">'+N(e)+R(t)+"</table>"},Y=function(o){var r=this,h=r.config(o);r._onMouseDown=function(e){if(r._v){e=e||window.event;var t=e.target||e.srcElement;if(t)if(l(t,"is-disabled")||(!l(t,"pika-button")||l(t,"is-empty")||l(t.parentNode,"is-disabled")?l(t,"pika-prev")?r.prevMonth():l(t,"pika-next")&&r.nextMonth():(r.setDate(new Date(t.getAttribute("data-pika-year"),t.getAttribute("data-pika-month"),t.getAttribute("data-pika-day"))),h.bound&&i(function(){r.hide(),h.field&&h.field.blur()},100))),l(t,"pika-select"))r._c=!0;else{if(!e.preventDefault)return e.returnValue=!1,!1;e.preventDefault()}}},r._onChange=function(e){e=e||window.event;var t=e.target||e.srcElement;t&&(l(t,"pika-select-month")?r.gotoMonth(t.value):l(t,"pika-select-year")&&r.gotoYear(t.value))},r._onKeyChange=function(e){if(e=e||window.event,r.isVisible())switch(e.keyCode){case 13:case 27:h.field.blur();break;case 37:e.preventDefault(),r.adjustDate("subtract",1);break;case 38:r.adjustDate("subtract",7);break;case 39:r.adjustDate("add",1);break;case 40:r.adjustDate("add",7)}},r._onInputChange=function(n){var a;n.firedBy!==r&&(t?(a=e(h.field.value,h.format,h.formatStrict),a=a&&a.isValid()?a.toDate():null):a=new Date(Date.parse(h.field.value)),f(a)&&r.setDate(a),r._v||r.show())},r._onInputFocus=function(){r.show()},r._onInputClick=function(){r.show()},r._onInputBlur=function(){var e=a.activeElement;do{if(l(e,"pika-single"))return}while(e=e.parentNode);r._c||(r._b=i(function(){r.hide()},50)),r._c=!1},r._onClick=function(e){e=e||window.event;var t=e.target||e.srcElement,a=t;if(t){!n&&l(t,"pika-select")&&(t.onchange||(t.setAttribute("onchange","return;"),s(t,"change",r._onChange)));do{if(l(a,"pika-single")||a===h.trigger)return}while(a=a.parentNode);r._v&&t!==h.trigger&&a!==h.trigger&&r.hide()}},r.el=a.createElement("div"),r.el.className="pika-single"+(h.isRTL?" is-rtl":"")+(h.theme?" "+h.theme:""),s(r.el,"mousedown",r._onMouseDown,!0),s(r.el,"touchend",r._onMouseDown,!0),s(r.el,"change",r._onChange),s(a,"keydown",r._onKeyChange),h.field&&(h.container?h.container.appendChild(r.el):h.bound?a.body.appendChild(r.el):h.field.parentNode.insertBefore(r.el,h.field.nextSibling),s(h.field,"change",r._onInputChange),h.defaultDate||(t&&h.field.value?h.defaultDate=e(h.field.value,h.format).toDate():h.defaultDate=new Date(Date.parse(h.field.value)),h.setDefaultDate=!0));var d=h.defaultDate;f(d)?h.setDefaultDate?r.setDate(d,!0):r.gotoDate(d):r.gotoDate(new Date),h.bound?(this.hide(),r.el.className+=" is-bound",s(h.trigger,"click",r._onInputClick),s(h.trigger,"focus",r._onInputFocus),s(h.trigger,"blur",r._onInputBlur)):this.show()};return Y.prototype={config:function(e){this._o||(this._o=_({},v,!0));var t=_(this._o,e,!0);t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.theme="string"==typeof t.theme&&t.theme?t.theme:null,t.bound=!!(void 0!==t.bound?t.field&&t.bound:t.field),t.trigger=t.trigger&&t.trigger.nodeName?t.trigger:t.field,t.disableWeekends=!!t.disableWeekends,t.disableDayFn="function"==typeof t.disableDayFn?t.disableDayFn:null;var n=parseInt(t.numberOfMonths,10)||1;if(t.numberOfMonths=n>4?4:n,f(t.minDate)||(t.minDate=!1),f(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate<t.minDate&&(t.maxDate=t.minDate=!1),t.minDate&&this.setMinDate(t.minDate),t.maxDate&&this.setMaxDate(t.maxDate),c(t.yearRange)){var a=(new Date).getFullYear()-10;t.yearRange[0]=parseInt(t.yearRange[0],10)||a,t.yearRange[1]=parseInt(t.yearRange[1],10)||a}else t.yearRange=Math.abs(parseInt(t.yearRange,10))||v.yearRange,t.yearRange>100&&(t.yearRange=100);return t},toString:function(n){return f(this._d)?t?e(this._d).format(n||this._o.format):this._d.toDateString():""},getMoment:function(){return t?e(this._d):null},setMoment:function(n,a){t&&e.isMoment(n)&&this.setDate(n.toDate(),a)},getDate:function(){return f(this._d)?new Date(this._d.getTime()):new Date},setDate:function(e,t){if(!e)return this._d=null,this._o.field&&(this._o.field.value="",r(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof e&&(e=new Date(Date.parse(e))),f(e)){var n=this._o.minDate,a=this._o.maxDate;f(n)&&e<n?e=n:f(a)&&e>a&&(e=a),this._d=new Date(e.getTime()),y(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),r(this._o.field,"change",{firedBy:this})),t||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(e){var t=!0;if(f(e)){if(this.calendars){var n=new Date(this.calendars[0].year,this.calendars[0].month,1),a=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),i=e.getTime();a.setMonth(a.getMonth()+1),a.setDate(a.getDate()-1),t=i<n.getTime()||a.getTime()<i}t&&(this.calendars=[{month:e.getMonth(),year:e.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths)),this.adjustCalendars()}},adjustDate:function(n,a){var i,s=this.getDate(),o=24*parseInt(a)*60*60*1e3;"add"===n?i=new Date(s.valueOf()+o):"subtract"===n&&(i=new Date(s.valueOf()-o)),t&&("add"===n?i=e(s).add(a,"days").toDate():"subtract"===n&&(i=e(s).subtract(a,"days").toDate())),this.setDate(i)},adjustCalendars:function(){this.calendars[0]=b(this.calendars[0]);for(var e=1;e<this._o.numberOfMonths;e++)this.calendars[e]=b({month:this.calendars[0].month+e,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(e){isNaN(e)||(this.calendars[0].month=parseInt(e,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++,this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--,this.adjustCalendars()},gotoYear:function(e){isNaN(e)||(this.calendars[0].year=parseInt(e,10),this.adjustCalendars())},setMinDate:function(e){e instanceof Date?(y(e),this._o.minDate=e,this._o.minYear=e.getFullYear(),this._o.minMonth=e.getMonth()):(this._o.minDate=v.minDate,this._o.minYear=v.minYear,this._o.minMonth=v.minMonth,this._o.startRange=v.startRange),this.draw()},setMaxDate:function(e){e instanceof Date?(y(e),this._o.maxDate=e,this._o.maxYear=e.getFullYear(),this._o.maxMonth=e.getMonth()):(this._o.maxDate=v.maxDate,this._o.maxYear=v.maxYear,this._o.maxMonth=v.maxMonth,this._o.endRange=v.endRange),this.draw()},setStartRange:function(e){this._o.startRange=e},setEndRange:function(e){this._o.endRange=e},draw:function(e){if(this._v||e){var t,n=this._o,a=n.minYear,s=n.maxYear,o=n.minMonth,r=n.maxMonth,h="";this._y<=a&&(this._y=a,!isNaN(o)&&this._m<o&&(this._m=o)),this._y>=s&&(this._y=s,!isNaN(r)&&this._m>r&&(this._m=r)),t="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2);for(var l=0;l<n.numberOfMonths;l++)h+='<div class="pika-lendar">'+C(this,l,this.calendars[l].year,this.calendars[l].month,this.calendars[0].year,t)+this.render(this.calendars[l].year,this.calendars[l].month,t)+"</div>";this.el.innerHTML=h,n.bound&&"hidden"!==n.field.type&&i(function(){n.trigger.focus()},1),"function"==typeof this._o.onDraw&&this._o.onDraw(this),n.bound&&n.field.setAttribute("aria-label","Use the arrow keys to pick a date")}},adjustPosition:function(){var e,t,n,i,s,o,r,h,l,d;if(!this._o.container){if(this.el.style.position="absolute",e=this._o.trigger,t=e,n=this.el.offsetWidth,i=this.el.offsetHeight,s=window.innerWidth||a.documentElement.clientWidth,o=window.innerHeight||a.documentElement.clientHeight,r=window.pageYOffset||a.body.scrollTop||a.documentElement.scrollTop,"function"==typeof e.getBoundingClientRect)d=e.getBoundingClientRect(),h=d.left+window.pageXOffset,l=d.bottom+window.pageYOffset;else for(h=t.offsetLeft,l=t.offsetTop+t.offsetHeight;t=t.offsetParent;)h+=t.offsetLeft,l+=t.offsetTop;(this._o.reposition&&h+n>s||this._o.position.indexOf("right")>-1&&h-n+e.offsetWidth>0)&&(h=h-n+e.offsetWidth),(this._o.reposition&&l+i>o+r||this._o.position.indexOf("top")>-1&&l-i-e.offsetHeight>0)&&(l=l-i-e.offsetHeight),this.el.style.left=h+"px",this.el.style.top=l+"px"}},render:function(e,t,n){var a=this._o,i=new Date,s=p(e,t),o=new Date(e,t,1).getDay(),r=[],h=[];y(i),a.firstDay>0&&(o-=a.firstDay)<0&&(o+=7);for(var l=0===t?11:t-1,d=11===t?0:t+1,u=0===t?e-1:e,c=11===t?e+1:e,g=p(u,l),_=s+o,b=_;b>7;)b-=7;_+=7-b;for(var v=0,w=0;v<_;v++){var R=new Date(e,t,v-o+1),N=!!f(this._d)&&D(R,this._d),C=D(R,i),Y=v<o||v>=s+o,E=v-o+1,S=t,j=e,I=a.startRange&&D(a.startRange,R),O=a.endRange&&D(a.endRange,R),F=a.startRange&&a.endRange&&a.startRange<R&&R<a.endRange,A=a.minDate&&R<a.minDate||a.maxDate&&R>a.maxDate||a.disableWeekends&&m(R)||a.disableDayFn&&a.disableDayFn(R);Y&&(v<o?(E=g+E,S=l,j=u):(E-=s,S=d,j=c));var L={day:E,month:S,year:j,isSelected:N,isToday:C,isDisabled:A,isEmpty:Y,isStartRange:I,isEndRange:O,isInRange:F,showDaysInNextAndPreviousMonths:a.showDaysInNextAndPreviousMonths};h.push(M(L)),7==++w&&(a.showWeekNumber&&h.unshift(k(v-o,t,e)),r.push(x(h,a.isRTL)),h=[],w=0)}return T(a,r,n)},isVisible:function(){return this._v},show:function(){this.isVisible()||(u(this.el,"is-hidden"),this._v=!0,this.draw(),this._o.bound&&(s(a,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var e=this._v;!1!==e&&(this._o.bound&&o(a,"click",this._onClick),this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto",d(this.el,"is-hidden"),this._v=!1,void 0!==e&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),o(this.el,"mousedown",this._onMouseDown,!0),o(this.el,"touchend",this._onMouseDown,!0),o(this.el,"change",this._onChange),this._o.field&&(o(this._o.field,"change",this._onInputChange),this._o.bound&&(o(this._o.trigger,"click",this._onInputClick),o(this._o.trigger,"focus",this._onInputFocus),o(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},Y}); |