PageSourceSearch

https://www.ums.ac.uk/assets/@easepick--core-2bbe806f438fc0eab00d8…1c2057495e3e86273ab6e9b3b166f4ddc69c7416.js

js ums.ac.uk collected 2026-10-02 06:51:31 UTC 13,437 bytes, 2 lines download raw bytes

vendor: 7,478 bytes, line 1
1import{DateTime as e}from"@easepick/datetime";class t{picker;constructor(e){this.picker=e}render(s,a){s||(s=new e),s.setDate(1),s.setHours(0,0,0,0),"function"==typeof this[`get${a}View`]&&this[`get${a}View`](s)}getContainerView(e){this.picker.ui.container.innerHTML="",this.picker.options.header&&this.picker.trigger("render",{date:e.clone(),view:"Header"}),this.picker.trigger("render",{date:e.clone(),view:"Main"}),this.picker.options.autoApply||this.picker.trigger("render",{date:e.clone(),view:"Footer"})}getHeaderView(e){const s=document.createElement("header");this.picker.options.header instanceof HTMLElement&&s.appendChild(this.picker.options.header),"string"==typeof this.picker.options.header&&(s.innerHTML=this.picker.options.header),this.picker.ui.container.appendChild(s),this.picker.trigger("view",{target:s,date:e.clone(),view:"Header"})}getMainView(e){const s=document.createElement("main");this.picker.ui.container.appendChild(s);const a=document.createElement("div");a.className=`calendars grid-${this.picker.options.grid}`;for(let s=0;s<this.picker.options.calendars;s++){const o=document.createElement("div");o.className="calendar",a.appendChild(o);const r=this.getCalendarHeaderView(e.clone());o.appendChild(r),this.picker.trigger("view",{date:e.clone(),view:"CalendarHeader",index:s,target:r});const c=this.getCalendarDayNamesView();o.appendChild(c),this.picker.trigger("view",{date:e.clone(),view:"CalendarDayNames",index:s,target:c});const l=this.getCalendarDaysView(e.clone());o.appendChild(l),this.picker.trigger("view",{date:e.clone(),view:"CalendarDays",index:s,target:l});const d=this.getCalendarFooterView(this.picker.options.lang,e.clone());o.appendChild(d),this.picker.trigger("view",{date:e.clone(),view:"CalendarFooter",index:s,target:d}),this.picker.trigger("view",{date:e.clone(),view:"CalendarItem",index:s,target:o}),e.add(1,"month")}s.appendChild(a),this.picker.trigger("view",{date:e.clone(),view:"Calendars",target:a}),this.picker.trigger("view",{date:e.clone(),view:"Main",target:s})}getFooterView(e){const s=document.createElement("footer"),a=document.createElement("div");a.className="footer-buttons";const o=document.createElement("button");o.className="cancel-button unit",o.innerHTML=this.picker.options.locale.cancel,a.appendChild(o);const r=document.createElement("button");r.className="apply-button unit",r.innerHTML=this.picker.options.locale.apply,r.disabled=!0,a.appendChild(r),s.appendChild(a),this.picker.ui.container.appendChild(s),this.picker.trigger("view",{date:e,target:s,view:"Footer"})}getCalendarHeaderView(e){const s=document.createElement("div");s.className="header";const a=document.createElement("div");a.className="month-name",a.innerHTML=`<span>${e.toLocaleString(this.picker.options.lang,{month:"long"})}</span> ${e.format("YYYY")}`,s.appendChild(a);const o=document.createElement("button");o.className="previous-button unit",o.innerHTML=this.picker.options.locale.previousMonth,s.appendChild(o);const r=document.createElement("button");return r.className="next-button unit",r.innerHTML=this.picker.options.locale.nextMonth,s.appendChild(r),s}getCalendarDayNamesView(){const e=document.createElement("div");e.className="daynames-row";for(let s=1;s<=7;s++){const a=3+this.picker.options.firstDay+s,o=document.createElement("div");o.className="dayname",o.innerHTML=new Date(1970,0,a,12,0,0,0).toLocaleString(this.picker.options.lang,{weekday:"short"}),o.title=new Date(1970,0,a,12,0,0,0).toLocaleString(this.picker.options.lang,{weekday:"long"}),e.appendChild(o),this.picker.trigger("view",{dayIdx:a,view:"CalendarDayName",target:o})}return e}getCalendarDaysView(e){const s=document.createElement("div");s.className="days-grid";const a=this.calcOffsetDays(e,this.picker.options.firstDay),o=32-new Date(e.getFullYear(),e.getMonth(),32).getDate();for(let e=0;e<a;e++){const e=document.createElement("div");e.className="offset",s.appendChild(e)}for(let a=1;a<=o;a++){e.setDate(a);const o=this.getCalendarDayView(e);s.appendChild(o),this.picker.trigger("view",{date:e,view:"CalendarDay",target:o})}return s}getCalendarDayView(s){const a=this.picker.options.date?new e(this.picker.options.date):null,o=new e,r=document.createElement("div");return r.className="day unit",r.innerHTML=s.format("D"),r.dataset.time=String(s.getTime()),s.isSame(o,"day")&&r.classList.add("today"),[0,6].includes(s.getDay())&&r.classList.add("weekend"),this.picker.datePicked.length?this.picker.datePicked[0].isSame(s,"day")&&r.classList.add("selected"):a&&s.isSame(a,"day")&&r.classList.add("selected"),this.picker.trigger("view",{date:s,view:"CalendarDay",target:r}),r}getCalendarFooterView(e,s){const a=document.createElement("div");return a.className="footer",a}calcOffsetDays(e,s){let a=e.getDay()-s;return a<0&&(a+=7),a}}class i{picker;instances={};constructor(e){this.picker=e}initialize(){const e=[];this.picker.options.plugins.forEach((s=>{"function"==typeof s?e.push(new s):"string"==typeof s&&"undefined"!=typeof easepick&&Object.prototype.hasOwnProperty.call(easepick,s)?e.push(new easepick[s]):console.warn(`easepick: ${s} not found.`)})),e.sort(((e,s)=>e.priority>s.priority?-1:e.priority<s.priority||e.dependencies.length>s.dependencies.length?1:e.dependencies.length<s.dependencies.length?-1:0)),e.forEach((e=>{e.attach(this.picker),this.instances[e.getName()]=e}))}getInstance(e){return this.instances[e]}addInstance(e){if(Object.prototype.hasOwnProperty.call(this.instances,e))console.warn(`easepick: ${e} already added.`);else{if("undefined"!=typeof easepick&&Object.prototype.hasOwnProperty.call(easepick,e)){const s=new easepick[e];return s.attach(this.picker),this.instances[s.getName()]=s,s}if("undefined"!==this.getPluginFn(e)){const s=new(this.getPluginFn(e));return s.attach(this.picker),this.instances[s.getName()]=s,s}console.warn(`easepick: ${e} not found.`)}return null}removeInstance(e){return e in this.instances&&this.instances[e].detach(),delete this.instances[e]}reloadInstance(e){return this.removeInstance(e),this.addInstance(e)}getPluginFn(e){return[...this.picker.options.plugins].filter((s=>"function"==typeof s&&(new s).getName()===e)).shift()}}class n{Calendar=new t(this);PluginManager=new i(this);calendars=[];datePicked=[];cssLoaded=0;binds={hidePicker:this.hidePicker.bind(this),show:this.show.bind(this)};options={doc:document,css:[],element:null,firstDay:1,grid:1,calendars:1,lang:"en-US",date:null,format:"YYYY-MM-DD",readonly:!0,autoApply:!0,header:!1,inline:!1,scrollToDate:!0,locale:{nextMonth:'<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M2.748 16L0 13.333 5.333 8 0 2.667 2.748 0l7.919 8z" fill-rule="nonzero"/></svg>',previousMonth:'<svg width="11" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M7.919 0l2.748 2.667L5.333 8l5.334 5.333L7.919 16 0 8z" fill-rule="nonzero"/></svg>',cancel:"Cancel",apply:"Apply"},documentClick:this.binds.hidePicker,plugins:[]};ui={container:null,shadowRoot:null,wrapper:null};version="1.2.1";constructor(e){const s={...this.options.locale,...e.locale};this.options={...this.options,...e},this.options.locale=s,this.handleOptions(),this.ui.wrapper=document.createElement("span"),this.ui.wrapper.style.display="none",this.ui.wrapper.style.position="absolute",this.ui.wrapper.style.pointerEvents="none",this.ui.wrapper.className="easepick-wrapper",this.ui.wrapper.attachShadow({mode:"open"}),this.ui.shadowRoot=this.ui.wrapper.shadowRoot,this.ui.container=document.createElement("div"),this.ui.container.className="
1container",this.options.zIndex&&(this.ui.container.style.zIndex=String(this.options.zIndex)),this.options.inline&&(this.ui.wrapper.style.position="relative",this.ui.container.classList.add("inline")),this.ui.shadowRoot.appendChild(this.ui.container),this.options.element.after(this.ui.wrapper),this.handleCSS(),this.options.element.addEventListener("click",this.binds.show),this.on("view",this.onView.bind(this)),this.on("render",this.onRender.bind(this)),this.PluginManager.initialize(),this.parseValues(),"function"==typeof this.options.setup&&this.options.setup(this),this.on("click",this.onClick.bind(this));const a=this.options.scrollToDate?this.getDate():null;this.renderAll(a)}on(e,s,a={}){this.ui.container.addEventListener(e,s,a)}off(e,s,a={}){this.ui.container.removeEventListener(e,s,a)}trigger(e,s={}){return this.ui.container.dispatchEvent(new CustomEvent(e,{detail:s}))}destroy(){this.options.element.removeEventListener("click",this.binds.show),"function"==typeof this.options.documentClick&&document.removeEventListener("click",this.options.documentClick,!0),Object.keys(this.PluginManager.instances).forEach((e=>{this.PluginManager.removeInstance(e)})),this.ui.wrapper.remove()}onRender(e){const{view:s,date:a}=e.detail;this.Calendar.render(a,s)}onView(e){const{view:s,target:a}=e.detail;"Footer"===s&&this.datePicked.length&&(a.querySelector(".apply-button").disabled=!1)}onClickHeaderButton(e){this.isCalendarHeaderButton(e)&&(e.classList.contains("next-button")?this.calendars[0].add(1,"month"):this.calendars[0].subtract(1,"month"),this.renderAll(this.calendars[0]))}onClickCalendarDay(s){if(this.isCalendarDay(s)){const a=new e(s.dataset.time);this.options.autoApply?(this.setDate(a),this.trigger("select",{date:this.getDate()}),this.hide()):(this.datePicked[0]=a,this.trigger("preselect",{date:this.getDate()}),this.renderAll())}}onClickApplyButton(e){if(this.isApplyButton(e)){if(this.datePicked[0]instanceof Date){const e=this.datePicked[0].clone();this.setDate(e)}this.hide(),this.trigger("select",{date:this.getDate()})}}onClickCancelButton(e){this.isCancelButton(e)&&this.hide()}onClick(e){const s=e.target;if(s instanceof HTMLElement){const e=s.closest(".unit");if(!(e instanceof HTMLElement))return;this.onClickHeaderButton(e),this.onClickCalendarDay(e),this.onClickApplyButton(e),this.onClickCancelButton(e)}}isShown(){return this.ui.container.classList.contains("inline")||this.ui.container.classList.contains("show")}show(e){if(this.isShown())return;const s=e&&"target"in e?e.target:this.options.element,{top:a,left:o}=this.adjustPosition(s);this.ui.container.style.top=`${a}px`,this.ui.container.style.left=`${o}px`,this.ui.container.classList.add("show"),this.trigger("show",{target:s})}hide(){this.ui.container.classList.remove("show"),this.datePicked.length=0,this.renderAll(),this.trigger("hide")}setDate(s){const a=new e(s,this.options.format);this.options.date=a.clone(),this.updateValues(),this.calendars.length&&this.renderAll()}getDate(){return this.options.date instanceof e?this.options.date.clone():null}parseValues(){this.options.date?this.setDate(this.options.date):this.options.element instanceof HTMLInputElement&&this.options.element.value.length&&this.setDate(this.options.element.value),this.options.date instanceof Date||(this.options.date=null)}updateValues(){const e=this.getDate(),s=e instanceof Date?e.format(this.options.format,this.options.lang):"",a=this.options.element;a instanceof HTMLInputElement?a.value=s:a instanceof HTMLElement&&(a.innerText=s)}hidePicker(e){let s=e.target,a=null;s.shadowRoot&&(s=e.composedPath()[0],a=s.getRootNode().host),this.isShown()&&a!==this.ui.wrapper&&s!==this.options.element&&this.hide()}renderAll(e){this.trigger("render",{view:"Container",date:(e||this.calendars[0]).clone()})}isCalendarHeaderButton(e){return["previous-button","next-button"].some((s=>e.classList.contains(s)))}isCalendarDay(e){return e.classList.contains("day")}isApplyButton(e){return e.classList.contains("apply-button")}isCancelButton(e){return e.classList.contains("cancel-button")}gotoDate(s){const a=new e(s,this.options.format);a.setDate(1),this.calendars[0]=a.clone(),this.renderAll()}clear(){this.options.date=null,this.datePicked.length=0,this.updateV
vendor: 1,730 bytes, lines 1-2
1alues(),this.renderAll(),this.trigger("clear")}handleOptions(){this.options.element instanceof HTMLElement||(this.options.element=this.options.doc.querySelector(this.options.element)),"function"==typeof this.options.documentClick&&document.addEventListener("click",this.options.documentClick,!0),this.options.element instanceof HTMLInputElement&&(this.options.element.readOnly=this.options.readonly),this.options.date?this.calendars[0]=new e(this.options.date,this.options.format):this.calendars[0]=new e}handleCSS(){if(Array.isArray(this.options.css))this.options.css.forEach((e=>{const s=document.createElement("link");s.href=e,s.rel="stylesheet";const i=()=>{this.cssLoaded++,this.cssLoaded===this.options.css.length&&(this.ui.wrapper.style.display="")};s.addEventListener("load",i),s.addEventListener("error",i),this.ui.shadowRoot.append(s)}));else if("string"==typeof this.options.css){const e=document.createElement("style"),s=document.createTextNode(this.options.css);e.appendChild(s),this.ui.shadowRoot.append(e),this.ui.wrapper.style.display=""}else"function"==typeof this.options.css&&(this.options.css.call(this,this),this.ui.wrapper.style.display="")}adjustPosition(e){const s=e.getBoundingClientRect(),a=this.ui.wrapper.getBoundingClientRect();this.ui.container.classList.add("calc");const o=this.ui.container.getBoundingClientRect();this.ui.container.classList.remove("calc");let r=s.bottom-a.bottom,c=s.left-a.left;return"undefined"!=typeof window&&(window.innerHeight<r+o.height&&r-o.height>=0&&(r=s.top-a.top-o.height),window.innerWidth<c+o.width&&s.right-o.width>=0&&(c=s.right-a.right-o.width)),{left:c,top:r}}}var s=Object.freeze({__proto__:null,Core:n,create:n});export{n as Core,n as create,s as easepick};
2

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.