/** * $angelhome °´Ã¼ * ¸ÞÀÎÆäÀÌÁö UI Á¦¾î * * Lee Won-Gyoon (richscript@gmail.com) <@richscript> * * D.FY Inc. * - http://www.dfy.co.kr/ * - (richscript@dfy.co.kr) * */ (function() { var o = "$angelhome"; window[o] = { e: new $.EventEmitter(), conf: { }, scale: { }, vars: { visualLength: 0 , visualIdx: 0 , bannerLength: 0 , bannerIdx: 0 }, duration: { visualBgPrev: 1100 , visualBgCur: 1100 , visualPrev: 1400 , visualCur: 1300 }, status: { onVisualMove: false , autoNextVisual: true , autoNextBanner: true }, timer: { changeTheme: null , showNextVisual: null , showNextBanner: null }, delay: { showNextVisual: 5000 , showNextBanner: 5000 }, showVisual: function(idx, dir) { if (this.vars.visualIdx!=idx&&!this.status.onVisualMove) { clearTimeout(this.timer.showNextVisual); this.status.onVisualMove = true; var viewportWidth = $(this.id.visualViewport).width(); var screenWidth = $(this.id.visualScreen).width(); var viewportMargin = (screenWidth - viewportWidth)/2; var prevIdx = this.vars.visualIdx; if (dir==undefined) { dir = (prevIdx= this.vars.visualLength) { idx = 0; } this.showVisual(idx, "R"); return this; }, runNextVisualTimer: function() { clearTimeout(this.timer.showNextVisual); this.timer.showNextVisual = setTimeout(function() { o.showNextVisual(); }, this.delay.showNextVisual); return this; }, stopNextVisualTimer: function() { this.status.autoNextVisual = false; clearTimeout(this.timer.showNextVisual); $(this.id.visualPlayButton).css({display:"inline-block"}); $(this.id.visualStopButton).css({display:"none"}); return false; }, playNextVisualTimer: function() { this.status.autoNextVisual = true; this.showNextVisual(); $(this.id.visualStopButton).css({display:"inline-block"}); $(this.id.visualPlayButton).css({display:"none"}); return false; }, showBanner: function(idx) { if (this.vars.bannerIdx!=idx) { clearTimeout(this.timer.showNextBanner); var prevIdx = this.vars.bannerIdx; var $banners = $(this.all.banners); var $pagingButtons = $(this.all.bannerPagingButtons); $banners.eq(prevIdx).css({display:"none"}); $banners.eq(idx).css({display:"block"}); $pagingButtons.eq(prevIdx).removeClass("selected"); $pagingButtons.eq(idx).addClass("selected"); if (this.status.autoNextBanner) { this.runNextBannerTimer(); } this.vars.bannerIdx = idx; $banners = $pagingButtons = null; } return this; }, showNextBanner: function() { var idx = this.vars.bannerIdx + 1; if (idx >= this.vars.bannerLength) { idx = 0; } this.showBanner(idx); return this; }, runNextBannerTimer: function() { clearTimeout(this.timer.showNextBanner); this.timer.showNextBanner = setTimeout(function() { o.showNextBanner(); }, this.delay.showNextBanner); return this; }, stopNextBannerTimer: function() { this.status.autoNextBanner = false; clearTimeout(this.timer.showNextBanner); $(this.id.bannerPlayButton).css({display:"inline-block"}); $(this.id.bannerStopButton).css({display:"none"}); return false; }, playNextBannerTimer: function() { this.status.autoNextBanner = true; this.showNextBanner(); $(this.id.bannerStopButton).css({display:"inline-block"}); $(this.id.bannerPlayButton).css({display:"none"}); return false; }, loadFacebook: function() { var dummy = (new Date()).getTime(); FB.api('/282560198486122/posts?_='+dummy , {access_token:'651605184866995|PHPK-MVCJ1GC0G8NqxkAAARacak', limit:15} , function(data){ var s = '', idx = 0, hasData = false; try{ s += ''; s += ''; if (hasData) { $(o.id.snsContentsFacebook).html(s).removeClass("fbContentsLoading"); $(o.id.snsContentsEmpty).removeClass("fbContentsEmpty"); } } catch(e) { } }); FB.api('/282560198486122?_='+dummy, function(data) { if (data&&data.likes) { var s = ''; s += ''+Math.toMoney(data.likes)+''; s += 'ÁÁ¾Æ¿ä'; $(o.id.snsCounterFacebook).html(s); } }); return this; }, loadTwitter: function() { $.ajax({ url: "/library/asp/ASPTwitter.asp", type: "get", dataType: "json", success: function(data){ var s = '', hasData = false, followers; try{ s += ''; s += ''; if (hasData) { $(o.id.snsContentsTwitter).html(s).removeClass("twiContentsLoading"); $(o.id.snsContentsEmpty).removeClass("twiContentsEmpty"); } if (followers!==undefined) { s = ''; s += ''+Math.toMoney(followers)+''; s += 'ÆÈ·Î¿ö'; $(o.id.snsCounterTwitter).html(s); } } catch(e) { } } }); return this; }, active: function() { $(this.all.visualPagingButtons).each(function(i) { $(this).bind("click", function(e) { e.preventDefault(); o.showVisual(i); return false; }); if (!$.browser.isMobile) { $(this).bind("mouseenter", function(e) { $(this).addClass("hover"); }).bind("mouseleave", function(e) { $(this).removeClass("hover"); }); } }); $(this.id.visualStopButton).bind("click", function(e) { e.preventDefault(); o.stopNextVisualTimer(); return false; }); $(this.id.visualPlayButton).bind("click", function(e) { e.preventDefault(); o.playNextVisualTimer(); return false; }); $(this.all.bannerPagingButtons).each(function(i) { $(this).bind("click", function(e) { e.preventDefault(); o.showBanner(i); return false; }); if (!$.browser.isMobile) { $(this).bind("mouseenter", function(e) { $(this).addClass("hover"); }).bind("mouseleave", function(e) { $(this).removeClass("hover"); }); } }); $(this.id.bannerStopButton).bind("click", function(e) { e.preventDefault(); o.stopNextBannerTimer(); return false; }); $(this.id.bannerPlayButton).bind("click", function(e) { e.preventDefault(); o.playNextBannerTimer(); return false; }); $(this.id.snsFacebookButton).bind("click", function(e) { e.preventDefault(); $(o.id.snsBox).removeClass("twi ka").addClass("fb"); return false; }); $(this.id.snsTwitterButton).bind("click", function(e) { e.preventDefault(); $(o.id.snsBox).removeClass("fb ka").addClass("twi"); return false; }); $(this.id.snsKakaoButton).bind("click", function(e) { e.preventDefault(); $(o.id.snsBox).removeClass("fb twi").addClass("ka"); return false; }); $(this.id.snsCloseButton).bind("click", function(e) { e.preventDefault(); $(o.id.snsBox).removeClass("fb twi ka"); return false; }); if (!$.browser.isMobile) { $(([this.id.snsFacebookButton,this.id.snsTwitterButton,this.id.snsKakaoButton]).join(",")).bind("mouseenter", function(e) { $(this).addClass("hover"); }).bind("mouseleave", function(e) { $(this).removeClass("hover"); }); } return this; }, initialize: function() { this.name = o; o = this; this.id = { visualPagingArea: ".o-visual-paging" , visualViewport: "#containerWrapAc .visCon" , visualScreen: "#containerWrapAc .visWrap" , visualStopButton: "#containerWrapAc .visCon .cirBtn .autoPlay a.stop" , visualPlayButton: "#containerWrapAc .visCon .cirBtn .autoPlay a.play" , bannerPagingArea: ".o-banner-paging" , bannerStopButton: ".conShare .newProduct .cirBtn .autoPlay a.stop" , bannerPlayButton: ".conShare .newProduct .cirBtn .autoPlay a.play" , snsBox: "#containerAc .conShare" , snsFacebookButton: ".conShare .snsAc a.facebook" , snsTwitterButton: ".conShare .snsAc a.twitter" , snsKakaoButton: ".conShare .snsAc a.kakao" , snsCloseButton: ".conShare a.close" , snsContentsFacebook: ".o-sns-contents-facebook" , snsContentsTwitter: ".o-sns-contents-twitter" , snsContentsEmpty: ".o-sns-contents-empty" , snsCounterFacebook: ".o-sns-counter-facebook" , snsCounterTwitter: ".o-sns-counter-twitter" }; this.all = { visualBgs: "#containerWrapAc .visBg" , visuals: "#containerWrapAc .visCon .titleAc" , visualPagingButtons: ".o-visual-paging .o-btn-paging" , banners: ".conShare .newProduct a.banner" , bannerPagingButtons: ".o-banner-paging .o-btn-paging" }; var s = ''; var visualLength = this.vars.visualLength = $(this.all.visualBgs).length; if (visualLength>1) { this.vars.visualIdx = Math.toInt(Math.random() * visualLength); } var $visualPagingArea = $(this.id.visualPagingArea); $(this.all.visuals).each(function(i) { var selected = (o.vars.visualIdx==i) ? true : false; $(this).css({display:selected?"block":"none",top:106}); }); $(this.all.visualBgs).each(function(i) { var selected = (o.vars.visualIdx==i) ? true : false; if (visualLength>1) { $visualPagingArea.append(''+(i+1)+'¹øÂ° À̹ÌÁö'+''); } $(this).css({display:selected?"block":"none",top:0}); var theme = $(this).data("theme"); $("body")[(theme=="dark")?"addClass":"removeClass"]("white"); }); if (visualLength>1) { s = ''; s += '
'; s += 'Á¤Áö'; s += 'Àç»ý'; s += '
'; $visualPagingArea.append(s); } var bannerLength = this.vars.bannerLength = $(this.all.banners).length; if (bannerLength>1) { this.vars.bannerIdx = Math.toInt(Math.random() * bannerLength); } var $bannerPagingArea = $(this.id.bannerPagingArea); if (bannerLength>1) { $(this.all.banners).each(function(i) { var selected = (o.vars.bannerIdx==i) ? true : false; $bannerPagingArea.append(''+(i+1)+'¹øÂ° À̹ÌÁö'+''); $(this).css({display:selected?"block":"none"}); }); s = ''; s += '
'; s += 'Á¤Áö'; s += 'Àç»ý'; s += '
'; $bannerPagingArea.append(s); } this.active(); if (visualLength>1) { this.runNextVisualTimer(); } if (bannerLength>1) { this.runNextBannerTimer(); } // Load Facebook Contents window.fbAsyncInit = function() { o.loadFacebook(); }; (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); //load Twitter Contents this.loadTwitter(); return this; } }; $(function() { window[o].initialize(); }); })();