/********************************************* * googlepay.js --------------------------------------------- @constructor @plugin *********************************************/ /* ------------------------------------------- * @constructor ------------------------------------------- */ var u = new EPOS_CARD.Util(); // u インスタンスを作成 /* ------------------------------------------- * @init ------------------------------------------- */ j$(function(){ j$.walletLink(); j$.accordion02(); j$.slider(); j$.tabNavFixed(); // SP幅の時に実行 if(u.isRangeSP()){ j$.spMenuControl(); j$.googleSmoothScrollsp(); u.$win.on("load",function(){ j$.spancFix(); }); } else { j$.googleSmoothScroll(); u.$win.on("load",function(){ j$.ancFix(); }); } }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function(j$){ /* * @plugin - walletLink */ j$.walletLink = function(){ var ua = navigator.userAgent.toLowerCase(); j$(function(){ /* iPhoneの場合 */ if(u.ua.indexOf('iphone') !== -1){ if (window.screen.height >= 569) { j$(".walletLink").css("display","inline-block"); } } }); }; /** * @method accordion */ j$.accordion02 = function(config){ var c = j$.extend({ elm: ".toggleWrap02", trigger: ".toggleTrigger02", alltrigger: ".togglerAll", target: ".toggleContent02", speed: 300, openNm: "open" },config); // vars var $elm = j$(c.elm), $trg = j$(c.trigger), $alltrg = j$(c.alltrigger), elmLen = $elm.length; if(elmLen === 0){ return false; } // setting j$(c.target).not("." + c.openNm).hide(); // function var openLenCheck = function(){ var openLen = j$(c.trigger + "." + c.openNm).length; switch(elmLen === openLen){ case true: $alltrg.addClass(c.openNm); $alltrg.children("span").text("全ての回答を閉じる"); break; case false: $alltrg.removeClass(c.openNm); $alltrg.children("span").text("全ての回答を開く"); break; } }; // trigger $alltrg.on("click",function(){ var self = j$(this); if(self.hasClass(c.openNm)){ $trg.each(function(){ var self = j$(this), $wrap = self.parents(c.elm), $target = $wrap.find(c.target); if(self.hasClass(c.openNm)){ self.removeClass(c.openNm); $target.stop().slideUp(c.speed); } }); self.removeClass(c.openNm); $alltrg.children("span").text("全ての回答を開く"); } else { $trg.each(function(){ var self = j$(this), $wrap = self.parents(c.elm), $target = $wrap.find(c.target); if(!self.hasClass(c.openNm)){ self.addClass(c.openNm); $target.stop().slideDown(c.speed); EPOS_CARD.module.equalHeight(true, true); EPOS_CARD.module.sizeFix(); } }); self.addClass(c.openNm); $alltrg.children("span").text("全ての回答を閉じる"); } }); $trg.on("click",function(){ var self = j$(this), $wrap = self.parents(c.elm), $target = $wrap.find(c.target); if(self.hasClass(c.openNm)){ self.removeClass(c.openNm); $target.stop().slideUp(c.speed,function(){ openLenCheck(); }); } else { self.addClass(c.openNm); $target.stop().slideDown(c.speed,function(){ openLenCheck(); }); EPOS_CARD.module.equalHeight(true, true); EPOS_CARD.module.sizeFix(); } }); }; /* * @ - ancFix * - アンカーナビ固定 */ j$.ancFix = function(){ /* element ------------------------------- */ var $elm = j$(".headUtil"); if($elm.length === 0){ return false; } /* vars ------------------------------- */ var elmTop = $elm.offset().top, $target = $elm.children("#menuWrap"), $fixHead = j$("#googleHeader .siteLogo"), fixName = "fixed", openName = "open", fixFlag = false, toggleSpeed = 300, isFix; $fixHead.clone().addClass("cloneHead").prependTo($target); var $cloneHead = j$(".cloneHead"), $toggleTrg = $cloneHead.next(".ancList02"); /* __initialize * 設定を初期化(読み込み時、リサイズ時用) ------------------------------- */ var __initialize = function(){ $target.removeClass(fixName); $cloneHead.removeClass(openName); $toggleTrg.show(); EPOS_CARD.module.equalHeight(); var elmH = $target.innerHeight(); elmTop = u.isRangeSP()? $elm.offset().top + elmH : $elm.offset().top; fixFlag = false; $elm.css("height",elmH); }; /* ancControl * 固定パーツ制御 ------------------------------- */ var ancControl = function(){ //if(u.isRangeSP()){ return; } var scrTop = u.$win.scrollTop(); if(elmTop < scrTop) { isFix = true; // static ==> fix if(fixFlag!==isFix){ $target.addClass(fixName); if(u.isRangeSP()){ $cloneHead.removeClass(openName); $toggleTrg.hide(); } EPOS_CARD.module.equalHeight(); fixFlag = isFix; } } else { isFix = false; // fix ==> static if(fixFlag!==isFix){ $target.removeClass(fixName); $cloneHead.removeClass(openName); $toggleTrg.show(); EPOS_CARD.module.equalHeight(); fixFlag = isFix; } } }; /* init ------------------------------- */ __initialize(); ancControl(); u.isWindowSizeCheck(function(){ __initialize(); ancControl(); }); u.$win.scroll(function(){ ancControl(); }); }; j$.googleSmoothScroll = function(config){ var c = j$.extend({ speed: 300, easing: "swing", noScrollClass: ".google-noScroll" }, config); /* vars ------------------------------- */ var url = j$(location).attr("href"), hash = location.hash, href, target, position, webkit = /webkit/, difference = j$("#menuWrap").innerHeight(); /* get hash ------------------------------ */ var $anc = j$(".navList03 li a"), hashLen = j$(".navList03 li a").length, hashArr = [], i; for(i = 0; i < hashLen; i++){ var __hash = $anc.eq(i).attr("href"); hashArr.push(__hash); } var hashes = hashArr.join("|"); /* trigger ------------------------------- */ /* ページ遷移+アンカー移動制御 */ u.$win.load(function(){ if((url.indexOf("#anc") !== -1)){ target = j$(hash); position = target.offset().top - difference; j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } }); /* スクロール制御 */ j$("a[href^=#]").not("a[href=#], a[href^=#tab], a[href^=#modal], " + c.noScrollClass + "").click(function(){ href = j$(this).attr("href"); target = j$(href); difference = j$("#menuWrap").innerHeight(); position = target.offset().top - difference; if(u.isRangeSP()){ j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } else { j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } return false; }); }; /* * @ - spancFix * - アンカーナビ固定 */ j$.spancFix = function(){ /* element ------------------------------- */ var $elm = j$("#headerContainer"); if($elm.length === 0){ return false; } /* vars ------------------------------- */ var elmTop = $elm.offset().top, $target = $elm.children("#googleHeader"), $fixHead = j$("#googleHeader .siteLogo"), fixName = "fixed", openName = "open", fixFlag = false, toggleSpeed = 300, isFix; $fixHead.clone().addClass("cloneHead").prependTo($target); var $cloneHead = j$(".cloneHead"), $toggleTrg = $cloneHead.next(".ancList02"); /* __initialize * 設定を初期化(読み込み時、リサイズ時用) ------------------------------- */ var __initialize = function(){ $target.removeClass(fixName); $cloneHead.removeClass(openName); $toggleTrg.show(); EPOS_CARD.module.equalHeight(); var elmH = $target.innerHeight(); elmTop = u.isRangeSP()? $elm.offset().top + elmH : $elm.offset().top; fixFlag = false; $elm.css("height",elmH); }; /* ancControl * 固定パーツ制御 ------------------------------- */ var ancControl = function(){ //if(u.isRangeSP()){ return; } var scrTop = u.$win.scrollTop(); if(elmTop < scrTop) { isFix = true; // static ==> fix if(fixFlag!==isFix){ $target.addClass(fixName); if(u.isRangeSP()){ $cloneHead.removeClass(openName); $toggleTrg.hide(); } EPOS_CARD.module.equalHeight(); fixFlag = isFix; } } else { isFix = false; // fix ==> static if(fixFlag!==isFix){ $target.removeClass(fixName); $cloneHead.removeClass(openName); $toggleTrg.show(); EPOS_CARD.module.equalHeight(); fixFlag = isFix; } } }; /* init ------------------------------- */ __initialize(); ancControl(); u.isWindowSizeCheck(function(){ __initialize(); ancControl(); }); u.$win.scroll(function(){ ancControl(); }); }; j$.googleSmoothScrollsp = function(config){ var c = j$.extend({ speed: 300, easing: "swing", noScrollClass: ".google-noScroll" }, config); /* vars ------------------------------- */ var url = j$(location).attr("href"), hash = location.hash, href, target, position, webkit = /webkit/, difference = j$("#googleHeader").innerHeight(); /* get hash ------------------------------ */ var $anc = j$(".navList03 li a"), hashLen = j$(".navList03 li a").length, hashArr = [], i; for(i = 0; i < hashLen; i++){ var __hash = $anc.eq(i).attr("href"); hashArr.push(__hash); } var hashes = hashArr.join("|"); /* trigger ------------------------------- */ /* ページ遷移+アンカー移動制御 */ u.$win.load(function(){ if((url.indexOf("#anc") !== -1)){ target = j$(hash); position = target.offset().top - difference; j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } }); /* スクロール制御 */ j$("a[href^=#]").not("a[href=#], a[href^=#tab], a[href^=#modal], " + c.noScrollClass + "").click(function(){ href = j$(this).attr("href"); target = j$(href); difference = j$("#googleHeader").innerHeight(); position = target.offset().top - difference; if(u.isRangeSP()){ j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } else { j$("html, body").animate({ scrollTop: position }, c.speed, c.easing); } return false; }); }; /* * @plugin - spMenuControl */ j$.spMenuControl= function(config){ var c = j$.extend({ menuTrigger: ".menuBtn", menuWrap: "#menuWrap", openNm: "open", closeNm: "close", closeBtn: ".menuClose", fixNm: "fixed", fadeSpeed: 300, HTML_SKIN: j$('
 
