PageSourceSearch

https://www.unescoicm.org/ko/_assets/js/front.js?ver=1784106194

js unescoicm.org collected 2026-10-02 12:36:58 UTC 8,508 bytes, 227 lines download raw bytes

1/* 이관: 구 사이트 _include/js/front.js + js/common.js + js/sns.js 의 라이브 동작 통합
2   변경점: ① TOP 버튼 클릭 핸들러를 scroll 핸들러 밖으로 분리(원본 중복 바인딩 버그 수정)
3          ② 사장 코드(.top_nav/.allmenu/레이어팝업 TypeError 블록) 미이식 */
4
5$(function() {
6    lnbPC();
7    lnbMobile();
8    scrollAnimate();
9
10    // 헤더 검색 열기/닫기 (구 js/common.js)
11    $(".sch_btn").on('click', function() {
12        $(".bx_search").show();
13    });
14    $(".btn_sclose").on('click', function() {
15        $(".bx_search").hide();
16        $(".sch_btn").focus();
17    });
18});
19
20/**
21 * 좌측메뉴 hover시 1차&2차 메뉴 animate 효과 (전체 펼침 메가메뉴)
22 */
23function lnbPC() {
24    var $lnbBtnPC = $('.lnb-pc .lnb-navi > li');
25    var $header = $('#header');
26    var speed = 200;
27    $lnbBtnPC.hover(
28        function() {
29            var $this = $(this);
30            var $secondDeps = $('.lnb-dep2');
31            $secondDeps.stop().css('display', 'block');
32            $header.addClass('menu-toggle');
33            $header.stop().animate({ 'height': '380px' }, speed);
34            $this.addClass('on');
35            $this.find('.lnb-dep2').addClass('on');
36        },
37        function() {
38            var $this = $(this);
39            var $secondDeps = $('.lnb-dep2');
40            $secondDeps.stop().css('display', 'none');
41            $header.removeClass('menu-toggle');
42            $header.stop().animate({ 'height': '100px' }, speed);
43            $this.removeClass('on');
44            $this.find('.lnb-dep2').removeClass('on');
45        }
46    );
47}
48
49/**
50 * lnb mobile 버튼 클릭시 효과 (햄버거 + 1뎁스 아코디언)
51 */
52function lnbMobile() {
53    var $lnbBtnMobile = $('.lnb-m .btn-menu');
54    var $lnbCloseMobile = $('.lnb-m .btn-close');
55    var $lnbBgMobile = $('.lnb-m .bg-body');
56    var $lnbBoxMobile = $('.lnb-m .lnb-box');
57    var $firstDepsMobile = $('.lnb-m .lnb-navi > li');
58    var speed = 300;
59    $lnbBtnMobile.on('click', function() {
60        $lnbBgMobile.stop().fadeIn(speed);
61        $lnbBoxMobile.stop().css('display', 'block').animate({ 'right': '0' }, speed);
62    });
63    $lnbCloseMobile.on('click', function() {
64        $lnbBgMobile.stop().fadeOut(speed);
65        $lnbBoxMobile.stop().css('display', 'none').animate({ 'right': '-50%' }, speed);
66    });
67    $firstDepsMobile.on('click', function() {
68        var $this = $(this);
69        var $secondDeps = $this.find('.lnb-dep2');
70        $this.addClass('on');
71        $firstDepsMobile.not($this).find('.lnb-dep2').slideUp();
72        $firstDepsMobile.not($this).removeClass('on');
73        $secondDeps.stop().slideToggle();
74    });
75}
76
77/**
78 * 마우스 스크롤 효과 + TOP 버튼
79 */
80function scrollAnimate() {
81    var $window = $(window);
82    var $document = $('html, body');
83    var $btnTop = $('.btn-top');
84
85    // TOP 버튼 — 스크롤 핸들러 밖에서 1회만 바인딩 (원본 버그 수정)
86    $btnTop.on('click', function() {
87        $document.stop().animate({ scrollTop: 0 });
88    });
89
90    $window.on('scroll touchmove mousewheel', function() {
91        $('.hideme').each(function() {
92            var $this = $(this);
93            var $bottomObject = $this.offset().top + $this.outerHeight();
94            var $bottomWindow = $window.scrollTop() + $window.height();
95            if($bottomWindow > $bottomObject - 100) {
96                $this.addClass('in-view');
97            }
98        });
99    });
100}
101
102/**
103 * 공통 탭 버튼 (구 사이트에서 5개 페이지가 복붙하던 인라인 탭 전환 통합)
104 */
105function tabButton() {
106    var $tabBtn = $('.tab-nav > li');
107    var $tabCon = $('.tab-con > li');
108    $tabBtn.on('click', function(e) {
109        e.preventDefault();
110        var $idx = $(this).index();
111        $tabBtn.removeClass('on');
112        $tabBtn.eq($idx).addClass('on');
113        $tabCon.removeClass('on');
114        $tabCon.eq($idx).addClass('on');
115    });
116}
117
118/**
119 * 유투브 제어 함수 (postMessage — API 키 불필요)
120 */
121function playYoutube(obj) {
122    var iframe = obj[0].contentWindow;
123    iframe.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
124    iframe.postMessage('{"method":"setVolume", "value":1}', '*');
125}
126function pauseYoutube(obj) {
127    var iframe = obj[0].contentWindow;
128    iframe.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
129    iframe.postMessage('{"method":"setVolume", "value":0}', '*');
130}
131function stopYoutube(obj) {
132    var iframe = obj[0].contentWindow;
133    iframe.postMessage('{"event":"command","func":"stopVideo","args":""}', '*');
134    iframe.postMessage('{"method":"setVolume", "value":0}', '*');
135}
136function stopAllYoutube() {
137    $('iframe[src*="youtube.com"]').each(function() {
138        var iframe = $(this)[0].contentWindow;
139        iframe.postMessage('{"event":"command","func":"stopVideo","args":""}', '*');
140        iframe.postMessage('{"method":"setVolume", "value":0}', '*');
141    });
142}
143
144/**
145 * SNS 공유 (구 js/sns.js) — 라이브 사용은 facebook 공유·인쇄뿐
146 */
147$(document).on("click", ".btn-share-sns", function() {
148    var media = $(this).attr("data-media");
149    var message = $(this).attr("data-messages");
150    var locurl = $(this).attr("data-locurl");
151    shareSNS(media, message, locurl);
152});
153
154var fnPrint = function() {
155    window.print();
156};
157
158function shareSNS(media, message, locUrl) {
159    var sendUrl;
160    if(locUrl == undefined) {
161        locUrl = window.location.href;
162    }
163    switch(media) {
164        case "twitter":
165            sendUrl = "http://twitter.com/home?status=" + encodeURIComponent(message) + "+" + encodeURIComponent(locUrl);
166            snsPop(sendUrl, 600, 500, 'yes');
167            break;
168        case "facebook":
169            sendUrl = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(locUrl) + "&t=" + encodeURIComponent(message);
170            snsPop(sendUrl, 600, 500, 'yes');
171            break;
172        case "naverblog":
173            sendUrl = "http://blog.naver.com/openapi/share?url=" + encodeURIComponent(locUrl) + "&title=" + encodeURIComponent(message);
174            snsPop(sendUrl, 600, 500, 'yes');
175            break;
176        case "kakaostory":
177            sendUrl = "https://story.kakao.com/share?url=" + encodeURIComponent(locUrl);
178            snsPop(sendUrl, 600, 500, 'yes');
179            break;
180        case "band":
181            sendUrl = "http://www.band.us/plugin/share?body=" + encodeURIComponent(message) + "&route=" + encodeURIComponent(locUrl);
182            snsPop(sendUrl, 600, 500, 'yes');
183            break;
184        case "line":
185            sendUrl = "http://line.me/R/msg/text/?" + encodeURIComponent(message) + "%0D%0A" + encodeURIComponent(locUrl);
186            snsPop(sendUrl, 600, 500, 'yes');
187            break;
188    }
189}
190
191function snsPop(url, w, h, s) {
192    w = (s) ? w + 17 : w;
193    s = (s) ? 'yes' : 'no';
194    var sw = screen.availWidth;
195    var sh = screen.availHeight;
196    var left = (sw / 2) - (w / 2);
197    var top = (sh / 2) - (h / 2);
198    var winname = url.substr(url.lastIndexOf('/') + 1).split(/\.html|\.php/)[0];
199    window.open(url, winname, 'left=' + left + ',top=' + top + ',width=' + w + ',height=' + h + ',scrollbars=' + s + ',resizeable=no,menubar=no,status=yes,location=no,toolbar=no');
200}
201
202/**
203 * 주요활동(5개 탭 공통) 항목 토글 — 항목 타이틀(h5)만 노출하고 클릭 시 본문 펼침
204 * 템플릿·데이터 변경 없는 마크업 후처리라 페이지 콘텐츠 렌더·박제 폴백 모두 동작.
205 * 본문 없는 타이틀은 토글 대상에서 제외한다.
206 */
207$(function() {
208    $('.active .tbl-active tbody td').each(function() {
209        const $td = $(this);
210        const $tit = $td.children('h5').first();
211        if ($tit.length === 0) return;
212        const $body = $tit.nextAll();
213        if ($body.length === 0) return;
214        $body.wrapAll('<div class="act-toggle-body" style="display:none;"></div>');
215        $td.addClass('act-toggle-cell');
216        $tit.addClass('act-toggle-tit').attr({ role: 'button', tabindex: 0, 'aria-expanded': 'false' });
217    });
218
219    $(document).on('click keydown', '.act-toggle-tit', function(e) {
220        if (e.type === 'keydown' && e.key !== 'Enter' && e.key !== ' ') return;
221        e.preventDefault();
222        const $tit = $(this);
223        const isOpen = !$tit.hasClass('open');
224        $tit.toggleClass('open', isOpen).attr('aria-expanded', isOpen ? 'true' : 'false');
225        $tit.siblings('.act-toggle-body').stop(true, true).slideToggle(200);
226    });
227});

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.