PageSourceSearch

https://www.lovisa.co.uk/cdn/shop/t/811/assets/gift-card-calendar.js?v=21889910120467390121789977862

js lovisa.co.uk collected 2026-09-26 13:25:38 UTC 16,511 bytes, 2 lines download raw bytes

1(function(){"use strict";var WRAP_SELECTOR="[data-gc-date-wrap]",DAY_MS=864e5,ICON_PREV='<svg viewBox="0 0 8 14" fill="none" aria-hidden="true" focusable="false"><path d="M6.52344 0.284912C6.60922 0.197321 6.75016 0.197309 6.83594 0.284912L7.59375 1.05933C7.67702 1.14437 7.67702 1.27995 7.59375 1.36499L2.70996 6.35327C2.46046 6.60833 2.46045 7.01619 2.70996 7.27124L7.59375 12.2595C7.67702 12.3446 7.67702 12.4801 7.59375 12.5652L6.83594 13.3396C6.75015 13.4272 6.60922 13.4272 6.52344 13.3396L0.28125 6.96558C0.197983 6.88054 0.197982 6.74398 0.28125 6.65894L6.52344 0.284912Z" fill="currentColor" stroke="currentColor" stroke-width="0.4375"/></svg>',ICON_NEXT='<svg viewBox="0 0 9 14" fill="none" aria-hidden="true" focusable="false"><path d="M0.343654 1.70609C0.177118 1.53601 0.177119 1.26399 0.343654 1.09391L1.10218 0.319249C1.27375 0.14403 1.55581 0.14403 1.72738 0.319249L7.96924 6.69391C8.13577 6.86399 8.13577 7.13601 7.96924 7.30609L1.72738 13.6807C1.55581 13.856 1.27375 13.856 1.10218 13.6807L0.343654 12.9061C0.177119 12.736 0.177119 12.464 0.343654 12.2939L5.22757 7.30608C5.3941 7.13601 5.3941 6.86399 5.22757 6.69391L0.343654 1.70609Z" fill="currentColor" stroke="currentColor" stroke-width="0.4375"/></svg>';function pad(n){return n<10?"0"+n:String(n)}function toIso(y,m,d){return y+"-"+pad(m+1)+"-"+pad(d)}function fromIso(s){var match=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s||"");return match?{y:+match[1],m:+match[2]-1,d:+match[3]}:null}function todayParts(){var now=new Date;return{y:now.getFullYear(),m:now.getMonth(),d:now.getDate()}}function monthIndex(p){return p.y*12+p.m}function daysInMonth(y,m){return new Date(y,m+1,0).getDate()}function Calendar(wrap){if(this.wrap=wrap,this.input=wrap.querySelector("[data-gc-date]"),this.display=wrap.querySelector("[data-gc-date-display]")||this.input,this.trigger=wrap.querySelector("[data-gc-date-open]"),!(!this.input||!this.trigger)){if(this.lang=this.resolveLocale(),this.weekStart=window.theme&&window.theme.store==="US"?0:1,this.monthFormat=new Intl.DateTimeFormat(this.lang,{month:"long",year:"numeric"}),this.weekdayFormat=new Intl.DateTimeFormat(this.lang,{weekday:"short"}),this.dayLabelFormat=new Intl.DateTimeFormat(this.lang,{weekday:"long",day:"numeric",month:"long",year:"numeric"}),this.displayFormat=new Intl.DateTimeFormat(this.lang,{day:"2-digit",month:"2-digit",year:"numeric"}),this.partOrder=["day","month","year"],this.separator="/",typeof this.displayFormat.formatToParts=="function"){for(var parts=this.displayFormat.formatToParts(new Date(2001,
11,3)),order=[],p=0;p<parts.length;p++)parts[p].type==="day"||parts[p].type==="month"||parts[p].type==="year"?order.push(parts[p].type):parts[p].type==="literal"&&this.separator==="/"&&parts[p].value.trim()&&(this.separator=parts[p].value.trim());order.length===3&&(this.partOrder=order)}this.display!==this.input&&(this.placeholderText=this.display.getAttribute("placeholder")||"",this.display.setAttribute("data-gc-format",this.skeleton()),this.display.addEventListener("input",this.onTyped.bind(this)),this.display.addEventListener("focus",this.onDisplayFocus.bind(this)),this.display.addEventListener("blur",this.onDisplayBlur.bind(this))),this.display!==this.input&&this.input.value&&!this.display.value&&(this.display.value=this.formatIso(this.input.value)),this.root=document.createElement("div"),this.root.className="pdp-gc-cal",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",wrap.getAttribute("data-gc-cal-label")||""),this.root.hidden=!0,wrap.appendChild(this.root),this.trigger.setAttribute("aria-haspopup","dialog"),this.trigger.setAttribute("aria-expanded","false"),this.onDocumentPointer=this.onDocumentPointer.bind(this),this.onKeydown=this.onKeydown.bind(this),this.onFocusOut=this.onFocusOut.bind(this),this.trigger.addEventListener("click",this.toggle.bind(this)),this.root.addEventListener("click",this.onClick.bind(this));var calendar=this;this.lastTextBlur=0,document.addEventListener("focusout",function(event){isTextControl(event.target)&&(calendar.lastTextBlur=Date.now())},!0)}}Calendar.prototype.resolveLocale=function(){var lang=(document.documentElement.lang||"").trim();return!lang||/^en$/i.test(lang)?window.theme&&window.theme.store==="US"?"en-US":"en-GB":lang},Calendar.prototype.range=function(){var min=fromIso(this.input.min)||todayParts(),max=fromIso(this.input.max);return{min:min,max:max,minIso:toIso(min.y,min.m,min.d),maxIso:max?toIso(max.y,max.m,max.d):null}},Calendar.prototype.toggle=function(){this.trigger.disabled||this.input.disabled||this.display.disabled||(this.root.hidden?this.open():this.close())},Calendar.prototype.formatIso=function(isoValue){var parts=fromIso(isoValue);return parts?this.displayFormat.format(new Date(parts.y,parts.m,parts.d)):""},Calendar.prototype.parseTyped=function(text){var digits=String(text||"").trim().split(/[^0-9]+/).filter(function(s){return s.length});if(digits.length!==3)return null;for(var values={},i=0;i<3;i++)values[this.partOrder[i]]=digits[i];var year=values.year;if(year.length===2&&(year="20"+year),year.length!==4)return null;var y=+year,m=+values.month,d=+values.day;return m<1||m>12||d<1||d>daysInMonth(y,m-1)?null:toIso(y,m-1,d)},Calendar.prototype.mask=function(digits){for(var lengths={day:2,month:2,year:4},out="",index=0,i=0;i<this.partOrder.length;i++){var length=lengths[this.partOrder[i]],chunk=digits.substr(index,length);if(!chunk.length||(out+=(out.length?this.separator:"")+chunk,index+=length,chunk.length<length))break}return out},Calendar.prototype.skeleton=function(){for(var tokens={day:"DD",month:"MM",year:"YYYY"},out=[],i=0;i<this.partOrder.length;i++)out.push(tokens[this.partOrder[i]]);return out.join(this.separator)},Calendar.prototype.digitsFromText=function(raw){var tokens=raw.split(/[^0-9]+/);if(tokens.length<2)return raw.replace(/\D/g,"").slice(0,8);for(var lengths={day:2,month:2,year:4},out="",i=0;i<tokens.length&&i<3;i++){var token=tokens[i],part=this.partOrder[i];i===tokens.length-1?out+=token:(part!=="year"&&token.length===1&&(token="0"+token),out+=token.slice(0,lengths[part]||4))}return out.slice(0,8)},Calendar.prototype.onTyped=function(){var raw=this.display.value,plainDigits=raw.replace(/\D/g,"").slice(0,8),digits;if(this.lastDigits&&plainDigits===this.lastDigits&&raw.length<(this.lastMasked||"").length){var caret=typeof this.display.selectionStart=="number"?this.display.selectionStart:raw.length,before=raw.slice(0,caret).replace(/\D/g,"").length,at=Math.max(0,before-1);digits=plainDigits.slice(0,at)+plainDigits.slice(at+1)}else digits=this.digitsFromText(raw);var masked=this.mask(digits),separatorTyped=/[^0-9]$/.test(raw)&&(this.lastDigits==null||plainDigits===this.lastDigits);if(masked&&separatorTyped&&(digits.length===2||digits.length===4)&&(masked+=this.separator),this.lastDigits=digits,this.lastMasked=masked,this.display.value!==masked){this.display.value=masked;try{this.display.setSelectionRange(masked.length,masked.length)}catch(error){}}var iso=digits.length>=6?this.parseTyped(masked):null;this.input.value=iso||"",this.input.dispatchEvent(new Event("input",{bubbles:!0}))},Calendar.prototype.onDisplayFocus=function(){this.display.value||this.display.setAttribute("placeholder",this.skeleton())},Calendar.prototype.onDisplayBlur=function(){this.input.value&&(this.display.value=this.formatIso(this.input.value),this.lastDigits=null,this.lastMasked=null),this.display.setAttribute("placeholder",this.placeholderText||"")},Calendar.prototype.place=function(){var PANEL=348,rect=this.wrap.getBoundingClientRect(),viewportHe
1ight=window.innerHeight||document.documentElement.clientHeight,below=viewportHeight-rect.bottom,above=rect.top;this.root.classList.toggle("pdp-gc-cal--above",below<PANEL&&above>below)};function cssPx(name){if(typeof window.getComputedStyle!="function")return 0;var value=parseFloat(window.getComputedStyle(document.documentElement).getPropertyValue(name));return isFinite(value)?value:0}function isTextControl(node){if(!node||!node.tagName)return!1;var tag=node.tagName.toLowerCase();if(tag==="textarea")return!0;if(tag!=="input")return!1;var type=(node.getAttribute("type")||"text").toLowerCase();return!/^(button|submit|reset|checkbox|radio|range|color|file|hidden|image)$/.test(type)}Calendar.prototype.ensureVisible=function(alreadyFlipped){if(!this.root.hidden){var vv=window.visualViewport,viewTop=vv?vv.offsetTop:0,viewHeight=vv?vv.height:window.innerHeight||document.documentElement.clientHeight,CUSHION=8,chromeTop=cssPx("--pdp-sticky-top"),chromeBottom=document.body.classList.contains("pdp-atb-sticky-active")?cssPx("--pdp-atb-sticky-height"):0,top=viewTop+(chromeTop>0?chromeTop:CUSHION),bottom=viewTop+viewHeight-chromeBottom-CUSHION,rect=this.root.getBoundingClientRect(),delta=0;if(rect.bottom>bottom&&(delta=rect.bottom-bottom),rect.top-delta<top&&(delta=rect.top-top),!(Math.abs(delta)<1)){var doc=document.documentElement,scrollY=window.pageYOffset||doc.scrollTop||0,maxDown=Math.max(0,doc.scrollHeight-(scrollY+(window.innerHeight||doc.clientHeight))),maxUp=Math.max(0,scrollY),above=this.root.classList.contains("pdp-gc-cal--above");if(!alreadyFlipped){if(delta>maxDown+1&&!above)return this.root.classList.add("pdp-gc-cal--above"),this.ensureVisible(!0);if(-delta>maxUp+1&&above)return this.root.classList.remove("pdp-gc-cal--above"),this.ensureVisible(!0)}if(delta>maxDown&&(delta=maxDown),-delta>maxUp&&(delta=-maxUp),!(Math.abs(delta)<1)){var reduced=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;try{window.scrollBy({top:delta,left:0,behavior:reduced?"auto":"smooth"})}catch(error){window.scrollBy(0,delta)}}}}},Calendar.prototype.open=function(){var selected=fromIso(this.input.value),range=this.range(),anchor=selected||range.min;this.view={y:anchor.y,m:anchor.m},this.render(),this.place(),this.root.hidden=!1,this.trigger.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",this.onDocumentPointer,!0),document.addEventListener("keydown",this.onKeydown,!0),this.root.addEventListener("focusout",this.onFocusOut);var focusTarget=this.root.querySelector(".pdp-gc-cal__day.is-selected:not(:disabled)")||this.root.querySelector(".pdp-gc-cal__day:not(:disabled)")||this.root.querySelector(".pdp-gc-cal__nav:not(:disabled)"),active=document.activeElement,keyboardClosing=isTextControl(active)||Date.now()-this.lastTextBlur<1e3;if(focusTarget)try{focusTarget.focus({preventScroll:!0})}catch(error){focusTarget.focus()}this.settleVisibility(keyboardClosing)},Calendar.prototype.settleVisibility=function(waitForViewport){var self=this;if(this.cancelVisibility(),!waitForViewport){typeof window.requestAnimationFrame=="function"?this.visibilityFrame=window.requestAnimationFrame(function(){self.visibilityFrame=null,self.ensureVisible(!1)}):self.ensureVisible(!1);return}var vv=window.visualViewport,run=function(){self.cancelVisibility(),self.ensureVisible(!1)},onResize=function(){clearTimeout(self.visibilityTimer),self.visibilityTimer=setTimeout(run,150)};this.visibilityResize=onResize,vv&&vv.addEventListener("resize",onResize),window.addEventListener("resize",onResize),this.visibilityTimer=setTimeout(run,700)},Calendar.prototype.cancelVisibility=function(){this.visibilityTimer&&(clearTimeout(this.visibilityTimer),this.visibilityTimer=null),this.visibilityFrame&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(this.visibilityFrame),this.visibilityFrame=null,this.visibilityResize&&(window.visualViewport&&window.visualViewport.removeEventListener("resize",this.visibilityResize),window.removeEventListener("resize",this.visibilityResize),this.visibilityResize=null)},Calendar.prototype.close=function(returnFocus){this.root.hidden||(this.root.hidden=!0,this.cancelVisibility(),this.trigger.setAttribute("aria-expanded","fal
1se"),document.removeEventListener("pointerdown",this.onDocumentPointer,!0),document.removeEventListener("keydown",this.onKeydown,!0),this.root.removeEventListener("focusout",this.onFocusOut),returnFocus!==!1&&this.trigger.focus())},Calendar.prototype.onDocumentPointer=function(event){this.wrap.contains(event.target)||this.close(!1)},Calendar.prototype.onFocusOut=function(event){var next=event.relatedTarget;next&&!this.root.contains(next)&&next!==this.trigger&&this.close(!1)},Calendar.prototype.onKeydown=function(event){if(!this.root.hidden){if(event.key==="Escape"){event.preventDefault(),this.close();return}var day=event.target&&event.target.closest?event.target.closest(".pdp-gc-cal__day"):null;if(day){var delta={ArrowLeft:-1,ArrowRight:1,ArrowUp:-7,ArrowDown:7}[event.key];delta&&(event.preventDefault(),this.moveFocus(+day.getAttribute("data-day"),delta))}}},Calendar.prototype.moveFocus=function(fromDay,delta){var target=fromDay+delta,button=this.root.querySelector('.pdp-gc-cal__day[data-day="'+target+'"]:not(:disabled)');button&&button.focus()},Calendar.prototype.onClick=function(event){var nav=event.target.closest(".pdp-gc-cal__nav");if(nav&&!nav.disabled){this.shiftMonth(nav.classList.contains("pdp-gc-cal__nav--prev")?-1:1);return}var day=event.target.closest(".pdp-gc-cal__day");day&&!day.disabled&&this.select(+day.getAttribute("data-day"))},Calendar.prototype.shiftMonth=function(delta){var index=monthIndex(this.view)+delta;this.view={y:Math.floor(index/12),m:index%12},this.render();var nav=this.root.querySelector(delta<0?".pdp-gc-cal__nav--prev":".pdp-gc-cal__nav--next");if(nav&&!nav.disabled)nav.focus();else{var first=this.root.querySelector(".pdp-gc-cal__day:not(:disabled)");first&&first.focus()}},Calendar.prototype.select=function(day){var iso=toIso(this.view.y,this.view.m,day);this.input.value=iso,this.display!==this.input&&(this.display.value=this.formatIso(iso)),this.lastDigits=null,this.lastMasked=null,this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.input.dispatchEvent(new Event("change",{bubbles:!0})),this.close()},Calendar.prototype.render=function(){var range=this.range(),view=this.view,viewIndex=monthIndex(view),today=todayParts(),todayIso=toIso(today.y,today.m,today.d),selectedIso=this.input.value,prevDisabled=viewIndex-1<monthIndex(range.min),nextDisabled=range.max?viewIndex+1>monthIndex(range.max):!1,html="";html+='<div class="pdp-gc-cal__header">',html+='<button type="button" class="pdp-gc-cal__nav pdp-gc-cal__nav--prev" aria-label="'+this.escape(this.wrap.getAttribute("data-gc-cal-prev")||"")+'"'+(prevDisabled?" disabled":"")+">"+ICON_PREV+"</button>",html+='<span class="pdp-gc-cal__title" aria-live="polite">'+this.escape(this.monthFormat.format(new Date(view.y,view.m,1)))+"</span>",html+='<button type="button" class="pdp-gc-cal__nav pdp-gc-cal__nav--next" aria-label="'+this.escape(this.wrap.getAttribute("data-gc-cal-next")||"")+'"'+(nextDisabled?" disabled":"")+">"+ICON_NEXT+"</button>",html+="</div>",html+='<div class="pdp-gc-cal__weekdays" aria-hidden="true">';for(var w=0;w<7;w++){var weekday=(this.weekStart+w)%7,initials=this.weekdayFormat.format(new Date(1970,0,4+weekday)).replace(/\.$/,"").slice(0,2);html+='<span class="pdp-gc-cal__weekday">'+this.escape(initials)+"</span>"}html+="</div>";var firstWeekday=new Date(view.y,view.m,1).getDay(),lead=(firstWeekday-this.weekStart+7)%7,count=daysInMonth(view.y,view.m);html+='<div class="pdp-gc-cal__grid" role="grid">';for(var cell=0;cell<42;cell++){var dayNumber=cell-lead+1;if(dayNumber<1||dayNumber>count){html+='<span class="pdp-gc-cal__cell" aria-hidden="true"></span>';continue}var iso=toIso(view.y,view.m,dayNumber),disabled=iso<range.minIso||range.maxIso!==null&&iso>range.maxIso,classes="pdp-gc-cal__day";iso===todayIso&&(classes+=" is-today"),iso===selectedIso&&(classes+=" is-selected"),html+='<span class="pdp-gc-cal__cell">',html+='<button type="button" class="'+classes+'" data-day="'+dayNumber+'"'+(disabled?" disabled":"")+(iso===selectedIso?' aria-pressed="true"':"")+' aria-label="'+this.escape(this.dayLabelFormat.format(new Date(view.y,view.m,dayNumber)))+'">'+dayNumber+"</button>",html+="</span>"}
1html+="</div>",this.root.innerHTML=html},Calendar.prototype.escape=function(value){return String(value).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")};function init(){for(var wraps=document.querySelectorAll(WRAP_SELECTOR),i=0;i<wraps.length;i++)wraps[i].__gcCalendar||(wraps[i].__gcCalendar=new Calendar(wraps[i]))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/811/assets/gift-card-calendar.js.map?v=21889910120467390121789977862

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.