/********************************************* * header02.js --------------------------------------------- * @noConflict * - j$ * @respondBrowser * - IE8 @init @plugin * - pcMenuControl * - spMenuControl *********************************************/ /* ------------------------------------------- * @noConflict ------------------------------------------- */ jqNew = jQuery.noConflict(); if($ === undefined){ $ = jQuery; } j$ = jQuery || jqNew; /* ------------------------------------------- * @respondBrowser * IE8以下の時にSP用CSSを削除 * media-queryを理解しないため ------------------------------------------- */ var ua = navigator.userAgent.toLowerCase(); if((ua.indexOf("msie 8") !== -1) || (ua.indexOf("msie 7") !== -1) || (ua.indexOf("msie 6") !== -1)){ j$('link[media="all and (max-width: 750px)"]').remove(); } /* ------------------------------------------- * @init ------------------------------------------- */ j$(function(){ // SP幅判定 isRangeSP = function(){ var winW = j$(window).width(); return (winW <= 750) ? true : false; }; //SP UA判別 isSmartphone = function(){ var UA = { iPhone: ua.indexOf('iphone') !== -1, iPod: ua.indexOf('ipod') !== -1, Android: ua.indexOf('android') !== -1 && ua.indexOf('mobile') !== -1, WindowsPhone: ua.indexOf('windows phone') !== -1 }; return (UA.iPhone || UA.iPod || UA.Android || UA.WindowsPhone) ? true : false; }; //TBL UA判別 isTablet = function(){ var UA = { iPad: ua.indexOf('ipad') !== -1, Android: ua.indexOf('android') !== -1 && ua.indexOf('mobile') === -1 }; return (UA.iPad || UA.Android) ? true : false; }; // SP幅の時に実行 if(isRangeSP()){ j$("#headerContainer .navToggle > li").navigationToggle(); j$.spMenuControl(); j$.spSearchBoxs(); } else { // SP幅じゃない時に実行 j$.pcMenuControl(); } // PC,SP共通で実行 j$.viewportSet(); j$.loginReplace(); j$("#headerContainer .linkToggle01 > li").navigationToggle({ childList: ".childLink" }); j$.searchSwap(); j$.campBnrSwap(); // 幅可変時に実行 var winChangeLoad = function(){ var resize = false, interval = 500; j$(window).on("resize", function(){ // リサイズされている間は何もしない if(resize !== false){ clearTimeout(resize); } resize = setTimeout(function(){ j$.equalHeight(); }, interval); }); }; winChangeLoad(); }); // load時に実行 j$(window).on("load",function(){ j$.equalHeight(); }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function(j$){ /* * @method viewportSet * - viewportが無い場合に設定 */ j$.viewportSet = function(){ var $meta_viewport = j$("meta[name='viewport']"); if($meta_viewport.length === 0){ var createMeta = ''; j$(createMeta).appendTo("head"); } }; /* * @method searchSwap * - 検索窓のactionをPC/SPで切換 */ j$.searchSwap = function(){ var $elm = j$('form[name="search"]'), pc_action = "/probosearch/redirect.html", sp_action = "/probosearch/smp/redirect.html"; if(isSmartphone()){ $elm.attr("action",sp_action); } else { $elm.attr("action",pc_action); } }; /* * @method loginReplace * - ログイン時のHTML変更 */ j$.loginReplace = function(){ if(j$("body").attr("id") === ("officialTop")){ return false; } // TOPページでは実行しない var loginFlg = j$.cookie("login") === "1"? true:false, escFlg = j$.cookie("esc_if")? true:false, logoutTxt = "マイページ ログイン・登録", loginTxt = "マイページトップ"; // vars var $loginBtn = j$("#header01 .utilList .login"), pcLogin = j$("> a > span.hdft_pcOnly",$loginBtn), //PCログインボタン pcRegist = j$("#header01 .utilList .register,#header01 .utilList .movie"), //PCご登録 spLogin = j$("> a > span.hdft_spOnly img",$loginBtn), //SPログインボタン spSignup = j$("#header01 .utilList .signup"), //SPお申込みボタン spMenuLogin = j$("#header01 #menuWrap .headerBtn02 .login > a > span img"); //SPメニュー内ログインボタン // 会員で非ログインの場合 if(escFlg && !loginFlg){ pcLogin.html(logoutTxt); pcRegist.hide(); spSignup.hide(); spLogin.attr("src", spLogin.attr("src").replace("sp_com_head_bt01", "sp_com_head_bt01_03")).on("load",function(){ $loginBtn.addClass("login--2"); }); if(spMenuLogin.length > 0){ spMenuLogin.attr("src", spMenuLogin.attr("src").replace("sp_com_head_bt03", "sp_com_head_bt01_03")).on("load",function(){ j$("#header01 #menuWrap .headerBtn02 .login").addClass("highlight"); }); } } // ログインしている場合 if(loginFlg){ $loginBtn.addClass("white"); pcLogin.html(loginTxt); pcRegist.hide(); spSignup.hide(); spLogin.attr("src", spLogin.attr("src").replace("sp_com_head_bt10", "sp_com_head_bt01_02")); if(spMenuLogin.length > 0){ spMenuLogin.attr("src", spMenuLogin.attr("src").replace("sp_com_head_bt03", "sp_com_head_bt03_02")); spMenuLogin.parents(".login").addClass("white"); } } }; /* * @method equalHeight * - 高さ揃え */ j$.equalHeight = function(config){ var c = j$.extend({ className: ".hdft_eqHeight", childBaseName: "equalChild" }, config); if(j$(c.className).length == 0) return false; /* vars ------------------------------- */ var $this = j$(c.className), $children = $this.children(), $childName = j$("." + c.childBaseName), num_$children = $children.size(), arr_parents = []; if(num_$children < 2) return false; function ChildrenGrouping(){ var arr_groups = [], $children = $this.find($childName); if($children.length) arr_groups.push($children); var $groupedChildren = $this.find('*[class*=' + c.childBaseName + ']:not(.' + c.childBaseName + ')'); if($groupedChildren.length){ var classNames = {}; $groupedChildren.each(function(){ var split_class = j$(this).attr("class").split(" "), len_split_class = split_class.length, i, new_class; for(i = 0; i < len_split_class; i++){ new_class = split_class[i].match(RegExp(c.childBaseName + "[a-z0-9_-]+", 'i')); if(!new_class) continue; new_class = new_class.toString(); if(new_class) classNames[new_class] = new_class; } }); for(var new_class in classNames) arr_groups.push($this.find("." + new_class)); } $children = $this.children(); if($children.length) arr_groups.push($children); $this.data("EqualHeightChildrenGroups", arr_groups); arr_parents.push($this); return arr_groups } j$.fn.EqualHeight = function(){ var maxHeight = 0; this.css("height", "auto"); // IE用 this.css("zoom", 1); this.each(function(){ if (j$(this).height() > maxHeight) { maxHeight = j$(this).height(); } }); return this.height(maxHeight) }; j$.fn.EqualHeightInit = function(){ var arr_groups = ChildrenGrouping(); j$.each(arr_groups, function(){ var $children = j$(this), arr_child = [], top = 0; $children.each(function(){ if(top != j$(this).position().top){ j$(arr_child).EqualHeight(); arr_child = []; top = j$(this).position().top; } arr_child.push(this); }); if(arr_child.length) j$(arr_child).EqualHeight(); }); }; /* 初期表示 */ $this.EqualHeightInit(); }; /* * @plugin - navigationToggle */ j$.fn.navigationToggle = function(config){ var c = j$.extend({ childList: ".navList02", speed: 300, openNm: "open" },config); // vars var self = j$(this), $trg = self.children("a"); // setting j$(this).find(c.childList).hide(); // trigger $trg.on("click",function(){ var self = j$(this).parents("li"), $childList = self.find(c.childList); if($childList.length === 0){ return; } if(self.hasClass(c.openNm)){ self.removeClass(c.openNm); $childList.stop().slideUp(c.speed); return false; } else { self.addClass(c.openNm); $childList.stop().slideDown(c.speed); return false; } }); // PCのみ領域外クリック if(!isRangeSP()){ if(navigator.userAgent.toLowerCase().indexOf('ipad') > 0){ j$("body").css("cursor","pointer"); } j$(document).on("click",function(){ $trg.parents("li").removeClass(c.openNm); $trg.parents("li").find(c.childList).stop().slideUp(c.speed); }); j$("#menuWrap .globalNav01 .navList01 > li > a").on("click",function(){ $trg.parents("li").removeClass(c.openNm); $trg.parents("li").find(c.childList).stop().slideUp(c.speed); }); $trg.on("click",function(e){ e.stopPropagation(); }); } }; /* * @plugin - pcMenuControl */ j$.pcMenuControl = function(config){ var c = j$.extend({ wrap: "#menuWrap .globalNav01 .navList01", nav: "#menuWrap .globalNav01 .navList01 > li", trigger:"#menuWrap .globalNav01 .navList01 > li > a", megaElm: ".megaWrap", currentNm: "on", openNm: "open", closeBt: ".megaClose", fadeSpeed: 300 },config); // Setting for iPad if(navigator.userAgent.toLowerCase().indexOf('ipad') > 0){ j$("body").css("cursor","pointer"); } // vars var $nav = j$(c.nav), $trigger = j$(c.trigger), $megaElm = j$(c.megaElm), $close = j$(c.closeBt); // Setting $megaElm.hide(); // function var menuClose = function(){ $nav.removeClass(c.openNm); $megaElm.stop().fadeOut(c.fadeSpeed); }; // クリックで開閉 var clickToggle = function(){ $trigger.on("click",function(){ var self = j$(this), $self_nav = self.parents(c.nav), $self_megaElm = $self_nav.children(c.megaElm); if($self_nav.hasClass(c.openNm)){ $self_nav.removeClass(c.openNm); $self_megaElm.stop().fadeOut(c.fadeSpeed); } else { menuClose(); $self_nav.addClass(c.openNm); $self_megaElm.stop().fadeIn(c.fadeSpeed); } }); }; // ホバーで開閉 var hoverToggle = function(){ $nav.hover(function(){ var self = j$(this), $self_megaElm = self.children(c.megaElm); menuClose(); self.addClass(c.openNm); $self_megaElm.stop().fadeIn(c.fadeSpeed); }, function(){ var self = j$(this), $self_megaElm = self.children(c.megaElm); self.removeClass(c.openNm); $self_megaElm.stop().fadeOut(c.fadeSpeed); }); }; // init if(isTablet()){ clickToggle(); // タブレットならクリックで開閉 } else { hoverToggle(); } $close.on("click",function(){ menuClose(); }); // 領域外クリック j$(document).on("click",function(){ menuClose(); }); j$(".linkToggle01 a").on("click",function(){ menuClose(); }); $nav.on("click",function(e){ e.stopPropagation(); }); }; /* * @plugin - spMenuControl */ j$.spMenuControl= function(config){ var c = j$.extend({ menuTrigger: ".menuBtn", menuWrap: "#menuWrap", openNm: "open", closeNm: "close", closeBtn: ".closeBtn", fixNm: "fixed", fadeSpeed: 300, HTML_SKIN: j$('