var CMixupCast = Class.create(); CMixupCast.prototype = { initialize: function(el_name, member_uid, owner_uid,owner_nick,owner_id) { this.el_name = el_name; this.member_uid = member_uid this.owner_uid = owner_uid; this.owner_nick = owner_nick; this.owner_id = owner_id; this.now_loading = 0; this.scroll_term = 20; this.scroll_step = 0; this.scroll_height = 0; }, scrollInit: function() { if(this.slider) this.slider.dispose(); this.scroll_term = 20; if($('cbody').getHeight()>=$('cbody').scrollHeight) { Event.stopObserving('cbody', 'DOMMouseScroll'); Event.stopObserving('cbody', 'mousewheel'); $('scrollbar').hide(); return; } else { this.scroll_height = $('cbody').scrollHeight-$('cbody').getHeight(); this.scroll_step = Math.ceil(this.scroll_height/this.scroll_term); this.slider = new Control.Slider($('scrollbar').down('.handle'), $('scrollbar'), { axis: 'vertical', range: $R(0,this.scroll_step), onSlide: (function(v){ this.scrollTo(v); }).bind(this), onChange: (function(v){ this.scrollTo(v); }).bind(this) }); Event.stopObserving('cbody', 'DOMMouseScroll'); Event.stopObserving('cbody', 'mousewheel'); Event.observe('cbody', 'DOMMouseScroll', this.scrollWheel.bind(this)); // mozilla Event.observe('cbody', 'mousewheel', this.scrollWheel.bind(this)); // IE/Opera $('scrollbar').show(); $(this.el_name).scrollTop = 0; } }, scrollTo: function(v) { v = Math.ceil(v); el = $('cbody'); el.scrollTop = this.scroll_term*v; }, scrollWheel: function(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } if (delta) { this.slider.setValueBy(-delta); } if (event.preventDefault) event.preventDefault(); event.returnValue = false; }, frameInit: function() { frame_height = document.viewport.getHeight(); profile_height = $('profile').getHeight(); endbar_height = $('endbar').getHeight(); actions_height = $('actions').getHeight(); menu_height = $('menu').getHeight(); $('content_c').style.height = (frame_height-profile_height-endbar_height)+'px'; $('cbody').style.height = (frame_height-profile_height-endbar_height-actions_height-menu_height-10)+'px'; $('scrollbar').style.height = (frame_height-profile_height-endbar_height-actions_height-menu_height-10)+'px'; $('loading_cover').style.width = document.viewport.getWidth()-2+'px'; $('loading_cover').style.height = frame_height-profile_height-endbar_height+'px'; }, setLoadingBg: function() { $('loading_cover').style.backgroundImage = "url('http://static.mixsh.net/img/widget/mixupcast/loading.gif')"; $('loading_cover').show(); }, clearLoadingBg: function() { new Effect.Fade($('loading_cover'),{duration:0.5}); }, showLogin: function() { $('login_pop').style.left = (document.viewport.getWidth()-106)/2+'px'; $('login_pop').style.top = (document.viewport.getHeight()-150)/2+'px'; $('loading_cover').style.backgroundImage = "url('http://static.mixsh.net/img/blank.gif')"; new Effect.Appear($('loading_cover'),{duration:0.5}); new Effect.Appear($('login_pop'),{duration:0.5, beforeFinish:function(){$('login_id').focus(); } }); }, onFocusLoginForm: function(tar) { if(tar.id=='login_id' && tar.value.length<1) tar.className=''; if(tar.id=='login_pw' && tar.value.length<1) tar.className = ''; }, onBlurLoginForm: function(tar) { if(tar.id=='login_id' && tar.value.length<1) tar.className='wlogin_id'; if(tar.id=='login_pw' && tar.value.length<1) tar.className='wlogin_pw'; }, submitLogin: function() { if($('login_id').value.length<2) { alert('아이디를 입력해 주세요.'); $('login_id').focus(); return false; } if($('login_pw').value.length<2) { alert('비밀번호를 입력해 주세요.'); $('login_pw').focus(); return false; } //파라미터 설정 content_url = '/widget/mixupcast/inc/ajax/proc_login.html'; param_templete = new Template('id=#{id}&pw=#{pw}'); content_param = param_templete.evaluate({ id : $('login_id').value, pw : $('login_pw').value }) //호출 //문서로딩 this.xmlRequest = new Ajax.Request( content_url, { method: 'post', parameters: content_param, onComplete: (function() { if(this.xmlRequest.transport.responseText) { switch(this.xmlRequest.transport.responseText) { case '-9': alert('전달된 값에 문제가 있습니다'); break; case '-1': alert('비밀번호가 일치하지 않습니다'); $('login_pw').focus(); break; case '-2': alert('존재하지 않는 아이디 입니다.'); $('login_id').focus(); break; default: //OK! this.hideLogin(); //member_uid 셋팅 postlist.setMemberUid(parseInt(this.xmlRequest.transport.responseText)); this.reload(); break; } } else { alert('처리중 오류가 발생하였습니다.'); } }).bind(this) }); return false; }, hideLogin:function() { new Effect.Fade($('loading_cover'),{duration:0.5}); new Effect.Fade($('login_pop'),{duration:0.5}); }, reload: function() { this.setContent(this.content_type, this.content_page, this.contents_itemcnt); }, setContent: function(type) { if(this.now_loading) return; this.now_loading = 1; //현재 페이지 정보 기억 this.content_type = type; //this.content_page = page; //this.contents_itemcnt = itemcnt; //메뉴 포커스 컨트롤 menu_list = $('menu').getElementsByClassName('item'); for(i=0;i잘못된 접근입니다."); this.clearLoadingBg(); this.now_loading = 0; return; break; } //파라미터 생성 var param_templete = new Template("owner_uid=#{owner_uid}&owner_nick=#{owner_nick}&owner_id=#{owner_id}"); content_param = param_templete.evaluate({ owner_uid : this.owner_uid, owner_nick : encodeURI(this.owner_nick), owner_id : this.owner_id }) setTimeout((function(){ //문서로딩 this.xmlRequest = new Ajax.Request( content_url, { method: 'get', parameters: content_param, onComplete: (function() { if(this.xmlRequest.transport.responseText) { $(this.el_name).update(this.xmlRequest.transport.responseText); } else { //alert('로딩중 에러가 발생하였습니다.'); } this.clearLoadingBg(); this.now_loading = 0; if(type=='mixup') { //var ctar = $(this.el_name).getElementsByClassName('postrow'); var ctar = $(this.el_name).select('div.postrow'); for(i=0;i28) //제목이 3줄이면 2줄로 축소 { s_el.setStyle({ height: '28px', overflow: 'hidden' }); } else if(s_h<=14) //제목이 한줄이면 등록일 정보 출력 { ctar[i].select('li.date')[0].show(); } } } //스크롤 리셋 this.scrollInit(); }).bind(this) }); }).bind(this),300); }, blank: function() { } }