1$( document ).ready(function() { 2 const popupBtnAll = document.querySelectorAll('[aria-haspopup="dialog"]'); 3 if (popupBtnAll) { 4 let currentTarget, focusEl = [], popupDepth = 0, popupDimmed, keyEscapeEvt, KeyEvtEl; 5 const _$this = this, 6 popupAll = document.querySelectorAll('[role="dialog"]'), 7 popupCloseBtnAll = document.querySelectorAll('[popup-close]'); 8 // ESC ëë¦ ê°ì§ 9 const keyEvent = { 10 get keyEscape() { 11 return this._state; 12 }, 13 set keyEscape(state) { 14 this._state = state; 15 if (state) escKeyEvt(KeyEvtEl, keyEscapeEvt); 16 }, 17 }; 18 keyEvent; 19 // popup dimmed ìì± 20 const createdDimmed = () => { 21 const createDiv = document.createElement('div'); 22 createDiv.classList.add('popup-dimmed'); 23 document.querySelector('body').appendChild(createDiv); 24 }; 25 // popup dimmed click ì íì ë«ê¸° 26 const dimmedClick = (e) => { 27 if (e.target.classList.contains('wrap-layer-popup')) { 28 popupCloseAll(); 29 keyEvent.keyEscape = false; 30 } 31 }; 32 // popup open 33 const popupOpen = (e) => { 34 currentTarget = e.target.tagName; 35 currentTarget === 'BUTTON' || currentTarget === 'A' ? currentTarget = e.target : currentTarget = e.target.closest('button') || e.target.closest('a'); 36 37 popupDimmed = document.querySelectorAll('.popup-dimmed'); 38 if (popupDimmed.length === 0) createdDimmed(); 39 40 popupAll.forEach((popupEl) => { 41 if (popupEl.getAttribute('data-popup') === currentTarget.getAttribute('data-popup')) { 42 popupDepth += 1; // popup depth ì ì¥ 43 focusEl.splice((popupDepth - 1), 0, currentTarget); // popup focus Element ì ì¥ 44 popupEl.classList.add('popup-open'); // open class add 45 popupEl.setAttribute('popup-depth', popupDepth); // popup depth ì¤ì 46 47 // dimmed click ì´ë²¤í¸ í ë¹ 48 popupEl.removeEventListener('click', dimmedClick); 49 popupEl.addEventListener('click', dimmedClick); 50 51 document.body.classList.add('scroll-lock'); // popup scroll lock 52 popupEl.querySelector('.wrap-layer-popup-title').focus(); // popup ì¤í ì íì´íì í¬ì»¤ì¤ 53 54 // shift+tab ëë <- íì´í í¤ í¤ë³´ë ëì ì íì ë°ì¼ë¡ í¬ì»¤ì¤ ì´ë ë°©ì§ ì´ë²¤í¸ í ë¹ 55 popupEl.querySelector('.wrap-layer-popup-title').removeEventListener('keydown', titleKeyDown); 56 popupEl.querySelector('.wrap-layer-popup-title').addEventListener('keydown', titleKeyDown); 57 58 // popup ì íì ì¼ì´ì¤ dimmed ìì 59 if (popupDepth > 1) document.querySelector(`[popup-depth='${popupDepth - 1}']`).classList.add('prev-popup'); 60 61 KeyEvtEl = popupEl; // ESC í¤ ëìì ìí íì¬ íì±í ë popup element ì ì¥ 62 }; 63 }); 64 }; 65 // popup close 66 const popupClose = (e) => { 67 // í¤ë³´ë ì´ë²¤í¸ ESC ì¼ ê²½ì° currentTarget ì¤ì 68 if (e.key == 'Escape' || e.key == 'Esc') currentTarget = KeyEvtEl.querySelector('.btn-layer-close'); 69 // ì¼ë°ì ì¸ í´ë¦, í¤ë³´ë ì´ë²¤í¸ ì¼ ê²½ì° currentTarget ì¤ì 70 else { 71 currentTarget = e.target.tagName; 72 currentTarget === 'BUTTON' || currentTarget === 'A' ? currentTarget = e.target : currentTarget = e.target.closest('button') || e.target.closest('a'); 73 let popupId = currentTarget.getAttribute('popup-close'); 74 if (currentTarget.getAttribute('popup-close-all') === 'true') return popupCloseAll(); 75 if (currentTarget.getAttribute('popup-confirm')) confirmEvt[popupId](); 76 else if (currentTarget.getAttribute('popup-cancel')) cancelEvt[popupId](); 77 } 78 popupAll.forEach((popupEl) => { 79 if (popupEl.getAttribute('data-popup') === currentTarget.getAttribute('popup-close')) { 80 popupEl.classList.remove('popup-open'); 81 // ì ì¥ë focus element ê° ìì ë 82 if (focusEl.length > 0) { 83 focusEl[popupDepth - 1].focus(); // focus ìí ì¬ì¤ì 84 focusEl.splice((popupDepth - 1), 1); // popup focus Element ìì 85 popupDepth -= 1; // popup depth ì¬ì¤ì 86 KeyEvtEl = document.querySelector(`.wrap-layer-popup[popup-depth='${popupDepth}']`); // ESC í¤ ëìì ìí íì¬ íì±í ë popup element ì ì¥ 87 }
87 else { // ì ì¥ë focus element ê° ìì ë 88 document.body.setAttribute('tabindex', '0'); 89 document.body.focus(); 90 KeyEvtEl = null; 91 } 92 }; 93 }); 94 // ì¤í ë popupì´ ìë ì§ íì¸ 95 const openPopups = document.querySelectorAll(`.popup-open`); 96 if (openPopups.length === 0) popupCloseAll('none'); 97 else if (openPopups.length > 0) { // ì¤íë popupì´ ìì ê²½ì° popup dimmed ìì 98 const getPopupValue = currentTarget.getAttribute('popup-close') || currentTarget.getAttribute('data-popup'); 99 const getPopupDepth = Number(document.querySelector(`.wrap-layer-popup[data-popup='${getPopupValue}']`).getAttribute('popup-depth')); 100 document.querySelector(`.wrap-layer-popup[popup-depth='${getPopupDepth - 1}']`).classList.remove('prev-popup'); 101 document.querySelector(`.wrap-layer-popup[data-popup='${getPopupValue}']`).removeAttribute('popup-depth'); 102 }; 103 }; 104 // popup close All 105 const popupCloseAll = (focusActionNone) => { 106 // dimmed ìì 107 const popupDimmed = document.querySelector('.popup-dimmed'); 108 popupDimmed.style.opacity = 0; 109 popupDimmed.addEventListener('transitionend', function() { 110 if (popupDimmed.parentNode !== null) popupDimmed.parentNode.removeChild(popupDimmed); 111 }); 112 // popup depth ì¤ì ìì 113 popupAll.forEach((popupEl) => { 114 popupEl.classList.remove('prev-popup'); 115 popupEl.removeAttribute('popup-depth'); 116 }); 117 // scroll lock í´ì§ 118 document.body.classList.remove('scroll-lock'); 119 // popupClose Event íµí´ì focus ì¤ì ì´ ëì§ ììì ê²½ì° (popupCloseAll ë¨ë ì¤íì¼ ê²½ì°) 120 if (focusActionNone !== 'none') { 121 if (focusEl.length > 0) focusEl[0].focus(); // ì ì¥ë focus element ê° ìì ë 122 else { // ì ì¥ë focus element ê° ìì ë 123 document.body.setAttribute('tabindex', '0'); 124 document.body.focus(); 125 }; 126 focusEl = []; // focus reset 127 } 128 popupAll.forEach((popupEl) => popupEl.classList.remove('popup-open')); // open class ìì 129 popupDepth = 0; // popup depth reset 130 KeyEvtEl = null; // KeyEvtEl reset 131 }; 132 133 // ESC í¤ë³´ë ì´ë²¤í¸ 134 const escKeyEvt = (El, e) => { 135 const openPopups = document.querySelectorAll(`.popup-open`); 136 // íì ì´ë¦° ìíìì í¤ë³´ë ESC í¤ ì´ë²¤í¸ ì¤í 137 if (openPopups.length > 0) popupClose(e); 138 }; 139 // popup ë«ê¸° í¤ë³´ë ì´ë²¤í¸ 140 const closeBtnKeyDown = (e) => { 141 if ((e.key == 'Tab' && !e.shiftKey) || e.key == 'ArrowRight') { 142 e.preventDefault(); 143 popupAll.forEach((popupEl) => { 144 if (popupEl.getAttribute('data-popup') === e.target.getAttribute('popup-close')) { 145 popupEl.querySelector('.wrap-layer-popup-title').focus(); 146 }; 147 }); 148 }; 149 }; 150 // popup title í¤ë³´ë ì´ë²¤í¸ 151 const titleKeyDown = (e) => { 152 if ((e.key == 'Tab' && e.shiftKey) || e.key == 'ArrowLeft') { 153 e.preventDefault(); 154 popupAll.forEach((popupEl) => { 155 if (popupEl.getAttribute('data-popup') === e.target.closest('.wrap-layer-popup').getAttribute('data-popup')) { 156 popupEl.querySelector('.btn-layer-close').focus(); 157 }; 158 }); 159 }; 160 }; 161 162 // í¤ë³´ë ESC í¤ ëë¦ ê°ì§ ì´ë²¤í¸ 163 const escKeyDown = (e) => { 164 if (e.key == 'Escape' || e.key == 'Esc') { 165 keyEscapeEvt = e; 166 keyEvent.keyEscape = true; 167 }; 168 }; 169 170 // í´ë¦/í¤ë³´ë íì ì´ë²¤í¸ ì ê±°/í ë¹ 171 // íì ì´ê¸° 172 popupBtnAll.forEach((popupBtn) => { 173 popupBtn.removeEventListener('click', popupOpen); 174 popupBtn.addEventListener('click', popupOpen); 175 }); 176 // íì ë«ê¸° 177 popupCloseBtnAll.forEach((popupCloseBtn) => { 178 popupCloseBtn.removeEventListener('click', popupClose); 179 popupCloseBtn.addEventListener('click', popupClose); 180 if (popupCloseBtn.classList.contains('btn-layer-close')) { 181 popupCloseBtn.removeEventListener('keydown', closeBtnKeyDown); 182 popupCloseBtn.addEventListener('keydown', closeBtnKeyDown); 183 } 184 });
185 // ESC í¤ë¡ íì ë«ê¸° 186 window.removeEventListener('keydown', escKeyDown); 187 window.addEventListener('keydown', escKeyDown); 188 } 189});
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.