/* 名前空間を定義 */ var ecblib = ecblib || {}; ecblib.ui = ecblib.ui || {}; /*! * UIの表示に関する関数群 * * @requires module:jquery1.11+ * @requires module:js.cookie.js * @requires module:modernizr-custom.js */ (function () { /* ローカル用の名前空間 */ var _ui = ecblib.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).find('.block-icon-image--angle-up').addClass('block-icon-image--angle-down'); }, function () { jQuery(this).children('.js-submenu-hover').stop(true).slideUp(200); jQuery(this).find('.block-icon-image--angle-up').removeClass('block-icon-image--angle-down'); }); }(); var megamenuForClick = function () { jQuery('.js-animation-megamenu-click').children('a').on('click', function (e) { var $this = jQuery(this); jQuery('.js-ani { if (!jQuery(this).is($this)) { jQuery(this).siblings('.js-submenu-click').stop(true).slideUp(200); jQuery(this).find('.block-icon-image--angle-up').removeClass('block-icon-image--angle-down'); } }); jQuery(this).find('.block-icon-image--angle-up').addClass('block-icon-image--angle-down'); 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); } }); }(); }); /*! * 動的なカテゴリを生成する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(ecblib.sys.wwwroot + '/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(ecblib.sys.wwwroot + '/shop/js/genre.aspx?genre=' + genre); }); }); /*! * カート内件数のバッジ表示 */ jQuery(document).ready(function () { _ui.showCartCount(); }); _ui.showCartCount = function () { if(!jQuery('.js-cart-count').length) return; jQuery.ajax({ url: ecblib.sys.wwwroot + "/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(); } } }); }; /*! * アラート表示 */ _ui.alert = function (title, msg, options) { jQuery(document.activeElement).blur(); var template = ecblib.tmpl.ui.ALERT; template = ecblib.sys.render(template, { Title: title }); var defaults = { quit: function () { }, ok: function () { }, width: null, height: null }; var options = jQuery.extend({}, defaults, options); var gloupId = 'stdui-dialog' + getUUID(); var $obj = jQuery(template); var $overlay = jQuery('