$(function(){ // ページトップへ戻る var appear = false; var pagetop = $('#page_top'); $(window).scroll(function () { var scrollHeight = $(document).height(); var scrollPosition = $(window).height() + $(window).scrollTop(); var footHeight = $("footer").height() + 10; if ($(this).scrollTop() > 100) { /* var pos = 0; var ani = 0; if ((scrollHeight - scrollPosition) <= (footHeight - 30) && window.innerWidth > 767) { pos = footHeight - (scrollHeight - scrollPosition); } else { pos = 30; ani = 100; } pagetop.stop().animate({ 'bottom': pos + 'px' }, ani); */ pagetop.stop().animate({ 'bottom': '30px' }, 100); if($(window).scrollTop() >= ($("footer").offset().top - window.innerHeight)){ pagetop.addClass("footer-bottom"); }else{ pagetop.removeClass("footer-bottom"); } if (appear == false) { appear = true; } } else { if (appear) { appear = false; pagetop.stop().animate({ 'bottom': '-50px' }, 100); } } }); pagetop.click(function () { $('body, html').animate({ scrollTop: 0 }, 500); return false; }); // タイトル変更用 var title = $("title").text(); // タイトル変更。「自ページタイトル」+「:」+「半角スペース」+「タブの項目名」 function switchTitle(){ var titleIndex = title.indexOf(" | "); var titleBef = title.slice(0, titleIndex); if(titleBef.indexOf(":") != -1){ var titleBefIndex = titleBef.indexOf(":"); titleBef = titleBef.slice(0, titleBefIndex); } var titleAft = title.slice(titleIndex, title.length); title = titleBef + ": " + $("a.tab01__link--current").text() + titleAft; $("title").text(title); } if($(".tab01__item").length >= 1){ // ハッシュタグがある場合、タブ切り替え var hash = location.hash; if(hash.length >= 1){ hash = hash.slice(1); var $tab = $(".tab01__" + hash); $(".tab01__link--current").removeClass("tab01__link--current"); $tab.children("a").addClass("tab01__link--current"); var index = $(".tab01__item").index($tab); if(index >= 0){ $(".is-show").removeClass("is-show"); $(".panel").eq(index).addClass("is-show"); } } // タブがクリックされた時 $(".tab01__link").click(function(){ var index = $(".tab01__link").index(this); $(".tab01__link--current").removeClass("tab01__link--current"); $(this).addClass("tab01__link--current"); $(".is-show").removeClass("is-show"); $(".panel").eq(index).addClass("is-show"); switchTitle(); }); // 「詳しい交換方法はこちら」がクリックされた時 $(".more__link").click(function(){ $(".tab01__link--current").removeClass("tab01__link--current"); $(".tab01__replace").children("a").addClass("tab01__link--current"); $(".is-show").removeClass("is-show"); $(".panel").eq(1).addClass("is-show"); switchTitle(); }); // ページが読み込まれたとき、タイトル変更 switchTitle(); } // セレクトボックスページ内リンク $('.store__content select').change(function () { var speed = 400; var href = $(this).val(); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top; $('body,html').animate({ scrollTop: position }, speed, 'swing'); return false; }); //モーダルウィンドウ $('.js-modal-open').each(function(){ $(this).on('click',function(){ var target = $(this).data('target'); var modal = document.getElementById(target); $(modal).fadeIn(); return false; }); }); $('.js-modal-close').on('click',function(){ var playerNum = 0; if($("#modal01").css("display") == "block"){ playerNum = 1; } if($("#modal02").css("display") == "block"){ playerNum = 2; } $('.js-modal').fadeOut(); // 動画初期化 if(playerNum == 1){ if($("#iframe1").length){ var src = $("#iframe1").attr("src"); setTimeout(function(){ $("#iframe1").attr("src", ""); $("#iframe1").attr("src", src); }, 400); } } if(playerNum == 2){ if($("#iframe2").length){ var src = $("#iframe2").attr("src"); setTimeout(function(){ $("#iframe2").attr("src", ""); $("#iframe2").attr("src", src); }, 400); } } return false; }); });