var comJs = {};
comJs.uaInfo = (function() {
'use strict';
var that = {};
var userAgent = window.navigator.userAgent;
var appVersion = window.navigator.appVersion.toLowerCase();
that.browser = null;
that.os = null;
that.ieVr = null;
that.oldIe = false;
that.terminal = null;
that.fixedSupport = true;
that.legacyAndroid = false;
that.interface = 'mouse';
if(('ontouchstart' in document) && ('orientation' in window)) {
that.interface = 'touch';
}
if (userAgent.indexOf('iPhone') > 0 || userAgent.indexOf('iPod') > 0) {
that.os = 'ios';
that.terminal = 'iPhone';
if (userAgent.indexOf('OS 4') !== -1 || userAgent.indexOf('OS 3') !== -1 || userAgent.indexOf('OS 2') !== -1) {
that.fixedSupport = false;
}
} else if (userAgent.indexOf('iPad') > 0) {
that.os = 'ios';
that.terminal = 'iPad';
if (userAgent.indexOf('OS 4') !== -1 || userAgent.indexOf('OS 3') !== -1 || userAgent.indexOf('OS 2') !== -1) {
that.fixedSupport = false;
}
} else if (userAgent.indexOf('Android') > 0) {
that.os = 'android';
if (userAgent.indexOf('Mobile') > 0) {
that.terminal = 'androidMob';
} else {
that.terminal = 'androidTab';
}
if (userAgent.indexOf('Android 3.') !== -1 || userAgent.indexOf('Android 2.') !== -1 || userAgent.indexOf('Android 1.') !== -1) {
that.fixedSupport = false;
}
if (userAgent.indexOf('Android 4.') > 0 || userAgent.indexOf('Android 3.') > 0 || userAgent.indexOf('Android 2.') > 0 || userAgent.indexOf('Android 1.') > 0) {
that.legacyAndroid = true;
}
} else if (userAgent.match(/Mac|PPC/)) {
that.os = 'mac';
} else {
that.os = 'other';
}
var ua = userAgent.toLowerCase();
if (ua.indexOf('msie') !== -1 || ua.indexOf('trident') >= 0) {
that.browser = 'ie';
if (ua.indexOf('msie 6.') !== -1) {
that.ieVr = 6;
that.fixedSupport = false;
that.oldIe = true;
} else if (appVersion.indexOf('msie 7.') !== -1) {
that.ieVr = 7;
that.oldIe = true;
} else if (appVersion.indexOf('msie 8.') !== -1) {
that.ieVr = 8;
that.oldIe = true;
} else if (appVersion.indexOf('msie 9.') !== -1) {
that.ieVr = 9;
} else if (appVersion.indexOf('msie 10.') !== -1) {
that.ieVr = 10;
}
} else if (ua.indexOf('edge') !== -1) {
that.browser = 'edge';
} else if (ua.indexOf('chrome') !== -1) {
that.browser = 'chrome';
} else if (ua.indexOf('safari') !== -1) {
that.browser = 'safari';
} else if (ua.indexOf('firefox') !== -1) {
that.browser = 'firefox';
}
if (that.os) {
$('html').addClass('is_' + that.os);
}
if (that.browser) {
$('html').addClass('is_' + that.browser);
}
if (that.ieVr) {
$('html').addClass('is_' + that.browser + that.ieVr);
}
if (that.oldIe) {
$('html').addClass('is_oldIe');
}
if (that.terminal) {
$('html').addClass('is_' + that.terminal);
}
if (!that.fixedSupport) {
$('html').addClass('is_no_fixedsupport');
} else {
$('html').addClass('is_fixedsupport');
}
if (that.legacyAndroid) {
$('html').addClass('is_legacyAndroid');
}
$('html').addClass('is_' + that.interface);
if ((/Android/.test(userAgent) && /Linux; U;/.test(userAgent) && !/Chrome/.test(userAgent)) ||
(/Android/.test(userAgent) && /Chrome/.test(userAgent) && /Version/.test(userAgent)) ||
(/Android/.test(userAgent) && /Chrome/.test(userAgent) && /SamsungBrowser/.test(userAgent))) {
$('html').addClass('is_legacyAndroid-default');
}
return that;
}());
if(comJs.uaInfo.terminal === 'androidMob' || comJs.uaInfo.terminal === 'iPhone') {
document.write('');
}else {
document.write('');
}
$(function() {
$(window).resize(function() {
//console.log($(window).width());
});
$('a').focus(function() {
this.blur();
});
//アンカースクロール
$('a[href^="#"]').not('.noScroll').click(function(e) {
e.preventDefault();
comJs.ancScr($($(this).attr('href')));
});
comJs.responseFlagObj = comJs.responseFlag();
/*comJs.responseFlagObj.addFunc(function(flag) {
console.log(flag);
});*/
/*comJs.loadCompFuncAry.push(function(){
console.log('push');
});*/
$('.js-flexWrap').each(function() {
comJs.flexBox($(this));
});
$('.js-shWrap').each(function() {
comJs.sameHeightCall($(this));
});
});
/*===========================================================================
↓要素開閉↓
===========================================================================*/
comJs.flexBox = function($wrap) {
var that = {};
var $btn = $wrap.find('.js-flexBtn');
var $box = $wrap.find('.js-flexBox');
var openClass = "js-open";
var speed = 500;
var easing = 'easeOutQuart';
var init = function() {
$btn.on('click',function(){
if(!$wrap.hasClass(openClass)) {
boxOpen();
}else {
boxClose();
}
});
};
var boxOpen = function() {
$wrap.addClass(openClass);
$box.stop();
if(!$box.is(':visible')) {
$box.css({
'height': 0,
'display': 'block'
});
}
var tmpH = $box.height();
$box.css('height','auto');
var toH = $box.height();
$box.css('height',tmpH);
$box.animate({
'height': toH
}, speed, easing, function() {
$box.css('height','auto');
});
};
var boxClose = function() {
$wrap.removeClass(openClass);
$box.stop();
$box.animate({
'height': 0
}, speed, easing, function() {
$box.css('display','none');
});
};
init();
return that;
};
/*===========================================================================
↓要素の高さを揃える 呼び出し↓
===========================================================================*/
comJs.sameHeightCall = function($target) {
$target.each(function() {
var $this = $(this);
var num = $this.data('jsprop-num');
var spNum = $this.data('jsprop-spnum');
var itemClass = $this.data('jsprop-shitem') || 'js-shItem';
var $item = $this.find('.' + itemClass);
var shObj = null;
if($item.length) {
if(num) {
shObj = comJs.sameHeightNum($item, num);
if(spNum) {
if($('html').hasClass('viewport_pc')) {
shObj.setNum(num);
}else {
shObj.setNum(spNum);
}
comJs.responseFlagObj.addFunc(function(){
if($('html').hasClass('viewport_pc')) {
shObj.setNum(num);
}else {
shObj.setNum(spNum);
}
});
}
}else {
shObj = comJs.sameHeightNum($item);
}
}
});
};
/*===========================================================================
↓要素の高さを揃える↓
===========================================================================*/
comJs.sameHeight = function($target) {
'use strict';
$target.css('height', 'auto');
if ($target.length > 1) {
var maxH = 0;
$target.each(function() {
if (maxH < $(this).height()) {
maxH = Math.ceil($(this).height());
}
});
$target.height(maxH);
}
};
/*===========================================================================
↓要素を数毎に高さを揃える↓
===========================================================================*/
comJs.sameHeightNum = function($target, num) {
'use strict';
var that = {};
var $win = $(window);
that.num = num || null;
//that.timer = null;
var init = function() {
/*that.timer = setInterval(function() {
sameHeightFunc();
}, 1500);*/
$win.on('resize.sameHeightNum',function(){
sameHeightFunc();
});
that.timer = setTimeout(function() {
sameHeightFunc();
}, 1500);
sameHeightFunc();
};
var sameHeightFunc = function() {
var tmpArySet = [];
var $tmpSet = null;
if(that.num) {
$target.each(function(index, element) {
if (index % that.num === 0) {
if ($tmpSet) {
tmpArySet.push($tmpSet);
}
$tmpSet = $(element);
} else {
$tmpSet = $tmpSet.add($(element));
}
});
}else {
$target.each(function(index, element) {
if (index === 0) {
$tmpSet = $(element);
} else {
$tmpSet = $tmpSet.add($(element));
}
});
}
tmpArySet.push($tmpSet);
for (var i = 0, len = tmpArySet.length; i < len; i++) {
comJs.sameHeight(tmpArySet[i]);
}
};
that.setNum = function(newNum) {
that.num = newNum;
};
that.triggerSameHeight = function() {
sameHeightFunc();
};
$.data($target.get(0), "sameHeightNum", {
'sameHeightNum': that
});
init();
return that;
};
/*===========================================================================
↓スクロール移動↓
===========================================================================*/
comJs.ancScr = function($ancTarget, option) {
'use strict';
var position;
var opt = option || {};
var speed = opt.speed || 1200;
var easing = opt.easing || 'easeOutExpo';
if (!$ancTarget.length) {
return false;
}
position = $ancTarget.offset().top;
$('body, html').stop().animate({
scrollTop: position
}, speed, easing);
};
/*===========================================================================
↓レスポンシブ切り替え判定↓
===========================================================================*/
comJs.responseFlag = function() {
'use strict';
var that = {};
var flagElmCss = {
'position': 'fixed',
'top': '-999px',
'display': 'none'
};
var $flagElmPc = $('
').css(flagElmCss);
var $flagElmTab = $('
').css(flagElmCss);
var $flagElmSp = $('
').css(flagElmCss);
$('body').append($flagElmPc, $flagElmTab, $flagElmSp);
var funcAry = [];
var flag = null;
var init = function() {
setInterval(function() {
responseCheck();
}, 500);
responseCheck();
};
var responseCheck = function() {
var tmpFlag = flag;
if ($('#responseFlagPc').is(':visible')) {
$('html').addClass('viewport_pc');
$('html').removeClass('viewport_tab');
$('html').removeClass('viewport_sp');
flag = 'pc';
//console.log('is_pc');
} else if ($('#responseFlagTab').is(':visible')) {
$('html').removeClass('viewport_pc');
$('html').addClass('viewport_tab');
$('html').removeClass('viewport_sp');
flag = 'tab';
//console.log('is_tab');
} else if ($('#responseFlagSp').is(':visible')) {
$('html').removeClass('viewport_pc');
$('html').removeClass('viewport_tab');
$('html').addClass('viewport_sp');
flag = 'sp';
//console.log('is_sp');
}
//console.log(window.outerWidth);
//console.log(flag);
if (tmpFlag !== flag) {
that.changeAction();
}
};
that.changeAction = function() {
$.each(funcAry, function(idx) {
funcAry[idx](flag);
});
};
that.addFunc = function(func) {
funcAry.push(func);
func(flag);
};
init();
return that;
};