let conf; // ready document.addEventListener('DOMContentLoaded', function() { render(); }); // sp Menu $(".menuSwitch, .menuClose").click(function() { $(".menuSwitch").toggleClass("open"); $(".menuBase").fadeToggle(200); }); // $(".timeSwitch").click(function() { $(".timeSwitch").removeClass('active'); $(this).addClass('active'); $(".timetableWrap").fadeOut(300); $(".timetableWrap[data-no='" + $(this).data("no") + "']").fadeIn(300); }); // // sp Menu // $(".about_label").click(function() { // $(this).next().slideToggle(); // $(this).toggleClass("open"); // }); // ランダム $(".treasure_header_close").on("click", function() { $(".treasure").fadeOut(300); }); $(".treasure_switch").on("click", function() { console.log( $.cookie("treasure")) if( $.cookie("treasure") ){ if( random() == 1 || random() == 2 || random() == 3 || random() == 4 || random() == 5){ openModal(true); }else{ openModal(false); } }else{ $.cookie("treasure", 1); openModal(false); } }); function random(){ var min = 1 ; var max = 6 ; var a = Math.floor( Math.random() * (max + 1 - min) ) + min ; return a; } function openModal(mode){ $(".treasure_body-" + mode).slideToggle(300); $(".treasure_body-normal").slideToggle(300); // $(".modal").fadeIn(300, function() { // // $(".modal_dialog[data-no='" + no + "']").fadeIn(300); // }); } // close modal $('.modal_dialog_close, .modal_bg').click(function() { $(".modal, .modal_dialog").fadeOut(300, function() { }); }); $(window).on("scroll", function() { scrollAnime(); }); function scrollAnime() { var windowHeight = $(window).innerHeight(), topWindow = $(document).scrollTop(), fadeH = 200 ; if(topWindow > 165){ $(".menuBase").addClass("follow"); }else{ $(".menuBase").removeClass("follow"); } $('.fadein').each(function() { var targetPosition = $(this).offset().top; fadeH = $(this).data("fadeheight") != undefined ? $(this).data("fadeheight") : 200; if (topWindow > targetPosition - windowHeight + (fadeH) || $(this).hasClass("firstView")) { $(this).addClass($(this).data("fadein")); } }); } $(".openShare").on("click", function() { console.log(conf.title); let URL = conf.url; let TITLE = conf.title; let TYPE = $(this).data("type"); if ($(this).data("page")) { URL = URL + $(this).data("page"); TITLE = $("title").first().text(); } URL = URL+"/index.html"; console.log(TITLE); // SNS type switch (TYPE) { case "tw": URL = "https://twitter.com/intent/tweet?text=" + TITLE + "&url=" + URL; break; case "fb": URL = "https://www.facebook.com/sharer/sharer.php?u=" + URL; break; case "line": URL = "https://social-plugins.line.me/lineit/share?url=" + URL; break; default: break; } window.open(URL, TYPE, 'width=550, height=450, personalbar=0, toolbar=0, scrollbars=1, resizable=1'); }); $('a.scroller[href^="#"]').on("click", function() { var target = $($(this).attr("href")); var position = target.offset().top; $(".menuBase, .menuSwitch").removeClass("open"); $('body,html').stop().animate({ scrollTop: position }, 500); return false; }); function render() { conf = new Object(); conf.url = ""; conf.title = ""; $(".loading").fadeOut(300); setTimeout(function(){ $(".treasure").fadeIn(300); }, 3500); }