/********************************************* * bangdream.js *********************************************/ /* ------------------------------------------- * @init ------------------------------------------- */ $(function(){ var u = new EPOS_CARD.Util(); $.gt_cBox(); $.modal(); $.customScroll(); $(window).on('load', function (){ $.base_equalHeight(true, true); }); }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function($){ /* * @method digitalcard_equalHeight * - 高さ揃え * @param {Boolean} * - 文字可変・リサイズに対応するかどうか */ $.base_equalHeight = function(fsCheck, wsCheck){ var u = new EPOS_CARD.Util(); var className = ".base_equalHeight", childBaseName = "equalChild", cancelName = "sp-eqCancel", $elm = $(className), $children = $elm.children(), $spChildren = $elm.not("." + cancelName).children(),// SP時に有効となる要素 winW = u.$win.width(), fsCheck = fsCheck || false, wsCheck = wsCheck || true, spCheck = false; if($elm.length === 0 || $children.length < 2){ return false; } if(winW < u.breakPoint1){ spCheck = true; } /* childBaseNameのグループ化 */ var grouping = function(w){ var $groupedChildren = $elm.find("*[class*=" + childBaseName + "]"), classNames = {},groups = []; $groupedChildren.each(function(){ var splitClass = $(this).attr("class").split(" "), splitClassNum = splitClass.length, newClassName; for(var i = 0; i < splitClassNum; i++){ newClassName = splitClass[i].match(RegExp(childBaseName + "[a-z0-9,_,-]*", "i")); if(!newClassName){ continue; } else { newClassName.toString(); classNames[newClassName] = newClassName; } } }); // childBaseNameの格納 for(var c in classNames){ if(w < u.breakPoint1){ groups.push($elm.not("." + cancelName).find("." + c));// SP時にcancelNameを持つ要素を対象から外す } else { groups.push($elm.find("." + c)); } } return groups; }; /* 各要素の高さを揃える */ var equalHeight = function(elm){ var maxHeight = 0; elm.css("height", "auto"); elm.each(function(){ if($(this).outerHeight() > maxHeight){ maxHeight = $(this).outerHeight(); } }); return elm.outerHeight(maxHeight); }; /* init */ var init = function(){ var winW = u.$win.width(), groups = grouping(winW); var eqAct = function(eqObj){ var h = [], child = [], maxHeight = 0, top = 0; $.each(eqObj, function(){ var $group = $(this).not(":hidden");// 非表示要素に適用させない場合.not(":hidden")を付与 $group.each(function(i){ $(this).css("height", "auto"); h[i] = $(this).outerHeight(); if ((top !== Math.round($(this).offset().top)) && (top !== Math.round($(this).offset().top) + 1) && (top !== Math.round($(this).offset().top) - 1)) { equalHeight($(child)); child = []; top = Math.round($(this).offset().top); } child.push(this); }); }); if(child.length > 1){ equalHeight($(child)); } } // childBaseName要素の高さを揃える eqAct(groups); // 子要素の高さを揃える if(winW < u.breakPoint1){ // SP時 eqAct($spChildren); $("." + cancelName).children().css("height", "auto"); $("." + cancelName).find("*[class*=" + childBaseName + "]").css("height", "auto"); } else { // PC時 eqAct($children); setTimeout( function(){ $(".equalChild_bottom").css({ top: "inherit", bottom: 0 }); },100); } }; // 文字可変への対応可否 fsCheck ? u.isFontSizeCheck(init) : init(); wsCheck ? u.isWindowSizeCheck(init) : init(); } /* * gt_cBox * モーダル */ $.gt_cBox = function(){ // instance var u = new EPOS_CARD.Util(); // element var $cbox = $(".bndr-cb-inline"); if($cbox.length === 0){ return false; } $cbox.colorbox({ inline: true, maxWidth: "90%", maxHeight: "95%", fixed: true, onComplete: function(){ EPOS_CARD.module.equalHeight(true, true); EPOS_CARD.module.sizeFix(); } }); }; $.modal = function(config){ var u = new EPOS_CARD.Util(); var c = $.extend({ elm: ".js-base01Modal" },config); // vars var $elm = $(c.elm); if($elm.length === 0){ return false; } // trigger if(!u.isRangeSP()){ $elm.colorbox({ inline: true, width: "100%", maxWidth: "1100px", maxHeight: "92%", fixed: true, onComplete: function(){ EPOS_CARD.module.equalHeight(true, true); EPOS_CARD.module.sizeFix(); } }); } else { $elm.colorbox({ inline: true, height: "", maxWidth: "100%", maxHeight: "100%", fixed: true, onComplete: function(){ EPOS_CARD.module.equalHeight(true, true); EPOS_CARD.module.sizeFix(); } }); } }, /* * 既存踏襲 * $.customScroll * カスタムスクロールバー */ $.customScroll = function(){ if($("#news_area").length === 0){ return false; } $(window).load(function(){ $("#news_area").mCustomScrollbar({ scrollButtons:{enable:true}, theme:"my-theme" }); }); }; })(jQuery);