/* 名前空間を定義 */ var eclib = eclib || {}; eclib.ui = eclib.ui || {}; /*! * UIの表示に関する関数群 * * @requires module:jquery1.11+ * @requires module:jquery.cookie.js * @requires module:modernizr-custom.js */ (function(){ /* ローカル用の名前空間 */ var _ui = eclib.ui; /*! * megamenu ui */ jQuery(document).ready(function(){ var megamenuForHover = function() { jQuery('.js-animation-megamenu-hover').hover(function() { jQuery(this).children('.js-submenu-hover').stop(true).slideDown(200); jQuery(this).children('a').addClass('active'); }, function() { jQuery(this).children('.js-submenu-hover').stop(true).slideUp(200); jQuery(this).children('a').removeClass('active'); }); }(); var megamenuForClick = function() { jQuery('.js-animation-megamenu-click').children('a').on('click', function(e) { var $this = jQuery(this); jQuery('.js-animation-megamenu-click').children('a').each(function() { if(!jQuery(this).is($this)) { .slideUp(200); jQuery(this).removeClass('active'); } }); jQuery(this).addClass('active'); jQuery(this).siblings('.js-submenu-click').stop(true).slideDown(200); return false; }); jQuery(document).on('click touchstart', function(e) { if (!jQuery(e.target).closest('.js-animation-megamenu-click').length) { jQuery('.js-animation-megamenu-click').children('.js-submenu-click').stop(true).slideUp(200); jQuery('.js-animation-megamenu-click').children('a').removeClass('active'); } }); }(); }); /*! * 動的なカテゴリを生成するAJAX */ jQuery(document).ready(function(){ jQuery('.js-dynamic-category').each(function() { var category = jQuery(this).data('category') != undefined ? jQuery(this).data('category') : ''; jQuery(this).load(EC_WWW_ROOT + '/shop/js/category.aspx?category=' + category); }); }); /*! * 動的なジャンルを生成するAJAX */ jQuery(document).ready(function(){ jQuery('.js-dynamic-genre').each(function() { var genre = jQuery(this).data('genre') != undefined ? jQuery(this).data('genre') : ''; jQuery(this).load(EC_WWW_ROOT + '/shop/js/genre.aspx?genre=' + genre); }); }); /*! * カート内件数のバッジ表示 */ jQuery(document).ready(function(){ jQuery.ajax({ url: EC_WWW_ROOT + "/shop/js/cart.aspx", cache: false, dataType: "html", success: function(html) { var count = jQuery(html).data('count'); if(!count) { jQuery('.js-cart-count').hide(); } else { jQuery('.js-cart-count').text(count) .show(); } } }); }); /*! * アラート表示 * * メッセージ表示 * eclib.ui.alert('タイトルXXXX', '本文テキスト\n改行本文テキスト'); * * メッセージ表示しつつ、イベントハンドリング * eclib.ui.alert('タイトルXXXX', '本文テキスト\n改行本文テキスト', { * quit : function() { * alert('×ボタン押下'); * }, * ok : function() { * alert('OKボタン押下'); * } * }); */ _ui.alert = function(title, msg, options) { var template = ''; template += '