/* ========================================================================== * script ========================================================================== */ $(function () { /* config, variable ----------------------------------------------------------------- */ var spSize = '767px', tbpcSize = '768px', pcSize = '1024px', deviceFlgNum = 0, deviceFlg = '', $win = $(window); /* user agent ----------------------------------------------------------------- */ if ( (navigator.userAgent.indexOf('Android') > 0 && navigator.userAgent.indexOf('Mobile') > 0) || navigator.userAgent.indexOf('iPod') > 0 || (navigator.userAgent.indexOf('iPhone') > 0 && navigator.userAgent.indexOf('iPad') == -1) ) { deviceFlgNum = 1; // sp } else if ( navigator.userAgent.indexOf('Android') > 0 || navigator.userAgent.indexOf('iPad') > 0 ) { deviceFlgNum = 2; // tb $('head').append(''); } else { deviceFlgNum = 3; // pc } function isUserAgent() { var ua = navigator.userAgent; if (ua.search(/iPhone/) != -1 || ua.search(/iPad/) != -1) { // iphone, ipad deviceFlg = 'apple'; } else { // Andoird, other deviceFlg = 'other'; } } isUserAgent(); /* anchor ----------------------------------------------------------------- */ $('a[href^="#"]').click(function () { var speed = 400; var href = $(this).attr('href'); var target = $(href == "#" || href == "" ? 'html' : href); var posGap = ''; if ( deviceFlgNum == 1 ) { posGap = $('.g_header').height(); } else { if ( $(window).scrollTop() > target.offset().top ) { // 上からか、下からか if ( $('.g_page_nav').length ) { posGap = $('.g_page_nav').height() + $('.g_nav').outerHeight(); } else { posGap = $('.g_nav').outerHeight(); } } else { if ( $('.g_page_nav').length ) { posGap = $('.g_page_nav').height(); } } } var position = target.offset().top - posGap; $('body,html').animate({ scrollTop: position }, speed, 'swing'); return false; }); /* sp menu ----------------------------------------------------------------- */ $('.g_header_toggle_link').click(function () { $(this).toggleClass('g_header_toggle_link_close'); $('body').toggleClass('g_scroll_lock'); $('.g_nav').slideToggle(320); }); if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { $('.g_nav').hide(); $('.g_header_toggle_link').removeClass('g_header_toggle_link_close'); } else { $('.g_nav').show(); $('body').removeClass('g_scroll_lock'); } // $(window).on('resize', function() { // if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { // $('.g_nav').hide(); // $('.g_header_toggle_link').removeClass('g_header_toggle_link_close'); // } else { // $('.g_nav').show(); // } // }); /* products sort ----------------------------------------------------------------- */ $('.g_sort_title_link').click(function () { $(this).closest('.g_sort').find('.g_sort_list').toggleClass('g_sort_list_display'); }); /* products sound toggle ----------------------------------------------------------------- */ $('.g_products_list_sound').click(function () { if ( $(this).hasClass('g_products_list_sound_off') ) { $(this).next('.g_products_list_audio')[0].pause(); $(this).next('.g_products_list_audio')[0].currentTime = 0; } else { $('.g_products_list_audio').each(function() { $(this)[0].pause(); $(this)[0].currentTime = 0; } ); $('.g_products_list_sound').each(function() { $(this).removeClass('g_products_list_sound_off'); } ); $(this).next('.g_products_list_audio')[0].play(); } $(this).toggleClass('g_products_list_sound_off'); }); /* navigation fixed ----------------------------------------------------------------- */ // var startPos = 0; // // var elePosNav; // if ( $('.g_nav').length ) { // var tgtTop = $('body').find('.g_nav'); // if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { // elePosNav = 73; // } else { // elePosNav = tgtTop.offset().top + 70; // } // } // // var elePosPnav; // if ( $('.g_page_nav').length ) { // var tgtTop = $('body').find('.g_page_nav'); // elePosPnav = tgtTop.offset().top; // } // // $win.on('load scroll resize', function() { // var currentPos = $(this).scrollTop(); // if ( $(window).scrollTop() >= elePosNav) { // $('.g_nav').addClass('g_nav_fixed_before'); // if (currentPos > startPos ) { // forward // $('.g_nav').removeClass('g_nav_fixed'); // $('.g_page_nav').removeClass('g_page_nav_fixed_dbl'); // } else if (currentPos < startPos ) { // backward // $('.g_nav').addClass('g_nav_fixed'); // $('.g_page_nav').addClass('g_page_nav_fixed_dbl'); // } // } else { // $('.g_nav').removeClass('g_nav_fixed'); // $('.g_nav').removeClass('g_nav_fixed_before'); // $('.g_page_nav').removeClass('g_page_nav_fixed_dbl'); // $('.g_page_nav').removeClass('g_page_nav_fixed'); // } // // if ( $('.g_page_nav').length ) { // var winHeight = $win.height(); // var scl = $win.scrollTop(); // //alert(scLockStart); // if( scl > elePosPnav ){ // $('.g_page_nav').addClass('g_page_nav_fixed'); // } else { // $('.g_page_nav').removeClass('g_page_nav_fixed'); // } // } // // startPos = currentPos; // } ); var startPos = 0; $win.on('load scroll resize', function() { if ( $(this).scrollTop() < startPos ){ //上スクロールの時の処理 $('.g_nav_wrap').addClass('is_sticky'); $('.g_page_nav_wrap').addClass('has_nav'); } else { //下スクロールの時の処理 $('.g_nav_wrap').removeClass('is_sticky'); $('.g_page_nav_wrap').removeClass('has_nav'); } startPos = $(this).scrollTop(); } ); if ( $('.wp_floating').length ) { $win.on('load scroll resize', function() { var $mainH = $('.wp_front_main').height() - 70; if ( $(this).scrollTop() < $mainH ){ $('.g_nav_wrap').addClass('front_reverse'); } else { $('.g_nav_wrap').removeClass('front_reverse'); } if ( $(this).scrollTop() > 200 ) { $('.wp_floating').addClass('is_active'); } else { $('.wp_floating').removeClass('is_active'); } } ); } /* products floating guide ----------------------------------------------------------------- */ $win.on('load scroll resize', function() { var winHeight = $win.height(); var tgtBtm; if ( $('.g_breadcrumb').length ) { tgtBtm = $('body').find('.g_breadcrumb'); } else { tgtBtm = $('body').find('.g_footer'); } var scLockEnd = tgtBtm.offset().top - winHeight; var scl = $win.scrollTop() - 100; if( scLockEnd >= scl ){ if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { $('.g_products_float_guide').fadeIn('fast'); } else { $('.g_products_float_guide').addClass('g_float_fixed'); } }else{ if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { $('.g_products_float_guide').fadeOut('fast'); } else { $('.g_products_float_guide').removeClass('g_float_fixed'); } } }); /* products fixed buy item ----------------------------------------------------------------- */ $win.on('load scroll resize', function() { if ( $('.g_products_floating_item').length ) { var winHeight = $win.height(); var tgtTop = $('body').find('.g_products_buy_cart'); var tgtBtm = $('body').find('.g_breadcrumb'); var scLockStart = tgtTop.offset().top; var scLockEnd = tgtBtm.offset().top - winHeight; var scl = $win.scrollTop() - 20; if( scLockStart >= scl ){ $('.g_products_floating_item').fadeOut('fast'); } else if( scLockEnd >= scl && scl >= scLockStart ){ if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { $('.g_products_floating_item').fadeIn('fast'); } else { $('.g_products_floating_item').addClass('g_products_floating_item_fixed'); $('.g_products_floating_item').fadeIn('fast'); } } else if( scl >= scLockEnd && scl >= scLockStart ) { if ( window.matchMedia('(max-width:' + spSize + ')').matches ) { $('.g_products_floating_item').fadeOut('fast'); $('.g_products_floating_item').fadeOut(''); } else { $('.g_products_floating_item').removeClass('g_products_floating_item_fixed'); } } } }); /* products sound carousel ----------------------------------------------------------------- */ $('.g_products_carousel_item').each(function() { var frameUrl = $(this).find('iframe').attr('src'); if ( frameUrl ) { if ( frameUrl.indexOf('youtube') != -1 || frameUrl.indexOf('nicovideo') != -1 ) { $('iframe', this).wrap('