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I,EAAGA,EAAIP,EAAYO,IAAK,CAChC,IAAImC,EAAcD,EAAYE,OAAOpC,GACrCE,EAAOF,GAAGQ,OAAO2B,EAAaR,EAClC,CACJ,EAIJ,MAAMpB,EAEFxC,YAAYC,GACRC,KAAKD,GAAKA,EACVC,KAAKoE,QAAU,KACfpE,KAAKqE,OAASrE,KAAKD,GAAGW,cAAc,uBACpCV,KAAKsE,QAAUtE,KAAKD,GAAGW,cAAc,wBACrCV,KAAKuE,KAAO,GAChB,CAEAhC,OAAO2B,EAAaR,GACbA,EAEC1D,KAAKqE,OAAOrC,UAAYkC,EAClBA,GAAelE,KAAKuE,OAE1BvE,KAAKsE,QAAQtC,UAAYkC,EAEzBlE,KAAKD,GAAGyD,UAAUC,IAAI,SACtBzD,KAAKoE,QAAUnB,YAAW,KACtBjD,KAAKqE,OAAOrC,UAAYkC,EACxBlE,KAAKD,GAAGyD,UAAUgB,OAAO,SACzBxB,aAAahD,KAAKoE,SAClBpE,KAAKoE,QAAU,IAAI,GACpB,MAEPpE,KAAKuE,KAAOL,CAChB,EAIG,SAASO,EAAWC,GACvBA,EAASvC,SAASwC,IAEQ,IAAlBA,EAAKC,UACL,IAAI/E,EAAU8E,EAClB,GAER,C","sources":["webpack://riat/./wwwroot/app/src/modules/countdown/countdown.js"],"sourcesContent":["import { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\nimport './countdown.scss';\r\n\r\nconst numbersHtml = '
0
1
',\r\n _day = 1000 * 60 * 60 * 24,\r\n _hour = 1000 * 60 * 60,\r\n _minute = 1000 * 60;\r\n\r\nclass Countdown {\r\n\r\n constructor(el) {\r\n\r\n this.el = el;\r\n this.active = false;\r\n this.width = 0;\r\n this.resizeRequested = false;\r\n this.resizeTimeout = null;\r\n this.columnSettings = el.dataset.columns.toLowerCase();\r\n this.stage = el.querySelector('.countdown--stage');\r\n this.liveAlert = el.querySelector('.countdown--live-alert');\r\n\r\n // parse deadline and set to zero if not valid\r\n this.deadline = new Date(el.dataset.deadline).getTime();\r\n if(isNaN(this.deadline)) this.deadline = 0;\r\n\r\n // column structure\r\n this.columns = {\r\n days: {\r\n render: this.columnSettings.indexOf('d') >= 0\r\n },\r\n hours: {\r\n render: this.columnSettings.indexOf('h') >= 0\r\n },\r\n minutes: {\r\n render: this.columnSettings.indexOf('m') >= 0\r\n },\r\n seconds: {\r\n render: this.columnSettings.indexOf('s') >= 0\r\n }\r\n };\r\n\r\n // get initial remaining values\r\n let r = this.getRemaining();\r\n\r\n // set digit count for each column\r\n this.columns.days.digitCount = Math.max(r.days.toString().length, 2);\r\n this.columns.hours.digitCount = Math.max(r.hours.toString().length, 2);\r\n this.columns.minutes.digitCount = Math.max(r.minutes.toString().length, 2);\r\n this.columns.seconds.digitCount = Math.max(r.seconds.toString().length, 2);\r\n\r\n // build and add initial html content\r\n let c = '',\r\n nHtml = numbersHtml;\r\n if(this.columns.days.render) {\r\n c += '
';\r\n for(let x = 0; x < this.columns.days.digitCount; x++) c+= nHtml;\r\n c += '
Days
';\r\n }\r\n if(this.columns.hours.render) {\r\n c += '
';\r\n for(let x = 0; x < this.columns.hours.digitCount; x++) c+= nHtml;\r\n c += '
Hrs
';\r\n }\r\n if(this.columns.minutes.render) {\r\n c += '
';\r\n for(let x = 0; x < this.columns.minutes.digitCount; x++) c+= nHtml;\r\n c += '
Mins
';\r\n }\r\n if(this.columns.seconds.render) {\r\n c += '
';\r\n for(let x = 0; x < this.columns.seconds.digitCount; x++) c+= nHtml;\r\n c += '
Secs
';\r\n }\r\n this.stage.innerHTML = c;\r\n\r\n // store digits\r\n if(this.columns.days.render) {\r\n this.columns.days.digits = [];\r\n [...this.stage.querySelectorAll('.column--days .column--digits')].forEach((digitElement) => {\r\n this.columns.days.digits.push(new ColumnDigit(digitElement));\r\n });\r\n }\r\n if(this.columns.hours.render) {\r\n this.columns.hours.digits = [];\r\n [...this.stage.querySelectorAll('.column--hours .column--digits')].forEach((digitElement) => {\r\n this.columns.hours.digits.push(new ColumnDigit(digitElement));\r\n });\r\n }\r\n if(this.columns.minutes.render) {\r\n this.columns.minutes.digits = [];\r\n [...this.stage.querySelectorAll('.column--minutes .column--digits')].forEach((digitElement) => {\r\n this.columns.minutes.digits.push(new ColumnDigit(digitElement));\r\n });\r\n }\r\n if(this.columns.seconds.render) {\r\n this.columns.seconds.digits = [];\r\n [...this.stage.querySelectorAll('.column--seconds .column--digits')].forEach((digitElement) => {\r\n this.columns.seconds.digits.push(new ColumnDigit(digitElement));\r\n });\r\n }\r\n // update columns\r\n this.update(true);\r\n\r\n // add resizeObserver to adjust the scale of the countdown if too wide for container\r\n this.ro = new ResizeObserver(entries => {\r\n for (let entry of entries) {\r\n const cr = entry.contentRect;\r\n if(cr.width != this.width) {\r\n this.width = Math.round(cr.width);\r\n if(!this.resizeRequested) {\r\n this.requestResize();\r\n }\r\n }\r\n }\r\n });\r\n this.ro.observe(this.el); // Watch dimension changes wrapping element\r\n }\r\n\r\n requestResize() {\r\n clearTimeout(this.resizeTimeout);\r\n this.resizeRequested = true;\r\n this.resizeTimeout = setTimeout(() => {\r\n this.resize();\r\n }, 100);\r\n }\r\n\r\n resize() {\r\n let stageWidth = this.stage.offsetWidth;\r\n //console.log(stageWidth + \" : \" + this.width);\r\n let scale = stageWidth > this.width ? (this.width / stageWidth) : 1;\r\n this.el.style.setProperty('--scale', `${scale}`);\r\n //console.log(stageWidth + ' : ' + this.width + ' = scale: ' + scale);\r\n // reset resizeRequested\r\n this.resizeRequested = false;\r\n // make active?\r\n if(!this.active) {\r\n this.el.classList.add('active');\r\n this.active = true;\r\n }\r\n }\r\n\r\n update(initial) {\r\n // initial = boolean : is this the first update (no animation)?\r\n // calculate the differences between now and deadline\r\n let r = this.getRemaining();\r\n // update accessible content with all relevant values\r\n let alertContent = 'Counting down: ';\r\n if(r.days > 0 && this.columns.days.render) alertContent += (r.days + ' days, ');\r\n if((r.days > 0 || r.hours > 0) && this.columns.hours.render) alertContent += (r.hours + ' hours, ');\r\n if((r.days > 0 || r.hours > 0 || r.minutes > 0) && this.columns.minutes.render) alertContent += (r.minutes + ' minutes, ');\r\n if(this.columns.seconds.render) alertContent += (r.seconds + ' seconds.');\r\n this.liveAlert.innerHTML = alertContent;\r\n // update digits?\r\n if(this.columns.days.render) this.updateDigits(r.days, this.columns.days.digitCount, this.columns.days.digits, initial);\r\n if(this.columns.hours.render) this.updateDigits(r.hours, this.columns.hours.digitCount, this.columns.hours.digits, initial);\r\n if(this.columns.minutes.render) this.updateDigits(r.minutes, this.columns.minutes.digitCount, this.columns.minutes.digits, initial);\r\n if(this.columns.seconds.render) this.updateDigits(r.seconds, this.columns.seconds.digitCount, this.columns.seconds.digits, initial);\r\n\r\n // trigger again in 1 second (if still needed)\r\n if(!r.complete) {\r\n setTimeout(()=> {\r\n this.update(false);\r\n },1000);\r\n }\r\n }\r\n\r\n getRemaining() {\r\n // calculate the differences between now and deadline\r\n let now = new Date().getTime(),\r\n r = this.deadline - now;\r\n if(r < 0) r = 0;\r\n // get column values\r\n let _days = Math.floor(r / _day),\r\n _hours = this.columns.days.render ? Math.floor((r % _day) / _hour) : Math.floor(r / _hour),\r\n _minutes = this.columns.hours.render ? Math.floor((r % _hour) / _minute) : Math.floor(r / _minute),\r\n _seconds = this.columns.minutes.render ? Math.floor((r % _minute) / 1000) : Math.floor(r / 1000);\r\n // return as object\r\n return {\r\n days: _days,\r\n hours: _hours,\r\n minutes: _minutes,\r\n seconds: _seconds,\r\n complete: r == 0\r\n }\r\n }\r\n\r\n updateDigits(total, digitCount, digits, initial) {\r\n // total = int : amount remaining\r\n // digitCount = int : number of digits in the column (3 or 2)\r\n // digits = array : of digit dom elements\r\n // initial = boolean : is this the first update (no animation)?\r\n // get total as a string and match number of digits\r\n let totalString = total.toString();\r\n while(totalString.length < digitCount) totalString = '0' + totalString;\r\n // loop through digits\r\n for(let x = 0; x < digitCount; x++) {\r\n let digitNumber = totalString.charAt(x);\r\n digits[x].update(digitNumber, initial);\r\n }\r\n }\r\n\r\n}\r\n\r\nclass ColumnDigit {\r\n\r\n constructor(el) {\r\n this.el = el;\r\n this.timeout = null;\r\n this.nowObj = this.el.querySelector('.column--digits-now');\r\n this.nextObj = this.el.querySelector('.column--digits-next');\r\n this.prev = '0';\r\n }\r\n\r\n update(digitNumber, initial) {\r\n if(initial) {\r\n // just put number into 'now' element\r\n this.nowObj.innerHTML = digitNumber;\r\n } else if(digitNumber != this.prev) {\r\n // put number into 'next' element\r\n this.nextObj.innerHTML = digitNumber;\r\n // animate\r\n this.el.classList.add('shift');\r\n this.timeout = setTimeout(() => {\r\n this.nowObj.innerHTML = digitNumber;\r\n this.el.classList.remove('shift');\r\n clearTimeout(this.timeout);\r\n this.timeout = null;\r\n }, 900);\r\n }\r\n this.prev = digitNumber;\r\n }\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new Countdown(node);\r\n }\r\n });\r\n}"],"names":["ResizeObserver","window","Polyfill","_day","_hour","_minute","Countdown","constructor","el","this","active","width","resizeRequested","resizeTimeout","columnSettings","dataset","columns","toLowerCase","stage","querySelector","liveAlert","deadline","Date","getTime","isNaN","days","render","indexOf","hours","minutes","seconds","r","getRemaining","digitCount","Math","max","toString","length","c","nHtml","x","innerHTML","digits","querySelectorAll","forEach","digitElement","push","ColumnDigit","update","ro","entries","entry","cr","contentRect","round","requestResize","observe","clearTimeout","setTimeout","resize","stageWidth","offsetWidth","scale","style","setProperty","classList","add","initial","alertContent","updateDigits","complete","now","floor","total","totalString","digitNumber","charAt","timeout","nowObj","nextObj","prev","remove","createFrom","wrappers","node","nodeType"],"sourceRoot":""}