/* ++++++++++++++++++++++++++++++++++++++++++++
//
// 環境チェック
//
++++++++++++++++++++++++++++++++++++++++++++ */
// UA判定
var ua = navigator.userAgent;
var deviceName = deviceOS = null;
var browser = null;
var ieVer = false;
if (ua.indexOf('iPhone') != -1) {
deviceName = 'iPhone';
deviceOS = "iOS";
} else if (ua.indexOf('iPad') != -1) {
deviceName = 'iPad';
deviceOS = "iOS";
} else if (ua.indexOf('iPod') != -1) {
deviceName = 'iPod';
deviceOS = "iOS";
} else if (ua.indexOf('Android') != -1) {
deviceName = 'Android';
} else if (ua.indexOf('Windows') != -1) {
deviceOS = 'Windows';
}
// ブラウザ
if (ua.indexOf('MSIE') != -1 || ua.indexOf('Trident') != -1) {
browser = 'IE';
} else if (ua.indexOf('Safari') != -1) {
browser = 'Safari';
}
// バージョン IE 8以下の場合 'lteIE8' を代入
if (ua.indexOf('MSIE 8') != -1) {
ieVer = 'IE8';
} else if ((ua.indexOf('MSIE 7') != -1) || (ua.indexOf('MSIE 6') != -1)) {
ieVer = 'ltIE8';
}
// タッチデバイス判定
var isTouch = 'ontouchstart' in window;
// イベントハンドラー変換
var overstart; // マウスオーバー・タッチ時
var outend;
if (!isTouch) {
overstart = 'mouseenter';
outend = 'mouseleave';
} else {
overstart = 'touchstart';
outend = 'touchend';
}
// ウィンドウオブジェ
var win = jQuery(window);
var html = jQuery('html');
// PC表示の区切りサイズ
var tgtSwichWidthMiddle = 767;
var tgtSwichWidthSmall = 480;
// 切り替えカウンター
var swithCounter = 0;
(function($) {
$(function() {
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// マウスのキーアップでフォーカスを解く
//
++++++++++++++++++++++++++++++++++++++++++++ */
$('.tk_contents').bind('mouseup', function() {
$(this).find('a').blur();
$(this).find('*[tabindex]').blur();
});
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// DOMが形成された時
//
++++++++++++++++++++++++++++++++++++++++++++ */
/* body に デバイスに応じた クラスを付与
-------------------------------------------- */
var body = $('body');
body.addClass('tk_page_accommodation');
body.addClass(deviceName);
if (isTouch) {
body.addClass('tk_touch_device');
} else {
body.addClass('tk_not_touch_device');
}
if (deviceOS) {
body.addClass('tk_' + deviceOS);
}
if (browser) {
body.addClass('tk_' + browser);
}
if (ieVer == 'IE8' || ieVer == 'ltIE8') {
body.addClass('tk_lteIE8');
}
/* jQueryでスクロール
--------------------------------------------
$('a[href*=#]').click(function() {
if ($(this).hasClass('tk_anchor_link')) {
var target = $(this.hash);
target = target.length && target;
if (target.length) {
var scldurat = 1000;
var targetOffset = target.offset().top - $('.tk_header').height();
$('html,body')
.animate({
scrollTop: targetOffset
}, {
duration: scldurat,
easing: "easeOutExpo"
});
return false;
}
}
});
*/
/* ページの先頭へボタンコントロール
-------------------------------------------- */
var ptopBtn = $('.tk_ptop_btn');
$(window).scroll(function() {
scVal = $(this).scrollTop();
if (scVal > 200) {
ptopBtn.addClass('tk_show');
} else {
ptopBtn.removeClass('tk_show');
}
});
/* フォントサイズの拡大・縮小コントロール
-------------------------------------------- */
var fontSizeBtn = $('.tk_header .tk_ho_fontsize');
fontSizeBtn.bind('click', function() {
changeFS();
});
var changeFS = changeFontSize();
function changeFontSize() {
this.changed = false;
return function(reset) {
reset = reset || false;
if (!changed && !reset) {
$('.tk_header, .tk_contents, .tk_footer, .tk_ptop_btn, .tk_footer_tripadvisor_bnr').css({
'font-size': '85%'
});
body.addClass('fs_changed');
this.changed = true;
} else if (changed || reset) {
$('.tk_header, .tk_contents, .tk_footer, .tk_ptop_btn, .tk_footer_tripadvisor_bnr').css({
'font-size': '71.5%'
});
body.removeClass('fs_changed');
this.changed = false;
}
}
};
/* リンク クリックしたらフォーカスアウト
-------------------------------------------- */
$('.tk_contents a').bind('click', function() {
$(this).blur();
});
/* スマフォ用 ナビゲーションコントロール
-------------------------------------------- */
// ナビボタン
var hmCat = $('.tk_header .tk_cat_nav');
var hmCatBtn = $('.tk_header .tk_cat_nav .tk_menu_btn');
// var hmSns = $('.tk_header .tk_sns_nav');
// var hmSnsBtn = $('.tk_header .tk_sns_nav .tk_menu_btn');
var hmBtnAry = [hmCatBtn];
// ナビメニュー
var hmCatNav = $('.tk_header .tk_cat_nav .tk_sub_menu');
// var hmSnsNav = $('.tk_header .tk_sns_nav .tk_sub_menu');
var hmNavAry = [hmCatNav];
if (!isTouch) { // タッチデバイスじゃない
// カテゴリーメニュー
hmCatBtn.bind('mouseenter focus', function() {
hmMenuControl($(this), hmCatNav);
});
hmCat.bind('mouseleave', function() {
hmMenuControl(hmCatBtn, hmCatNav);
});
hmCatNav.find('li:last').bind('focusout', function() {
hmMenuControl(hmCatBtn, hmCatNav);
});
} else { // タッチデバイス
hmCatBtn.bind('touchstart', function() {
hmMenuControl($(this), hmCatNav);
hmCatNav.scrollTop(0);
});
}
// ナビメニューの表示・非表示とナビボタンへのonクラスの追加・削除
// PCカテゴリー別メニュー用
function hmMenuControl(btn, menu) {
$.each(hmNavAry, function() {
if ($(this).parent().attr('id') == menu.parent().attr('id')) {
if (menu.css('display') != 'block') {
swicthOnCls(btn);
menu.animate({
'height': 'toggle'
}, 200);
} else {
menu.animate({
'height': 'toggle'
}, 200, function() {
swicthOnCls(btn);
btn.blur();
});
}
} else {
$(this).hide();
}
btn.parent().siblings().children('.tk_menu_btn').removeClass('tk_on');
});
}
// onクラスのスイッチ(onクラスがあれば削除、無ければ追加)
function swicthOnCls(obj) {
if (obj.hasClass('tk_on')) {
obj.removeClass('tk_on');
} else {
obj.addClass('tk_on');
}
}
/* デバイスの縦横切り替えに応じて、viewport を書き換え。
++++++++++++++++++++++++++++++++++++++++++++ */
var metaViewport = $('meta[name="viewport"]');
// デバイスの縦横で viewport を変更する
win.bind('orientationchange', function() {
// portrait
if (!matchMedia('(min-device-width:768px)').matches) {
if (matchMedia('(orientation:portrait)').matches) {
if (deviceOS == "iOS") {
resetViewport('portrait');
} else if (deviceOS == "Android") {
resetViewport('landscape');
}
} else if (matchMedia('(orientation:landscape)').matches) { // landscape
if (deviceOS == "iOS") {
resetViewport('landscape');
} else if (deviceOS == "Android") {
resetViewport('portrait');
}
}
}
});
function resetViewport(orient) {
if (orient == 'portrait') {
metaViewport.attr('content', 'width=device-width, initial-scale=1, minimum-scale=1');
} else if (orient == 'landscape') {
metaViewport.attr('content', 'width=device-height, initial-scale=1, minimum-scale=1');
}
}
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// 旅くら追加
//
++++++++++++++++++++++++++++++++++++++++++++ */
$('#header, #footer').css({'width':'100%'});
});
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// スロール
//
++++++++++++++++++++++++++++++++++++++++++++ */
function scrollAnchor(targetPos) {
var winBody = $('html,body');
winBody.animate({
scrollTop: targetPos
}, {
duration: 500,
easing: "easeOutExpo",
queue: false
});
}
})(jQuery);
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// 初html読み込み時にViewPortをセットする
//
++++++++++++++++++++++++++++++++++++++++++++ */
/*
function setViewport() {
if (typeof matchMedia == "function") {
if (matchMedia('(min-device-width:768px)').matches) {
document.write('');
} else {
if (matchMedia('(orientation:portrait)').matches) {
document.write('');
} else {
document.write('');
}
}
}
}
*/
function setViewport() {
if (typeof matchMedia == "function") {
if (matchMedia('(min-device-width:768px)').matches) {
jQuery('head').append('');
} else {
if (matchMedia('(orientation:portrait)').matches) {
jQuery('head').append('');
} else {
jQuery('head').append('');
}
}
}
}
setViewport();
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// メディアクエリーに合わせたウィンドウの幅取得
//
++++++++++++++++++++++++++++++++++++++++++++ */
function getWinWidth() {
var innerWidth = window.innerWidth;
var bodyClientWidth = document.body.clientWidth;
var docElClientWidth = document.documentElement.clientWidth;
if (deviceOS == "Windows") {
if (ieVer == 'IE8') {
return bodyClientWidth;
} else {
return innerWidth;
}
} else if (isTouch) {
return bodyClientWidth;
} else {
return innerWidth;
}
}
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// セレクトボックスでのリンク
//
++++++++++++++++++++++++++++++++++++++++++++ */
function selectLink(obj) {
location.href = obj.value;
}
/* ++++++++++++++++++++++++++++++++++++++++++++
//
// 拡大率取得
//
++++++++++++++++++++++++++++++++++++++++++++ */
function getZoomePacentage() {
var aSize = window.innerWidth;
var bSize = document.body.clientWidth;
var zoomer = bSize / aSize;
return zoomer;
}