var CGnb = Class.create(); CGnb.prototype = { initialize: function(now_menu) { this.now_menu = now_menu; this.showtarget = null; //gnb에 표시할 실시간 정보 대상. if(this.now_menu) this.now_cate_mid = this.now_menu; else this.now_cate_mid = 0; this.timer_pop = null; this.timer_popl = null; }, initPipe:function(showtarget) { this.nowproc_pipe = false; this.showtarget = showtarget; this.poolingPipe(); //this.timer_pipe = setInterval(this.poolingPipe.bind(this),300000); //5분 }, poolingPipe: function() { if(this.nowproc_pipe) return; this.nowproc_pipe=true; this.xmlRequest = new Ajax.Request( '/inc/ajax/member/polling_pipe.html', { method: 'post', onComplete: (function(t) { jv = t.responseText.evalJSON(); if(this.showtarget.token!=0) { this.setTokenCount(jv.token); } if(this.showtarget.mylib!=0 && jv.mylib!=0) { $('gnb').select('.mymenu .mylib a')[0].addClassName('havenew'); } if(this.showtarget.myhome!=0 && jv.myhome!=0) { $('gnb').select('.mymenu .myhome a')[0].addClassName('havenew'); } this.nowproc_pipe = false; }).bind(this) }); }, chkSearchForm: function(t) { if(t.skeyword.value.length<1) { alert('검색어를 입력 해 주세요.'); return false; } location.href='/search/'+t.skeyword.value; return false; }, showPop: function(event,cate_mid) { //자칫 마우스가 법어난 후에도 팝업이 닫히지 않았을 경우 화면의 어느곳이라도 클릭하면 사라지도록 this.hidePopClick = this.hidePop.bindAsEventListener(this); $('body').observe('click', this.hidePopClick); //타이머 클리어 clearTimeout(this.timer_pop); this.timer_pop = null; clearTimeout(this.timer_popl); this.timer_popl = null; this.changePop('hide',this.now_cate_mid); this.changePop('show',cate_mid); this.now_cate_mid = cate_mid; }, hidePop: function() { this.timer_pop = setTimeout((function(){ this.changePop('hide',this.now_cate_mid); this.now_cate_mid = 0; $(body).stopObserving('click', this.hidePopClick); }).bind(this),100); }, clearPopTimer: function() { clearTimeout(this.timer_pop); this.timer_pop = null; }, changePop: function(type,cate_mid) { if(cate_mid==0) return; tarel = $('gnb_catemenu_pop_'+cate_mid); menuel = $('gnb_catemenu_'+cate_mid); /* if(!isIE()) { menuxy = menuel.viewportOffset(); menux = menuxy['left']; } else { //menux = menuel.offsetLeft+126; menuxy = menuel.viewportOffset(); menux = menuxy['left']; } */ //alert(menuel.offsetLeft); menuxy = menuel.viewportOffset(); menux = menuxy['left']; if(type=='show') { if(menuel.className!='selected') menuel.addClassName('selected'); this.timer_popl = setTimeout((function(){ tarel.show(); tarel.style.left = (menux-8)+'px'; }).bind(this),150); } else //hide { clearTimeout(this.timer_popl); this.timer_popl = null; if(this.now_menu!=cate_mid) menuel.removeClassName('selected'); tarel.hide(); } }, /* toogleCatepop: function(cate_mid) { if(cate_mid==this.nowExpendPop) //끄기 { this.nowExpendPop = 0; this.setCatepop(cate_mid,'hide'); } else //켜기 { if(this.nowExpendPop!=0) //선택되어 있던것이 있다면 { this.setCatepop(this.nowExpendPop,'hide'); } this.nowExpendPop = cate_mid; this.setCatepop(cate_mid,'show'); } }, //카테고리 팝 이외의 위치 클릭시 팝업 닫기 observeCatePop: function(ev) { if(ev.target.className!='mbut'&&ev.target.className!='mlist'&&this.nowExpendPop!=0) { this.setCatepop(this.nowExpendPop,'hide'); this.nowExpendPop = 0; //이벤트 제거 Event.stopObserving('body','click'); } }, setCatepop: function(cate_mid,type) { var tar_el = $('gnb_cate_'+cate_mid); var pop_el = tar_el.getElementsByClassName('mlist')[0]; var but_el = tar_el.getElementsByClassName('cbut')[0]; if(type=='show') { but_el.addClassName('popon'); pop_el.show(); but_el.blur(); Event.observe('body', 'click', (this.observeCatePop).bind(this)); } else if(type=='hide') { but_el.removeClassName('popon'); pop_el.hide(); } }, expendCategory: function() { if(this.nowAniCate) return; tarel = $('cate_expend'); if(tarel.visible()) { Effect.SlideUp(tarel,{afterFinish:(function(){ $('gnb_catemore_but').className='but_cateex'; this.nowAniCate=0; }).bind(this)}); visiblev = 0; } else { Effect.SlideDown(tarel,{afterFinish:(function(){ $('gnb_catemore_but').className='but_catecl'; this.nowAniCate=0; }).bind(this)}); visiblev = 1; } //에니메이션 진행중임을 기록 this.nowAniCate = 1; var now = new Date(); var expire = new Date(now.getTime() + 2592000000); setCookie('flag_ec', visiblev, expire, '/', '.mixsh.com'); //setCookie('flag_ec', visiblev, expire, '', '.mixsh.com'); //setCookie('flag_ec', visiblev); }, */ initGnb: function() { }, loadFeedCnt: function() { }, setTokenCount: function(token_info) { $('now_token_cnt').update(token_info[0].number_format()); if(token_info[1]!="0"&!token_info[1]) $('now_token_ud').update('▲'+token_info[1].number_format()); }, focusSearchQ: function(el) { //el.style.background = "url(http://static.mixsh.net/img/search_bg2.gif) no-repeat"; }, blurSearchQ: function(el) { /* if(el.value.length==0) { el.style.background = "url(http://static.mixsh.net/img/search_bg1.gif) no-repeat"; } */ }, submitSearchQ: function(el) { if(el.searchq.value.length<1) { alert('검색어를 입력해 주세요.'); el.searchq.focus(); return false; } location.href='http://mixsh.com/search/'+el.searchq.value; return false; } }