PageSourceSearch

https://www.wikim.re.kr/sme/js/layout.js

js wikim.re.kr collected 2026-10-02 18:00:14 UTC 17,771 bytes, 534 lines download raw bytes

1/*-------------------------------------------------
2title       : 레이아웃
3-------------------------------------------------*/
4
5$(function()
6{	
7    // 사이트바로가기
8    $('.hnb1').classtoggle
9    ({
10        'button'            : '.label',     // 이벤트 받을 타겟 선택
11        'respond'           : true,         // 반응형일 때 (true 시 반응형일때 가로 사이즈 이하에서만 / click 일때만)
12        'respondWidth'      : '1024',       // 반응형 가로 사이즈
13    });
14
15    // 언어
16    $('.global').classtoggle
17    ({
18        'button'            : '.btn'  // 이벤트 받을 타겟 선택
19    });
20
21    // 패밀리사이트
22    $('.family').classtoggle
23    ({
24        'button'            : '.btn'  // 이벤트 받을 타겟 선택
25    });
26
27    // 검색어
28    $('.search').classtoggle();
29
30    // 주메뉴
31    $('#gnb1').gnb1();
32
33    // 전체메뉴이자 모바일 메뉴
34    $('#gnb2').gnb2();
35
36    // 퀵메뉴
37    $('#quick').classtoggle();
38
39    // 관련사이트
40    $('.related .group').classtoggle
41    ({
42        'button'            : '.label'  // 이벤트 받을 타겟 선택
43    });
44    
45    // 내용더보기
46    $('.agree').classtoggle
47    ({
48        'button'            : '.btn'  // 이벤트 받을 타겟 선택
49    });
50    
51    var windowWidth = $(window).width();
52	if(windowWidth > 1280){
53	    $(window).on('load',function(){
54	        $(window).scroll(function () {
55			    var _offsetTop = $(window).scrollTop();
56			    var _footerH = $('#footer').outerHeight() + 35;
57			    var _footerOffset = ($(document).height() - $(window).height()) - _footerH;
58	            if (_offsetTop >= 50) {
59	    			$('.btn-top').addClass('show');
60	    		} else {
61	    			$('.btn-top').removeClass('show');
62	    		}
63	            if (_offsetTop >= 400) {
64	    			$('.btn-top').addClass('black');
65	    		} else {
66	    			$('.btn-top').removeClass('black');
67	    		}
68	            if (_offsetTop > _footerOffset) {
69	                $('.btn-top').css('bottom', _footerH);
70	            }else{
71	                $('.btn-top').css('bottom', 35);
72	            }
73	        }).scroll();
74	    });
75	}
76});
77
78	
79/*앵커태그*/
80$(document).ready(function() {
81	$("#footer .btn-top a").anchorAnimate();
82});
83
84jQuery.fn.anchorAnimate = function(settings) {
85
86 	settings = jQuery.extend({
87		speed : 1100
88	}, settings);	
89	
90	return this.each(function(){
91		var caller = this
92		$(caller).click(function (event) {	
93			event.preventDefault();
94			var locationHref = window.location.href
95			var elementClick = $(caller).attr("href");
96			
97			var destination = $(elementClick).offset().top;
98			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
99				window.location.hash = elementClick
100			});
101		  	return false;
102		});
103	});
104};
105
106/*-------------------------------------------------
107title       : 메뉴1
108-------------------------------------------------*/
109
110$.fn.gnb1 = function( options )
111{
112    var settings = $.extend
113    ({
114        'actionType'        : 'mouseenter focusin',     // 메뉴가 동작하는 액션 (mouseenter focusin, click)
115        'target'            : '#wrap',                // 활성화 시 클래스가 추가되는 요소 (공란일 경우 오버되는 a 링크 부모 li에만 í
115´ëž˜ìФ 추가됨)        
116        'class'             : 'active',                 // 추가할 클래스명 (target에 추가됨)
117        'depth2'            : '.submenu',               // 서브메뉴
118        'closeBtn'          : '.close'                  // 닫기 버튼이 별도로 존재하는 경우 (닫기 버튼은 클릭시에만)
119    }, 
120    options );
121
122    // gnb2 2차 메뉴 가지고 있는 li에 클래스 추가
123    $('#gnb1 .submenu > ul > li').each(function(i)
124    {
125        if ( $(this).find('div').length > 0 )
126        {
127            $(this).addClass('type1');
128        }
129    });
130    
131    //현재 페이지 메뉴 active
132    $('#gnb1 .submenu > ul > li > a').each( function(){
133    	const now_page_url = new URL(window.location.href);
134    	const menu_url = new URL($(this).prop('href'));
135    	const urlParams = now_page_url.searchParams;
136    	const menu_urlParams = menu_url.searchParams;
137    	var href = $(this).prop('href');
138    	if(urlParams.get("mid") != null && urlParams.get("mid") ==  menu_urlParams.get("mid")){
139    		$(this).parents().addClass('on');
140    	}
141	});
142    
143  //현재 페이지 메뉴 active
144    $('#gnb1 .submenu > ul > li > div > ul > li > a').each( function(){
145    	const now_page_url = new URL(window.location.href);
146    	const menu_url = new URL($(this).prop('href'));
147    	const urlParams = now_page_url.searchParams;
148    	const menu_urlParams = menu_url.searchParams;
149    	var href = $(this).prop('href');
150    	if(urlParams.get("mid") != null && urlParams.get("mid") ==  menu_urlParams.get("mid")){
151    		$(this).parents('li').addClass('on');
152    	}
153	});
154    
155    return this.each(function()
156    {
157        var $selecter = $(this);
158
159        $selecter.find('a').on(settings.actionType, function()
160        {
161            if ( $("#wrap").hasClass('active') == false )
162            {
163            	 $("#wrap").addClass('active');
164            }
165            
166            if ( $(this).parent('li').hasClass('active') == false )
167            {
168            	$('.lnb-detail-item').removeClass('active');
169                $(this).parent('li').addClass('active');
170                $(this).parent('li').siblings('li').removeClass('active');
171
172                $(this).parents('li').addClass('active');
173                $(this).parents('li').siblings('li').removeClass('active');
174
175                if (settings.target != '')
176                {
177                    $(settings.target).addClass('active');
178                }
179            }
180
181            if ( settings.actionType == 'click' )
182            {
183                if ( $(this).next('*').length > 0 )
184                {
185                    return false;
186                }
187            }
188        });
189
190        // 탭 아웃
191        $selecter.find('a:last').keydown(function(e) 
192        {
193            if(e.keyCode === 9) 
194            {
195                $selecter.find('li').removeClass(settings.class);
196                $(settings.target).removeClass('active');
197            }
198        });
199
200        // 역탭 아웃
201        $selecter.find('a:first').keydown(function(e) 
202        {
203            if(e.keyCode === 9 && e.shiftKey) 
204            {
205                $selecter.find('li').removeClass(settings.class);
206                $selecter.removeClass('active');
207            }
208        });
209        // 마우스 아웃
210    	$('.header_wrap').on('mouseleave',function(){
211    		$('#wrap').removeClass('active');
212    		$('#gnb1 #head_menu').children().removeClass('active');
213    	});
214    });
215};
216
217/*-------------------------------------------------
218title       : 메뉴2
219-------------------------------------------------*/
220
221$.fn.gnb2 = function( options )
222{
223    var settings = $.extend
224    ({
225        'btnOpen'           : '.open',      // 최초 메뉴를 여는 버튼
226        'btnClose'          : '.close',     // 닫기 버튼이 별도로 존재하는 경우
227        'classAdd'          : '#gnb2',      // 활성화 시 클래스가 추가되는 요소
228        'className'         : 'active',     // 추가할 클래스명 (classAdd에 추가됨)
229        'siblings'			: true,		    // active 될 때 형제요소의 반응 여부
230        'responsive'        : false,         // 반응형일 때 (true 시 반응형일때 가로 사이즈 이하에서만 / fal
230se 시 반응형 아닐 때도 클릭 동작함)
231        'responsiveWidth'   : '1024',        // 반응형 가로 사이즈
232        'target'            : '#wrap',                // 활성화 시 클래스가 추가되는 요소 (공란일 경우 오버되는 a 링크 부모 li에만 클래스 추가됨)        
233        'class'             : 'sitemap',                 // 추가할 클래스명 (target에 추가됨)
234        	
235    }, 
236    options );
237    
238    // gnb2 2차 메뉴 가지고 있는 li에 클래스 추가
239    $('#gnb2 .submenu > ul > li').each(function(i)
240    {
241        if ( $(this).find('div').length > 0 )
242        {
243            $(this).addClass('type1');
244        }
245    });
246    
247    // 모바일 class active가 있는지 체크, 없다면 첫메뉴 active
248    if(!$('#gnb2 > ul.topmenu_all > li').hasClass('active')){
249    	$('#gnb2 > ul.topmenu_all > li.mnfirst').addClass('active');
250    }
251    
252    // 모바일 메뉴에서 3뎁스 있을 때
253	$('#gnb2 .submenu > ul > li.type1 > a').on('click', function(){
254		if($(this).parent().hasClass('active')){
255			$(this).parent().removeClass('active');
256		}else{
257			$(this).parent().addClass('active').siblings().removeClass('active');
258		}		
259		return false;
260	});
261    
262    return this.each(function()
263    {
264        var $selecter = $(this);
265
266        // 열기
267        $selecter.find(settings.btnOpen).on('click', function()
268        {
269            if ( $selecter.find(settings.btnClose).length > 0 )
270            {            
271                $(settings.classAdd).addClass(settings.className);
272                $(settings.target).addClass(settings.class);
273            }
274            
275            else
276            {
277                if ( $(settings.classAdd).hasClass(settings.className) == false )
278                {
279                    $(settings.classAdd).addClass(settings.className);
280                }
281                else
282                {
283                    $(settings.classAdd).removeClass(settings.className);
284                }
285            }
286
287            return false;
288        });
289        
290        // 닫기
291        if ( $selecter.find(settings.btnClose).length > 0 )
292        {
293            $selecter.find(settings.btnClose).on('click', function()
294            {
295                $(settings.classAdd).removeClass(settings.className);
296                $(settings.target).removeClass(settings.class);
297
298                return false;
299            });
300        };
301
302        // 메뉴 클릭 이벤트
303        function menuAction($this)
304        {
305        	 if ( $this.next('*').length > 0 && $this.next('*').css('display') != 'none' )
306            {
307        		 $this.parent('li').siblings('li').removeClass('active');
308                 $this.parent('li').addClass('active');
309
310                event.preventDefault();
311            }      
312        }
313
314        // 메뉴
315        $selecter.find('li a').on('click', function(e)
316        {
317            if ( settings.responsive == true )
318            {
319                if ( $(window).width() <= settings.responsiveWidth )
320                {
321                    menuAction($(this));
322                }
323            }
324            else
325            {
326                menuAction($(this));
327            }
328        });
329    });
330};
331
332/*-------------------------------------------------
333title       : 클래스를 넣고 빼고
334Author      : 
335Create date : 2021-07-06
336-------------------------------------------------*/
337
338$.fn.classtoggle = function( options )
339{
340    var settings = $.extend
341    ({
342        'button'            : '.open',      // 이벤트 받을 타겟 선택
343        'action'            : 'click',      // 액션 선택 (click | over)
344        'classname'         : 'active',     // 추가할 클래스명
345        'accordion'			: false,		// active 될 때 형제요소의 반응 여부
346        'respond'           : false,        // 반응형일 때 (true 시 반응형일때 가로 사이즈 이하에서만 / click 일때만)
347        'respondWidth'      : '768',        // 반응형 가로 사이즈
348        'close'             : '.close',      // 닫기 버튼이 별도로 존재하는 경우 (닫기 버튼은 클릭시에만)
349        'menu_yn'			: 'N'			//메뉴 열림, 닫힘 title 제공
350    }, 
351    options );
352
353    return this.each(function()
354    {
355        var $selecter = $(this);
356
357        function clickActive()
358        {
359            if ( $selecter.hasClass(settings.classname) == false )
360            {
361            	if(settings.menu_yn == 'Y'){
362            		$selecter.attr("title","메뉴 열림");
363            	}
364                $selecter.addClass(settings.classname);
365
366                if (settings.accordion == true)
367                {
368                    $selecter.siblings().removeClass(settings.classname);
369                }
370            }
371            else
372            {
373            	if(settings.menu_yn == 'Y'){
374            		$selecter.attr("title","메뉴 닫힘");
375            	}
376                // 닫기 버튼 존재할 경우 토글되지 않음
377                if ( $selecter.find(settings.close).length == 0 )
378                {
379                    $selecter.removeClass(settings.classname);
380                }
381            }
382        }
383
384        if ( settings.action == 'click' )
385        {
386            $selecter.find(settings.button).on(settings.action, function()
387            {
388                if ( settings.respond == false )
389                {
390                    clickActive();
391
392                    return false;
393                }
394                else
395                {
396                    if ( $(window).width() <= settings.respondWidth )
397                    {
398                        clickActive();
399
400                        return false;
401                    }
402                    else
403                    {
404                        $selecter.find(settings.button).off();
405                    }
406                }
407            });
408        }
409        else
410        {
411            $selecter.find(settings.button).on
412            ({
413                mouseenter  : function()
414                {
415                    $selecter.addClass(settings.classname);
416                },
417                focusin     : function()
418                {
419                    $selecter.addClass(settings.classname);
420                },
421                mouseleave  : function()
422                {
423                    $selecter.removeClass(settings.classname);
424                },
425                focusout    : function()
426                {
427                    $selecter.removeClass(settings.classname);
428                }
429            });
430        }
431
432        // 닫기 버튼이 별도로 존재하는 경우
433        if ( $selecter.find(settings.close).length > 0 )
434        {
435            $selecter.find(settings.close).on('click', function()
436            {
437                $selecter.removeClass(settings.classname);
438
439                return false;
440            });
441        }
442        else
443        {
444            // 탭 아웃
445            $selecter.find('a:last').keydown(function(e) 
446            {
447                if(e.keyCode === 9) 
448                {
449                    $selecter.removeClass(settings.classname);
450                }
451            });
452
453            // 역탭 아웃
454            $selecter.find('a:first').keydown(function(e) 
455            {
456                if(e.keyCode === 9 && e.shiftKey) 
457                {
458                    $selecter.removeClass(settings.classname);
459                }
460            });
461        }
462    });
463};
464
465/*텍스트 복사*/
466function copyToClipboard(elementId) 
467{
468	var aux = document.createElement("input");
469	aux.setAttribute("value", document.getElementById(elementId).innerHTML);
470	document.body.appendChild(aux);
471	aux.select();
472	document.execCommand("copy");
473	document.body.removeChild(aux);
474	alert('주소가 복사되었습니다.');
475}
476
477//head_menu_depth - class on 추가
478$(function(){
479	var url = window.location.href;
480	const url2 = new URL(url);
481	// URLSearchParams 객체
482	const urlParams = url2.searchParams;
483	
484	if(urlParams != "" && urlParams.get('mid') != null){
485		var sid = urlParams.get('mid').substr(0, 2);
486		var depth1_mid = urlParams.get('mid').substr(2, 2)+"00000000C";
487		var depth1_mid_ori = urlParams.get('mid').substr(2, 2)+"00000000";
488		var depth2_mid = urlParams.get('mid').substr(2, 4)+"000000C";
489		var depth3_mid = urlParams.get('mid').substr(2, 6)+"0000C";
490		var depth4_mid = urlParams.get('mid').substr(2, 8)+"00C";
491		var depth5_mid = urlParams.get('mid').substr(2, 10)+"C";
492		
493		if($("#depth1_li"+depth1_mid).hasClass('hide')){
494			$("li[id*='depth1_li']").each(function(){
495				var check = this.id;
496				if(check.indexOf(depth1_mid_ori) == -1){
497					$("#"+check).hide();
498				}
499			});
500		}else{
501			$("li[id*='depth1_li']").each(function(){
502				var check = this.id;
503				if($("#"+check).hasClass('hide')){
504					$("#"+check).hide();
505				}
506			});
507		}
508		
509		$("#depth1_li"+depth1_mid).addClass('on');
510		$("#depth2_li"+depth2_mid).addClass('on');
511		$("#depth3_li"+depth3_mid).addClass('on');
512		$("#depth4_li"+depth4_mid).addClass('on');
513		$("#depth5_li"+depth5_mid).addClass('on');
514	}
515	
516	// 숨김메뉴
517    const searchParams = new URLSearchParams(location.search);
518	for (const param of searchParams) {
519	  if(param[0] == 'mid'){
520	  	var depth1_active_id = $('ul#head_menu_depth1 > li.active').attr('id');
521	    var depth2_active_id = $('ul#head_menu_depth2 > li.active').attr('id');
522	    if (depth2_active_id == undefined) {
523	    	$("ul#head_menu_depth1 > li.active.hide").removeClass('hide'); 
524	    	$("ul#head_menu_depth1 > li.on.hide").removeClass('hide'); 
525		    break;
526	    
527	    } else if (depth1_active_id.substring(9, 11) == depth2_active_id.substring(9, 11) ) {
528	    	$("ul#head_menu_depth1 > li.active.hide").removeClass('hide'); 
529	    	$("ul#head_menu_depth1 > li.on.hide").removeClass('hide'); 
530		    break;
531	    }
532	  }
533	}
534});

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.