UNPKG

@pdftron/webviewer

Version:

[WebViewer](https://www.apryse.com/webviewer) is a powerful JavaScript Document SDK and UI Component Library that is a part of the [Apryse PDF SDK](https://www.apryse.com). It provides a slick, out-of-the-box responsive UI that interacts with the core lib

41 lines (39 loc) 17.6 kB
/** 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([[16],{684:function(wa,ua){!function(e,ka){if("object"==typeof ua){try{var pa=require("moment")}catch(na){}wa.exports=ka(pa)}else"function"==typeof define&&define.amd?define(function(na){try{pa=na("moment")}catch(ia){}return ka(pa)}):e.Pikaday=ka(e.moment)}(this,function(e){function ka(la){var qa=this,ja=qa.config(la);qa._onMouseDown=function(sa){if(qa._v){var oa=(sa=sa||window.event).target||sa.srcElement;if(oa)if(a(oa,"is-disabled")|| (!a(oa,"pika-button")||a(oa,"is-empty")||a(oa.parentNode,"is-disabled")?a(oa,"pika-prev")?qa.prevMonth():a(oa,"pika-next")?qa.nextMonth():a(oa,"pika-set-today")&&(qa.setDate(new Date),qa.hide()):(qa.setDate(new Date(oa.getAttribute("data-pika-year"),oa.getAttribute("data-pika-month"),oa.getAttribute("data-pika-day"))),ja.bound&&ma(function(){qa.hide();ja.blurFieldOnSelect&&ja.field&&ja.field.blur()},100))),a(oa,"pika-select"))qa._c=!0;else{if(!sa.preventDefault)return sa.returnValue=!1,!1;sa.preventDefault()}}}; qa._onChange=function(sa){var oa=(sa=sa||window.event).target||sa.srcElement;oa&&(a(oa,"pika-select-month")?qa.gotoMonth(oa.value):a(oa,"pika-select-year")&&qa.gotoYear(oa.value))};qa._onKeyChange=function(sa){if(sa=sa||window.event,qa.isVisible())switch(sa.keyCode){case 13:case 27:ja.field&&ja.field.blur();break;case 37:qa.adjustDate("subtract",1);break;case 38:qa.adjustDate("subtract",7);break;case 39:qa.adjustDate("add",1);break;case 40:qa.adjustDate("add",7);break;case 8:case 46:qa.setDate(null)}}; qa._parseFieldValue=function(){if(ja.parse)return ja.parse(ja.field.value,ja.format);if(z){var sa=e(ja.field.value,ja.format,ja.formatStrict);return sa&&sa.isValid()?sa.toDate():null}return new Date(Date.parse(ja.field.value))};qa._onInputChange=function(sa){var oa;sa.firedBy!==qa&&(oa=qa._parseFieldValue(),b(oa)&&qa.setDate(oa),qa._v||qa.show())};qa._onInputFocus=function(){qa.show()};qa._onInputClick=function(){qa.show()};qa._onInputBlur=function(){var sa=ea.activeElement;do if(a(sa,"pika-single"))return; while(sa=sa.parentNode);qa._c||(qa._b=ma(function(){qa.hide()},50));qa._c=!1};qa._onClick=function(sa){var oa=(sa=sa||window.event).target||sa.srcElement;if(sa=oa){!fa&&a(oa,"pika-select")&&(oa.onchange||(oa.setAttribute("onchange","return;"),aa(oa,"change",qa._onChange)));do if(a(sa,"pika-single")||sa===ja.trigger)return;while(sa=sa.parentNode);qa._v&&oa!==ja.trigger&&sa!==ja.trigger&&qa.hide()}};qa.el=ea.createElement("div");qa.el.className="pika-single"+(ja.isRTL?" is-rtl":"")+(ja.theme?" "+ja.theme: "");aa(qa.el,"mousedown",qa._onMouseDown,!0);aa(qa.el,"touchend",qa._onMouseDown,!0);aa(qa.el,"change",qa._onChange);ja.keyboardInput&&aa(ea,"keydown",qa._onKeyChange);ja.field&&(ja.container?ja.container.appendChild(qa.el):ja.bound?ea.body.appendChild(qa.el):ja.field.parentNode.insertBefore(qa.el,ja.field.nextSibling),aa(ja.field,"change",qa._onInputChange),ja.defaultDate||(ja.defaultDate=qa._parseFieldValue(),ja.setDefaultDate=!0));la=ja.defaultDate;b(la)?ja.setDefaultDate?qa.setDate(la,!0):qa.gotoDate(la): qa.gotoDate(new Date);ja.bound?(this.hide(),qa.el.className+=" is-bound",aa(ja.trigger,"click",qa._onInputClick),aa(ja.trigger,"focus",qa._onInputFocus),aa(ja.trigger,"blur",qa._onInputBlur)):this.show()}function pa(la,qa,ja){return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+ja+'">'+function(sa){var oa,ra=[];sa.showWeekNumber&&ra.push("<th></th>");for(oa=0;7>oa;oa++)ra.push('<th scope="col"><abbr title="'+ia(sa,oa)+'">'+ia(sa,oa,!0)+"</abbr></th>");return"<thead><tr>"+ (sa.isRTL?ra.reverse():ra).join("")+"</tr></thead>"}(la)+("<tbody>"+qa.join("")+"</tbody>")+(la.showTodayButton?function(sa){var oa=[];return oa.push('<td colspan="'+(sa.showWeekNumber?"8":"7")+'"><button class="pika-set-today">'+sa.i18n.today+"</button></td>"),"<tfoot>"+(sa.isRTL?oa.reverse():oa).join("")+"</tfoot>"}(la):"")+"</table>"}function na(la,qa,ja,sa,oa,ra){var ta,va,Ca=la._o,Aa=ja===Ca.minYear,Ba=ja===Ca.maxYear,Ea='<div id="'+ra+'" class="pika-title" role="heading" aria-live="assertive">', xa=!0,Da=!0;var Ma=[];for(ra=0;12>ra;ra++)Ma.push('<option value="'+(ja===oa?ra-qa:12+ra-qa)+'"'+(ra===sa?' selected="selected"':"")+(Aa&&ra<Ca.minMonth||Ba&&ra>Ca.maxMonth?' disabled="disabled"':"")+">"+Ca.i18n.months[ra]+"</option>");oa='<div class="pika-label">'+Ca.i18n.months[sa]+'<select class="pika-select pika-select-month" tabindex="-1">'+Ma.join("")+"</select></div>";h(Ca.yearRange)?(ra=Ca.yearRange[0],ta=Ca.yearRange[1]+1):(ra=ja-Ca.yearRange,ta=1+ja+Ca.yearRange);for(Ma=[];ra<ta&&ra<=Ca.maxYear;ra++)ra>= Ca.minYear&&Ma.push('<option value="'+ra+'"'+(ra===ja?' selected="selected"':"")+">"+ra+"</option>");return va='<div class="pika-label">'+ja+Ca.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+Ma.join("")+"</select></div>",Ca.showMonthAfterYear?Ea+=va+oa:Ea+=oa+va,Aa&&(0===sa||Ca.minMonth>=sa)&&(xa=!1),Ba&&(11===sa||Ca.maxMonth<=sa)&&(Da=!1),0===qa&&(Ea+='<button class="pika-prev'+(xa?"":" is-disabled")+'" type="button">'+Ca.i18n.previousMonth+"</button>"),qa===la._o.numberOfMonths- 1&&(Ea+='<button class="pika-next'+(Da?"":" is-disabled")+'" type="button">'+Ca.i18n.nextMonth+"</button>"),Ea+"</div>"}function ia(la,qa,ja){for(qa+=la.firstDay;7<=qa;)qa-=7;return ja?la.i18n.weekdaysShort[qa]:la.i18n.weekdays[qa]}function ca(la){return 0>la.month&&(la.year-=Math.ceil(Math.abs(la.month)/12),la.month+=12),11<la.month&&(la.year+=Math.floor(Math.abs(la.month)/12),la.month-=12),la}function ba(la,qa,ja){var sa;ea.createEvent?((sa=ea.createEvent("HTMLEvents")).initEvent(qa,!0,!1),sa=x(sa, ja),la.dispatchEvent(sa)):ea.createEventObject&&(sa=ea.createEventObject(),sa=x(sa,ja),la.fireEvent("on"+qa,sa))}function x(la,qa,ja){var sa,oa;for(sa in qa)(oa=void 0!==la[sa])&&"object"==typeof qa[sa]&&null!==qa[sa]&&void 0===qa[sa].nodeName?b(qa[sa])?ja&&(la[sa]=new Date(qa[sa].getTime())):h(qa[sa])?ja&&(la[sa]=qa[sa].slice(0)):la[sa]=x({},qa[sa],ja):!ja&&oa||(la[sa]=qa[sa]);return la}function y(la){b(la)&&la.setHours(0,0,0,0)}function r(la,qa){return[31,0==la%4&&0!=la%100||0==la%400?29:28,31, 30,31,30,31,31,30,31,30,31][qa]}function b(la){return/Date/.test(Object.prototype.toString.call(la))&&!isNaN(la.getTime())}function h(la){return/Array/.test(Object.prototype.toString.call(la))}function n(la,qa){var ja;la.className=(ja=(" "+la.className+" ").replace(" "+qa+" "," ")).trim?ja.trim():ja.replace(/^\s+|\s+$/g,"")}function f(la,qa){a(la,qa)||(la.className=""===la.className?qa:la.className+" "+qa)}function a(la,qa){return-1!==(" "+la.className+" ").indexOf(" "+qa+" ")}function w(la,qa,ja, sa){fa?la.removeEventListener(qa,ja,!!sa):la.detachEvent("on"+qa,ja)}function aa(la,qa,ja,sa){fa?la.addEventListener(qa,ja,!!sa):la.attachEvent("on"+qa,ja)}var z="function"==typeof e,fa=!!window.addEventListener,ea=window.document,ma=window.setTimeout,ha={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 ka.prototype={config:function(la){this._o||(this._o=x({},ha,!0));la=x(this._o,la,!0);la.isRTL=!!la.isRTL;la.field=la.field&&la.field.nodeName?la.field:null;la.theme="string"==typeof la.theme&&la.theme?la.theme:null;la.bound=!!(void 0!==la.bound?la.field&&la.bound:la.field); la.trigger=la.trigger&&la.trigger.nodeName?la.trigger:la.field;la.disableWeekends=!!la.disableWeekends;la.disableDayFn="function"==typeof la.disableDayFn?la.disableDayFn:null;var qa=parseInt(la.numberOfMonths,10)||1;(la.numberOfMonths=4<qa?4:qa,b(la.minDate)||(la.minDate=!1),b(la.maxDate)||(la.maxDate=!1),la.minDate&&la.maxDate&&la.maxDate<la.minDate&&(la.maxDate=la.minDate=!1),la.minDate&&this.setMinDate(la.minDate),la.maxDate&&this.setMaxDate(la.maxDate),h(la.yearRange))?(qa=(new Date).getFullYear()- 10,la.yearRange[0]=parseInt(la.yearRange[0],10)||qa,la.yearRange[1]=parseInt(la.yearRange[1],10)||qa):(la.yearRange=Math.abs(parseInt(la.yearRange,10))||ha.yearRange,100<la.yearRange&&(la.yearRange=100));return la},toString:function(la){return la=la||this._o.format,b(this._d)?this._o.toString?this._o.toString(this._d,la):z?e(this._d).format(la):this._d.toDateString():""},getMoment:function(){return z?e(this._d):null},setMoment:function(la,qa){z&&e.isMoment(la)&&this.setDate(la.toDate(),qa)},getDate:function(){return b(this._d)? new Date(this._d.getTime()):null},setDate:function(la,qa){if(!la)return this._d=null,this._o.field&&(this._o.field.value="",ba(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof la&&(la=new Date(Date.parse(la))),b(la)){var ja=this._o.minDate,sa=this._o.maxDate;b(ja)&&la<ja?la=ja:b(sa)&&la>sa&&(la=sa);this._d=new Date(la.getTime());this.gotoDate(this._d);this._o.field&&(this._o.field.value=this.toString(),ba(this._o.field,"change",{firedBy:this}));qa||"function"!=typeof this._o.onSelect|| this._o.onSelect.call(this,this.getDate())}},clear:function(){this.setDate(null)},gotoDate:function(la){var qa=!0;if(b(la)){if(this.calendars){qa=new Date(this.calendars[0].year,this.calendars[0].month,1);var ja=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),sa=la.getTime();ja.setMonth(ja.getMonth()+1);ja.setDate(ja.getDate()-1);qa=sa<qa.getTime()||ja.getTime()<sa}qa&&(this.calendars=[{month:la.getMonth(),year:la.getFullYear()}],"right"===this._o.mainCalendar&& (this.calendars[0].month+=1-this._o.numberOfMonths));this.adjustCalendars()}},adjustDate:function(la,qa){var ja,sa=this.getDate()||new Date;qa=864E5*parseInt(qa);"add"===la?ja=new Date(sa.valueOf()+qa):"subtract"===la&&(ja=new Date(sa.valueOf()-qa));this.setDate(ja)},adjustCalendars:function(){this.calendars[0]=ca(this.calendars[0]);for(var la=1;la<this._o.numberOfMonths;la++)this.calendars[la]=ca({month:this.calendars[0].month+la,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)}, gotoMonth:function(la){isNaN(la)||(this.calendars[0].month=parseInt(la,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++;this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--;this.adjustCalendars()},gotoYear:function(la){isNaN(la)||(this.calendars[0].year=parseInt(la,10),this.adjustCalendars())},setMinDate:function(la){la instanceof Date?(y(la),this._o.minDate=la,this._o.minYear=la.getFullYear(),this._o.minMonth=la.getMonth()):(this._o.minDate=ha.minDate, this._o.minYear=ha.minYear,this._o.minMonth=ha.minMonth,this._o.startRange=ha.startRange);this.draw()},setMaxDate:function(la){la instanceof Date?(y(la),this._o.maxDate=la,this._o.maxYear=la.getFullYear(),this._o.maxMonth=la.getMonth()):(this._o.maxDate=ha.maxDate,this._o.maxYear=ha.maxYear,this._o.maxMonth=ha.maxMonth,this._o.endRange=ha.endRange);this.draw()},setStartRange:function(la){this._o.startRange=la},setEndRange:function(la){this._o.endRange=la},draw:function(la){if(this._v||la){var qa= this._o;var ja=qa.minYear;var sa=qa.maxYear,oa=qa.minMonth,ra=qa.maxMonth;la="";this._y<=ja&&(this._y=ja,!isNaN(oa)&&this._m<oa&&(this._m=oa));this._y>=sa&&(this._y=sa,!isNaN(ra)&&this._m>ra&&(this._m=ra));for(sa=0;sa<qa.numberOfMonths;sa++)ja="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2),la+='<div class="pika-lendar">'+na(this,sa,this.calendars[sa].year,this.calendars[sa].month,this.calendars[0].year,ja)+this.render(this.calendars[sa].year,this.calendars[sa].month,ja)+ "</div>";this.el.innerHTML=la;qa.bound&&"hidden"!==qa.field.type&&ma(function(){qa.trigger.focus()},1);"function"==typeof this._o.onDraw&&this._o.onDraw(this);qa.bound&&qa.field.setAttribute("aria-label",qa.ariaLabel)}},adjustPosition:function(){var la,qa,ja,sa,oa,ra,ta,va,Ca;if(!this._o.container){if(this.el.style.position="absolute",qa=la=this._o.trigger,ja=this.el.offsetWidth,sa=this.el.offsetHeight,oa=window.innerWidth||ea.documentElement.clientWidth,ra=window.innerHeight||ea.documentElement.clientHeight, ta=window.pageYOffset||ea.body.scrollTop||ea.documentElement.scrollTop,va=!0,Ca=!0,"function"==typeof la.getBoundingClientRect){var Aa=(qa=la.getBoundingClientRect()).left+window.pageXOffset;var Ba=qa.bottom+window.pageYOffset}else for(Aa=qa.offsetLeft,Ba=qa.offsetTop+qa.offsetHeight;qa=qa.offsetParent;)Aa+=qa.offsetLeft,Ba+=qa.offsetTop;(this._o.reposition&&Aa+ja>oa||-1<this._o.position.indexOf("right")&&0<Aa-ja+la.offsetWidth)&&(Aa=Aa-ja+la.offsetWidth,va=!1);(this._o.reposition&&Ba+sa>ra+ta||-1< this._o.position.indexOf("top")&&0<Ba-sa-la.offsetHeight)&&(Ba=Ba-sa-la.offsetHeight,Ca=!1);0>Aa&&(Aa=0);0>Ba&&(Ba=0);this.el.style.left=Aa+"px";this.el.style.top=Ba+"px";f(this.el,va?"left-aligned":"right-aligned");f(this.el,Ca?"bottom-aligned":"top-aligned");n(this.el,va?"right-aligned":"left-aligned");n(this.el,Ca?"top-aligned":"bottom-aligned")}},render:function(la,qa,ja){var sa=this._o,oa=new Date,ra=r(la,qa),ta=(new Date(la,qa,1)).getDay(),va=[],Ca=[];y(oa);0<sa.firstDay&&0>(ta-=sa.firstDay)&& (ta+=7);for(var Aa=0===qa?11:qa-1,Ba=11===qa?0:qa+1,Ea=0===qa?la-1:la,xa=11===qa?la+1:la,Da=r(Ea,Aa),Ma=ra+ta,Ka=Ma;7<Ka;)Ka-=7;Ma+=7-Ka;for(var Oa=!1,Qa=Ka=0;Ka<Ma;Ka++){var Pa=new Date(la,qa,Ka-ta+1),eb=!!b(this._d)&&Pa.getTime()===this._d.getTime(),cb=Pa.getTime()===oa.getTime(),jb=-1!==sa.events.indexOf(Pa.toDateString()),Za=Ka<ta||Ka>=ra+ta,Ia=Ka-ta+1,Xa=qa,Ta=la,Ua=sa.startRange&&sa.startRange.getTime()===Pa.getTime(),ab=sa.endRange&&sa.endRange.getTime()===Pa.getTime(),$a=sa.startRange&&sa.endRange&& sa.startRange<Pa&&Pa<sa.endRange;Za&&(Ka<ta?(Ia=Da+Ia,Xa=Aa,Ta=Ea):(Ia-=ra,Xa=Ba,Ta=xa));var fb=eb,mb;!(mb=sa.minDate&&Pa<sa.minDate||sa.maxDate&&Pa>sa.maxDate)&&(mb=sa.disableWeekends)&&(mb=Pa.getDay(),mb=0===mb||6===mb);Za={day:Ia,month:Xa,year:Ta,hasEvent:jb,isSelected:fb,isToday:cb,isDisabled:mb||sa.disableDayFn&&sa.disableDayFn(Pa),isEmpty:Za,isStartRange:Ua,isEndRange:ab,isInRange:$a,showDaysInNextAndPreviousMonths:sa.showDaysInNextAndPreviousMonths,enableSelectionDaysInNextAndPreviousMonths:sa.enableSelectionDaysInNextAndPreviousMonths}; sa.pickWholeWeek&&eb&&(Oa=!0);eb=Ca;Pa=eb.push;a:{Ua=Za;ab=[];$a="false";if(Ua.isEmpty){if(!Ua.showDaysInNextAndPreviousMonths){Za='<td class="is-empty"></td>';break a}ab.push("is-outside-current-month");Ua.enableSelectionDaysInNextAndPreviousMonths||ab.push("is-selection-disabled")}Za=(Ua.isDisabled&&ab.push("is-disabled"),Ua.isToday&&ab.push("is-today"),Ua.isSelected&&(ab.push("is-selected"),$a="true"),Ua.hasEvent&&ab.push("has-event"),Ua.isInRange&&ab.push("is-inrange"),Ua.isStartRange&&ab.push("is-startrange"), Ua.isEndRange&&ab.push("is-endrange"),'<td data-day="'+Ua.day+'" class="'+ab.join(" ")+'" aria-selected="'+$a+'"><button class="pika-button pika-day" type="button" data-pika-year="'+Ua.year+'" data-pika-month="'+Ua.month+'" data-pika-day="'+Ua.day+'">'+Ua.day+"</button></td>")}Pa.call(eb,Za);7==++Qa&&(sa.showWeekNumber&&(Qa=Ca,eb=Qa.unshift,Ua=sa.firstWeekOfYearMinDays,Pa=new Date(la,qa,Ka-ta),z?Pa=e(Pa).isoWeek():(Pa.setHours(0,0,0,0),ab=Pa.getDate(),Za=Ua-1,Pa.setDate(ab+Za-(Pa.getDay()+7-1)%7), Ua=new Date(Pa.getFullYear(),0,Ua),Pa=1+Math.round(((Pa.getTime()-Ua.getTime())/864E5-Za+(Ua.getDay()+7-1)%7)/7)),eb.call(Qa,'<td class="pika-week">'+Pa+"</td>")),Qa=va,eb=Qa.push,Ca='<tr class="pika-row'+(sa.pickWholeWeek?" pick-whole-week":"")+(Oa?" is-selected":"")+'">'+(sa.isRTL?Ca.reverse():Ca).join("")+"</tr>",eb.call(Qa,Ca),Ca=[],Qa=0,Oa=!1)}return pa(sa,va,ja)},isVisible:function(){return this._v},show:function(){this.isVisible()||(this._v=!0,this.draw(),n(this.el,"is-hidden"),this._o.bound&& (aa(ea,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var la=this._v;!1!==la&&(this._o.bound&&w(ea,"click",this._onClick),this._o.container||(this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto"),f(this.el,"is-hidden"),this._v=!1,void 0!==la&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){var la=this._o;this.hide();w(this.el,"mousedown",this._onMouseDown, !0);w(this.el,"touchend",this._onMouseDown,!0);w(this.el,"change",this._onChange);la.keyboardInput&&w(ea,"keydown",this._onKeyChange);la.field&&(w(la.field,"change",this._onInputChange),la.bound&&(w(la.trigger,"click",this._onInputClick),w(la.trigger,"focus",this._onInputFocus),w(la.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},ka})}}]);}).call(this || window)