// JavaScript Document // Prototype.js 共存前提:$ は使用しない // ================================ // 多棟物件(既存処理・安全書き換え) // ================================ jQuery(function () { if (jQuery("div#tatou_child").length) { jQuery("div#tatou_child").each(function () { jQuery(this).children('.secInfoBox').wrapAll('
'); jQuery(this).find('.secInfoBox').wrapAll('
'); jQuery(this).find(".accordion").prepend('
'); }); } jQuery("#tatou_child .accordion_title").on("click", function () { jQuery(this).next().slideToggle(); jQuery(this).toggleClass("open"); }); }); // ================================ // 多棟物件スライダー(既存処理・安全) // ================================ jQuery(function () { jQuery(".secInfoBox .sliderInfo").each(function () { if (jQuery(this).children("p").length) { jQuery(this).bxSlider({ mode: 'fade', auto: false }); } }); }); // ================================ // 物件詳細:写真ギャラリー(本体) // ================================ jQuery(function () { var slideWidthSize = window.matchMedia('(max-width: 750px)').matches ? 50 : 180; jQuery("div.photo_gallery").each(function () { var $gallery = jQuery(this); var $main = $gallery.find('.bxslider'); var $thumb = $gallery.find('.slider_tm'); // 念のため存在チェック if (!$main.length || !$thumb.length) { return; } // data-slide-index を付与 $thumb.find('li').each(function (i) { jQuery(this).find('a').attr('data-slide-index', i); }); // メインスライダー var mainSlider = $main.bxSlider({ pagerCustom: $thumb, controls: true, onSlideBefore: function ($slideElement, oldIndex, newIndex) { setActive(newIndex); } }); // サムネスライダー var thumbSlider = $thumb.bxSlider({ pager: false, controls: true, minSlides: 5, maxSlides: 5, moveSlides: 1, slideWidth: slideWidthSize, slideMargin: 5, onSlideBefore: function ($slideElement, oldIndex, newIndex) { mainSlider.goToSlide(newIndex); setActive(newIndex); } }); // active 制御(HTML に合わせて is-active) function setActive(index) { $thumb.find('a').removeClass('is-active'); $thumb.find('li').eq(index).find('a').addClass('is-active'); } // 初期状態 setActive(0); }); });