-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamaze.deployable.js
1 lines (1 loc) · 18 KB
/
amaze.deployable.js
1
if(/vista.adp.com/.test(window.location)){var body=document.body,amazei18n=document.createElement("script");amazei18n.setAttribute("type","text/javascript"),amazei18n.setAttribute("rel","amaze"),amazei18n.setAttribute("class","amaze-i18n"),amazei18n.setAttribute("role","presentation"),amazei18n.setAttribute("aria-hidden","true"),amazei18n.innerHTML='window.__amazei18n = { "title": { "en": "Title", "es": "Titulo", "de": "Titel", "fr": "Titre", "cn": "\u6A19\u984C" }}';var amazeGlobalCss=document.createElement("div");amazeGlobalCss.setAttribute("rel","amaze"),amazeGlobalCss.setAttribute("class","amaze-global-css"),amazeGlobalCss.setAttribute("role","presentation"),amazeGlobalCss.setAttribute("aria-hidden","true"),amazeGlobalCss.innerHTML="­<style>.amaze-test { display: none;}*:focus { box-shadow: #fff 0 0 0 1px,#476bc3 0 0 0 3px!important;}.collapsed { display: none;}</style>";var amazeCss=document.createElement("div");amazeCss.setAttribute("rel","amaze"),amazeCss.setAttribute("class","amaze-local-css"),amazeCss.setAttribute("role","presentation"),amazeCss.setAttribute("aria-hidden","true"),amazeCss.innerHTML="­<style></style>";var script=document.createElement("script");script.setAttribute("type","text/javascript"),script.setAttribute("rel","amaze"),script.setAttribute("class","amaze-js"),script.setAttribute("role","presentation"),script.setAttribute("aria-hidden","true"),script.innerHTML='(()=>{var Ae=Object.create,R=Object.defineProperty,Ee=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty,qe=Object.getOwnPropertyNames,Se=Object.getOwnPropertyDescriptor;var xe=e=>R(e,"__esModule",{value:!0});var m=(e,t)=>()=>(t||(t={exports:{}},e(t.exports,t)),t.exports);var ke=(e,t,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qe(t))!_e.call(e,o)&&o!=="default"&&R(e,o,{get:()=>t[o],enumerable:!(i=Se(t,o))||i.enumerable});return e},we=e=>ke(xe(R(e!=null?Ae(Ee(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var ne=m(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.default=(e,t,i,o)=>{if(!e)return console.error("addEventHandler: element is required but missing"),!1;if(typeof e=="string")return console.error("addEventHandler: type element is not an HTMLElement"),!1;if(!t||!t.length)return console.error("addEventHandler: at least one handler is required (click, keydown, etc.)"),!1;if(!i||!i.length)return console.error("addEventHandler: an array of functions is required but missing"),!1;let u="data-amaze-event";o&&o.checkString&&(u=`data-${o.checkString}`),t.forEach((b,g)=>{e.getAttribute(u)||(e.addEventListener(b,i[g]),e.setAttribute(u,"true"))})}});var ie=m(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.default=e=>!e||!e.length?(console.error("blacklist: missing urlArray"),!1):!!e.includes(window.location.pathname)});var V=m(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});var Te=(e,t=document.body)=>e?typeof e=="string"?(console.error("insertAfter: newNode must be an HTMLElement"),!1):(t.parentNode.insertBefore(e,t.nextSibling),!0):(console.error("insertAfter: the new node was not supplied"),!1);I.default=Te});var oe=m(x=>{"use strict";var Le=x&&x.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(x,"__esModule",{value:!0});var Me=Le(V()),Pe=(e,t,i,o)=>{if(!e)return console.error("changeElement: no initial element provided"),!1;if(typeof e=="string")return console.error("changeElement: el must be an HTMLElement"),!1;if(!t)return console.error("changeElement: nothing provided to change the element to"),!1;let u=document.createElement(t),b=document.createTextNode(e.innerText);u.appendChild(b);let g=e.attributes;if(g)for(let p=0;p<g.length;p++){let v=g[p];u.setAttribute(v.name,v.value?v.value:"")}i&&(u.innerHTML=e.innerHTML),Me.default(u,e),e.remove(),o&&o(u)};x.default=Pe});var k=m(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.default=(e,t)=>{if(!e)return console.error("setAttributes: missing required el"),!1;if(!t)return console.error("setAttributes: missing object of attributes and values you are wanting to add"),!1;if(t&&!Object.keys(t).length)return console.error("setAttributes: supplied attributes is not an object or has no key value pairs"),!1;for(let i of Object.keys(t))e.setAttribute(i,t[i]);return!0}});var se=m(w=>{"use strict";var Ce=w&&w.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(w,"__esModule",{value:!0});var Oe=Ce(k());w.default=e=>e?(Oe.default(e,{tabindex:"0",role:"button"}),console.info("fixButton: you will need to create event handlers for this element",e),!0):(console.error("fixButton: no element provided"),!1)});var le=m(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var je=e=>{let t=e.offsetParent,i=window.getComputedStyle(e),o=e.getAttribute("aria-hidden");return!!(t===null||i.display==="none"||o&&o==="true")},ae=e=>e.disabled||je(e)&&e.nodeName.toUpperCase()!=="AREA",He=e=>{if(!e||ae(e))return!1;switch(e.nodeName.toUpperCase()){case"A":case"AREA":if(e.href)return!0;break;case"INPUT":return e.type!=="hidden";case"TEXTAREA":case"SELECT":case"DETAILS":case"BUTTON":return!0}return!1},De=e=>{if(ae(e))return!1;if(He(e))return!0;let t=e.getAttribute("tabindex");return!!(t&&!isNaN(parseInt(t,10))&&parseInt(t,10)>-1)};U.default=e=>e?Array.from(e.querySelectorAll("*")).map(o=>{if(De(o))return o}).filter(o=>{if(o!==void 0)return o}):(console.error("getFocusable: no element supplied to get focusables"),!1)});var ue=m(T=>{"use strict";var Fe=T&&T.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(T,"__esModule",{value:!0});var Re=Fe(k()),Be=(e,t,i)=>{if(t.querySelectorAll(".amaze-live-region").length)return;let o=i||{ariaAtomic:"false",ariaRelevant:"additions"},u=document.createElement("div");Re.default(u,{role:"log","aria-live":e,"aria-atomic":o.ariaAtomic,"aria-relevant":o.ariaRelevant,class:"amaze-live-region",id:`amaze-live-region-${e}`}),t.appendChild(u)};T.default=(e,t=document.body,i)=>e?e!=="polite"&&e!=="assertive"?(console.error("liveRegion: invalid type"),!1):(Be(e,t,i),!0):(console.error("liveRegion: type missing"),!1)});var ce=m($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});var ze=()=>(document.documentElement.getAttribute("lang")||"en").trim().toLowerCase();$.default=(e,t,i)=>{if(!e)return console.error("localization: missing the id from your json file"),!1;let o=t||ze(),u=window.__amazei18n[e][o];for(let b=0;b<i.length;b++){let g=new RegExp(`\\\\{${b}\\\\}`,"g");u=u.replace(g,i[b])}return u}});var G=m(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.default=(e,t,i)=>{if(!e)return console.error("mutationObserver: missing required element (Document or HTMLElement"),!1;if(!i)return console.error("mutationObserver: missing required callback function to run on mutation events"),!1;if(i&&typeof i=="string")return console.error("mutationObserver: callback should be a function"),!1;let u=Object.assign({attributes:!1,characterData:!1,childList:!0,subtree:!0},t);return new MutationObserver(i).observe(e,u)}});var Z=m(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.default=(e=16)=>{let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",i="amaze-";for(let o=0;o<e;o++)i+=t[Math.round(Math.random()*(t.length-1))];return i}});var de=m(L=>{"use strict";var Ie=L&&L.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(L,"__esModule",{value:!0});var Ve=Ie(Z()),Ne=/s+/,fe=e=>(e.getAttribute("id")||e.setAttribute("id",Ve.default()),!0);L.default=(e,t,i)=>{if(!e)return console.error("noClobber: missing required el"),!1;if(typeof e=="string")return console.error("noClobber: type of el must be an HTMLElement"),!1;if(!t)return console.error("noClobber: which attr are you trying to modify?"),!1;if(typeof t!="string")return console.error("noClobber: attr must be a string"),!1;if(!i)return console.error("noClobber: missing attr value"),!1;if(typeof i!="string")return console.error("noClobber: value must be a string"),!1;let o=e.getAttribute(t);if(o){let u=o.split(Ne);if(u.indexOf(i)<0)return u.push(i),e.setAttribute(t,u.join(" ")),fe(e),!0}return e.setAttribute(t,i),fe(e),!0}});var me=m(M=>{"use strict";var be=M&&M.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(M,"__esModule",{value:!0});var Ue=be(k()),$e=be(G());M.default=(e,t,i,o,u)=>{if(!e){console.error("trapFocus: missing modal element (HTMLElement)");return}t||console.error("trapFocus: missing modal trigger button (HTMLElement)");let b=document.querySelectorAll("iframe"),g=Array.from(document.body.querySelectorAll("*")),p=Array.from(e.querySelectorAll("*")),v=Array.from(e.querySelectorAll("button, a, [role=button], [role=link]"))[0],C=(()=>g.filter(a=>a!==e&&!p.includes(a)))(),A=a=>{let c=a.getAttribute("data-amaze-tabindex");c!==null&&c!=="undefined"?a.setAttribute("tabindex",c):a.removeAttribute("tabindex"),a.removeAttribute("aria-hidden"),a.removeAttribute("data-amaze-hide"),a.removeAttribute("data-amaze-tabindex")},S=a=>{let c=a.getAttribute("tabindex");c&&(c==="0"||c==="-1")&&a.setAttribute("data-amaze-tabindex",c),Ue.default(a,{"aria-hidden":"true","data-amaze-hide":"true",tabindex:"-1"})},O=()=>(b.length&&b.forEach(a=>S(a)),C.forEach(a=>S(a))),E=()=>{let a=document.querySelectorAll("[data-amaze-hide]");return b.length&&b.forEach(c=>A(c)),a.forEach(c=>A(c))},j=()=>{let a=e,c=[];for(;a;)c.unshift(a),a=a.parentElement;c.length&&c.forEach(F=>A(F))},H=()=>{p.forEach(a=>A(a))},D=a=>{a.code==="Escape"&&(a.preventDefault(),i[0].click(),E(),t&&setTimeout(()=>t.focus(),500))};if(e.addEventListener("keydown",D,!1),i&&i.length&&i.forEach(a=>{u&&u.length&&u.includes(a)||(a.setAttribute("aria-label","Close modal: press Shift + Enter to close"),a.addEventListener("click",c=>{if(c.preventDefault(),c.target.click(),E(),!!t)return t.focus()}),a.addEventListener("keydown",c=>{(c.code==="Space"||c.code==="Enter")&&(c.preventDefault(),c.target.click())}))}),o&&typeof o=="string"){let a=document.querySelector(o);if(!a)return;$e.default(a,{},()=>{a.style.display==="none"&&E()})}return O(),j(),H(),setTimeout(()=>{v?v.focus():e.focus()},500)}});var ye=m(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});var Ke=(e,t)=>{let i=Object.keys(t).reduce((o,u)=>`${o+=u.split(/(?=[A-Z])/).join("-").toLowerCase()}:${t[u]};`,"");return`${e}{${i}}`};X.default=(e,t)=>{if(!e)return console.error("useCss: no selector provided"),!1;if(typeof e!="string")return console.error("useCss: selector must be a string"),!1;if(!t)return console.error("useCss: no CSS provided"),!1;let i=Ke(e,t),o=document.querySelector(".amaze-local-css");if(!o)return console.error("useCss: could not find target amaze CSS container"),!1;let u=o.querySelector("style");if(u)return u.innerHTML+=`${i}`,!0}});var ge=m(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.default=(e,t)=>{if(!e)return console.error("useRegex: missing urlString regular expression or a callback function."),!1;if(!t)return console.error("useRegex: missing the callback function"),!1;if(new RegExp(e).test(window.location))return t(),!0}});var pe=m(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.default=e=>!e||!e.length?(console.error("whitelist: missing urlArray"),!1):!!e.includes(window.location.pathname)});var ve=m(l=>{"use strict";var y=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(l,"__esModule",{value:!0});l.whitelist=l.useRegex=l.useCss=l.trapFocus=l.setAttributes=l.randomString=l.noClobber=l.mutationObserver=l.localization=l.liveRegions=l.insertAfter=l.getFocusable=l.fixButton=l.changeElement=l.blacklist=l.addEventHandler=void 0;var Ge=y(ne());l.addEventHandler=Ge.default;var We=y(ie());l.blacklist=We.default;var Ze=y(oe());l.changeElement=Ze.default;var Xe=y(se());l.fixButton=Xe.default;var Ye=y(le());l.getFocusable=Ye.default;var Je=y(V());l.insertAfter=Je.default;var Qe=y(ue());l.liveRegions=Qe.default;var et=y(ce());l.localization=et.default;var tt=y(G());l.mutationObserver=tt.default;var rt=y(de());l.noClobber=rt.default;var nt=y(Z());l.randomString=nt.default;var it=y(k());l.setAttributes=it.default;var ot=y(me());l.trapFocus=ot.default;var st=y(ye());l.useCss=st.default;var at=y(ge());l.useRegex=at.default;var lt=y(pe());l.whitelist=lt.default});var Q=we(ve());function q(e,t){e.addEventListener("keydown",function(i){i.key==="Enter"&&(t?t():e.click())})}var he=(()=>{function e(){var n;let r=(n=document.querySelector("sfc-shell-app-bar"))==null?void 0:n.shadowRoot.querySelector(".avatar-button");r&&(r.setAttribute("aria-label","User Profile"),r.setAttribute("aria-haspopup","true"),r.setAttribute("aria-expanded","false"),r.addEventListener("click",function(){r.getAttribute("aria-expanded")==="true"?r.setAttribute("aria-expanded","false"):r.setAttribute("aria-expanded","true")}),q(r))}setTimeout(()=>{e()},3e3);let t=window.location.href;console.log("Demo Fix Loaded");function i(r,n){document.addEventListener("click",function(s){r.contains(s.target)||(console.log("clicked outside",s.target),n())})}function o(r,n){return Array.from(document.querySelectorAll(r)).find(s=>s.textContent.includes(n))}function u(r,n){return Array.from(document.querySelectorAll(r)).filter(s=>s.textContent.includes(n))}function b(r){if(!r)return;let n=Array.from(r.querySelectorAll("button, [href], input, select, textarea, [tabindex]")).filter(d=>!d.hasAttribute("disabled")&&d.getAttribute("tabindex")!=="-1"&&d.offsetParent!==null),s=n[0],f=n[n.length-1];console.log("firstElement",s),console.log("lastElement",f),s.addEventListener("keydown",function(d){d.shiftKey&&d.key==="Tab"&&(d.preventDefault(),f.focus())}),f.addEventListener("keydown",function(d){!d.shiftKey&&d.key==="Tab"&&(console.log("tab pressed"),d.preventDefault(),s.focus())})}function g(){document.querySelectorAll(".vdl-dropdown-list").forEach((n,s)=>{let f="vdl-dd"+s,d=n.parentElement.previousElementSibling;if(d&&d.tagName==="LABEL"){let P="vdl-dd-label"+s;d.id=P,n.setAttribute("aria-labelledby",P)}n.setAttribute("aria-expanded","false"),n.setAttribute("aria-activedescendant",""),n.setAttribute("aria-controls",f),q(n),n.addEventListener("click",function(){n.getAttribute("aria-expanded")==="true"?n.setAttribute("aria-expanded","false"):(n.setAttribute("aria-expanded","true"),p(f))}),i(n,function(){n.setAttribute("aria-expanded","false")})})}function p(r){var n=document.querySelector(".vdl-list");n.setAttribute("role","listbox"),n.setAttribute("aria-label","Financial Year"),n.id=r,Array.from(n.children).forEach((s,f)=>{f===0&&s.classList.add("active"),s.setAttribute("id",r+"-opt-"+f)})}function v(){let r=document.querySelector("meta[name=viewport]");if(r){let n=r.getAttribute("content");n=n.replace(/(user-scalable=[^,]*,?)|(maximum-scale=1.0,?)/g,"").trim(),n.endsWith(",")&&(n=n.slice(0,-1)),r.setAttribute("content",n)}}function h(){var r=document.querySelectorAll("a");r.forEach(n=>{n.hasAttribute("href")||n.setAttribute("href","javascript:void(0)"),n.addEventListener("click",function(){h()})})}h();function C(){document.querySelectorAll("adp-button").forEach(n=>{n.removeAttribute("tabindex"),n.addEventListener("click",function(){h()})})}function A(r){var n,s,f;(n=r.querySelector(".vdl-slidein slidein-title"))==null||n.setAttribute("id","modal-title"),(s=r.querySelector(".vdl-slidein"))==null||s.setAttribute("aria-modal","true"),(f=r.querySelector(".vdl-slidein"))==null||f.setAttribute("aria-labelledby","modal-title")}function S(){var n;g(),D(),a(),E(),O();let r=document.querySelector("adp-overlay");b(r),(n=r.querySelector("slidein-body [tabindex]"))==null||n.focus(),A(r)}function O(){let r=u("adp-tile a.font-size-small","View Pay Breakdown"),n=Array.from(document.querySelectorAll(".div-list")).filter(s=>s.getAttribute("title")==="Graph View");r=r.concat(n),r.length>0&&r.forEach(s=>{s.addEventListener("click",function(){setTimeout(()=>{E(),_()},300)})})}function E(){document.querySelectorAll("adp-accordion .vdl-accordion").forEach(r=>{r==null||r.removeAttribute("role")})}function j(){let r=o("adp-button","Go to Pay History");r&&r.addEventListener("click",function(){setTimeout(()=>{S(),_()},300)})}function H(){var r=o("button","View Payslip");r&&r.addEventListener("click",function(){setTimeout(()=>{var s;h(),j(),_();let n=document.querySelector("adp-overlay");b(n),(s=n.querySelector("slidein-body button"))==null||s.focus(),A(n)},300)})}function D(){setTimeout(()=>{h()},3e3)}function a(){document.querySelectorAll(".div-list").forEach(n=>{(0,Q.fixButton)(n),q(n)})}function c(){var r=document.querySelector("[skiplocationchange]");r&&r.addEventListener("click",function(){S(),_()})}function F(){let r=document.querySelector("adp-modal"),n=r==null?void 0:r.querySelector("modal-title");if(r&&n){let s=r.querySelector(".vdl-modal__close");n.id||(n.id="modal-title"),(0,Q.fixButton)(s),s.setAttribute("aria-label","Close"),q(s),r.setAttribute("role","dialog"),r.setAttribute("aria-labelledby",n.id),r.setAttribute("aria-modal","true"),b(r),setTimeout(()=>{s.focus()},0)}}function _(){document.querySelectorAll(".custom-tile-title, slidein-title").forEach(s=>{s.setAttribute("role","heading"),s.setAttribute("aria-level","2")}),document.querySelectorAll("tile-title").forEach(s=>{s.setAttribute("role","heading"),s.setAttribute("aria-level","3")})}if(setTimeout(()=>{F(),c(),v(),h(),C(),H(),_()},3e3),t.includes("reports")){let r=function(){var n=o("button","Tax Statement");n&&n.addEventListener("click",function(){setTimeout(()=>{var s;h(),_(),(s=document.querySelector("adp-overlay slidein-body [tabindex]"))==null||s.focus()},300)})};setTimeout(()=>{g(),r()},3e3)}if(t.includes("changeprofile")){let r=function(){let f=document.querySelector(".profileImg");f&&f.setAttribute("alt","User Profile Picture")},n=function(){document.querySelectorAll("adp-form-group").forEach((d,P)=>{let ee=d.querySelector("label"),te=d.querySelector("input");if(ee&&te){let re="input"+P;te.id=re,ee.setAttribute("for",re)}})},s=function(){let f=document.querySelector(".fa-upload+span");f&&(f.setAttribute("tabindex","0"),q(f))};setTimeout(()=>{r(),n(),s()},3e3)}})();var Ct={Main:he};})();',body.appendChild(amazei18n),body.appendChild(amazeGlobalCss),body.appendChild(amazeCss),body.appendChild(script)}