1/* ============================================================ 2 * EX_AJAXBOARD â ê³µíµ ì¸íë ì´ì¤ ê²ìí ë¡ë 3 * ëì: pr/news, pr/notice, pr/press (ëª©ë¡ ì¸íë ì´ì¤ + ìì¸ ë¼ìë£ê¸°) 4 * portfolio (ëª©ë¡ ì¸íë ì´ì¤ + view=wr_id 모ë¬; 모ë¬ì íì´ì§ ìì²´ JSê° ì²ë¦¬) 5 * ì°¸ê³ í¨í´: contact/faq.php ì faqFetch (ìëµ ì ì²´ HTML â find(ì ë í°) ì¶ì¶ â êµì²´) 6 * 7 * íµì¬ ìì¹ 8 * - ê²ìì´/page/view(ë·°í ê¸) ì ë¶ querystring ì¼ë¡ URL ì ë°ì â ê·¸ URL ì§ì ì ì ì ìë²ê° ëì¼ ìí ë ë 9 * - ìì¸ë pretty url(/pf_news/79) ê·¸ëë¡ pushState. í´ë¹ URL ì§ì ì ì ì G5 ê° í ìì¸íì´ì§ ë ë(progressive enhancement) 10 * - 목ë¡âìì¸ ì íë§ ì¸íë ì´ì¤. ìëµ HTML ìì íìí ì¡°ê°ë§ ì¶ì¶í´ 컨í ì´ë êµì²´ 11 * - popstate(ë¤/ì)ìì íì¬ URL ì ë¤ì fetch í´ ëì¼ ìí ë³µì 12 * 13 * exAjaxBoard({ 14 * container : '#board-ajax', // êµì²´ ëì 컨í ì´ë(íì) 15 * listSel : '#board-ajax', // ëª©ë¡ ìëµìì ì¶ì¶í ì ë í°(기본=container) 16 * navLinks : '#board-ajax .paginate a, #board-ajax .view-toggle a', // í´ë¦âëª©ë¡ fetch (ìì) 17 * searchForm : '#board-ajax .search-form', // submitâëª©ë¡ fetch 18 * detailSel : '#section-pr-view', // ìì¸ ìëµìì ì¶ì¶í ì ë í°(ì í) 19 * detailLinks : '#board-ajax .subject a, #board-ajax .board-list a, #board-ajax .board-cards a', // ìì¸ fetch (ìì) 20 * detailTest : /\/pf_[a-z0-9_]+\/\d+/, // ìì¸ URL íë³ ì ê·ì(ì í) 21 * listPath : location.pathname, // ëª©ë¡ ê¸°ì¤ ê²½ë¡ 22 * onReplace : function(mode, html){} // êµì²´ í ì½ë°±(ì í) 23 * }); 24 * ========================================================== */ 25(function ($) { 26 'use strict'; 27 if (!$) return; 28 29 /* EX_BOARD_SCROLLTOP: íì´ì§/ê²ì/í ì í í ê²ì물 ìì ìë¨ì¼ë¡ ë¶ëë½ê² ì¤í¬ë¡¤. 30 * ê³ ì í¤ë(#header position:fixed, ë°ì¤í¬í ~100px / 768ì´í ~90px)ì ê°ë ¤ì§ì§ ìê² 31 * í¤ë ì¤ì¸¡ ëì´ + ì¬ì 16px ë§í¼ ì¤íì . ì ì ë ¸ì¶ â FAQ(faqFetch) ë±ììë ì¬ì¬ì©(ì¤ë³µ ì ê±°). 32 * target: ì¤í¬ë¡¤ ê¸°ì¤ ì리먼í¸(jQueryê°ì²´ ëë ì ë í°). ì´ë¯¸ íë©´ ìë¨ ì쪽ì´ë©´ ì¤í¬ë¡¤ ìëµ. */ 33 /* EX_AJAX_TITLE: ì¸íë ì´ì¤ êµì²´ ì <title> ë기íì© â ìëµ íHTML(ìë²ë ë)ìì 34 * <title> í ì¤í¸ë¥¼ ì¶ì¶(ìë²ê° ê¸ì 목ì¼ë¡ ëì ì¸í ). ë´ì AJAX 미ì¤íì´ë¼ SEO ìí¥ ìê³ , 35 * ì¬ë íì ì ë¸ë¼ì°ì í/íì¤í 리 ì 목ì ê¸ì ë§ê² ê°±ì íë UX 목ì . */ 36 window.exExtractTitle = function (html) { 37 if (!html || typeof html !== 'string') return ''; 38 var m = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i); 39 if (!m) return ''; 40 var t = document.createElement('textarea'); 41 t.innerHTML = m[1]; 42 return t.value.replace(/\s+/g, ' ').trim(); 43 }; 44 45 window.exScrollToBoardTop = function (target) { 46 var $t = (target && target.jquery) ? target : $(target); 47 var el = $t && $t.length ? $t.get(0) : null; 48 if (!el) return; 49 var $hd = $('#header'); 50 var headerH = ($hd.length && $hd.css('position') === 'fixed') ? $hd.outerHeight() : 0; 51 var offset = headerH + 16; 52 var top = el.getBoundingClientRect().top + window.pageYOffset - offset; 53 if (top < 0) top = 0; 54 // ì´ë¯¸ íê¹ ìë¨ì´ í¤ë ìëë¡ ì¶©ë¶í ë³´ì´ë©´(ìë¡ ì¤í¬ë¡¤ ë¶íì) ì¤íµ 55 if (Math.abs(window.pageYOffset - top) < 4) return; 56 if ('scrollBehavior' in document.documentElement.style) { 57 window.scrollTo({ top: top, behavior: 'smooth' }); 58 } else { 59 $('html, body').stop().animate({ scrollTop: top }, 300); 60 } 61 }; 62 63 window.exAjaxBoard = function (opt) { 64 opt = opt || {}; 65 var container = opt.container; 66 if (!container || !$(container).length) return; 67 var listSel = opt.listSel || container; 68 var detailSel = opt.detailSel || null; 69 var detailTest = opt.detailTest || null; 70 var listPath = opt.listPath || location.pathname; 71 var onReplace = opt.onReplace || function () {}; 72 73 function isDetailUrl(url) { return detailSel && detailTest && detailTest.test(url); } 74 75 function fetchList(url, push) { 76 $.get(url, function (html) {
77 var $piece = $('<div>').html(html).find(listSel).first(); 78 if ($piece.length) $(container).replaceWith($piece); 79 if (push) history.pushState({ ex: 'list' }, '', url); 80 /* EX_AJAX_TITLE: ëª©ë¡ ë³µê· ì ëª©ë¡ íì´ì§ title ë¡ ë³µì */ 81 var exListTitle = window.exExtractTitle(html); 82 if (exListTitle) document.title = exListTitle; 83 /* EX_BOARD_SCROLLTOP: íì´ì§/ê²ì/í í êµì²´ë ëª©ë¡ ì»¨í ì´ë ìë¨ì¼ë¡ ì¤í¬ë¡¤ */ 84 if ($piece.length) window.exScrollToBoardTop($piece); 85 onReplace('list', html); 86 }); 87 } 88 89 function fetchDetail(url, push) { 90 $.get(url, function (html) { 91 var $piece = $('<div>').html(html).find(detailSel).first(); 92 if ($piece.length) $(container).empty().append($piece); 93 if (push) history.pushState({ ex: 'detail' }, '', url); 94 /* EX_AJAX_TITLE: ìì¸ ê¸ì 목ì¼ë¡ document.title ê°±ì */ 95 var exDetailTitle = window.exExtractTitle(html); 96 if (exDetailTitle) document.title = exDetailTitle; 97 $(window).scrollTop(0); 98 onReplace('detail', html); 99 }); 100 } 101 102 function navigate(url, push) { 103 if (isDetailUrl(url)) fetchDetail(url, push); 104 else fetchList(url, push); 105 } 106 107 // ëª©ë¡ ë¤ë¹ê²ì´ì (íì´ì§Â·ë·°í ê¸Â·í) 108 if (opt.navLinks) { 109 $(document).on('click.exab', opt.navLinks, function (e) { 110 var href = this.getAttribute('href'); 111 if (!href || href === '#') { e.preventDefault(); return; } 112 e.preventDefault(); 113 var url = (href.charAt(0) === '?') ? (listPath + href) : href; 114 fetchList(url, true); 115 }); 116 } 117 118 // ê²ìí¼ 119 if (opt.searchForm) { 120 $(document).on('submit.exab', opt.searchForm, function (e) { 121 e.preventDefault(); 122 var qs = $(this).serialize(); 123 var url = listPath + (qs ? '?' + qs : ''); 124 fetchList(url, true); 125 }); 126 } 127 128 // ìì¸ ë§í¬(ëª©ë¡ â ìì¸ ë¼ìë£ê¸°) 129 if (detailSel && opt.detailLinks) { 130 $(document).on('click.exab', opt.detailLinks, function (e) { 131 var href = this.getAttribute('href'); 132 if (!href || !isDetailUrl(href)) return; // ë¹ìì¸ ë§í¬ë 기본 ëì ì ì§ 133 e.preventDefault(); 134 fetchDetail(href, true); 135 }); 136 } 137 138 // ë¤ë¡/ìì¼ë¡ 139 window.addEventListener('popstate', function () { navigate(location.href, false); }); 140 141 return { navigate: navigate, fetchList: fetchList, fetchDetail: fetchDetail }; 142 }; 143})(window.jQuery);
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.