(function($){ "use strict"; var traveltour_display = 'desktop'; if( typeof(window.matchMedia) == 'function' ){ $(window).on('resize traveltour-set-display', function(){ if( window.matchMedia('(max-width: 419px)').matches ){ traveltour_display = 'mobile-portrait'; }else if( window.matchMedia('(max-width: 767px)').matches ){ traveltour_display = 'mobile-landscape' }else if( window.matchMedia('(max-width: 959px)').matches ){ traveltour_display = 'tablet' }else{ traveltour_display = 'desktop'; } }); $(window).trigger('traveltour-set-display'); }else{ $(window).on('resize traveltour-set-display', function(){ if( $(window).innerWidth() <= 419 ){ traveltour_display = 'mobile-portrait'; }else if( $(window).innerWidth() <= 767 ){ traveltour_display = 'mobile-landscape' }else if( $(window).innerWidth() <= 959 ){ traveltour_display = 'tablet' }else{ traveltour_display = 'desktop'; } }); $(window).trigger('traveltour-set-display'); } // ref : http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ // ensure 1 is fired var traveltour_debounce = function(func, threshold, execAsap){ var timeout; return function debounced(){ var obj = this, args = arguments; function delayed(){ if( !execAsap ){ func.apply(obj, args); } timeout = null; }; if( timeout ){ clearTimeout(timeout); }else if( execAsap ){ func.apply(obj, args); } timeout = setTimeout(delayed, threshold); }; } // reduce the event occurance var traveltour_throttling = function(func, threshold){ var timeout; return function throttled(){ var obj = this, args = arguments; function delayed(){ func.apply(obj, args); timeout = null; }; if( !timeout ){ timeout = setTimeout(delayed, threshold); } }; } ///////////////////////// // menu handle function ///////////////////////// var traveltour_sf_menu = function( menu ){ if( menu.length == 0 ) return; this.main_menu = menu; this.slide_bar = this.main_menu.children('.traveltour-navigation-slide-bar'); this.slide_bar_val = { width: 0, left: 0 }; this.slide_bar_offset = '3'; this.current_menu = this.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); this.init(); } // traveltour_sf_menu traveltour_sf_menu.prototype = { init: function(){ var t = this; // sf menu mod t.sf_menu_mod(); // init superfish menu if(typeof($.fn.superfish) == 'function'){ t.main_menu.superfish({ delay: 400, speed: 'fast' }); t.sf_menu_position(); $(window).resize(traveltour_debounce(function(){ t.sf_menu_position(); }, 300)); } // init the slidebar if( t.slide_bar.length > 0 ){ t.init_slidebar(); } }, // init sf_menu_mod: function(){ // create the mega menu script this.main_menu.find('.sf-mega > ul').each(function(){ var mega_content = $('
'); var mega_row = $(''); var mega_column_size = 0; $(this).children('li').each(function(){ var column_size = parseInt($(this).attr('data-size')); if( mega_column_size + column_size <= 60 ){ mega_column_size += column_size; }else{ mega_column_size = column_size; mega_content.append(mega_row); mega_row = $(''); } mega_row.append( $('') .addClass('traveltour-column-' + column_size) .html( $('') .addClass($(this).attr('class')) .attr('id', $(this).attr('id')) .html($(this).html()) ) ); }); mega_content.append(mega_row); $(this).replaceWith(mega_content.html()); }); }, // sf_menu_mod sf_menu_position: function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; // submenu of normal menu var sub_normal_menu = this.main_menu.find('.sf-menu > li.traveltour-normal-menu .sub-menu'); sub_normal_menu.css({display: 'block'}).removeClass('sub-menu-right'); if( $("body").hasClass("rtl") ){ sub_normal_menu.each(function(){ if( $(this).offset().left < 0 ){ $(this).addClass('sub-menu-right'); } }); }else{ sub_normal_menu.each(function(){ if( $(this).offset().left + $(this).width() > $(window).width() ){ $(this).addClass('sub-menu-right'); } }); } sub_normal_menu.css({display: 'none'}); // submenu of mega menu this.main_menu.find('.sf-menu > li.traveltour-mega-menu .sf-mega').each(function(){ if( !$(this).hasClass('sf-mega-full') ){ $(this).css({ display: 'block' }); // set the position $(this).css({ right: '', 'margin-left': -(($(this).width() - $(this).parent().outerWidth()) / 2) }); // if exceed the screen if( $(this).offset().left + $(this).width() > $(window).width() ){ $(this).css({ right: 0, 'margin-left': '' }); } $(this).css({ display: 'none' }); } }); }, // sf_menu_position init_slidebar: function(){ var t = this; t.init_slidebar_pos(); $(window).load(function(){ t.init_slidebar_pos(); }); // animate slidebar t.main_menu.children('.sf-menu').children('li').hover(function(){ var nav_element = $(this).children('a'); if( nav_element.length > 0 ){ t.slide_bar.animate({ width: nav_element.outerWidth() + (2 * t.slide_bar_offset), left: nav_element.position().left - t.slide_bar_offset }, { queue: false, duration: 250 }); } }, function(){ t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); }); // window resize event $(window).on('resize', function(){ t.init_slidebar_pos(); }); $(window).on('traveltour-navigation-slider-bar-init', function(){ t.current_menu = t.main_menu.children('.sf-menu').children('.current-menu-item, .current-menu-ancestor').children('a'); t.animate_slidebar_pos(); }); $(window).on('traveltour-navigation-slider-bar-animate', function(){ t.animate_slidebar_pos(); }); }, // init_slidebar init_slidebar_pos: function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; var t = this; if( t.current_menu.length > 0 ){ t.slide_bar_val = { width: t.current_menu.outerWidth() + (2 * t.slide_bar_offset), left: t.current_menu.position().left - t.slide_bar_offset }; }else{ t.slide_bar_val = { width: 0, left: t.main_menu.children('ul').children('li:first-child').position().left } } t.slide_bar.css({ width: t.slide_bar_val.width, left: t.slide_bar_val.left, display: 'block' }); }, // set_slidebar_pos animate_slidebar_pos: function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; var t = this; if( t.current_menu.length > 0 ){ t.slide_bar_val = { width: t.current_menu.outerWidth() + (2 * t.slide_bar_offset), left: t.current_menu.position().left - t.slide_bar_offset }; }else{ t.slide_bar_val = { width: 0, left: t.main_menu.children('ul').children('li:first-child').position().left } } t.slide_bar.animate({ width: t.slide_bar_val.width, left: t.slide_bar_val.left }, { queue: false, duration: 250 }); } // set_slidebar_pos }; // traveltour_sf_menu.prototype ///////////////////////// // mobile menu ///////////////////////// $.fn.traveltour_mobile_menu = function( args ){ var menu_button = $(this).siblings('.traveltour-mm-menu-button'); var options = { navbar: { title: '' }, extensions: [ 'pagedim-black' ], }; var extensions = { offCanvas: { pageNodetype: '.traveltour-body-outer-wrapper' } }; // remove the wrap for submenu $(this).find('a[href="#"]').each(function(){ var content = $(this).html(); $('').html(content).insertBefore($(this)); $(this).remove(); }); if( $(this).attr('data-slide') ){ var html_class = 'traveltour-mmenu-' + $(this).attr('data-slide'); $('html').addClass(html_class); options.offCanvas = { position : $(this).attr('data-slide') }; } $(this).mmenu(options, extensions); var menu_api = $(this).data('mmenu'); $(this).find('a').not('.mm-next, .mm-prev').click(function(){ menu_api.close(); }); $(this).find('.mmenu-custom-close').click(function(){ menu_api.close(); }); // add class active to button menu_api.bind('open', function($panel){ menu_button.addClass('traveltour-active'); }); menu_api.bind('close', function($panel){ menu_button.removeClass('traveltour-active'); }); } ///////////////////////// // overlay menu ///////////////////////// var traveltour_overlay_menu = function( menu ){ this.menu = menu; this.menu_button = menu.children('.traveltour-overlay-menu-icon'); this.menu_content = menu.children('.traveltour-overlay-menu-content'); this.menu_close = this.menu_content.children('.traveltour-overlay-menu-close'); this.init(); } traveltour_overlay_menu.prototype = { init: function(){ var t = this; // add transition delay for each menu var delay_count = 0; t.menu_content.appendTo('body'); t.menu_content.find('ul.menu > li').each(function(){ $(this).css('transition-delay', (delay_count * 150) + 'ms'); delay_count++; }); // bind the menu button t.menu_button.click(function(){ $(this).addClass('traveltour-active'); t.menu_content.fadeIn(200, function(){ $(this).addClass('traveltour-active'); }); return false; }); // bind the menu close button t.menu_close.click(function(){ t.menu_button.removeClass('traveltour-active'); t.menu_content.fadeOut(400, function(){ $(this).removeClass('traveltour-active'); }); t.menu_content.find('.sub-menu').slideUp(200).removeClass('traveltour-active'); return false; }); // menu item click t.menu_content.find('a').click(function(e){ var sub_menu = $(this).siblings('.sub-menu'); if( sub_menu.length > 0 ){ if( !sub_menu.hasClass('traveltour-active') ){ var prev_active = sub_menu.closest('li').siblings().find('.sub-menu.traveltour-active'); if( prev_active.length > 0 ){ prev_active.removeClass('traveltour-active').slideUp(150); sub_menu.delay(150).slideDown(400, 'easeOutQuart').addClass('traveltour-active'); }else{ sub_menu.slideDown(400, 'easeOutQuart').addClass('traveltour-active'); } $(this).addClass('traveltour-no-preload'); return false; }else{ $(this).removeClass('traveltour-no-preload'); } }else{ t.menu_close.trigger('click'); } }); } }; // traveltour_overlay_menu.prototype ///////////////////////// // header side navigation ///////////////////////// var traveltour_header_side_nav = function( side_nav ){ if( side_nav.length == 0 ) return; this.prev_scroll = 0; this.side_nav = side_nav; this.side_nav_content = side_nav.children(); this.init(); } // traveltour_header_side_nav traveltour_header_side_nav.prototype = { init: function(){ var t = this; t.init_nav_bar_element(); $(window).resize(function(){ t.init_nav_bar_element(); }); $(window).scroll(function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; // if content longer than screen height if( t.side_nav.hasClass('traveltour-allow-slide') ){ var admin_bar_height = parseInt($('html').css('margin-top')); var scroll_down = ($(window).scrollTop() > t.prev_scroll); t.prev_scroll = $(window).scrollTop(); // if scroll down if( scroll_down ){ if( !t.side_nav.hasClass('traveltour-fix-bottom') ){ if( t.side_nav.hasClass('traveltour-fix-top') ){ t.side_nav.css('top', t.side_nav.offset().top); t.side_nav.removeClass('traveltour-fix-top'); }else if( $(window).height() + $(window).scrollTop() > t.side_nav_content.offset().top + t.side_nav_content.outerHeight() ){ if( !t.side_nav.hasClass('traveltour-fix-bottom') ){ t.side_nav.addClass('traveltour-fix-bottom'); t.side_nav.css('top', ''); } } } // if scroll up }else{ if( !t.side_nav.hasClass('traveltour-fix-top') ){ if( t.side_nav.hasClass('traveltour-fix-bottom') ){ var top_pos = $(window).scrollTop() + ($(window).height() - admin_bar_height) - t.side_nav_content.outerHeight(); t.side_nav.css('top', top_pos); t.side_nav.removeClass('traveltour-fix-bottom'); }else if( $(window).scrollTop() + admin_bar_height < t.side_nav_content.offset().top ){ if( !t.side_nav.hasClass('traveltour-fix-top') ){ t.side_nav.addClass('traveltour-fix-top'); t.side_nav.css('top', ''); } } } } } }); }, init_nav_bar_element: function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; var t = this; var middle_pos = t.side_nav_content.children('.traveltour-pos-middle').addClass('traveltour-active'); var bottom_pos = t.side_nav_content.children('.traveltour-pos-bottom').addClass('traveltour-active'); // remove all additional space t.side_nav_content.children('.traveltour-pre-spaces').remove(); // add class depends on the screen size/content if( $(window).height() < t.side_nav_content.height() ){ t.side_nav.addClass('traveltour-allow-slide'); }else{ t.side_nav.removeClass('traveltour-allow-slide traveltour-fix-top traveltour-fix-bottom').css('top', ''); // set the middle position if( t.side_nav.hasClass('traveltour-style-middle') ){ middle_pos.each(function(){ var top_padding = parseInt($(this).css('padding-top')); var prespace = ((t.side_nav.height() - (t.side_nav_content.height() - top_padding)) / 2) - top_padding; if( prespace > 0 ){ $('').css('height', prespace).insertBefore($(this)); } }); } // set the bottom position bottom_pos.each(function(){ var prespace = t.side_nav.height() - t.side_nav_content.height(); if( prespace > 0 ){ $('').css('height', prespace).insertBefore($(this)); } }); } } }; // traveltour_sf_menu.prototype ///////////////////////// // anchoring ///////////////////////// var traveltour_anchor = function(){ this.anchor_link = $('a[href^="#"]').not('[href="#"]').filter(function(){ // for mm-menu plugin if( $(this).is('.traveltour-mm-menu-button, .mm-next, .mm-prev, .mm-title, .gdlr-core-ilightbox') ){ return false; } // for additional plugins if( $(this).is('.fbx-btn-transition') ){ return false; } // for woocommerce if( !$(this).hasClass('traveltour-footer-back-to-top-button') ){ if( $(this).parent('.description_tab, .reviews_tab').length || $(this).closest('.woocommerce').length ){ return false; } } return true; }); if( this.anchor_link.length ){ this.menu_anchor = $('#traveltour-main-menu, #traveltour-bullet-anchor, #tourmaster-content-navigation-item-outer'); this.home_anchor = this.menu_anchor.find('ul.sf-menu > li.current-menu-item > a, ul.sf-menu > li.current-menu-ancestor > a, .traveltour-bullet-anchor-link.current-menu-item, .tourmaster-content-navigation-tab.tourmaster-active'); this.init(); } } traveltour_anchor.prototype = { init: function(){ var t = this; t.animate_anchor(); t.scroll_section(); // init bullet anchor height t.menu_anchor.filter('#traveltour-bullet-anchor').each(function(){ $(this).css('margin-top', - t.menu_anchor.height() / 2).addClass('traveltour-init'); }); // initialize if the page hash exists // wait for all element to initialize ( eg. flexslider ) var url_hash = window.location.hash; if( url_hash ){ setTimeout(function(){ var current_menu = t.menu_anchor.find('a[href*="' + url_hash + '"]'); if( !current_menu.is('.current-menu-item, .current-menu-ancestor') ){ current_menu.addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); $(window).trigger('traveltour-navigation-slider-bar-init'); } t.scroll_to(url_hash, false, 300); }, 500); } }, animate_anchor: function(){ var t = this; // home anchor t.home_anchor.click(function(){ if( window.location.href == this.href ){ $('html, body').animate({ scrollTop: 0 }, { duration: 1500, easing: 'easeOutQuart' }); return false; } }); // normal anchor t.anchor_link.click(function() { if( location.hostname == this.hostname && location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') ){ return t.scroll_to(this.hash, true); } }); }, // animate anchor scroll_to: function( hash, redirect, duration ){ // start scrolling if( hash == '#traveltour-top-anchor' ){ var scroll_position = 0; }else{ var target = $(hash); if( target.length ){ var scroll_position = target.offset().top; } } if( typeof(scroll_position) != 'undefined' ){ // offset for wordpress admin bar scroll_position = scroll_position - parseInt($('html').css('margin-top')); // offset for fixed nav bar if( typeof(window.traveltour_anchor_offset) != 'undefined' ){ scroll_position = scroll_position - parseInt(window.traveltour_anchor_offset); } if( scroll_position < 0 ) scroll_position = 0; $('html, body').animate({ scrollTop: scroll_position }, { duration: 1500, easing: 'easeOutQuart', queue: false }); return false; }else if( redirect ){ if( hash != '#tourmaster-single-review' ){ window.location.href = traveltour_script_core.home_url + hash; } return false; } }, // scroll to scroll_section: function(){ var t = this; // have anchor in anchor menu var menu_link_anchor = this.menu_anchor.find('a[href*="#"]').not('[href="#"]'); if( !menu_link_anchor.length ){ return; } // get anchor section var home_anchor_section = $('#traveltour-page-wrapper'); var anchor_section = home_anchor_section.find('[id]'); if( !anchor_section.length ){ return; } // add data for faster query menu_link_anchor.each(function(){ if( $(this.hash).length ){ $(this).attr('data-anchor', this.hash); } }); // check section on scroll event $(window).scroll(function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' ) return; if( t.home_anchor.length && $(window).scrollTop() < home_anchor_section.offset().top ){ t.home_anchor.each(function(){ if( $(this).hasClass('tourmaster-content-navigation-tab') ){ $(this).addClass('tourmaster-active').siblings().removeClass('tourmaster-active tourmaster-slidebar-active'); }else if( $(this).hasClass('traveltour-bullet-anchor-link') ){ $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); $(this).parent('.traveltour-bullet-anchor').attr('data-anchor-section', 'traveltour-home'); }else if( !$(this).parent('.current-menu-item, .current-menu-ancestor').length ){ $(this).parent().addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); $(window).trigger('traveltour-navigation-slider-bar-init'); } }); }else{ var section_position = $(window).scrollTop() + ($(window).height() * 0.3); anchor_section.each(function(){ if( $(this).css('display') == 'none' || $(this).closest('.tourmaster-tour-booking-bar-wrap').length || $(this).is('#tourmaster-page-wrapper') ) return; var top_offset_pos = $(this).offset().top; if( (section_position > top_offset_pos) && (section_position < top_offset_pos + $(this).outerHeight()) ){ var section_id = $(this).attr('id'); menu_link_anchor.filter('[data-anchor="#' + section_id + '"]').each(function(){ if( $(this).hasClass('tourmaster-content-navigation-tab') ){ $(this).addClass('tourmaster-active').siblings().removeClass('tourmaster-active tourmaster-slidebar-active'); $(this).closest('#tourmaster-content-navigation-item-outer').trigger('tourmaster-change'); }else if( $(this).hasClass('traveltour-bullet-anchor-link') ){ $(this).addClass('current-menu-item').siblings().removeClass('current-menu-item'); $(this).parent('.traveltour-bullet-anchor').attr('data-anchor-section', section_id); }else if( $(this).parent('li.menu-item').length && !$(this).parent('li.menu-item').is('.current-menu-item, .current-menu-ancestor') ){ $(this).parent('li.menu-item').addClass('current-menu-item').siblings().removeClass('current-menu-item current-menu-ancestor'); $(window).trigger('traveltour-navigation-slider-bar-init'); } }); return false; } }); } }); } // scroll section }; var traveltour_sticky_navigation = function(){ this.sticky_nav = $('.traveltour-with-sticky-navigation .traveltour-sticky-navigation'); this.sticky_nav_logo = this.sticky_nav.find('.traveltour-logo-inner img'); this.logo_height = 35; if( this.sticky_nav.length ){ this.mobile_menu = $('#traveltour-mobile-header'); this.init(); } } traveltour_sticky_navigation.prototype = { init: function(){ var t = this; if( t.sticky_nav.hasClass('traveltour-style-fixed') ){ t.style_fixed(); }else if( t.sticky_nav.hasClass('traveltour-style-slide') ){ t.style_slide(); } t.style_mobile_slide(); if( t.sticky_nav.hasClass('traveltour-sticky-navigation-height') ){ window.traveltour_anchor_offset = t.sticky_nav.outerHeight(); $(window).resize(function(){ window.traveltour_anchor_offset = t.sticky_nav.outerHeight(); }); }else{ window.traveltour_anchor_offset = 75; } $(window).trigger('traveltour-set-sticky-navigation'); $(window).trigger('traveltour-set-sticky-mobile-navigation'); }, style_fixed: function(){ var t = this; var placeholder = $(''); $(window).on('scroll traveltour-set-sticky-navigation', function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ) return; var page_offset = parseInt($('html').css('margin-top')); if( !t.sticky_nav.hasClass('traveltour-fixed-navigation') ){ if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top ){ if( !t.sticky_nav.hasClass('traveltour-without-placeholder') ){ placeholder.height(t.sticky_nav.outerHeight()); } placeholder.insertAfter(t.sticky_nav); $('body').append(t.sticky_nav); t.sticky_nav.addClass('traveltour-fixed-navigation'); var logo_padding = (t.logo_height - t.sticky_nav_logo.height()) / 2; if( logo_padding > 0 ){ t.sticky_nav_logo.css({'padding-top': logo_padding, 'padding-bottom': logo_padding}); }else{ t.sticky_nav_logo.css({'height': t.sticky_nav_logo.height(), 'width': 'auto'}); // set for css animation t.sticky_nav.addClass('traveltour-animate-logo-height'); } setTimeout(function(){ t.sticky_nav.addClass('traveltour-animate-fixed-navigation'); }, 10); setTimeout(function(){ t.sticky_nav.css('height', ''); $(window).trigger('traveltour-navigation-slider-bar-animate'); }, 200); } }else{ if( $(window).scrollTop() + page_offset <= placeholder.offset().top ){ if( !t.sticky_nav.hasClass('traveltour-without-placeholder') ){ t.sticky_nav.height(placeholder.height()); } t.sticky_nav.insertBefore(placeholder); t.sticky_nav.removeClass('traveltour-fixed-navigation'); placeholder.remove(); t.sticky_nav_logo.css({'padding-top': '', 'padding-bottom': ''}); setTimeout(function(){ t.sticky_nav.removeClass('traveltour-animate-fixed-navigation traveltour-animate-logo-height'); }, 10); setTimeout(function(){ t.sticky_nav.css('height', ''); t.sticky_nav_logo.css({'height': '', 'width': ''}); $(window).trigger('traveltour-navigation-slider-bar-animate'); }, 200); } } }); }, // style_fixed style_slide: function(){ var t = this; var placeholder = $(''); $(window).on('scroll traveltour-set-sticky-navigation', function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ){ return; } var page_offset = parseInt($('html').css('margin-top')); if( !t.sticky_nav.hasClass('traveltour-fixed-navigation') ){ if( $(window).scrollTop() + page_offset > t.sticky_nav.offset().top + t.sticky_nav.outerHeight() + 200 ){ var logo_padding = (t.logo_height - t.sticky_nav_logo.height()) / 2; if( !t.sticky_nav.hasClass('traveltour-without-placeholder') ){ placeholder.height(t.sticky_nav.outerHeight()); } placeholder.insertAfter(t.sticky_nav); t.sticky_nav.css('display', 'none'); if( logo_padding > 0 ){ t.sticky_nav_logo.css({'padding-top': logo_padding, 'padding-bottom': logo_padding}); } $('body').append(t.sticky_nav); t.sticky_nav.addClass('traveltour-fixed-navigation traveltour-animate-fixed-navigation'); t.sticky_nav.slideDown(200); $(window).trigger('traveltour-navigation-slider-bar-animate'); } }else{ if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ var clone = t.sticky_nav.clone(); clone.insertAfter(t.sticky_nav); clone.slideUp(200, function(){ $(this).remove(); }); t.sticky_nav.insertBefore(placeholder); t.sticky_nav_logo.css({'padding-top': '', 'padding-bottom': ''}); placeholder.remove(); t.sticky_nav.removeClass('traveltour-fixed-navigation traveltour-animate-fixed-navigation'); t.sticky_nav.css('display', 'block'); $(window).trigger('traveltour-navigation-slider-bar-animate'); } } }); }, // style_slide style_mobile_slide: function(){ var t = this; var placeholder = $(''); $(window).on('scroll traveltour-set-sticky-mobile-navigation', function(){ if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' || traveltour_display == 'tablet' ){ var page_offset = parseInt($('html').css('margin-top')); if( !t.mobile_menu.hasClass('traveltour-fixed-navigation') ){ if( $(window).scrollTop() + page_offset > t.mobile_menu.offset().top + t.mobile_menu.outerHeight() + 200 ){ placeholder.height(t.mobile_menu.outerHeight()).insertAfter(t.mobile_menu); $('body').append(t.mobile_menu); t.mobile_menu.addClass('traveltour-fixed-navigation'); t.mobile_menu.css('display', 'none').slideDown(200); } }else{ if( $(window).scrollTop() + page_offset <= placeholder.offset().top + placeholder.height() + 200 ){ var clone = t.mobile_menu.clone(); clone.insertAfter(t.mobile_menu); clone.slideUp(200, function(){ $(this).remove(); }); t.mobile_menu.insertBefore(placeholder); placeholder.remove(); t.mobile_menu.removeClass('traveltour-fixed-navigation'); t.mobile_menu.css('display', 'block'); } } } }); }, // style_slide }; var traveltour_font_resize = function(){ this.heading_font = $('h1, h2, h3, h4, h5, h6'); this.init(); } traveltour_font_resize.prototype = { init: function(){ var t = this; t.resize(); $(window).on('resize', traveltour_throttling(function(){ t.resize(); }, 100)); }, resize: function(){ var t = this; if( traveltour_display == 'mobile-landscape' || traveltour_display == 'mobile-portrait' ){ t.heading_font.each(function(){ if( parseInt($(this).css('font-size')) > 40 ){ if( !$(this).attr('data-orig-font') ){ $(this).attr('data-orig-font', $(this).css('font-size')); } $(this).css('font-size', '40px'); } }); // return font to normal }else{ t.heading_font.filter('[data-orig-font]').each(function(){ $(this).css('font-size', $(this).attr('data-orig-font')); }); } } }; //////////////////////////////// // starting running the script //////////////////////////////// $(document).ready(function(){ // resize font on mobile new traveltour_font_resize(); // init main navigation menu $('#traveltour-main-menu, #traveltour-right-menu, #traveltour-mobile-menu').each(function(){ if( $(this).hasClass('traveltour-overlay-menu') ){ new traveltour_overlay_menu( $(this) ); }else if( $(this).hasClass('traveltour-mm-menu-wrap') ){ $(this).traveltour_mobile_menu(); }else{ new traveltour_sf_menu( $(this) ); } }); $('#traveltour-top-search, #traveltour-mobile-top-search').each(function(){ var search_wrap = $(this).siblings('.traveltour-top-search-wrap'); search_wrap.appendTo('body'); // bind click button $(this).click(function(){ search_wrap.fadeIn(200, function(){ $(this).addClass('traveltour-active'); }); }); // bind close button search_wrap.find('.traveltour-top-search-close').click(function(){ search_wrap.fadeOut(200, function(){ $(this).addClass('traveltour-active'); }); }); // bind search button search_wrap.find('.search-submit').click(function(){ if( search_wrap.find('.search-field').val().length == 0 ){ return false; } }); }); $('#traveltour-main-menu-cart, #traveltour-mobile-menu-cart').each(function(){ $(this).hover(function(){ $(this).addClass('traveltour-active traveltour-animating'); }, function(){ var menu_cart = $(this); menu_cart.removeClass('traveltour-active'); setTimeout(function(){ menu_cart.removeClass('traveltour-animating'); }, 400) }); }); // wpml $('#traveltour-dropdown-wpml-flag').hover(function(){ $(this).children('.traveltour-dropdown-wpml-list').fadeIn(200); }, function(){ $(this).children('.traveltour-dropdown-wpml-list').fadeOut(200); }); // additional space for header transparent $('.traveltour-header-boxed-wrap, .traveltour-header-background-transparent, .traveltour-navigation-bar-wrap.traveltour-style-transparent').each(function(){ var header_transparent = $(this); var header_transparent_sub = $('.traveltour-header-transparent-substitute'); header_transparent_sub.height(header_transparent.outerHeight()); $(window).on('load resize', function(){ header_transparent_sub.height(header_transparent.outerHeight()); }); }); // full screen for 404 not found $('body.error404, body.search-no-results').each(function(){ var wrap = $(this).find('#traveltour-full-no-header-wrap'); var body_wrap_offset = parseInt($(this).children('.traveltour-body-outer-wrapper').children('.traveltour-body-wrapper').css('margin-bottom')); var padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; if( padding > 0 ){ wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); } $(window).on('load resize', function(){ wrap.css({ 'padding-top': 0, 'padding-bottom': 0 }); padding = ($(window).height() - wrap.offset().top - wrap.outerHeight() - body_wrap_offset) / 2; if( padding > 0 ){ wrap.css({ 'padding-top': padding, 'padding-bottom': padding }); } }); }); // back to top button var back_to_top = $('#traveltour-footer-back-to-top-button'); if( back_to_top.length ){ $(window).on('scroll', function(){ if( $(window).scrollTop() > 300 ){ back_to_top.addClass('traveltour-scrolled'); }else{ back_to_top.removeClass('traveltour-scrolled'); } }); } // page preload $('body').children('#traveltour-page-preload').each(function(){ var page_preload = $(this); var animation_time = parseInt(page_preload.attr('data-animation-time')); $('a[href]').not('[href^="#"], [target="_blank"], .gdlr-core-js, .strip, .add_to_cart_button').click(function(e){ if( e.which != 1 || $(this).hasClass('traveltour-no-preload') ) return; if( $(this).closest('.woocommerce-cart-form').length ) return; if( window.location.href != this.href ){ page_preload.addClass('traveltour-out').fadeIn(animation_time); } }); $(window).load(function(){ page_preload.fadeOut(animation_time); }); }); }); // fix back button for preload $(window).bind('pageshow', function(event) { if( event.originalEvent.persisted ){ $('body').children('#traveltour-page-preload').each(function(){ $(this).fadeOut(400); }); } }); // $(window).on('beforeunload', function(){ // $('body').children('#traveltour-page-preload').each(function(){ // $(this).fadeOut(400); // }); // }); $(window).load(function(){ // fixed footer $('#traveltour-fixed-footer').each(function(){ var fixed_footer = $(this); var placeholder = $(''); placeholder.insertBefore(fixed_footer); placeholder.height(fixed_footer.outerHeight()); $(window).resize(function(){ placeholder.height(fixed_footer.outerHeight()); }); }); // side navigation bar new traveltour_header_side_nav( $('#traveltour-header-side-nav') ); // sticky navigation if( !$('body').hasClass('single-tour') && !$('body').hasClass('tourmaster-template-payment') ){ new traveltour_sticky_navigation(); } // anchoring new traveltour_anchor(); }); })(jQuery); /***********/ /* Plugins */ /***********/ /* * jQuery mmenu v5.6.1 */ !function(e){function t(){e[n].glbl||(r={$wndw:e(window),$docu:e(document),$html:e("html"),$body:e("body")},i={},a={},o={},e.each([i,a,o],function(e,t){t.add=function(e){e=e.split(" ");for(var n=0,s=e.length;s>n;n++)t[e[n]]=t.mm(e[n])}}),i.mm=function(e){return"mm-"+e},i.add("wrapper menu panels panel nopanel current highest opened subopened navbar hasnavbar title btn prev next listview nolistview inset vertical selected divider spacer hidden fullsubopen"),i.umm=function(e){return"mm-"==e.slice(0,3)&&(e=e.slice(3)),e},a.mm=function(e){return"mm-"+e},a.add("parent sub"),o.mm=function(e){return e+".mm"},o.add("transitionend webkitTransitionEnd click scroll keydown mousedown mouseup touchstart touchmove touchend orientationchange"),e[n]._c=i,e[n]._d=a,e[n]._e=o,e[n].glbl=r)}var n="mmenu",s="5.6.1";if(!(e[n]&&e[n].version>s)){e[n]=function(e,t,n){this.$menu=e,this._api=["bind","init","update","setSelected","getInstance","openPanel","closePanel","closeAllPanels"],this.opts=t,this.conf=n,this.vars={},this.cbck={},"function"==typeof this.___deprecated&&this.___deprecated(),this._initMenu(),this._initAnchors();var s=this.$pnls.children();return this._initAddons(),this.init(s),"function"==typeof this.___debug&&this.___debug(),this},e[n].version=s,e[n].addons={},e[n].uniqueId=0,e[n].defaults={extensions:[],navbar:{add:!0,title:"Menu",titleLink:"panel"},onClick:{setSelected:!0},slidingSubmenus:!0},e[n].configuration={classNames:{divider:"Divider",inset:"Inset",panel:"Panel",selected:"Selected",spacer:"Spacer",vertical:"Vertical"},clone:!1,openingInterval:25,panelNodetype:"ul, ol, div",transitionDuration:400},e[n].prototype={init:function(e){e=e.not("."+i.nopanel),e=this._initPanels(e),this.trigger("init",e),this.trigger("update")},update:function(){this.trigger("update")},setSelected:function(e){this.$menu.find("."+i.listview).children().removeClass(i.selected),e.addClass(i.selected),this.trigger("setSelected",e)},openPanel:function(t){var s=t.parent(),a=this;if(s.hasClass(i.vertical)){var o=s.parents("."+i.subopened);if(o.length)return void this.openPanel(o.first());s.addClass(i.opened),this.trigger("openPanel",t),this.trigger("openingPanel",t),this.trigger("openedPanel",t)}else{if(t.hasClass(i.current))return;var r=this.$pnls.children("."+i.panel),l=r.filter("."+i.current);r.removeClass(i.highest).removeClass(i.current).not(t).not(l).not("."+i.vertical).addClass(i.hidden),e[n].support.csstransitions||l.addClass(i.hidden),t.hasClass(i.opened)?t.nextAll("."+i.opened).addClass(i.highest).removeClass(i.opened).removeClass(i.subopened):(t.addClass(i.highest),l.addClass(i.subopened)),t.removeClass(i.hidden).addClass(i.current),a.trigger("openPanel",t),setTimeout(function(){t.removeClass(i.subopened).addClass(i.opened),a.trigger("openingPanel",t),a.__transitionend(t,function(){a.trigger("openedPanel",t)},a.conf.transitionDuration)},this.conf.openingInterval)}},closePanel:function(e){var t=e.parent();t.hasClass(i.vertical)&&(t.removeClass(i.opened),this.trigger("closePanel",e),this.trigger("closingPanel",e),this.trigger("closedPanel",e))},closeAllPanels:function(){this.$menu.find("."+i.listview).children().removeClass(i.selected).filter("."+i.vertical).removeClass(i.opened);var e=this.$pnls.children("."+i.panel),t=e.first();this.$pnls.children("."+i.panel).not(t).removeClass(i.subopened).removeClass(i.opened).removeClass(i.current).removeClass(i.highest).addClass(i.hidden),this.openPanel(t)},togglePanel:function(e){var t=e.parent();t.hasClass(i.vertical)&&this[t.hasClass(i.opened)?"closePanel":"openPanel"](e)},getInstance:function(){return this},bind:function(e,t){this.cbck[e]=this.cbck[e]||[],this.cbck[e].push(t)},trigger:function(){var e=this,t=Array.prototype.slice.call(arguments),n=t.shift();if(this.cbck[n])for(var s=0,i=this.cbck[n].length;i>s;s++)this.cbck[n][s].apply(e,t)},_initMenu:function(){this.$menu.attr("id",this.$menu.attr("id")||this.__getUniqueId()),this.conf.clone&&(this.$menu=this.$menu.clone(!0),this.$menu.add(this.$menu.find("[id]")).filter("[id]").each(function(){e(this).attr("id",i.mm(e(this).attr("id")))})),this.$menu.contents().each(function(){3==e(this)[0].nodeType&&e(this).remove()}),this.$pnls=e('').append(this.$menu.children(this.conf.panelNodetype)).prependTo(this.$menu),this.$menu.parent().addClass(i.wrapper);var t=[i.menu];this.opts.slidingSubmenus||t.push(i.vertical),this.opts.extensions=this.opts.extensions.length?"mm-"+this.opts.extensions.join(" mm-"):"",this.opts.extensions&&t.push(this.opts.extensions),this.$menu.addClass(t.join(" "))},_initPanels:function(t){var n=this,s=this.__findAddBack(t,"ul, ol");this.__refactorClass(s,this.conf.classNames.inset,"inset").addClass(i.nolistview+" "+i.nopanel),s.not("."+i.nolistview).addClass(i.listview);var o=this.__findAddBack(t,"."+i.listview).children();this.__refactorClass(o,this.conf.classNames.selected,"selected"),this.__refactorClass(o,this.conf.classNames.divider,"divider"),this.__refactorClass(o,this.conf.classNames.spacer,"spacer"),this.__refactorClass(this.__findAddBack(t,"."+this.conf.classNames.panel),this.conf.classNames.panel,"panel");var r=e(),l=t.add(t.find("."+i.panel)).add(this.__findAddBack(t,"."+i.listview).children().children(this.conf.panelNodetype)).not("."+i.nopanel);this.__refactorClass(l,this.conf.classNames.vertical,"vertical"),this.opts.slidingSubmenus||l.addClass(i.vertical),l.each(function(){var t=e(this),s=t;t.is("ul, ol")?(t.wrap(''),s=t.parent()):s.addClass(i.panel);var a=t.attr("id");t.removeAttr("id"),s.attr("id",a||n.__getUniqueId()),t.hasClass(i.vertical)&&(t.removeClass(n.conf.classNames.vertical),s.add(s.parent()).addClass(i.vertical)),r=r.add(s)});var d=e("."+i.panel,this.$menu);r.each(function(t){var s,o,r=e(this),l=r.parent(),d=l.children("a, span").first();if(l.is("."+i.panels)||(l.data(a.sub,r),r.data(a.parent,l)),l.children("."+i.next).length||l.parent().is("."+i.listview)&&(s=r.attr("id"),o=e('').insertBefore(d),d.is("span")&&o.addClass(i.fullsubopen)),!r.children("."+i.navbar).length&&!l.hasClass(i.vertical)){l.parent().is("."+i.listview)?l=l.closest("."+i.panel):(d=l.closest("."+i.panel).find('a[href="#'+r.attr("id")+'"]').first(),l=d.closest("."+i.panel));var c=e('');if(l.length){switch(s=l.attr("id"),n.opts.navbar.titleLink){case"anchor":_url=d.attr("href");break;case"panel":case"parent":_url="#"+s;break;default:_url=!1}c.append('').append(e('").text(d.text())).prependTo(r),n.opts.navbar.add&&r.addClass(i.hasnavbar)}else n.opts.navbar.title&&(c.append(''+n.opts.navbar.title+"").prependTo(r),n.opts.navbar.add&&r.addClass(i.hasnavbar))}});var c=this.__findAddBack(t,"."+i.listview).children("."+i.selected).removeClass(i.selected).last().addClass(i.selected);c.add(c.parentsUntil("."+i.menu,"li")).filter("."+i.vertical).addClass(i.opened).end().each(function(){e(this).parentsUntil("."+i.menu,"."+i.panel).not("."+i.vertical).first().addClass(i.opened).parentsUntil("."+i.menu,"."+i.panel).not("."+i.vertical).first().addClass(i.opened).addClass(i.subopened)}),c.children("."+i.panel).not("."+i.vertical).addClass(i.opened).parentsUntil("."+i.menu,"."+i.panel).not("."+i.vertical).first().addClass(i.opened).addClass(i.subopened);var p=d.filter("."+i.opened);return p.length||(p=r.first()),p.addClass(i.opened).last().addClass(i.current),r.not("."+i.vertical).not(p.last()).addClass(i.hidden).end().filter(function(){return!e(this).parent().hasClass(i.panels)}).appendTo(this.$pnls),r},_initAnchors:function(){var t=this;r.$body.on(o.click+"-oncanvas","a[href]",function(s){var a=e(this),o=!1,r=t.$menu.find(a).length;for(var l in e[n].addons)if(e[n].addons[l].clickAnchor.call(t,a,r)){o=!0;break}var d=a.attr("href");if(!o&&r&&d.length>1&&"#"==d.slice(0,1))try{var c=e(d,t.$menu);c.is("."+i.panel)&&(o=!0,t[a.parent().hasClass(i.vertical)?"togglePanel":"openPanel"](c))}catch(p){}if(o&&s.preventDefault(),!o&&r&&a.is("."+i.listview+" > li > a")&&!a.is('[rel="external"]')&&!a.is('[target="_blank"]')){t.__valueOrFn(t.opts.onClick.setSelected,a)&&t.setSelected(e(s.target).parent());var h=t.__valueOrFn(t.opts.onClick.preventDefault,a,"#"==d.slice(0,1));h&&s.preventDefault(),t.__valueOrFn(t.opts.onClick.close,a,h)&&t.close()}})},_initAddons:function(){var t;for(t in e[n].addons)e[n].addons[t].add.call(this),e[n].addons[t].add=function(){};for(t in e[n].addons)e[n].addons[t].setup.call(this)},_getOriginalMenuId:function(){var e=this.$menu.attr("id");return e&&e.length&&this.conf.clone&&(e=i.umm(e)),e},__api:function(){var t=this,n={};return e.each(this._api,function(e){var s=this;n[s]=function(){var e=t[s].apply(t,arguments);return"undefined"==typeof e?n:e}}),n},__valueOrFn:function(e,t,n){return"function"==typeof e?e.call(t[0]):"undefined"==typeof e&&"undefined"!=typeof n?n:e},__refactorClass:function(e,t,n){return e.filter("."+t).removeClass(t).addClass(i[n])},__findAddBack:function(e,t){return e.find(t).add(e.filter(t))},__filterListItems:function(e){return e.not("."+i.divider).not("."+i.hidden)},__transitionend:function(e,t,n){var s=!1,i=function(){s||t.call(e[0]),s=!0};e.one(o.transitionend,i),e.one(o.webkitTransitionEnd,i),setTimeout(i,1.1*n)},__getUniqueId:function(){return i.mm(e[n].uniqueId++)}},e.fn[n]=function(s,i){return t(),s=e.extend(!0,{},e[n].defaults,s),i=e.extend(!0,{},e[n].configuration,i),this.each(function(){var t=e(this);if(!t.data(n)){var a=new e[n](t,s,i);a.$menu.data(n,a.__api())}})},e[n].support={touch:"ontouchstart"in window||navigator.msMaxTouchPoints||!1,csstransitions:function(){if("undefined"!=typeof Modernizr&&"undefined"!=typeof Modernizr.csstransitions)return Modernizr.csstransitions;var e=document.body||document.documentElement,t=e.style,n="transition";if("string"==typeof t[n])return!0;var s=["Moz","webkit","Webkit","Khtml","O","ms"];n=n.charAt(0).toUpperCase()+n.substr(1);for(var i=0;i