1document.addEventListener('DOMContentLoaded',()=>{ 2 console.log("common_modal.js start!"); 3/* 4 5 /!** 6 * ëª¨ë¬ ì°½ì ëëê·¸íì¬ ì´ëí ì ìëë¡ ì¤ì íë ê¸°ë¥ 7 *!/ 8 /!* ëª¨ë¬ ëëê·¸ ê¸°ë¥ start *!/ 9 // ëª¨ë¬ ë° ëª¨ë¬ í¤ë ìì ê°ì ¸ì¤ê¸° 10 const modalList = document.querySelectorAll(".modalPopup"); 11 //const modalHeaderList = document.querySelectorAll(".pop_header"); 12 13 // ëëê·¸ ìí ë° ì¢í ì¤íì ë³ì 14 let isDragging = false; 15 let offsetX, offsetY; 16 17 // ëª¨ë¬ ììê° ìì¼ë©´ ì¤í ì¤ì§ 18 if (isNull(modalList[0])) return; 19 //if (isNull(modalList[0]) || isNull(modalHeaderList[0])) return; 20 21 /!** 22 * ëª¨ë¬ ëëê·¸ ìì (mousedown ì´ë²¤í¸) 23 * ì¬ì©ìê° ëª¨ë¬ í¤ë를 í´ë¦íë©´ ëëê·¸ ìì 24 *!/ 25 modalList.forEach(modal => modal.querySelector('.pop_header').addEventListener("mousedown", function (event) { 26 isDragging = true; 27 28 // íì¬ ë§ì°ì¤ ìì¹ìì 모ë¬ì ìëì ìì¹ ê³ì° 29 offsetX = event.clientX - modal.getBoundingClientRect().left; 30 offsetY = event.clientY - modal.getBoundingClientRect().top; 31 32 // ëëê·¸ ì¤ ì¤í¬ë¡¤ ë°©ì§ ë° ì»¤ì ì¤íì¼ ë³ê²½ 33 document.body.style.overflow = "hidden"; 34 modal.querySelector('.pop_header').style.cursor = "grabbing"; 35 })); 36 37 /!** 38 * ëª¨ë¬ ì´ë (mousemove ì´ë²¤í¸) 39 * ë§ì°ì¤ë¥¼ ìì§ì´ë©´ ëª¨ë¬ ìì¹ë¥¼ ë³ê²½ 40 *!/ 41 modalList.forEach(modal => modal.querySelector('.pop_header').addEventListener("mousemove", function (event) { 42 if (!isDragging) return; 43 44 // ìë¡ì´ X, Y ì¢í ê³ì° (ì¤í¬ë¡¤ ê³ ë ¤) 45 let newX = event.clientX - offsetX; 46 let newY = event.clientY - offsetY + window.scrollY; 47 48 // íë©´ ê²½ê³ë¥¼ ë²ì´ëì§ ìëë¡ ì í 49 let maxX = window.innerWidth - modal.offsetWidth; 50 let maxY = window.innerHeight - modal.offsetHeight + window.scrollY; 51 52 newX = Math.max(0, Math.min(newX, maxX)); 53 newY = Math.max(window.scrollY, Math.min(newY, maxY)); 54 55 // ëª¨ë¬ ìì¹ ì ë°ì´í¸ 56 modal.style.left = newX + "px"; 57 modal.style.top = newY + "px"; 58 modal.style.transform = "none"; // ë³í ì´ê¸°í 59 })); 60 61 /!** 62 * ëª¨ë¬ ëëê·¸ ì¢ ë£ (mouseup ì´ë²¤í¸) 63 * ë§ì°ì¤ ë²í¼ì ëì¼ë©´ ëëê·¸ ì¤ì§ 64 *!/ 65 modalList.forEach(modal => modal.querySelector('.pop_header').addEventListener("mouseup", function () { 66 isDragging = false; 67 document.body.style.overflow = ""; // ì¤í¬ë¡¤ ì ê¸ í´ì 68 modal.querySelector('.pop_header').style.cursor = "grab"; 69 })); 70 71 /!* ëª¨ë¬ ëëê·¸ ê¸°ë¥ end *!/ 72*/ 73}); 74 75/** 76 * ëª¨ë¬ íì ì ëì ì¼ë¡ ì´ê³ íë©´ ì¤ìì ë°°ì¹íë í¨ì 77 * @param {string} title - íì ì 목 78 * @param {string} contentHtml - íì ë´ë¶ì ì½ì í HTML ì½í ì¸ 79 * @param {Object} [options={}] - íì í¬ê¸° ì¤ì ìµì 80 * @param {number} [options.width=1700] - íì ê°ë¡ í¬ê¸° (기본ê°: 1700px) 81 * @param {number} [options.height=800] - íì ì¸ë¡ í¬ê¸° (기본ê°: 800px) 82 */ 83/*async function openModalPopupUrl(url, title, data={}, {width = 1700, height = 800} = {}) { 84 85 const contentHtml = await fetchWrapper(url, data, { method : "GET",isShowLoading: true}); 86 87 // ëª¨ë¬ íì ìì ê°ì ¸ì¤ê¸° 88 const modalElement = document.querySelector('#modalPopupUrl'); 89 90 // íì ì 목 ì¤ì 91 modalElement.querySelector('.popUpTitle').innerText = title; 92 93 // íì ë´ì© ì¤ì (ìµë ëì´ ì í í ì½í ì¸ ì¶ê°) 94 modalElement.querySelector('.popUpContent').style.maxHeight = (height - 100) + "px"; 95 modalElement.querySelector('.popUpContent').innerHTML = null; 96 modalElement.querySelector('.popUpContent').insertAdjacentHTML('beforeend', contentHtml); 97
98 // ëª¨ë¬ íì ì í¬ê¸°ì ìì¹ë¥¼ ì¤ì íê³ íë©´ì íìíë¤. 99 setShowModalPopupSizeAndPosition(modalElement, width, height); 100}*/ 101 102/** 103 * ëª¨ë¬ íì ì ëì ì¼ë¡ ì´ê³ íë©´ ì¤ìì ë°°ì¹íë í¨ì 104 * @param {string} title - íì ì 목 105 * @param {string} contentHtml - íì ë´ë¶ì ì½ì í HTML ì½í ì¸ 106 * @param {Object} [options={}] - íì í¬ê¸° ì¤ì ìµì 107 * @param {number} [options.width=1700] - íì ê°ë¡ í¬ê¸° (기본ê°: 1700px) 108 * @param {number} [options.height=800] - íì ì¸ë¡ í¬ê¸° (기본ê°: 800px) 109 */ 110/* 111function openModalPopup(title, contentHtml, { width = 1700, height = 800 } = {}) { 112 // ëª¨ë¬ íì ìì ê°ì ¸ì¤ê¸° 113 const modalElement = document.querySelector('#modalPopupDefault'); 114 115 // íì ì 목 ì¤ì 116 modalElement.querySelector('.popUpTitle').innerText = title; 117 118 // íì ë´ì© ì¤ì (ìµë ëì´ ì í í ì½í ì¸ ì¶ê°) 119 modalElement.querySelector('.popUpContent').style.maxHeight = (height - 100) + "px"; 120 modalElement.querySelector('.popUpContent').innerHTML = contentHtml; 121 //modalElement.querySelector('.popUpContent').insertAdjacentHTML('beforeend', contentHtml); 122
123 // ëª¨ë¬ íì ì í¬ê¸°ì ìì¹ë¥¼ ì¤ì íê³ íë©´ì íìíë¤. 124 setShowModalPopupSizeAndPosition(modalElement, width, height); 125} 126*/ 127 128/** 129 * ê²ìí 미리보기 ëª¨ë¬ íì 130 * @param {string} contentHtml - ë¯¸ë¦¬ë³´ê¸°ë¡ ì¶ë ¥í html 131 * @param {Object} [options={}] - íì í¬ê¸° ì¤ì ìµì 132 * @param {number} [options.width=1700] - íì ê°ë¡ í¬ê¸° (기본ê°: 1700px) 133 * @param {number} [options.height=800] - íì ì¸ë¡ í¬ê¸° (기본ê°: 800px) 134 */ 135/*function openBbsPreview(contentHtml, {width = 1280, height = 800} = {}){ 136 137 const modalPopup = document.querySelector('#previewModalPopup'); 138 const iframe = modalPopup.querySelector('#previewIframe'); 139 const iframeHtml = iframeHtmlStart + contentHtml + iframeHtmlEnd; 140 141 const doc = iframe.contentWindow.document; 142 doc.open(); 143 doc.write(iframeHtml); 144 doc.close(); 145 iframe.style.height = (height - 100) + "px"; 146 iframe.style.width = (width - 80) + "px"; 147 setShowModalPopupSizeAndPosition(modalPopup, width, height); 148}*/ 149 150/** 151 * êµê°ë¦¬ì¤í¸ë¥¼ ì¶ë ¥íê³ ì ííë ëª¨ë¬ íì 152 * @param cntntCd ëë¥ì½ë 153 * @param rgnGroupCd ì§ìì½ë 154 * @param {string} [options.type="radio"] - ì í íì , radio or checkbox 155 * @param {number} [options.width=1700] - íì ê°ë¡ í¬ê¸° (기본ê°: 1700px) 156 * @param {number} [options.height=800] - íì ì¸ë¡ í¬ê¸° (기본ê°: 800px) 157 */ 158function openSelectNtnListModalPopup(cntntCd = null, {type = "radio", width = 900, height = 800} = {}) { 159 160 return new Promise(async (resolve, reject) => { 161 // ëª¨ë¬ íì ìì ê°ì ¸ì¤ê¸° 162 const modalElement = document.querySelector('#selectNtnListModalPopup'); 163 164 showLoading(true); 165 // ê²ìí 컨í ì¸ ì¶ê° 166 /*let [ntnList, rgnCdList, cntntCdList] = await Promise.all( 167 [getNtnList({cntntCd: cntntCd, rgnGroupCd:rgnGroupCd}) 168 , getComnCdList("RGN") 169 , getComnCdList("CNTNT")]);*/ 170 171 let [ntnList, cntntCdList] = await Promise.all( 172 [getNtnList({cntntCd: cntntCd}) 173 , getComnCdList("CNTNT")]); 174 175 showLoading(false); 176 177 const searchHtml =` 178 <div class="input-btn-01"> 179 <select name="cntntCd" class="selectbox" title="ëë¥"> 180 <option value="">ì ì²´</option> 181 ${cntntCdList.map(item => 182 item.comnCd == cntntCd 183 ? `<option value="${item.comnCd}" selected >${item.comnCdNm}</option>` 184 : `<option value="${item.comnCd}">${item.comnCdNm}</option>` 185 ).join('')} 186 </select> 187 <input type="text" class="input-01" placeholder="êµê°/ì§ìì ê²ìí´ ì£¼ì¸ì." id="ntnListNtnSearchTxt" name="keyword"> 188 <label for="popupCS01" class="blind">êµê°/ì§ìì ê²ì</label> 189 <input type="submit" value="ê²ì" class="btn btn-blue-02" id="ntnListNtnSearch"> 190 </div> 191 `; 192 // íì ë´ì© ì¤ì (ìµë ëì´ ì í í ì½í ì¸ ì¶ê°) 193 modalElement.querySelector('.ntnListModalSearchForm').innerHTML = null; 194 modalElement.querySelector('.ntnListModalSearchForm').insertAdjacentHTML('beforeend', searchHtml); 195 //modalElement.querySelector('.tbody_scroll').style.height = (height - 350) + "px"; 196 197 insertNtnList(ntnList); 198
199 // ëª¨ë¬ íì ì í¬ê¸°ì ìì¹ë¥¼ ì¤ì íê³ íë©´ì íìíë¤. 200 //setShowModalPopupSizeAndPosition(modalElement, width, height); 201 202 modalElement.style.display = 'block'; 203 if(!isNull(document.querySelector('.dim'))){ 204 document.querySelector('.dim').style.display = 'block'; 205 } 206 207 // ì·¨ìë²í¼ 208/* function cancelSelectNtn(){ 209 resolve(null); 210 closeModalPopup(modalElement); 211 modalElement.querySelectorAll('.cancelSelectNtn').forEach(e => e.removeEventListener('click', cancelSelectNtn)); 212 }*/ 213 // êµê° ê²ì 214 async function searchNtn() { 215 const searchData = getFormValuesContainer(modalElement.querySelector('#ntnListModalSearchForm')); 216 ntnList = await getNtnList(searchData,{isShowLoading: true}); // ntnListì ì¬í ë¹ 217 insertNtnList(ntnList); 218 } 219 220 // êµê°ë¦¬ì¤í¸ë¥¼ íì ì ì½ì 221 async function insertNtnList(ntnList) { 222 const selectNtnListTbody = modalElement.querySelector('#selectNtnListTbody'); 223 selectNtnListTbody.innerHTML = null; 224 225 if(ntnList.length === 0 || isEmptyObject(ntnList)) { 226 modalElement.querySelector('#ntnSearchListTable').style.display = 'none'; 227 modalElement.querySelector('#ntnSearchNoList').style.display = 'block'; 228 return; 229 } 230 231 modalElement.querySelector('#ntnSearchListTable').style.display = 'block'; 232 modalElement.querySelector('#ntnSearchNoList').style.display = 'none'; 233 234 selectNtnListTbody.innerHTML = ntnList.reduce((acc, ntn, indx, array) => { 235 const html = ` 236 <tr> 237 <input type="hidden" name="ntnCd" value="${ntn.ntnCd}"> 238 <td class="pc-only">${ntn.cntntCdNm}</td> 239 <td> 240 <button class="btn ntnListSelectNtn" data-ntn-cd="${ntn.ntnCd}"> 241 <p class="mo-only">${ntn.cntntCdNm}</p><!-- mo íë©´ì© ëë¥ëª --> 242 <p class="btn-text-01">${ntn.ntnNm}</p> 243 </button> 244 </td> 245 <td><button class="btn btn-white-02 ntnListSelectNtn" data-ntn-cd="${ntn.ntnCd}" >ì í</button></td> 246 </tr> 247 `; 248 return acc + "" + html; 249 }, ""); 250 251 modalElement.querySelectorAll('.ntnListSelectNtn').forEach(e => e.addEventListener('click', (ev)=>{ 252 const ntnCd = ev.currentTarget.dataset.ntnCd 253 const ntnInfo = ntnList.find(ntn => ntn.ntnCd == ntnCd); 254 resolve(ntnInfo); 255 closeModalPopup(modalElement); 256 })); 257 258 } 259 260 //modalElement.querySelectorAll('.btn-popup-close-ntn-list-modal').forEach(e => e.addEventListener('click', cancelSelectNtn)); 261 modalElement.querySelector('#ntnListNtnSearch').addEventListener('click', searchNtn); 262 modalElement.querySelector('#ntnListNtnSearchTxt').addEventListener('keyup', (key)=>{ 263 if(key.keyCode && key.keyCode === 13){ 264 searchNtn(); 265 } 266 }); 267 268 $('body').addClass('noscroll'); 269 }); 270} 271 272 273function closeModalPopup(modalElement){ 274 if(!isNull(document.querySelector('.dim'))){ 275 document.querySelector('.dim').style.display = 'none'; 276 } 277 278 modalElement.style.display='none'; 279 document.querySelector('#ntnSearchListTable').scrollTo({ top: 0}); 280 if ( $('body').hasClass('noscroll') ){ 281 $('body').removeClass('noscroll').find('.wrap').removeAttr('style'); 282 } 283} 284 285 286/**
287 * ëª¨ë¬ íì ì í¬ê¸°ì ìì¹ë¥¼ ì¤ì íê³ íë©´ì íìíë í¨ì 288 * @param {HTMLElement} modalElement - í¬ê¸°ì ìì¹ë¥¼ ì¤ì í ëª¨ë¬ ìì 289 * @param {number} width - ëª¨ë¬ íì ì ëë¹ (px ë¨ì) 290 * @param {number} height - ëª¨ë¬ íì ì ëì´ (px ë¨ì) 291 */ 292/* 293function setShowModalPopupSizeAndPosition(modalElement, width = 1700, height = 800) { 294 // íì ì íë©´ ì¤ìì ë°°ì¹í기 ìí ì¢í ê³ì° 295 const { left, top } = calcPopupCenterPosition(width, height); 296 297 // ëª¨ë¬ íì ì í¬ê¸° ì¤ì 298 modalElement.style.width = width + "px"; 299 modalElement.style.height = height + "px"; 300 301 // ëª¨ë¬ íì ì ìì¹ ì¤ì (íë©´ ì¤ì ì ë ¬) 302 modalElement.style.left = left + "px"; 303 modalElement.style.top = top + "px"; 304 305 // ëª¨ë¬ íì ì íë©´ì íì 306 modalElement.style.display = "block"; 307 308 // ë°°ê²½ì ì´ë¡ê²(dim ì²ë¦¬)íì¬ íì ì´ ê°ì¡°ëëë¡ ì¤ì 309 document.querySelector('.dim').style.display = 'block'; 310} 311*/ 312 313 314/** 315 * íì ì°½ í¬ê¸°ë¥¼ 기ì¤ì¼ë¡ ì¤ì ìì¹ë¥¼ ê³ì°íë í¨ì 316 * 317 * @param {number} popupWidth - íì ì°½ ê°ë¡ í¬ê¸° 318 * @param {number} popupHeight - íì ì°½ ì¸ë¡ í¬ê¸° 319 * @returns {Object} - íì ì `left` ë° `top` ì¢í 320 */ 321/* 322function calcPopupCenterPosition(popupWidth, popupHeight) { 323 // íì¬ íë©´ì ê°ë¡ ë° ì¸ë¡ í¬ê¸° ê°ì ¸ì¤ê¸° 324 const windowWidth = window.innerWidth; 325 const windowHeight = window.innerHeight; 326 327 // íì¬ ë¬¸ìì ì¤í¬ë¡¤ ìì¹ ê°ì ¸ì¤ê¸° (ì¤í¬ë¡¤ì´ ìë ê²½ì° ë°ì) 328 const scrollTop = window.scrollY || document.documentElement.scrollTop; 329 330 // íì ì íë©´ ì ì¤ìì ë°°ì¹í ì¢í ê³ì° 331 const left = (windowWidth - popupWidth) / 2; 332 const top = (windowHeight - popupHeight) / 2 + scrollTop; 333 334 return { left, top }; 335} 336*/
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.