PageSourceSearch

https://dept.ysc.ac.kr/resources/_Templet/Header/header_tmpl/Js/topmenu.js

js ysc.ac.kr collected 2026-10-01 14:40:07 UTC 17,745 bytes, 629 lines download raw bytes

1var mnTitBoxContent ={
2    "sText0":""
3};
4
5var mnOvNum = [];
6var mainNavi_W = {
7		mnObj : $("#mainNavi"),Timer:null,subTimer:null,isOver:false,initNum:[],
8	_init:function(){
9
10		var this_s = this;
11
12		//alert(this.mnObj.length);
13		$("li",$(this.mnObj)).each(function(){
14			if($("ul",$(this)).length>0 && !$(this).hasClass("has-sub")) $(this).addClass("has-sub");
15			$("#mainNavi li button.tgl-btn").remove();
16
17		});
18		this._initOvNum();
19		this.setEvt();
20
21
22	},
23	_set:function(){
24
25	},
26	_unset:function(){
27
28	},
29	_retset:function(){
30		this.setEvt();
31	},
32	isOpen:function(){
33		return this.mnObj.hasClass("mn-h-open");
34	},
35	clearEvt:function(){
36		$(".depth2-wrap").hide();
37		$("a",$(this.mnObj)).unbind("mousedown mouseover focus click mouseout blur");
38		$(".depth2-wrap",$(this.mnObj)).unbind("mousedown mouseover click focus mouseout blur");
39		$("> li > .depth2-wrap",$(this.mnObj)).unbind("mousedown mouseover click focus mouseout blur");
40	},
41	setEvt:function(){
42		var this_s = this;
43		this.clearEvt();
44
45		$(".depth2-wrap",$(this.mnObj)).bind("mouseover focus", function(){	clearTimeout(this_s.subTimer ); this_s.isSubOver = true;	});
46		$(".depth2-wrap",$(this.mnObj)).bind("mouseout blur", function(){	clearTimeout(this_s.subTimer ); this_s.isSubOver = false;this_s.setSubMenuOutSet(500);	});
47
48		$("a",$(this.mnObj)).bind("mouseover focus", function(){	 clearTimeout(this_s.subTimer ); this_s.isOver = true;	});
49		$("> li > .depth2-wrap",$(this.mnObj)).bind("mouseover focus", function(){	clearTimeout(this_s.subTimer );  this_s.isOver = true;	});
50
51		$("a",$(this.mnObj)).bind("mouseout blur", function(){	clearTimeout(this_s.subTimer ); this_s.isSubOver = false;this_s.setSubMenuOutSet(500); this_s.setMenuOut();	});
52		$("> li > .depth2-wrap",$(this.mnObj)).bind("mouseout blur", function(){	this_s.setMenuOut();	});
53		var tmpItems = $(".mn_li1",$(this.mnObj)) ;
54
55		for (i=0;i<tmpItems.length ;i++ )
56		{
57			var thisSubObj = $(".depth2-wrap" ,$(tmpItems[i]));
58			//var subH = $(thisSubObj).stop().show().css({"visibility":"visible","height":"auto"}).outerHeight();
59
60			//thisSubObj.prop("sHeight",$(".depth2-wrap",$(tmpItems[i])).outerHeight()).css({"overflow":"hidden"});
61		}
62
63		var mnItems = $(".mn_a1",$(this.mnObj)) ;
64		for (var i=0; i < mnItems.length ; i++ ){
65			mnItems[i].seq = i + 1;
66			$($(mnItems[i]).parents("li").get(0)).attr("seq",mnItems[i].seq);
67			$(mnItems[i]).bind("mouseover focus",function(){
68				var seq = $($(this).parents("li").get(0)).index() + 1;
69				this_s.setMenuOn(seq);
70			});
71
72			$(".depth2 a",$(mnItems[i])).each(function(){
73				var li2 = $($(this).parents("li.mn_l2").get(0));
74				var li1 = $($(li2).parents("li.mn_li1").get(0));
75
76				var n = $(li1).attr("seq");
77				$(this).attr("seq",n);
78				$(this).attr("seq2",$(li2).index()+1);
79
80
81				$(this).bind("mouseover focus",function(){
82					var n =$(this).attr("seq");
83					var n2 = $(this).attr("seq2");
84					this_s.setMenuOn(n,n2);
85
86				});
87			});
88		}
89		
90		$(".depth2-wrap",$(this.mnObj)).each(function(){
91			var n = $(this).parent().index();
92			if($(this).has(".depth1-tit").length<1){
93				//var sloganText = mnSloganText[n-1];
94				$(this).prepend("<div class='depth1-tit'><strong>"+$(".logo .logo-txt").text()+"</strong></div>");
95			}
96		});
97		
98		var chkMn =  (this.initNum[0]>0)? $(".mn_li1:eq(" +(this.initNum[0]-1)+")", this.mnObj) : null;
99		if(chkMn!=null && chkMn.length>0){
100			 this.isFirstOpen = true;
101		}else{
102			this.isFirstOpen = false;
103		}
104
105		if(this.initNum[0]<1) {
106
107		}else{
108			this.setMenuOn(this.initNum[0],this.initNum[1],this.initNum[2]);
109		}
110	},
111	resetMenuBar:function(){
112		this.setMenuBar(this.currentSeq);
113	},
114	setMenuBar:function(n){
115		var thisMenu = (n>0)? $(".mn_li1:eq(" + ( n-1 ) +")", this.mnObj):null;
116		var otherMenu = $(".mn_li1", this.mnObj).not(thisMenu);
117
118		$(thisMenu).addClass("over");
119		$(otherMenu).removeClass("over");
120
121		if(this.ovbar!=undefined){
122		this.ovbar.stop().animate({
123
124			width: (thisMenu!=null)? thisMenu.width()  -30 : 0,
125			left:(thisMenu!=null)? $(this.mnObj).position().left + thisMenu.position().left + 15 : 0
126		},300);
127		}
128
129		//IE8 메뉴바 사이즈 오류 보정
130		var this_s = this;	try{			if(!lowReloadCheck(function(){ this_s.setMenuBar(n); },{cnt:0,Timer:null,limit:5})){			}			}catch(e){}
131	},
132	setMenuOn:function(){
133		clearTimeout(this.Timer );
134		var this_s = this;
135		var s  = new Array();
136		for(var i=0; i<arguments.length;i++){
137			s[i] = arguments[i];
138		}
139		if(parseInt(s[1])<1 || s[1]==undefined) s[1] = 0;
140		var thisMenu = (s[0]>0)? $(".mn_li1:eq(" + ( s[0]-1 ) +")", this.mnObj) : null;
141		var subMenu = $("> .depth2-wrap",$(thisMenu));
142		var otherMenu = $(".mn_li1", this.mnObj).not(thisMenu);
143		var otherSubMenu = $("> .depth2-wrap",$(otherMenu));
144		if(this.currentSeq !=s[0]  || this.isSubClose){
145			this.setSubMenuOut(this.currentSeq);
146			$(thisMenu).addClass("over");
147			if(!this.isFirstOpen) this.setSubMenuOn(s[0]);
148		}
149		$(otherMenu).removeClass("over");
150		if(!this.isFirstOpen) this.currentSeq = s[0];
151		this.isFirstOpen = false;
152		this.setMenuBar(s[0]);
153	},
154
155	getSubMenuHeight:function(subMn){
156
157		var tmpItems = $(".mn_li1",$(this.mnObj)) ;
158		var maxSubHeight = 0;
159		for (i=0;i<tmpItems.length ;i++ )
160		{
161			var thisSubObj = $(".depth2-wrap" ,$(tmpItems[i]));
162			var subH = $(thisSubObj).stop().show().css({"visibility":"visible","height":"auto"}).outerHeight();
163
164			if(maxSubHeight <=subH) maxSubHeight = subH;
165		}
166
167		return maxSubHeight;
168	},
169	getMenuBarHeight:function(){
170		var h = _getLayoutHeaderHeight() - parseInt($("#mainNavi-wrap").css("top"));
171		return h;
172	},
173	
174	subMenuBarClose:function(){
175		$("#mainNavi-wrap").stop().animate({"height":$("#mainNavi").height()},300).removeClass("over");
176		$(".mn-bg").stop().animate({"height":0},300).removeClass("is-open");
177	},
178
179	setSubMenuOn:function(seq){
180		clearTimeout(this.subTimer );
181		var this_s = this;
182
183		this_s.isSubClose = false;
184
185		var subMenu = (seq>0)? $(".mn_li1:eq(" +  (seq -1) +")  .depth2-wrap",this.mnObj) : null;
186		//서브메뉴 박스 높이에 맞게 wrap 높이 조절
187
188		$(".mn_li1 .depth2-wrap").not(subMenu).hide();
189
190		if(subMenu!=null && subMenu.length>0){
191
192			// ** 열릴때
193			$(subMenu).show().css({"opacity":0});
194
195			$("#header-wrap").addClass("over");
196			// ** li.mn_l2 높이 일치화. PC
197			var maxHeight = -1;
198			$(".depth2-ul > li.mn_li2" , subMenu).each(function() {
199				maxHeight = (maxHeight > $(this).height()) ? maxHeight : $(this).height();
200			});
201			$(".depth2-ul > li.mn_li2" , subMenu).each(function() {
202				$(this).css({ "height":maxHeight+"px" });
203			});
204
205			var toH = $("#mainNavi").height() + $(subMenu).outerHeight();
206			var subH = $(subMenu).height();
207			$("#mainNavi-wrap").stop().addClass('over').animate({"height":toH},300);
208			$(".mn-bg").stop().animate({"height":subH},300).addClass("is-open");
209			$(subMenu).animate({"opacity":1},300);
210		}else{
211			$("#mainNavi-wrap").stop().removeClass("over").animate({"height":$("#mainNavi").height()},300);
212			$(".mn-bg").stop().animate({"height":0},300).removeClass("is-open");
213		}
214
215		this.setSubMenuOutSet(4000);
216
217	},
218	setSubMenuOut:function(seq){
219
220		clearTimeout(this.subTimer );
221		var this_s = this;
222		var subMenu = $("> li:eq(" +  (seq -1) +") .depth2-wrap",this.mnObj);
223
224		$("#mainNavi-wrap").stop().animate({"height":$("#mainNavi").height()},300);
225
226	},
227	setSubMenuOutSet:function(time){
228		var this_s = this;
229		this.subTimer = setTimeout(function(){
230			if(!this_s.isSubOver){
231
232				this_s.isSubClose = true;
233
234				// ** 닫힐때
235				//*
236				$("#mainNavi-wrap").stop().animate({height: _getLayoutHeaderHeight()},300,function(){});
237				$("#mainNavi-wrap").stop().removeClass('over').animate({"height":$("#mainNavi").height()},300,
238					function() {
239						$("#header-wrap").delay(300).removeClass("over");
240					}
241				);
242				$(".depth2-wrap").stop().animate({opacity:1},300,function(){$(this).hide();});	//전체 서브메뉴 숨김
243				$(".mn-bg").stop().delay(100).animate({"height":0},300).removeClass("is-open");
244				// */
245
246				var thisMn =  (this_s.initNum[0]>0)? $("> li:eq(" + ( this_s.initNum[0]-1 ) +")",this_s.mnObj) :null;
247				var otherMenu = $("> li", this_s.mnObj).not(thisMn);
248
249				if(thisMn!=null) thisMn.addClass("over");
250				otherMenu.removeClass("over");
251				this_s.setMenuBar(this_s.initNum[0]);
252
253			}else{
254			}
255
256		},time);
257	},
258	setMenuOut:function(){
259		clearTimeout(this.Timer );
260		var this_s = this;
261		this.isOver = false;
262		this.Timer = setTimeout(function(){
263
264			if(this_s.isOver==false) {
265			}
266		},400);
267	},
268	_initOvNum:function(initNum){
269
270		if(initNum!=undefined) this.initNum = initNum;
271		else{
272			//Over Number Search
273			this.initNum[0] =( $(".mn_li1.over",this.mnObj).length> 0)? $(".mn_li1.over",this.mnObj).index() + 1 : 0;
274			this.initNum[1] =( $(".mn_l2.over",this.mnObj).length> 0)? $(".mn_l2.over",this.mnObj).index() + 1 : 0;
275			this.initNum[2] =( $(".mn_l3.over",this.mnObj).length> 0)? $(".mn_l3.over",this.mnObj).index() + 1 : 0;
276		}
277	}
278}
279
280
281
282var mainNavi_H = {
283	mnObj : $("#menu-wrap"),Timer:null,subTimer:null,isOver:false,initNum:[],
284	_init:function(){
285		// ** li.mn_l2 높이 일치화 해제. MOBILE
286		$(".depth2-ul > li.mn_li2").css({ "height":"auto" });
287
288		var this_s = this;
289		this.setBodyContainer();
290		$("li",$(this.mnObj)).each(function(){
291			var sLI = $("ul",$(this));
292			if(sLI.length>0){
293				if ($(">.tgl-btn",this).length<1)
294				$(this).prepend("<button class='tgl-btn' type='button'><span class='blind'>하위메뉴보기</span></button>");
295				$(this).addClass("has-sub");
296				$(this).addClass("is-close");
297				if($(this).hasClass("over")){
298					if(this_s.isOpen)	this_s.openSubMenu($(this));
299				}
300			}
301	});
302
303	$("#btn-open-mn").click(function(){ this_s.toggleMenu(); });
304		this._initOvNum();
305		this.setEvt();
306	},
307	_set:function(){},
308	_unset:function(){
309		this.closeMenu();
310	},
311
312	_retset:function(){
313		this.setEvt();
314	},
315	isOpen:function(){
316		return this.mnObj.hasClass("mn-h-open");
317	},
318	clearEvt:function(){
319		$("a",$(this.mnObj)).unbind("mousedown mouseover focus click mouseout blur");
320		$(".depth2-wrap",$(this.mnObj)).unbind("mousedown mouseover click focus mouseout blur");
321		$("> li > .depth2-wrap",$(this.mnObj)).unbind("mousedown mouseover click focus mouseout blur");
322	},
323	setEvt:function(){
324		var this_s = this;
325		this.clearEvt();
326
327		$("a",$(this.mnObj)).unbind("mousedown mouseover focus click mouseout blur");
328		$(".depth2-wrap",$(this.mnObj)).unbind("mouseover focus mouseout blur");
329		$("> li > .depth2-wrap",$(this.mnObj)).unbind("mouseover focus mouseout blur");
330
331		$("a",$(this.mnObj)).bind("focus", function(){
332			this_s.isOver = true;
333			if(!this_s.isOpen()){				this_s.openMenu();			}
334		});
335		$("a",$(this.mnObj)).bind("blur", function(){		});
336
337		$("*",$(this.mnObj)).bind("mouseover", function(){
338			this_s.isOver = true;
339		});
340		$("*",$(this.mnObj)).bind("mouseout", function(){
341			this_s.isOver = false;
342			this_s.clearTimer();
343			//this_s.setCloseMenu();
344
345		});
346
347		$(".tgl-btn",$(this.mnObj)).bind("click", function(){
348			var thisParentEl = $($(this).parents("li").get(0));
349			if(thisParentEl.hasClass("has-sub")){
350				this_s.toggleSubMenu(thisParentEl);
351			}else{
352				return;
353			}
354		});
355
356		$("a",$(this.mnObj)).bind("click", function(){
357			var thisParentEl = $($(this).parents("li").get(0));
358			if(thisParentEl.hasClass("has-sub")){
359				if(thisParentEl.hasClass("is-open")){
360					return true;
361				}else{
362					this_s.openSubMenu(thisParentEl);
363				}
364				return false;
365			}else{
366				return true;
367			}
368		});
369
370		//this.setMenuOn(this.initNum[0]);
371
372	},
373	setMenuOn:function(){
374		var this_s = this;
375		var s  = new Array();	for(var i=0; i<arguments.length;i++){			s[i] = arguments[i];			}
376		var li = (s[0]>0)? $(".mn_l1:eq(" + ( s[0]-1 ) +")", this.mnObj) : null;
377
378		//this_s.openSubMenu(li);
379	},
380
381	///////////////////////////////////
382	openSubMenu:function(selLi){
383		var this_s = this;
384		var li = $(selLi);
385
386		li.addClass("is-open");
387		$(">div",li).slideDown("fast",function(){  this_s.setContentHeight(); });
388
389		var parentUL = $(li).parent();
390		$(" > li",parentUL).not(li).each(function(){
391			this_s.closeSubMenu($(this));
392		});
393
394	},
395	closeSubMenu:function(li){
396		var this_s = this;
397
398		li.removeClass("is-open");
399		$(">div",li).slideUp("fast",function(){  this_s.setContentHeight(); });
400	},
401	toggleSubMenu:function(li){
402		var this_s = this;
403
404		if($(li).hasClass("is-open")){
405			this_s.closeSubMenu($(li));
406		}else{
407			this_s.openSubMenu($(li));
408		}
409
410	},
411	setContentHeight:function(){
412		this.clearTimer();
413		this.subTimer = setTimeout(function(){
414			try{setLayoutMinHeight();}catch(e){}
415		},300);
416	},
417
418	//////////////////////////////////
419	toggleMenu:function(){
420
421		if(this.isOpen()){
422			this.closeMenu();
423		}else{
424			this.openMenu();
425		}
426
427	},
428	openMenu:function(){
429		var this_s = this;
430		if(!this.mnObj.hasClass("mn-h-open")){
431			this.mnObj.addClass("mn-h-open");
432		}
433
434		if($(".body-slider-ovclick").length<1) $("body").append("<div class='body-slider-ovclick'/>");
435		var $back = 	$(".body-slider-ovclick");
436		var $back_btn = $(".btn-close-mn");
437		$back.unbind("click").bind("click",function(){
438			this_s.closeMenu();
439		}).stop().css({"left":-400}).show();
440		$back_btn.unbind("click").bind("click",function(){
441			this_s.closeMenu();
442		});
443
444		//$("body").css({"overflow":"hidden"});
445		$(".body-slide-wr").addClass("off").bind("touchmove");
446		$("#global-wrap").addClass("over");
447		$("#mn-ctr-toggle").hide();
448
449	},
450	closeMenu:function(){
451		if(this.mnObj.hasClass("mn-h-open")){
452			this.mnObj.removeClass("mn-h-open");
453		}
454		$(".body-slider-ovclick").hide();
455
456		//$("body").css({"overflow":"visible"});
457		$(".body-slide-wr").css({"margin-left":0});
458		$("#t-logo").css({"z-index":15});
459		$("#global-wrap").removeClass("over");
460		$("#mn-ctr-toggle").show();
461	},
462	setBodyContainer:function(){
463		/*
464		if($(".body-slide-wr").length<1){
465			$(".doc-pg").wrapInner("<div class='body-slide-wr'/>");
466			$(".body-slide-wr").wrapInner("<div class='body-slide'/>");
467			$(".body-slide-wr").css({"overflow":"hidden"});
468		}
469		*/
470	},
471
472	clearTimer:function(){
473		try{clearTimeout(this.Timer);clearTimeout(this.subTimer);}catch(e){}
474	},
475	_initOvNum:function(initNum){
476
477		if(initNum!=undefined) this.initNum = initNum;
478		else{
479			//Over Number Search
480			this.initNum[0] =( $(".mn_li1.over",this.mnObj).length> 0)? $(".mn_li1.over",this.mnObj).index() + 1 : 0;
481			this.initNum[1] =( $(".mn_l2.over",this.mnObj).length> 0)? $(".mn_l2.over",this.mnObj).index() + 1 : 0;
482			this.initNum[2] =( $(".mn_l3.over",this.mnObj).length> 0)? $(".mn_l3.over",this.mnObj).index() + 1 : 0;
483		}
484	},
485	setMenuOn:function(){
486		clearTimeout(this.Timer );
487		var this_s = this;
488		var s  = new Array();
489		for(var i=0; i<arguments.length;i++){
490			s[i] = arguments[i];
491		}
492
493		var thisMenu = (s[0]>0)? $(".mn_li1:eq(" + ( s[0]-1 ) +")", this.mnObj) : null;
494		var subMenu = $("> .depth2-wrap",$(thisMenu));
495		var otherMenu = (s[0]>0)? $(".mn_li1", this.mnObj).not(thisMenu): $(".mn_li1", this.mnObj);
496
497		var otherSubMenu = $("> .depth2-wrap",$(otherMenu));
498
499		$(thisMenu).addClass("over");
500
501
502		this_s.setSubMenuOn(s[0],0);
503		var toH = this_s.getSubMenuHeight(subMenu);
504
505		$(subMenu).stop().css({"visibility":"visible"}).hide();
506		subMenu.slideDown();
507
508		if(s[0]==this.initNum[0]){
509			this_s.setSubMenuOn(s[0],this.initNum[1]);
510		}
511
512
513		$(otherMenu).removeClass("over");
514		$(otherSubMenu).hide();
515
516		this.currentSeq = s[0];
517	},
518	setMenuOut:function(){
519		clearTimeout(this.Timer );
520		var this_s = this;
521		this.isOver = false;
522		this.Timer = setTimeout(function(){
523			if(this_s.isOver==false) {
524				this_s.setMenuOn(this_s.initNum[0]);
525			}
526		},400);
527	},
528	menuOnAction:function(obj){
529		var thisParentEl = $($(obj).parents("li").get(0));
530			var thisSubObj = $(".depth2-wrap",thisParentEl);
531			//alert(this.seq +"click");
532			if(thisSubObj.length>0 && this_s.currentSeq!=obj.seq){
533				this_s.setMenuOn(obj.seq);
534				return false;
535			}
536
537
538	},
539	setSubMenuOn:function(n1,n2){
540		return;
541		var subMns = $(".depth3-wrap",$(this.mnObj));
542		if(n2>0){
543			var thisSubMns = $(" .mn_li1:eq("+(n1-1)+") .depth2-wrap .mn_l2:eq("+(n2-1)+") .depth3-wrap",$(this.mnObj));
544			var toH = $(".depth3",thisSubMns).outerHeight();
545			thisSubMns.stop().animate({"height":toH},300);
546			subMns.not(thisSubMns).stop().css({"height":0});
547		}else{
548			subMns.stop().css({"height":0});
549		}
550
551	},
552	getSubMenuHeight:function(subMn){
553
554		$(subMn).css({"visibility":"hidden","height":"auto","padding-top":"0px","padding-bottom":"0px"});
555
556		return $(".depth2",subMn).outerHeight();
557	}
558}
559
560
561var mainNavi = {
562	mnObj : $("#menu-wrap"),
563	initNum:Array(), currNum:Array(), Timer:null, mnType:"",
564	_init:function(mn,initNum){
565		var this_s = this;
566
567		$(".doc-pg").wrapInner("<div class='body-slide-wr'/>");
568		$(".body-slide-wr").wrapInner("<div class='body-slide'/>");
569		$(".body-slide-wr").css({"overflow":"hidden"});
570
571		this.checkMenuType();
572		this.setMenu();
573
574		var mnToggleBtn = $("#mn-ctrs-btns");
575
576		$("#menu-wrap .btn-close").click(function(){
577			if(this_s.mnType!="H") return;
578			mainNavi_H.closeMenu();
579		});
580
581		//버튼 초기화
582		mnToggleBtn.click(function(){
583			if(this_s.mnType!="H") return;
584			mainNavi_H.toggleMenu();
585		});
586
587	},
588	_reset:function(){
589
590		this.resetMenu();
591	},
592	setMenu:function(){
593		if(this.mnType=="W"){
594			mainNavi_W._init();
595		}else{
596			mainNavi_W._unset();
597		}
598
599		if(this.mnType=="H"){
600			mainNavi_H._init();
601		}else{
602			mainNavi_H._unset();
603		}
604		console.log("setMenu" + this.mnType);
605	},
606	resetMenu:function(){
607		var orgMnType = this.mnType;
608		this.checkMenuType();
609		if(orgMnType!=this.mnType){
610			console.log("resetMenu : "+ orgMnType +" ->" + this.mnType);
611			this.setMenu();
612		}
613	},
614	checkMenuType:function(){
615		//var chkWinW = wsize.win.w;
616		var chkContW = $("body").width();
617		if(chkContW >= 1000){
618			this.mnType = "W";
619		}else{
620			this.mnType = "H";
621		}
622	},
623	clearTimer:function(){
624	}
625}
626
627function initNavigation() {
628	mainNavi._init();
629}

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.