var ShopApp = function() { function handleLayout() { (function($,sr){ var debounce = function (func, threshold, execAsap) { var timeout; return function debounced() { var obj = this, args = arguments; function delayed () { if (!execAsap) func.apply(obj, args); timeout = null; } if (timeout) clearTimeout(timeout); else if (execAsap) func.apply(obj, args); timeout = setTimeout(delayed, threshold || 100); }; }; jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); var $WRAPPER = $('.wrapper'), $TOPBANNER = $('.top-banner-wrap'), $TOPBAR = $('.header-topbar'), $TITLE = $('.header-title'), $NAV = $('.header-nav'); $PAGETITLE = $('.page-title-wrap'); $FOOTER = $('.footer'); $FOOTERTOP = $('.footer-top'); $SIDE = $('.basic-body-side'); $BODYPAGE = $('.basic-body-page'); $(document).ready(function() { var setContentHeight = function() { var wrapperHeight = $WRAPPER.outerHeight(), topbarHeight = $TOPBAR.height(), titleHeight = $TITLE.height(), navHeight = $NAV.height(), footertopHeight = $FOOTERTOP.height(), footerHeight = $FOOTER.height(), sideHeight = $SIDE.height(); contentHeight = $(window).height() - topbarHeight - titleHeight - navHeight - footertopHeight - footerHeight - 153; $BODYPAGE.css('min-height', contentHeight); if (contentHeight < sideHeight) { $BODYPAGE.css('min-height', sideHeight + 50); } else { $BODYPAGE.css('min-height', contentHeight); } }; $(window).smartresize(function() { setContentHeight(); }); setContentHeight(); }); } function handleViewport() { $("input, textarea, select, button, i, div.note-editing-area, span.select2-selection, .calendar-time, ul.tag-editor, div.asSpinner-control").on({ 'touchstart' : function() { zoomDisable(); }}); $("input, textarea, select, button, i, div.note-editing-area, span.select2-selection, .calendar-time, ul.tag-editor, div.asSpinner-control").on({ 'touchend' : function() { setTimeout(zoomEnable, 500); }}); function zoomDisable() { $('head meta[name=viewport]').remove(); $('head').prepend(''); } function zoomEnable() { $('head meta[name=viewport]').remove(); $('head').prepend(''); } } function handleIEFixes() { //fix html5 placeholder attribute for ie7 & ie8 if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) < 9) { // ie7&ie8 $('input[placeholder], textarea[placeholder]').each(function () { var input = jQuery(this); $(input).val(input.attr('placeholder')); $(input).focus(function() { if (input.val() == input.attr('placeholder')) { input.val(''); } }); $(input).blur(function() { if (input.val() == '' || input.val() == input.attr('placeholder')) { input.val(input.attr('placeholder')); } }); }); } } function handleBootstrap() { /*Bootstrap Carousel*/ $('.carousel').carousel({ interval: 15000, pause: 'hover' }); /*Tooltips*/ $('.tooltips').tooltip(); $('.tooltips-show').tooltip('show'); $('.tooltips-hide').tooltip('hide'); $('.tooltips-toggle').tooltip('toggle'); $('.tooltips-destroy').tooltip('destroy'); /*Popovers*/ $('.popovers').popover(); $('.popovers-show').popover('show'); $('.popovers-hide').popover('hide'); $('.popovers-toggle').popover('toggle'); $('.popovers-destroy').popover('destroy'); } function handleToggle() { $('.list-toggle').on('click', function() { $(this).toggleClass('active'); }); } function handleTopBanner() { $(window).load(function() { $('.top-banner-wrap .top-banner-swiper').slideDown(200, function() { var $TBIMG = $('.top-banner-mo-img img'), tbImgHight = $TBIMG.height(); if ($(window).width() <= 767) { $(".top-banner-wrap").css("height", tbImgHight); } else { $(".top-banner-wrap").css("height", "auto"); } var swiper = new Swiper('.top-banner-swiper', { direction: 'vertical', loop: true, autoplay: { delay: 5000, }, navigation: { nextEl: '.top-banner-btn-next', prevEl: '.top-banner-btn-prev', }, }); }); }); $(window).resize(function() { var $TBIMG = $('.top-banner-mo-img img'), tbImgHight = $TBIMG.height(); if ($(window).width() <= 767) { $(".top-banner-wrap").css("height", tbImgHight); } else { $(".top-banner-wrap").css("height", "auto"); } }); function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i= 992) { var cateitem = 9; if (cateitem <= $("#nav_category > ul >li").length) { $('#nav_category > ul').append(''); } var show_cateitem = cateitem - 1; $('#nav_category > ul > li.item-vertical').each(function(i) { if (i > show_cateitem) { $(this).css('display', 'none'); } }); $("#nav_category > ul > li.navcate-load-more").click(function () { if ($(this).hasClass('open')) { $('#nav_category > ul > li.item-vertical').each(function(i) { if (i > show_cateitem) { $(this).slideUp(200); $(this).css('display', 'none'); } }); $(this).removeClass('open'); $('#nav_category > ul > li.navcate-load-more').html('카테고리 더보기'); } else { $('#nav_category > ul > li.item-vertical').each(function(i) { if (i > show_cateitem) { $(this).slideDown(200); } }); $(this).addClass('open'); $('#nav_category > ul > li.navcate-load-more').html('카테고리 닫기'); } }) } else { $('.item-vertical.dropdown').on('show.bs.dropdown', function(e) { $(this).find('.dropdown-menu').first().stop(true, true).slideDown(200); }); $('.item-vertical.dropdown').on('hide.bs.dropdown', function(e) { $(this).find('.dropdown-menu').first().stop(true, true).slideUp(200); }); } } function handleSidebar() { var sides = ["left", "top", "right", "bottom"]; for (var i = 0; i < sides.length; ++i) { var cSide = sides[i]; $(".sidebar." + cSide).sidebar({side: cSide}); } $(".sidebar-left-trigger[data-action]").on("click", function() { var $this = $(this); var action = $this.attr("data-action"); var side = $this.attr("data-side"); $(".sidebar." + side).trigger("sidebar:" + action); $("html").toggleClass("overflow-hidden"); $(".sidebar-left-mask, .sidebar-left-content").toggleClass("active"); return false; }); $(".sidebar-right-trigger[data-action]").on("click", function() { var $this = $(this); var action = $this.attr("data-action"); var side = $this.attr("data-side"); $(".sidebar." + side).trigger("sidebar:" + action); $("html").toggleClass("overflow-hidden"); $(".sidebar-right-mask").toggleClass("active"); return false; }); $(".sidebar-shop-trigger").on("click", function() { $(".sidebar-shop-member").animate({width:"toggle"}, 200); $("html").toggleClass("overflow-hidden"); $(".sidebar-shop-member-btn, .sidebar-shop-mask").toggleClass("active"); return false; }); $(".shop-member-box-btn").on("click", function() { $(this).next(".op-area").slideToggle(300).siblings(".op-area").slideUp(); }); setTimeout(function() { $(".sidebar").show(); }, 500); $(window).resize(function() { $(".sidebar").show(); }); } function handleFsite() { $(document).ready(function() { $(".fsite-cont dt a").click(function() { $(".fsite-cont dd").slideToggle(300); return false; }); }); } function handleBackToTop() { $(document).ready(function() { var prgsPath = document.querySelector('.eb-backtotop path'); var pathLength = prgsPath.getTotalLength(); prgsPath.style.transition = prgsPath.style.WebkitTransition = 'none'; prgsPath.style.strokeDasharray = pathLength + ' ' + pathLength; prgsPath.style.strokeDashoffset = pathLength; prgsPath.getBoundingClientRect(); prgsPath.style.transition = prgsPath.style.WebkitTransition = 'stroke-dashoffset 0.01s linear'; var chkPrgs = function() { var scrollTop = $(window).scrollTop(); var pageHeight = $(document).height() - $(window).height(); var percentage = (scrollTop / pageHeight) * 100; var textColor; var prgs = pathLength - (scrollTop * pathLength / pageHeight); prgsPath.style.strokeDashoffset = prgs; if (percentage > 99) { textColor = '#2b2b2e'; } else { textColor = '#a5a5a5'; } $('.progress-count').text(Math.round(percentage) + '%').css({ color: textColor }); } chkPrgs(); $(window).scroll(chkPrgs); $(window).on('scroll', function() { if ($(this).scrollTop() > 50) { $('.eb-backtotop').addClass('active-progress'); } else { $('.eb-backtotop').removeClass('active-progress'); } }); $('.eb-backtotop, .btt-up-btn').on('click', function(e) { e.preventDefault(); $('html, body').animate({scrollTop: 0}, 500); return false; }); $('.btt-down-btn').on('click', function(e) { e.preventDefault(); $('html, body').animate({scrollTop:$(document).height()}, 500); return false; }) }); } return { init: function() { handleLayout(); handleViewport(); handleBootstrap(); handleIEFixes(); handleToggle(); handleTopBanner(); handleCategory(); handleSidebar(); handleFsite(); handleBackToTop(); } }; }();