'), CSS_SKIN: { position: "fixed", opacity: 0, top: 0, left: 0, width: "100%", height: j$(document).height(), display: "block", background: "rgba(68,68,68,0.95)", "z-index": "999" } },config); var $menuTrigger = j$(c.menuTrigger), $menuWrap = j$(c.menuWrap), $closeBtn = j$(c.closeBtn), $skin = j$(c.HTML_SKIN).css(c.CSS_SKIN); var menuPositionSet = function(){ $menuWrap.css("padding-top",$menuTrigger.outerHeight() + 20 + "px"); }; menuPositionSet(); /* 幅可変に対応 */ u.isWindowSizeCheck(function(){ menuPositionSet(); if(!u.isRangeSP()){ $skin.remove(); } }); // function var menuOpen = function(){ $menuWrap.show().addClass(c.openNm).stop().animate({ opacity: 1.0 },c.fadeSpeed); $skin.appendTo("body").stop().animate({ opacity: 1.0 },c.fadeSpeed); $menuTrigger.addClass(c.openNm); j$("body").css("cursor","pointer"); }; var menuClose = function(){ $menuWrap.stop().animate({ opacity: 0 },c.fadeSpeed,function(){ $menuWrap.hide().removeClass(c.openNm); }); $skin.stop().animate({ opacity: 0 },c.fadeSpeed,function(){ $skin.remove(); }); $menuTrigger.removeClass(c.openNm); j$("body").css("cursor","inherit"); }; var menuClose02 = function(){ $menuWrap.stop().animate({ opacity: 0 },c.fadeSpeed,function(){ $menuWrap.hide().removeClass(c.openNm); }); $skin.stop().animate({ opacity: 0 },c.fadeSpeed,function(){ $skin.remove(); }); $menuTrigger.removeClass(c.openNm); j$("body").css("cursor","inherit"); }; // trigger $menuTrigger.on("click",function(){ if($menuWrap.hasClass(c.openNm)){ menuClose(); } else { menuOpen(); } }); $closeBtn.on("click",function(){ menuClose(); }); $(".useAnc").on("click",function(){ menuClose02(); }); // 領域外クリック j$("html").on("click",function(e){ // メニューが展開している時のみ if($menuWrap.hasClass(c.openNm)){ var target = e.target; //メニュータップ時は処理しない if(j$(target).parents(c.menuWrap)[0]||target===j$(c.menuTrigger)[0]||j$(target).parents(c.menuTrigger)[0]||j$(target).parents(c.closeBtn)[0]) { return; } menuClose(); } else { return; } }); }; /*スライダー -----------------------------*/ j$.slider = function(config){ var c = $.extend({ sliderName: ".js-slider01", pagerCurrentClassName: ".current", pagerTotalClassName: ".total" }, config); var $elm = j$(c.sliderName); if($elm.length === 0){ return false; } $elm.each(function(){ var $this = j$(this); $this.on('init', function(event, slick) { j$('.slick-arrow.slick-prev', $this).attr("style", "display: none !important"); $this.append('
/
'); j$(c.pagerCurrentClassName, $this).text(slick.currentSlide + 1); j$(c.pagerTotalClassName, $this).text(slick.slideCount); }) .slick({ autoplay: false, infinite: false, variableWidth: true, slidesToScroll: 1, slidesToShow: 1, centerMode: true, centerPadding: '0px', dots: false }) .on('beforeChange', function(event, slick, currentSlide, nextSlide) { //スライドボタン制御 var self = $(this), $arrow = $('.slick-arrow', self), speed = 300, targetIndex = slick.slideCount - 1; if(nextSlide == targetIndex){ $('.slick-arrow.slick-prev', self).fadeIn(speed, function() { $(this).attr("style", "display: inline-block !important"); }); $('.slick-arrow.slick-next', self).fadeOut(speed, function() { $(this).attr("style", "display: none !important"); }); }else if(nextSlide == 0){ $('.slick-arrow.slick-prev', self).fadeOut(speed, function() { $(this).attr("style", "display: none !important"); }); $('.slick-arrow.slick-next', self).fadeIn(speed, function() { $(this).attr("style", "display: inline-block !important"); }); }else{ $arrow.fadeIn(speed, function() { $(this).attr("style", "display: inline-block !important"); }); } //ページャー制御 j$(c.pagerCurrentClassName, $this).text(nextSlide + 1); }); }); } /*タブ -----------------------------*/ j$.tabNavFixed = function(){ var c = { elm: "js-fixedItem", wrap: "js-fixedItemWrap", tablist: "tabList", fixedClass : "fixed", nav : "googleHeader" } var $elm = j$('.' + c.elm), $wrap = j$('.' + c.wrap), $nav = j$('#' + c.nav); if($elm.length === 0 || $wrap.length === 0 ){return false} var elmTop = $wrap.offset().top, elmHeight = $wrap.outerHeight(), navHeight = $nav.outerHeight(), elmFixedPosition = elmTop - navHeight; j$('.'+c.tablist, $elm).on("click", "a", function(){ if($elm.hasClass(c.fixedClass)){ j$("html, body").animate({ scrollTop: elmFixedPosition - 20 }, 300, 'swing'); } }); j$(window).on('load', function(){ if(!(j$(window).width() > 750)){//sp時 elmTop = $wrap.offset().top, elmHeight = $wrap.outerHeight(), navHeight = $nav.outerHeight(), elmFixedPosition = elmTop - navHeight; if(j$(window).scrollTop() > elmFixedPosition){ $elm.addClass(c.fixedClass).css('top', navHeight + 'px'); $wrap.css('height', elmHeight + 'px'); }else{ $elm.removeClass(c.fixedClass).css('top', ''); $wrap.css('height', ''); } } }); j$(window).on('resize', function(){ if(j$(window).width() > 750){//pc時 $elm.removeClass(c.fixedClass).css('top', ''); $wrap.css('height', ''); }else{//sp時 elmTop = $wrap.offset().top, elmHeight = $wrap.outerHeight(), navHeight = $nav.outerHeight(), elmFixedPosition = elmTop - navHeight; if(j$(window).scrollTop() > elmFixedPosition){ $elm.addClass(c.fixedClass).css('top', navHeight + 'px'); $wrap.css('height', elmHeight + 'px'); }else{ $elm.removeClass(c.fixedClass).css('top', ''); $wrap.css('height', ''); } } }); var fixdChangeFlag = 0; j$(window).on('scroll', function(){ if(!(j$(window).width() > 750)){//sp時 if(j$(window).scrollTop() > elmFixedPosition){ $elm.addClass(c.fixedClass).css('top', navHeight + 'px'); $wrap.css('height', elmHeight + 'px'); if(fixdChangeFlag === 0){ EPOS_CARD.module.equalHeight(true, true); fixdChangeFlag = 1; } }else{ $elm.removeClass(c.fixedClass); $wrap.css('height', ''); if(fixdChangeFlag === 1){ EPOS_CARD.module.equalHeight(true, true); fixdChangeFlag = 0; } } } }); } })(jQuery);