/* 共通パーツjs */ (function(w, $){ // jQueryプラグインの定義や即時実行しなければならないものは // ここに書く // タブプラグイン $.fn.tab = function() { return this.each(function(){ var panel_active_class = "tab__panel--active", tab_active_class = "tab__item--active", $container = $(this), $tab_items = $container.find(".tab__items li"), $panels = $container.find(".tab__panels"), $selected_tab_item = $tab_items.filter(function(){ return $(this).hasClass(tab_active_class); }); // 初期選択状態の取得 var selected = $tab_items.find("a").first().attr("href"); if ( location.hash != "" && /^#.*/.test(location.hash) ) { selected = location.hash; } else if ( $selected_tab_item.length > 0 ) { selected = $selected_tab_item.first().attr("href"); } function showSelectedTab(context) { var panels = $panels.children(".tab__panel"); // パネルの選択 panels.hide().removeClass(panel_active_class); $panels.find(context).addClass(panel_active_class).show(); // タブの選択 $tab_items.removeClass(tab_active_class).filter(function(){ return $("a", this).attr("href") == context; }).addClass(tab_active_class); } $tab_items.find("a").bind("click", function(e){ e.preventDefault(); showSelectedTab($(this).attr("href")); }); showSelectedTab(selected); }); }; $.fn.panel_slider = function() { return this.each(function(){ var $t = $(this), $panel = $($t.attr("href")); $t.click(function(e){ if( $panel.attr("id") === "tab__map__categories" || $panel.attr("id") === "tab__list__categories" ){ if( $panel.css("position") === "absolute" ){ $panel.css({"top": $(this).parents(".tab__category").first().innerHeight() - 1 + "px"}); } }else if( $t.attr("href") === "#navi__container" ){ if( $t.hasClass("open") ){ $("html, body").css({"overflow": "auto"}); }else{ $("html, body").css({"overflow": "hidden"}); } } $t.toggleClass("open"); $panel.stop(true, true).slideToggle("fast"); e.preventDefault(); }); }); }; // // 地図の詳細モーダル表示プラグイン // $.fn.map_modal = function() { // function do_resize_modal() { // if(!$("#shop-detail__content").is(":visible")) return; // // $("#shop-detail__content").css({ // "height": $("#shop-detail__container").height() - $("#close-modal").innerHeight() - 10 + "px" // }); // } // $(window).resize(do_resize_modal); // do_resize_modal(); // // return this.each(function(){ // var $this = $(this), // $modal = $("#shop-detail__overlay"), // $detail = $modal.find("#shop-detail__container"); // // ここでajax処理を実施し、データを取得出来たらHTMLを形成する // // $this.on("click", function(e){ // e.preventDefault(); // $modal.fadeIn("fast", function(){ // $detail.fadeIn("fast"); // do_resize_modal(); // $("html, body").css({"overflow": "hidden", "height": "100%"}); // }); // }); // $modal.find("#close-modal a").on("click touch", function(e){ // e.preventDefault(); // $detail.fadeOut("fast", function(){ // $modal.fadeOut("fast"); // $("html, body").css({"overflow": "auto", "height": "auto"}); // }); // }); // }); // }; })(window, jQuery); /* 画面の読み込み時に地図や店舗の一覧を画面に収まるように調整する */ function resize_content_size() { var $window = $(window), $tab_items = $(".tab__items"); function init_resize_event(e) { var max_height = $window.height(); var container_outer_space = 51, $show_map = $("#show__map"), $map = $show_map.find("#map"), $show_list = $("#show__list"), $footer = $("footer.footer"), map_minus_heights = [ container_outer_space, $tab_items.height(), $show_map.find(".tab__category__opener").outerHeight(true), parseInt($show_map.find("#map").css("margin-top")), $footer.height() ]; function do_resize() { // 「地図で見る」の高さ調整 var map_minus_height = 0; $.map(map_minus_heights, function(h) { return map_minus_height += h; }); $map.height($window.height() - map_minus_height); $show_map.find("#ZdcEmapMap").height($window.height() - map_minus_height).width($window.width()); $("#navi__container").css({"height": $window.height() - 44 + "px"}); if( $(".navi__hambuger").hasClass("opened") ){ $window.scrollTop(0); } } $window.resize(do_resize); do_resize(); } init_resize_event(); $tab_items.find("a").click(function(){ init_resize_event(); }); } $(function(){ // DOM ContentLoadedイベント後の処理はこちらに書く var $trigger = $(".result__filters__trigger a, .shop__category .shop__category__trigger a, .tab__category__opener a"); $trigger.panel_slider(); var $tab_contents = $(".tab"); if ( $tab_contents.length > 0 ) { //var $tmp = $tab_contents.find("#show__map"); if ( $tab_contents.find("#show__map").length == 0 && $tab_contents.find("#show__list").length == 0 ) { $tab_contents.tab(); } } // Copyrightの年号書き換え var $copy_year = $(".copyright--year"); if ( $copy_year.length > 0 ) { $copy_year.text(new Date().getFullYear()); } // dynamic-loader.jsで定義している非同期共通パーツ読み込みスクリプト var loader = new DynamicLoader(); loader.load("sp", resize_content_size); // 地図の詳細モーダル表示 // var $modal_trigger = $("#tab__shop__list li a"); // $modal_trigger.map_modal(); // // function do_touch() { // $(".tab #show__list #tab__shop__list li a").add("#shop-detail__container dl dd a").bind({ // "touchstart": function(e) { // $(this).removeClass("notouchstyle").addClass("touchstyle"); // }, // "touchend": function(e) { // $(this).removeClass("touchstyle").addClass("notouchstyle"); // } // }); // } // do_touch(); function do_touch() { var eventObj = { "touchstart": function(e) { $(this).removeClass("notouchstyle").addClass("touchstyle"); }, "touchend": function(e) { $(this).removeClass("touchstyle").addClass("notouchstyle"); } }; $(".tab #show__list #tab__shop__list").on(eventObj, "li a"); $("#shop-detail__container").on(eventObj, "dl dd a"); } do_touch(); function do_resize_modal() { if(!$("#shop-detail__content").is(":visible")) return; $("#shop-detail__content").css({ "height": $("#shop-detail__container").height() - $("#close-modal").innerHeight() - 10 + "px" }); } $(window).resize(do_resize_modal); do_resize_modal(); });