$(document).ready(function() { var mainPage = new main( $("#contentsWrap") ); mainPage.init(); }); function main( targetStage ){ var mainStage = targetStage; var sale = {}; var visual = {}; this.init = function(){ //ºÐ¾ç ¸®½ºÆ® sale = new mainSale(mainStage); //ºñÁÖ¾ó ¿µ¿ª visual = new mainVisual(mainStage); }; //ºñÁÖ¾ó //////////////////////////////////////////////////////////////////////////////// function mainVisual(){ var visualStage = mainStage.find( '.mainVisual' ); var visualList = visualStage.find( '.thum' ); var visualListObj = visualList.children(); var visualTotalPage = 1; var visualLen = 0; var visualListNum = 0; //var direction = -1; var currentNum; //var timer; //±âÁ¸ ·Ñ¸µºÎºÐ »èÁ¦ var visualContWid = visualStage.width(); var visualWid = 3040; var visualPos = (visualContWid - visualWid) / 2; setVisual(); addEvent(); //startTimer(); //±âÁ¸ ·Ñ¸µºÎºÐ »èÁ¦ // ·Ñ¸µ4°³ ÀÌ»óÀ϶§¸¸ ¸ð¼Ç if( visualListObj.length > 4 ){ //introMotion(); } function setVisual(){ visualLen = visualListObj.length; visualStage.css({'background-position':visualPos+'px 0px'}); if( visualLen < 5 ){ //À̹ÌÁö°¡ 5°³ ÀÌÇÏÀ϶§ ¹öÆ° »èÁ¦ visualStage.find( '.prev').css({'display':'none'}); visualStage.find( '.next').css({'display':'none'}); } } function addEvent(){ /* //±âÁ¸ ŸÀÌ¸Ó ÄÁÆ®·Ñ »èÁ¦ visualStage.find( '.visualThum' ).bind( 'mouseenter', function( event ){ stopTimer(); }) visualStage.find( '.visualThum' ).bind( 'mouseleave', function( event ){ startTimer(); }) */ visualStage.find( '.prev' ).bind( 'click', function( event ){ visualListNum--; if( visualListNum < -1 )visualListNum = -1; visualMove(); event.preventDefault(); }); visualStage.find( '.next' ).bind( 'click', function( event ){ visualListNum++; if( visualListNum > visualTotalPage )visualListNum = visualTotalPage; visualMove(); event.preventDefault(); }); visualListObj.each( function( i ){ var btn = $(this); btn.bind( 'mouseover', function( event ){ btn.css({'z-index':'14'}); }); btn.bind( 'mouseout', function( event ){ btn.css({'z-index':'0'}); }); /*btn.bind( 'click', function( event ){ //alert(btn.css()); showPopup(i); event.preventDefault(); }) */ }); visualStage.find( '.visualPopup' ).find('.close').bind('click', function(event){ hidePopup(); event.preventDefault(); }); } function showPopup(id){ if( currentNum != id ){ visualStage.find( '.visualPopup' ).css({'display':'block', 'opacity':'0.1'}); visualStage.find( '#mask' ).css({'display':'block', 'opacity':'0.1'}); visualStage.find( '.visualPopup' ).stop().animate({'opacity':1},300); visualStage.find( '#mask' ).stop().animate({'opacity':0.5},300); //id°ª ´ëÀÔ currentNum = id; } } function hidePopup(){ visualStage.find( '.visualPopup' ).animate({'opacity':0},{ duration:300, complete:function(){ visualStage.find( '.visualPopup' ).css({'display':'none', 'opacity':'0'}); visualStage.find( '#mask' ).css({'display':'none', 'opacity':'0'}); }}); visualStage.find( '#mask' ).animate({'opacity':0},300); } function visualMove(){ //ºñÁÖ¾ó var bgPos = -(450 * visualListNum); visualStage.stop().animate({'backgroundPosition':bgPos+'px 0px'}, { duration:2500, easing:"easeInOutCubic"}); visualList.stop().animate({'left':-(450 * visualListNum)}, { duration:2900, easing:"easeInOutCubic"}); } /* //°í°´»çÀÇ ¿äûÀ¸·Î ÀÚµ¿ ·Ñ¸µ »èÁ¦.. Çѹø ·Ñ¸µÀ¸·Î ±³Ã¼ function startTimer(){ if( visualLen > 4 ){ timer = setInterval( timerEvent, 6000 ); } } function timerEvent(){ if( visualListNum < 1 )direction = 1; if( visualListNum > visualTotalPage - 1 )direction = -1; visualListNum += direction; visualMove(); } function stopTimer(){ clearInterval( timer ); } */ function introMotion(){ //ÀÎÆ®·Î ºÎºÐ BGÀ̵¿ visualStage.animate({'backgroundPosition':'0px 0px'}, { duration:4000, complete:function(){ visualStage.animate({'backgroundPosition':-( 160 * visualTotalPage )+'px 0px'}, { duration:2700, easing:"easeInOutCubic", complete:function(){ visualStage.animate({'backgroundPosition':-( 160 * visualTotalPage )+'px 0px'}, { duration:3400, complete:function(){ visualStage.animate({'backgroundPosition':'0px 0px'}, { duration:2700, easing:"easeInOutCubic" }); } }); } }); }}); //¸®½ºÆ® À̵¿ visualList.animate({'left':0}, { duration:4000, easing:"easeInOutCubic", complete:function(){ visualList.animate({'left':-(1023 * visualTotalPage)}, { duration:3100, easing:"easeInOutCubic", complete:function(){ visualListNum = visualTotalPage; visualList.animate({'left':-(1023 * visualTotalPage)}, { duration:3000, easing:"easeInOutCubic", complete:function(){ if( visualListNum > visualTotalPage )visualListNum = visualTotalPage; visualList.animate({'left':0}, { duration:3100, easing:"easeInOutCubic"}); }}); }}); }}); } } //ÆǸÅ(ÆäÀÌÁö Áß°£ ½½¶óÀÌµå ºÎºÐ)/////////////////////////////////////////////////////////// function mainSale(){ // $.Scroll = ($.browser.mozilla || $.browser.msie) ? $('html') : $('body'); var rollList = mainStage.find( '.saleList' ); var rollListMenu = rollList.children(); var rollLostThumb = rollList.find('li').find(".saleInfo"); var rollListArr = []; var popup = mainStage.find('.saleView'); var repeat = rollList.find(".repeat"); var rollListNum = 0; var rollListLen = 0; var currentNum = -1; var targetPos = 0; var rollTimer; setList(); addEvent(); addEvent1(); setPop(-1); //·Ñ¸µ À̹ÌÁö ÃʱâÈ­ function setList(){ rollListLen = ( rollLostThumb.length )- 4; if( rollListLen < 0)rollListLen = 0; rollListNum = 0; if( rollListLen == 0 ){ rollList.find( '.prev' ).css({'display':'none'}); rollList.find( '.next' ).css({'display':'none'}); } rollLostThumb.each(function(i){ var listObj = $(this); listObj.css("left",(247 * i)+"px"); rollListArr[i] = (247 * i); }); } var events; function addEvent(){ //¸®½ºÆ® ¼ÂÆà - ·Ñ ¸Þ´º rollListMenu.find('li').each( function( i ){ var btn = $(this).find(".thum"); btn.data("id", i); //IE, FireFox¿¡¼­ clickÀÌ ÀÛµ¿Çϱâ Àü focusin À̺¥Æ® ¹ß»ý ¹®Á¦·Î //focusÀ̺¥Æ®¸¦ mouse over½Ã¿¡ À̺¥Æ® »èÁ¦, mouse out½Ã¿¡ À̺¥Æ® µî·ÏÀ» ÇÑ´Ù. btn.bind( 'mousedown', function( event ){ //console.log("mousedown"); btn.unbind( 'focusin' ); btn.unbind( 'focusout' ); }); btn.bind( 'mouseup', function( event ){ //console.log("mouseup " + $(this).data("id")); btn.bind( 'focusin', {"id":$(this).data("id")}, focusinHandler); btn.bind( 'focusin', focusoutHandler); }); btn.bind( 'click', function( event ){ //console.log("click"); if( currentNum != i ){ setMenu(i); setPop(i); openPopup(); currentNum = i; }else{ setMenu( -1 ); closePopup(); currentNum = -1; } event.preventDefault(); }); btn.bind( 'focusin', {"id":i}, focusinHandler); btn.bind( 'focusin', focusoutHandler); }); function focusinHandler(event){ var i = event.data["id"]; //console.log("focusin"); stopTimer(); rollListNum = i; if( rollListNum > rollListLen )rollListNum = rollListLen; listMove(false); } function focusoutHandler(event){ startTimer(); } //Æ˾÷ ¼ÂÆà - ´Ý±â ¹öÆ° popup.find( '.close' ).bind( 'click', function( event ){ closePopup(); setMenu( -1 ); currentNum = -1; event.preventDefault(); }); rollList.find( '.prev' ).bind( 'click', function( event ){ rollListNum = rollListNum - 4; if( rollListNum < 0 )rollListNum = 0; listMove(); event.preventDefault(); }); rollList.find( '.next' ).bind( 'click', function( event ){ rollListNum = rollListNum + 4; if( rollListNum > rollListLen )rollListNum = rollListLen; listMove(); event.preventDefault(); }); //arrow¾Æ¿ô½Ã... ¿ø·¡ À§Ä¡·Î.. rollList.bind( 'mouseenter', function( event ){ event.preventDefault(); stopTimer(); }); rollList.bind( 'mouseleave', function( event ){ event.preventDefault(); startTimer(); }); $(document).mousewheel(function(e){ //½ºÅ©·Ñ½Ã¿¡ À̺¥Æ® »èÁ¦ $.Scroll.stop(); }); } function addEvent1(){ //¸®½ºÆ® ¼ÂÆà - ·Ñ ¸Þ´º rollListMenu.find('li').each( function( i ){ var btn = $(this).find(".thum1"); btn.data("id", i); //IE, FireFox¿¡¼­ clickÀÌ ÀÛµ¿Çϱâ Àü focusin À̺¥Æ® ¹ß»ý ¹®Á¦·Î //focusÀ̺¥Æ®¸¦ mouse over½Ã¿¡ À̺¥Æ® »èÁ¦, mouse out½Ã¿¡ À̺¥Æ® µî·ÏÀ» ÇÑ´Ù. btn.bind( 'mousedown', function( event ){ //console.log("mousedown"); btn.unbind( 'focusin' ); btn.unbind( 'focusout' ); }); btn.bind( 'mouseup', function( event ){ //console.log("mouseup " + $(this).data("id")); btn.bind( 'focusin', {"id":$(this).data("id")}, focusinHandler); btn.bind( 'focusin', focusoutHandler); }); btn.bind( 'click', function( event ){ //console.log("click"); if( currentNum != i ){ setMenu(i); setPop(i); openPopup(); currentNum = i; }else{ setMenu( -1 ); closePopup(); currentNum = -1; } event.preventDefault(); }); btn.bind( 'focusin', {"id":i}, focusinHandler); btn.bind( 'focusin', focusoutHandler); }); function focusinHandler(event){ var i = event.data["id"]; //console.log("focusin"); stopTimer(); rollListNum = i; if( rollListNum > rollListLen )rollListNum = rollListLen; listMove(false); } function focusoutHandler(event){ startTimer(); } //Æ˾÷ ¼ÂÆà - ´Ý±â ¹öÆ° popup.find( '.close' ).bind( 'click', function( event ){ closePopup(); setMenu( -1 ); currentNum = -1; event.preventDefault(); }); rollList.find( '.prev' ).bind( 'click', function( event ){ rollListNum = rollListNum - 4; if( rollListNum < 0 )rollListNum = 0; listMove(); event.preventDefault(); }); rollList.find( '.next' ).bind( 'click', function( event ){ rollListNum = rollListNum + 4; if( rollListNum > rollListLen )rollListNum = rollListLen; listMove(); event.preventDefault(); }); //arrow¾Æ¿ô½Ã... ¿ø·¡ À§Ä¡·Î.. rollList.bind( 'mouseenter', function( event ){ event.preventDefault(); stopTimer(); }); rollList.bind( 'mouseleave', function( event ){ event.preventDefault(); startTimer(); }); $(document).mousewheel(function(e){ //½ºÅ©·Ñ½Ã¿¡ À̺¥Æ® »èÁ¦ $.Scroll.stop(); }); } //¸®½ºÆ® À̵¿ function listMove(isMotion){ if(isMotion != false)isMotion = true; targetPos = (247 *( -rollListNum)); rollLostThumb.each(function(i){ var litObj = $(this); if(isMotion == true)litObj.stop().animate({'left':rollListArr[i] + targetPos}, { duration:300, easing:"easeInOutCubic"}); else litObj.stop().css("left", (rollListArr[i] + targetPos) +"px"); }); } //¸®½ºÆ® ¼¿·º function setMenu(id){ rollListMenu.find('li').each( function( i ){ var img = $(this).find('.thum'); var arr = $(this).find(".arr"); if( id == i ){ img.addClass( 'on' ); arr.css("display","block"); }else{ img.removeClass( 'on' ); arr.css("display","none"); } }); } function setPop(id){ rollListMenu.find('li').each( function( i ){ var saleView = $(this).find(".saleView"); if( id == i ){ saleView.css("display","block"); }else{ saleView.css("display","none"); } }); } function openPopup(){ rollList.animate({"height":"749"}, {duration:500,easing:"easeOutCubic", step:function(){ repeat.css("height",rollList.height() + "px"); }, complete:function(){ repeat.css("height",rollList.height() + "px"); scrollMotion(); } }); } function closePopup(){ rollList.animate({"height":"318"}, {duration:500,easing:"easeOutCubic", step:function(){ repeat.css("height",rollList.height() + "px"); }, complete:function(){ repeat.css("height",rollList.height() + "px"); setPop(-1); } }); } function startTimer(){ rollTimer = setInterval( goCurrentPage, 1000 ); } function scrollMotion() { targetTop = rollList.offset().top; $.Scroll.animate({scrollTop:targetTop},{duration:300, ease:'easeInOutQuart'}); } function goCurrentPage(){ //È­¸é ¹ÛÀ¸·Î ³ª°£ À̹ÌÁö¸¦ ã¾Æ¿Â´Ù. stopTimer(); if( currentNum != rollListNum && currentNum >= 0 ){ //-¹æÇâÀ¸·Î ³ª°£ ÇöÀç À̹ÌÁö¸¦ ¿ÞÂÊÀ¸·Î if( currentNum < rollListNum ){ rollListNum = currentNum; } //+¹æÇâÀ¸·Î ³ª°£ ÇöÀç À̹ÌÁö¸¦ °¡Àå ¿À¸¥ÂÊÀ¸·Î if( currentNum > ( rollListNum + 3 )){ rollListNum = currentNum - 3; } listMove(); } } function stopTimer(){ clearInterval( rollTimer ); } } }