(function($) { $(function() { // SP版headerメニュー $('.h-menu, .btn-close').on('click', function() { $('.h-menu-box').slideToggle(); return false; }); // toggleボタン $('.toggle').click(function(ev) { var $currentTarget = $(ev.currentTarget); if ($currentTarget.hasClass('opened')) { $currentTarget.removeClass('opened'); $('.toggle-target').removeClass('opened'); } else { $currentTarget.addClass('opened'); $('.toggle-target').addClass('opened'); } }); // TOPへ戻るスクロール $('.to-top').click(function() { var speed = 400; var href= $(this).attr('href'); var target = $(href == '#' || href == '' ? 'html' : href); if (target.length > 0) { var position = target.offset().top; $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; } }); // totopの表示 $(window).scroll(function () { var s = $(this).scrollTop(); var m = 300; if(s > m) { $("a.to-top").fadeIn('slow'); } else if(s < m) { $("a.to-top").fadeOut('fast'); } }); // Topバナー取得 $.ajax({ url: $('#home_url').val() + 'wp-content/slideshow.json', dataType: 'json', success: function (data) { var items = data.items, html = [], navi = [], item , active = ""; if (items.length <= 0) { $('#slideshow').remove(); } for (var i = 0, length = items.length; i < length; i++) { item = items[i]; html.push([ '
  • ', '', '' + item.title + '', '', '
  • ' ].join('')); if (i == 0) { active = "active"; } else { active = ""; } navi.push([ '
  • ', ``, '', '
  • ' ].join('')); } $('#slide-contents').html(html.join('')); $('.slide-navi').html(navi.join('')); // スライドショーの表示 $('.slide').slick({ prevArrow: $('.slide-prev'), nextArrow: $('.slide-next'), dots: true }); } }); // カテゴリータブ var articles = $('.nest.frame.v-pc'); $(articles).not(':eq(0)').hide(); $('.tabs.v-pc.clearfix.home a').on('click', function(event){ $(this).parent().parent().children().each(function(){ $(this).children().eq(0).removeClass('active'); }); $(this).addClass('active'); var index = ($(this).parent().attr('class').replace('menu', '')) - 1; $(articles).not(index).hide(); $(articles).eq(index).fadeIn(); return false; }); }); })(jQuery);