40 lines
16 KiB
JavaScript
40 lines
16 KiB
JavaScript
/** Notice * This file contains works from many authors under various (but compatible) licenses. Please see core.txt for more information. **/
|
|
(function(){/*
|
|
Pikaday
|
|
|
|
Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/Pikaday/Pikaday
|
|
*/
|
|
(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[19],{435:function(ia,ba){!function(e,ea){if("object"==typeof ba){try{var x=require("moment")}catch(ha){}ia.exports=ea(x)}else"function"==typeof define&&define.amd?define(function(e){try{x=e("moment")}catch(ca){}return ea(x)}):e.Pikaday=ea(e.moment)}(this,function(e){function ba(f){var h=this,n=h.config(f);h._onMouseDown=function(e){if(h._v){var f=(e=e||window.event).target||e.srcElement;if(f)if(ja(f,"is-disabled")||(!ja(f,"pika-button")||
|
|
ja(f,"is-empty")||ja(f.parentNode,"is-disabled")?ja(f,"pika-prev")?h.prevMonth():ja(f,"pika-next")?h.nextMonth():ja(f,"pika-set-today")&&(h.setDate(new Date),h.hide()):(h.setDate(new Date(f.getAttribute("data-pika-year"),f.getAttribute("data-pika-month"),f.getAttribute("data-pika-day"))),n.bound&&sa(function(){h.hide();n.blurFieldOnSelect&&n.field&&n.field.blur()},100))),ja(f,"pika-select"))h._c=!0;else{if(!e.preventDefault)return e.returnValue=!1,!1;e.preventDefault()}}};h._onChange=function(e){var f=
|
|
(e=e||window.event).target||e.srcElement;f&&(ja(f,"pika-select-month")?h.gotoMonth(f.value):ja(f,"pika-select-year")&&h.gotoYear(f.value))};h._onKeyChange=function(e){if(e=e||window.event,h.isVisible())switch(e.keyCode){case 13:case 27:n.field&&n.field.blur();break;case 37:h.adjustDate("subtract",1);break;case 38:h.adjustDate("subtract",7);break;case 39:h.adjustDate("add",1);break;case 40:h.adjustDate("add",7);break;case 8:case 46:h.setDate(null)}};h._parseFieldValue=function(){if(n.parse)return n.parse(n.field.value,
|
|
n.format);if(la){var f=e(n.field.value,n.format,n.formatStrict);return f&&f.isValid()?f.toDate():null}return new Date(Date.parse(n.field.value))};h._onInputChange=function(e){var f;e.firedBy!==h&&(f=h._parseFieldValue(),r(f)&&h.setDate(f),h._v||h.show())};h._onInputFocus=function(){h.show()};h._onInputClick=function(){h.show()};h._onInputBlur=function(){var e=ra.activeElement;do if(ja(e,"pika-single"))return;while(e=e.parentNode);h._c||(h._b=sa(function(){h.hide()},50));h._c=!1};h._onClick=function(e){var f=
|
|
(e=e||window.event).target||e.srcElement;if(e=f){!na&&ja(f,"pika-select")&&(f.onchange||(f.setAttribute("onchange","return;"),ma(f,"change",h._onChange)));do if(ja(e,"pika-single")||e===n.trigger)return;while(e=e.parentNode);h._v&&f!==n.trigger&&e!==n.trigger&&h.hide()}};h.el=ra.createElement("div");h.el.className="pika-single"+(n.isRTL?" is-rtl":"")+(n.theme?" "+n.theme:"");ma(h.el,"mousedown",h._onMouseDown,!0);ma(h.el,"touchend",h._onMouseDown,!0);ma(h.el,"change",h._onChange);n.keyboardInput&&
|
|
ma(ra,"keydown",h._onKeyChange);n.field&&(n.container?n.container.appendChild(h.el):n.bound?ra.body.appendChild(h.el):n.field.parentNode.insertBefore(h.el,n.field.nextSibling),ma(n.field,"change",h._onInputChange),n.defaultDate||(n.defaultDate=h._parseFieldValue(),n.setDefaultDate=!0));f=n.defaultDate;r(f)?n.setDefaultDate?h.setDate(f,!0):h.gotoDate(f):h.gotoDate(new Date);n.bound?(this.hide(),h.el.className+=" is-bound",ma(n.trigger,"click",h._onInputClick),ma(n.trigger,"focus",h._onInputFocus),
|
|
ma(n.trigger,"blur",h._onInputBlur)):this.show()}function x(e,f,h){return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+h+'">'+function(e){var f,h=[];e.showWeekNumber&&h.push("<th></th>");for(f=0;7>f;f++)h.push('<th scope="col"><abbr title="'+w(e,f)+'">'+w(e,f,!0)+"</abbr></th>");return"<thead><tr>"+(e.isRTL?h.reverse():h).join("")+"</tr></thead>"}(e)+("<tbody>"+f.join("")+"</tbody>")+(e.showTodayButton?function(e){var f=[];return f.push('<td colspan="'+
|
|
(e.showWeekNumber?"8":"7")+'"><button class="pika-set-today">'+e.i18n.today+"</button></td>"),"<tfoot>"+(e.isRTL?f.reverse():f).join("")+"</tfoot>"}(e):"")+"</table>"}function ha(e,f,h,n,r,w){var x,y,aa=e._o,ba=h===aa.minYear,da=h===aa.maxYear,ca='<div id="'+w+'" class="pika-title" role="heading" aria-live="assertive">',ea=!0,fa=!0;var ha=[];for(w=0;12>w;w++)ha.push('<option value="'+(h===r?w-f:12+w-f)+'"'+(w===n?' selected="selected"':"")+(ba&&w<aa.minMonth||da&&w>aa.maxMonth?' disabled="disabled"':
|
|
"")+">"+aa.i18n.months[w]+"</option>");r='<div class="pika-label">'+aa.i18n.months[n]+'<select class="pika-select pika-select-month" tabindex="-1">'+ha.join("")+"</select></div>";z(aa.yearRange)?(w=aa.yearRange[0],x=aa.yearRange[1]+1):(w=h-aa.yearRange,x=1+h+aa.yearRange);for(ha=[];w<x&&w<=aa.maxYear;w++)w>=aa.minYear&&ha.push('<option value="'+w+'"'+(w===h?' selected="selected"':"")+">"+w+"</option>");return y='<div class="pika-label">'+h+aa.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+
|
|
ha.join("")+"</select></div>",aa.showMonthAfterYear?ca+=y+r:ca+=r+y,ba&&(0===n||aa.minMonth>=n)&&(ea=!1),da&&(11===n||aa.maxMonth<=n)&&(fa=!1),0===f&&(ca+='<button class="pika-prev'+(ea?"":" is-disabled")+'" type="button">'+aa.i18n.previousMonth+"</button>"),f===e._o.numberOfMonths-1&&(ca+='<button class="pika-next'+(fa?"":" is-disabled")+'" type="button">'+aa.i18n.nextMonth+"</button>"),ca+"</div>"}function ca(e,f,h,n){return'<tr class="pika-row'+(h?" pick-whole-week":"")+(n?" is-selected":"")+'">'+
|
|
(f?e.reverse():e).join("")+"</tr>"}function da(f,h,n,r){f=new Date(n,h,f);la?r=e(f).isoWeek():(f.setHours(0,0,0,0),n=f.getDate(),h=r-1,f.setDate(n+h-(f.getDay()+7-1)%7),r=new Date(f.getFullYear(),0,r),r=1+Math.round(((f.getTime()-r.getTime())/864E5-h+(r.getDay()+7-1)%7)/7));return'<td class="pika-week">'+r+"</td>"}function aa(e){var f=[],h="false";if(e.isEmpty){if(!e.showDaysInNextAndPreviousMonths)return'<td class="is-empty"></td>';f.push("is-outside-current-month");e.enableSelectionDaysInNextAndPreviousMonths||
|
|
f.push("is-selection-disabled")}return e.isDisabled&&f.push("is-disabled"),e.isToday&&f.push("is-today"),e.isSelected&&(f.push("is-selected"),h="true"),e.hasEvent&&f.push("has-event"),e.isInRange&&f.push("is-inrange"),e.isStartRange&&f.push("is-startrange"),e.isEndRange&&f.push("is-endrange"),'<td data-day="'+e.day+'" class="'+f.join(" ")+'" aria-selected="'+h+'"><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>"}function w(e,f,h){for(f+=e.firstDay;7<=f;)f-=7;return h?e.i18n.weekdaysShort[f]:e.i18n.weekdays[f]}function y(e){return 0>e.month&&(e.year-=Math.ceil(Math.abs(e.month)/12),e.month+=12),11<e.month&&(e.year+=Math.floor(Math.abs(e.month)/12),e.month-=12),e}function n(e,f,n){var r;ra.createEvent?((r=ra.createEvent("HTMLEvents")).initEvent(f,!0,!1),r=h(r,n),e.dispatchEvent(r)):ra.createEventObject&&(r=ra.createEventObject(),r=h(r,n),e.fireEvent("on"+f,r))}function h(e,f,n){var w,
|
|
x;for(w in f)(x=void 0!==e[w])&&"object"==typeof f[w]&&null!==f[w]&&void 0===f[w].nodeName?r(f[w])?n&&(e[w]=new Date(f[w].getTime())):z(f[w])?n&&(e[w]=f[w].slice(0)):e[w]=h({},f[w],n):!n&&x||(e[w]=f[w]);return e}function f(e){r(e)&&e.setHours(0,0,0,0)}function r(e){return/Date/.test(Object.prototype.toString.call(e))&&!isNaN(e.getTime())}function z(e){return/Array/.test(Object.prototype.toString.call(e))}function fa(e,f){var h;e.className=(h=(" "+e.className+" ").replace(" "+f+" "," ")).trim?h.trim():
|
|
h.replace(/^\s+|\s+$/g,"")}function ia(e,f){ja(e,f)||(e.className=""===e.className?f:e.className+" "+f)}function ja(e,f){return-1!==(" "+e.className+" ").indexOf(" "+f+" ")}function pa(e,f,h,n){na?e.removeEventListener(f,h,!!n):e.detachEvent("on"+f,h)}function ma(e,f,h,n){na?e.addEventListener(f,h,!!n):e.attachEvent("on"+f,h)}var la="function"==typeof e,na=!!window.addEventListener,ra=window.document,sa=window.setTimeout,Da={field:null,bound:void 0,ariaLabel:"Use the arrow keys to pick a date",position:"bottom left",
|
|
reposition:!0,format:"YYYY-MM-DD",toString:null,parse:null,defaultDate:null,setDefaultDate:!1,firstDay:0,firstWeekOfYearMinDays:4,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,showTodayButton:!1,pickWholeWeek:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,enableSelectionDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,
|
|
blurFieldOnSelect:!0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",today:"Today",months:"January February March April May June July August September October November December".split(" "),weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),weekdaysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" ")},theme:null,events:[],onSelect:null,onOpen:null,onClose:null,onDraw:null,keyboardInput:!0};return ba.prototype={config:function(e){this._o||(this._o=h({},Da,!0));e=h(this._o,
|
|
e,!0);e.isRTL=!!e.isRTL;e.field=e.field&&e.field.nodeName?e.field:null;e.theme="string"==typeof e.theme&&e.theme?e.theme:null;e.bound=!!(void 0!==e.bound?e.field&&e.bound:e.field);e.trigger=e.trigger&&e.trigger.nodeName?e.trigger:e.field;e.disableWeekends=!!e.disableWeekends;e.disableDayFn="function"==typeof e.disableDayFn?e.disableDayFn:null;var f=parseInt(e.numberOfMonths,10)||1;(e.numberOfMonths=4<f?4:f,r(e.minDate)||(e.minDate=!1),r(e.maxDate)||(e.maxDate=!1),e.minDate&&e.maxDate&&e.maxDate<e.minDate&&
|
|
(e.maxDate=e.minDate=!1),e.minDate&&this.setMinDate(e.minDate),e.maxDate&&this.setMaxDate(e.maxDate),z(e.yearRange))?(f=(new Date).getFullYear()-10,e.yearRange[0]=parseInt(e.yearRange[0],10)||f,e.yearRange[1]=parseInt(e.yearRange[1],10)||f):(e.yearRange=Math.abs(parseInt(e.yearRange,10))||Da.yearRange,100<e.yearRange&&(e.yearRange=100));return e},toString:function(f){return f=f||this._o.format,r(this._d)?this._o.toString?this._o.toString(this._d,f):la?e(this._d).format(f):this._d.toDateString():""},
|
|
getMoment:function(){return la?e(this._d):null},setMoment:function(f,h){la&&e.isMoment(f)&&this.setDate(f.toDate(),h)},getDate:function(){return r(this._d)?new Date(this._d.getTime()):null},setDate:function(e,f){if(!e)return this._d=null,this._o.field&&(this._o.field.value="",n(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof e&&(e=new Date(Date.parse(e))),r(e)){var h=this._o.minDate,w=this._o.maxDate;r(h)&&e<h?e=h:r(w)&&e>w&&(e=w);this._d=new Date(e.getTime());this.gotoDate(this._d);
|
|
this._o.field&&(this._o.field.value=this.toString(),n(this._o.field,"change",{firedBy:this}));f||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},clear:function(){this.setDate(null)},gotoDate:function(e){var f=!0;if(r(e)){if(this.calendars){f=new Date(this.calendars[0].year,this.calendars[0].month,1);var h=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),n=e.getTime();h.setMonth(h.getMonth()+1);h.setDate(h.getDate()-
|
|
1);f=n<f.getTime()||h.getTime()<n}f&&(this.calendars=[{month:e.getMonth(),year:e.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths));this.adjustCalendars()}},adjustDate:function(e,f){var h,n=this.getDate()||new Date;f=864E5*parseInt(f);"add"===e?h=new Date(n.valueOf()+f):"subtract"===e&&(h=new Date(n.valueOf()-f));this.setDate(h)},adjustCalendars:function(){this.calendars[0]=y(this.calendars[0]);for(var e=1;e<this._o.numberOfMonths;e++)this.calendars[e]=
|
|
y({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?(f(e),
|
|
this._o.minDate=e,this._o.minYear=e.getFullYear(),this._o.minMonth=e.getMonth()):(this._o.minDate=Da.minDate,this._o.minYear=Da.minYear,this._o.minMonth=Da.minMonth,this._o.startRange=Da.startRange);this.draw()},setMaxDate:function(e){e instanceof Date?(f(e),this._o.maxDate=e,this._o.maxYear=e.getFullYear(),this._o.maxMonth=e.getMonth()):(this._o.maxDate=Da.maxDate,this._o.maxYear=Da.maxYear,this._o.maxMonth=Da.maxMonth,this._o.endRange=Da.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 f=this._o;var h=f.minYear;var n=f.maxYear,r=f.minMonth,w=f.maxMonth;e="";this._y<=h&&(this._y=h,!isNaN(r)&&this._m<r&&(this._m=r));this._y>=n&&(this._y=n,!isNaN(w)&&this._m>w&&(this._m=w));for(n=0;n<f.numberOfMonths;n++)h="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2),e+='<div class="pika-lendar">'+ha(this,n,this.calendars[n].year,this.calendars[n].month,this.calendars[0].year,h)+this.render(this.calendars[n].year,
|
|
this.calendars[n].month,h)+"</div>";this.el.innerHTML=e;f.bound&&"hidden"!==f.field.type&&sa(function(){f.trigger.focus()},1);"function"==typeof this._o.onDraw&&this._o.onDraw(this);f.bound&&f.field.setAttribute("aria-label",f.ariaLabel)}},adjustPosition:function(){var e,f,h,n,r,w,x,y,aa;if(!this._o.container){if(this.el.style.position="absolute",f=e=this._o.trigger,h=this.el.offsetWidth,n=this.el.offsetHeight,r=window.innerWidth||ra.documentElement.clientWidth,w=window.innerHeight||ra.documentElement.clientHeight,
|
|
x=window.pageYOffset||ra.body.scrollTop||ra.documentElement.scrollTop,y=!0,aa=!0,"function"==typeof e.getBoundingClientRect){var z=(f=e.getBoundingClientRect()).left+window.pageXOffset;var ba=f.bottom+window.pageYOffset}else for(z=f.offsetLeft,ba=f.offsetTop+f.offsetHeight;f=f.offsetParent;)z+=f.offsetLeft,ba+=f.offsetTop;(this._o.reposition&&z+h>r||-1<this._o.position.indexOf("right")&&0<z-h+e.offsetWidth)&&(z=z-h+e.offsetWidth,y=!1);(this._o.reposition&&ba+n>w+x||-1<this._o.position.indexOf("top")&&
|
|
0<ba-n-e.offsetHeight)&&(ba=ba-n-e.offsetHeight,aa=!1);0>z&&(z=0);0>ba&&(ba=0);this.el.style.left=z+"px";this.el.style.top=ba+"px";ia(this.el,y?"left-aligned":"right-aligned");ia(this.el,aa?"bottom-aligned":"top-aligned");fa(this.el,y?"right-aligned":"left-aligned");fa(this.el,aa?"top-aligned":"bottom-aligned")}},render:function(e,h,n){var w=this._o,y=new Date,z=[31,0==e%4&&0!=e%100||0==e%400?29:28,31,30,31,30,31,31,30,31,30,31][h],ba=(new Date(e,h,1)).getDay(),ea=[],fa=[];f(y);0<w.firstDay&&0>(ba-=
|
|
w.firstDay)&&(ba+=7);for(var ha=0===h?11:h-1,ia=11===h?0:h+1,ja=0===h?e-1:e,qa=11===h?e+1:e,ka=[31,0==ja%4&&0!=ja%100||0==ja%400?29:28,31,30,31,30,31,31,30,31,30,31][ha],la=z+ba,ra=la;7<ra;)ra-=7;la+=7-ra;ra=!1;for(var oa=0,na=0;oa<la;oa++){var ma=new Date(e,h,oa-ba+1),va=!!r(this._d)&&ma.getTime()===this._d.getTime(),sa=ma.getTime()===y.getTime(),wa=-1!==w.events.indexOf(ma.toDateString()),pa=oa<ba||oa>=z+ba,Da=oa-ba+1,Oa=h,Ta=e,Nb=w.startRange&&w.startRange.getTime()===ma.getTime(),sc=w.endRange&&
|
|
w.endRange.getTime()===ma.getTime(),bb=w.startRange&&w.endRange&&w.startRange<ma&&ma<w.endRange;pa&&(oa<ba?(Da=ka+Da,Oa=ha,Ta=ja):(Da-=z,Oa=ia,Ta=qa));var lb;!(lb=w.minDate&&ma<w.minDate||w.maxDate&&ma>w.maxDate)&&(lb=w.disableWeekends)&&(lb=ma.getDay(),lb=0===lb||6===lb);ma={day:Da,month:Oa,year:Ta,hasEvent:wa,isSelected:va,isToday:sa,isDisabled:lb||w.disableDayFn&&w.disableDayFn(ma),isEmpty:pa,isStartRange:Nb,isEndRange:sc,isInRange:bb,showDaysInNextAndPreviousMonths:w.showDaysInNextAndPreviousMonths,
|
|
enableSelectionDaysInNextAndPreviousMonths:w.enableSelectionDaysInNextAndPreviousMonths};w.pickWholeWeek&&va&&(ra=!0);fa.push(aa(ma));7==++na&&(w.showWeekNumber&&fa.unshift(da(oa-ba,h,e,w.firstWeekOfYearMinDays)),ea.push(ca(fa,w.isRTL,w.pickWholeWeek,ra)),fa=[],na=0,ra=!1)}return x(w,ea,n)},isVisible:function(){return this._v},show:function(){this.isVisible()||(this._v=!0,this.draw(),fa(this.el,"is-hidden"),this._o.bound&&(ma(ra,"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&&pa(ra,"click",this._onClick),this._o.container||(this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto"),ia(this.el,"is-hidden"),this._v=!1,void 0!==e&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){var e=this._o;this.hide();pa(this.el,"mousedown",this._onMouseDown,!0);pa(this.el,"touchend",this._onMouseDown,!0);pa(this.el,"change",this._onChange);e.keyboardInput&&
|
|
pa(ra,"keydown",this._onKeyChange);e.field&&(pa(e.field,"change",this._onInputChange),e.bound&&(pa(e.trigger,"click",this._onInputClick),pa(e.trigger,"focus",this._onInputFocus),pa(e.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},ba})}}]);}).call(this || window)
|