/* =========================================== common.js =========================================== */ /*=========================================== function =========================================== */ jQuery(document).ready(function($){ /* smoothScroll ------------------------------------- */ //scroll speed var speed = 500; //pagetop btn $('a[href="#top"]').on('click',function(){ $('body,html').animate({scrollTop:'0'}, speed, 'swing'); return false; }); //other link $('a[href^="#"]:not([href="#top"])').on('click',function(){ var href= $(this).attr('href'); var target = $(href === '#' || href === '' ? 'html' : href); var position = target.offset().top; $('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); /* js-switch-tabs ------------------------------------- */ if($('#js-switch-tabs').length){ $('#js-switch-tabs li').on('click',function(){ //num set var num = $('#js-switch-tabs li').index(this); //class="active" set in content $('.js-switch-content').removeClass('active'); $('.js-switch-content').eq(num).addClass('active'); //class="active" set in tab $('#js-switch-tabs li').removeClass('active'); $(this).addClass('active'); }); } /* js-toggle ------------------------------------- */ if($('.js-toggle-tit').length){ $('.js-toggle-tit').on('click',function(){ $(this).toggleClass('on'); $(this).next('.js-toggle-content').slideToggle('fast'); }); } /* js-btn-menu ------------------------------------- */ if($('#js-btn-menu').length){ $('#js-btn-menu,#js-btn-close,#js-overlay').on('click',function(){ $('#js-btn-menu').toggleClass('active'); $('#js-overlay').toggleClass('active'); $('#gNav').toggleClass('active'); }); } /* js-sticky ------------------------------------- */ if (window.matchMedia( '(max-width: 600px)' ).matches) { var b = $('.js-sticky'); $(window).scroll(function () { if ($(this).scrollTop() > 200) { b.addClass('fixed'); var $fBtmMargin = b.outerHeight(true); //$('.footer').css('margin-bottom',$fBtmMargin + 10 + "px"); $('.footer').css('margin-bottom',$fBtmMargin + "px"); } else { b.removeClass('fixed'); } }); } else { }; }); /* popup save status action ------------------------------------- */ $(document).ready(function(){ save_status_popup.execute(); }); var save_status_popup = { execute : function(){ // open $('.js-lightbox-save-status').on('click', function(e){ e.preventDefault(); var href = $(this).attr('href'); save_status_popup.open(href); }); // close $(document).on('click', '.js-close', function(){ save_status_popup.close(); }); }, open : function( href ){ $.ajax({ url : href, type : 'get', data : {}, datatype:'html', success: function(data){ $('body').append(data); $('#popup-container-save').fadeIn(300); detail_map_init(); } }); $('body, html').scrollTop(0); }, close : function(){ $('#popup-container-save').fadeOut(200,function(){ $('#popup-container-save').remove(); // $(this).remove(); }); } }