UNPKG

9.38 kBJavaScriptView Raw
1!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";let e,t;const o=e=>{let t=e.target.parentElement.querySelector(".hoo-mdldialog-outer");t.classList.remove("is-hidden"),t.classList.add("is-visible")},l=e=>{let t=e.target.closest(".hoo-mdldialog-outer");t.classList.remove("is-visible"),t.classList.add("is-hidden")},a=e=>{const t=e;console.log("csSelector",t);const o=t.querySelector("input"),l=t.querySelector("ul"),a=l.querySelectorAll("li");t.querySelectorAll("svg");const r=document.querySelector("#custom-select-status"),i=Array.from(a);let n="initial";function s(e){"Open"===e?(l.classList.remove("hidden-all"),t.setAttribute("aria-expanded","true")):(l.classList.add("hidden-all"),t.setAttribute("aria-expanded","false"))}function c(){return document.activeElement}function d(e,t){const l=i.filter((function(e){if(""===e.style.display)return!0}));if(0!==l.length)switch("input"===t&&o.focus(),e){case o:"forward"===t?l[0].focus():"back"===t&&l[l.length-1].focus();break;case a[0]:"forward"===t?l[1].focus():"back"===t&&o.focus();break;case a[a.length-1]:"forward"===t?l[0].focus():"back"===t&&l[l.length-2].focus();break;default:const e=c(),r=l.indexOf(e);if("forward"===t){l[r+1].focus()}else if("back"===t&&r>0){l[r-1].focus()}else o.focus()}}function u(){const e=o.value,t=i.filter((function(t){if(t.innerText.toUpperCase().startsWith(e.toUpperCase()))return!0}));var l;a.forEach((e=>e.style.display="none")),t.forEach((function(e){e.style.display=""})),h("filtered"),l=t.length,r.textContent=l+" options available."}function f(e){const t=e.dataset.value;o.value=t,d(document.activeElement,"input")}function h(e){switch(e){case"initial":n="initial";break;case"opened":n="opened";break;case"filtered":n="filtered";break;case"closed":n="closed"}}t.setAttribute("role","combobox"),t.setAttribute("aria-haspopup","listbox"),t.setAttribute("aria-owns","custom-select-list"),o.setAttribute("aria-autocomplete","both"),o.setAttribute("aria-controls","custom-select-list"),l.setAttribute("role","listbox"),a.forEach((e=>{e.setAttribute("role","option"),e.setAttribute("tabindex","-1")})),r.textContent=a.length+" options available. Arrow down to browse or start typing to filter.",t.addEventListener("click",(function(e){const t=c();switch(n){case"initial":s("Open"),h("opened");break;case"opened":t===o?(s("Shut"),h("initial")):"LI"===t.tagName&&(f(t),s("Shut"),h("closed"));break;case"filtered":"LI"===t.tagName&&(f(t),s("Shut"),h("closed"));break;case"closed":s("Open"),h("filtered")}})),t.addEventListener("keyup",(function(e){!function(e){const t=c();switch(e){case"Enter":"initial"===n?(s("Open"),h("opened")):"opened"===n&&"LI"===t.tagName?(f(t),s("Shut"),h("closed")):"opened"===n&&t===o?(s("Shut"),h("closed")):"filtered"===n&&"LI"===t.tagName?(f(t),s("Shut"),h("closed")):"filtered"===n&&t===o?(s("Open"),h("opened")):(s("Open"),h("filtered"));break;case"Escape":"opened"!==n&&"filtered"!==n||(s("Shut"),h("initial"));break;case"ArrowDown":"initial"===n||"closed"===n?(s("Open"),d(o,"forward"),h("opened")):(s("Open"),d(t,"forward"));break;case"ArrowUp":"initial"===n||"closed"===n?(s("Open"),d(o,"back"),h("opened")):d(t,"back");break;default:"initial"===n?(s("Open"),u(),h("filtered")):"opened"===n||"closed"===n?(u(),h("filtered")):u()}}(e.key)})),document.addEventListener("click",(function(e){e.target.closest(".hoo-select")||(s("Shut"),h("initial"))}))},r=e=>{const t=e.target.closest("tr"),o=e.target.closest("table"),l=t.dataset.sectionheader;let a=null;a="all"===l?"tr[data-section]":"tr[data-section="+l+"]";const r=o.querySelectorAll(a);for(let e=0;e<r.length;e++){const o=r[e];o.classList.contains("is-hidden")?(o.classList.remove("is-hidden"),o.classList.add("is-visible"),o.setAttribute("aria-hidden","false"),t.setAttribute("aria-expanded","true")):(o.classList.add("is-hidden"),o.classList.remove("is-visible"),o.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"))}if("all"===l){let e=document.querySelectorAll("tbody tr.collapsable");if("true"===t.getAttribute("aria-expanded"))for(let t=0;t<e.length;t++){const o=e[t];o.setAttribute("aria-hidden","false"),o.setAttribute("aria-expanded","true")}else for(let t=0;t<e.length;t++){const o=e[t];o.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false")}}},i="left",n="right",s="top",c="bottom",d=(e,t,o)=>{const l=e.querySelectorAll(t);for(let e=0;e<l.length;e++){const t=l[e];o===i&&(t.style[o]=t.offsetLeft+"px"),o===n&&(t.style[o]=t.offsetRight+"px"),o===s&&(t.style[o]=t.offsetTop+"px"),o===c&&(t.style[o]=t.offsetBottom+"px")}},u=()=>{document.querySelectorAll(".hoo-table.is-collapsable").forEach((e=>{e.querySelectorAll(".collapsable").forEach((e=>{e.addEventListener("click",r)}))})),(()=>{const e=document.querySelectorAll("table.sticky");for(let t=0;t<e.length;t++){const o=e[t];d(o,"tr td.is-sticky.left",i),d(o,"tr th.is-sticky.left",i)}})()},f=".hoo-pivotbar",h=".hoo-button-pivot",p=".hoo-navitem-text",b="is-active",g=e=>{e.preventDefault(),console.log(e.target);let t=e.target.classList.contains(h.substr(1))?e.target:e.target.closest(h);t||(t=e.target.classList.contains(p.substr(1))?e.target:e.target.closest(p));e.target.closest(f).querySelectorAll(h).forEach((e=>{e.classList.remove(b)})),t.classList.add(b)},m=e=>{console.log(e);let t=e.target.closest(".hoo-navitem");console.log(t),console.log(t.getAttribute("aria-expanded")),console.log(typeof t.getAttribute("aria-expanded")),console.log(" LOOMA ::: ",t.getAttribute("aria-expanded"),Boolean(t.getAttribute("aria-expanded")),!0===Boolean(t.getAttribute("aria-expanded"))),"true"===t.getAttribute("aria-expanded")?t.setAttribute("aria-expanded",!1):t.setAttribute("aria-expanded",!0)},v=[],y=(e,t)=>{e.target.parentElement.querySelectorAll(".hoo-overflow > *");((e,t,o,l)=>{let a=v[l].filter((t=>t.overallWidth>e-40)),r=v[l].filter((t=>t.overallWidth<e-40)),i=o.querySelector(".hoo-buttonicon-overflow .hoo-buttonflyout");if(i&&i.children.length<a.length)for(let e=0;e<a.length;e++)if(null!==o.querySelector("[data-ref="+a[e].ref+"]")){let t=document.createElement("li");t.appendChild(o.querySelector("[data-ref="+a[e].ref+"]")),i.appendChild(t)}var n;if(0!==i.children.length?(n=i.closest(".hoo-buttonicon-overflow"))&&n.classList.add("is-active"):(n=i.closest(".hoo-buttonicon-overflow"))&&n.classList.remove("is-active"),i&&i.children.length>a.length)for(let e=0;e<r.length;e++)if(null!==i.querySelector("[data-ref="+r[e].ref+"]")){let t=i.querySelector("[data-ref="+r[e].ref+"]");o.appendChild(t)}for(let e=0;e<i.children.length;e++)0===i.children[e].children.length&&i.children[e].remove()})(e.target.parentElement.clientWidth,0,e.target,t)},A=(e,t)=>{e.forEach(((e,t)=>{E(e.target.children,t),y(e,t)}))},E=(e,t)=>{let o=0;if(v.length<=t){v[t]=[];for(let l=0;l<e.length;l++)if(o+=e[l].clientWidth,!e[l].classList.contains("hoo-buttonicon-overflow")){let a={chlld:e[l],ref:"ref-"+t+"-"+l,width:e[l].clientWidth,overallWidth:o};e[l].dataset.ref=a.ref,v[t].push(a)}}},L=(e,t)=>{document.querySelectorAll(e).forEach((e=>{e.addEventListener("click",(e=>{t(e)}))}))},S=(e,t)=>{let o=e.getAttribute("aria-pressed");void 0===o?e.setAttribute("aria-pressed",!0):e.setAttribute("aria-pressed",!o),t.classList.toggle("show-flyout")},k=e=>{let t=e.target,o=t.parentElement;S(t,o)},w=e=>{console.log("\nEVENT: splitButtonClick");let t=e.target,o=t.parentElement;S(t,o)},x=e=>{let t=e.target,o=t.parentElement.dataset.animation;t.classList.add(o);let l=window.getComputedStyle(t),a=1e3*parseFloat(l.getPropertyValue("animation-duration"));console.log(l,l.getPropertyValue("animation-duration"),a),setTimeout((()=>{t.remove()}),a)},q=e=>{let t=e.target,o=t.parentElement.dataset.animation;t.classList.add(o);let l=document.importNode(t,!0);l.classList.add(o);let a=window.getComputedStyle(l),r=1e3*parseFloat(a.getPropertyValue("animation-duration"));e.target.parentElement.appendChild(l),l.addEventListener("click",q),console.log(a,a.getPropertyValue("animation-duration"),r),setTimeout((()=>{l.classList.remove("anim-add-slide")}),r)},O=(e,t)=>{document.querySelectorAll(e+" > .sg-anim-block").forEach((e=>{e.addEventListener("click",t)}))};window.onload=(L(".hoo-buttonsplit > .hoo-buttonsplit-carret",w),L(".hoo-buttonsplit-primary > .hoo-buttonsplit-carret",w),L("button.hoo-buttonicon-overflow",k),L("button.hoo-buttoncmd",k),L("button.hoo-buttoncmdbar",k),L("button.hoo-buttonicon-flyout",k),L("button.hoo-buttoncontext",k),O(".anim-deleteNslide",x),O(".anim-addNslide",q),e=document.querySelectorAll(".show-dialog"),t=document.querySelectorAll(".hoo-dlgheader-closer"),e&&e.forEach((e=>{e.addEventListener("click",o)})),t&&t.forEach((e=>{e.addEventListener("click",l)})),(()=>{let e=document.querySelectorAll(".hoo-select");e&&e.forEach(((e,t)=>{a(e)}))})(),u(),document.querySelectorAll(".hoo-pivotbar .hoo-button-pivot").forEach((e=>{e.dataset.ref=e.textContent.trim(),e.addEventListener("click",g)})),document.querySelectorAll(".hoo-navitem[aria-expanded]").forEach((e=>{e.addEventListener("click",m)})),(()=>{let e=document.querySelectorAll(".hoo-overflow");if(0!==e.length){const t=new ResizeObserver(A);e.forEach((e=>{t.observe(e)}))}})(),void setTimeout((()=>{let e=document.querySelectorAll(".tmp-hidden");console.log(e),e.forEach((t=>{t.addEventListener("focus",(t=>{t.target.classList.remove(".tmp-hidden"),console.log(e)}))}))}),1e3))}));