/*! * RT-Theme 20 WordPress Theme Scripts * Copyright (C) 2014 RT-Themes * http://rtthemes.com * * various scripts file */ (function($,sr){ // debouncing function from John Hann // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ var 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 || 500); }; } // smartresize jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; })(jQuery,'smartresize'); (function($){ "use strict"; /* ******************************************************************************* Featured Image Slider ***********************************************************************************/ if( ! $.fn.featured_image_slider ){ $.fn.featured_image_slider = function() { $(this).each(function () { var image_holder = $(this).parents(".featured_image:eq(0)"), image = image_holder.find("img"), nav_item = $(this).find("li"); nav_item.on("click",function(){ nav_item.each(function(){ $(this).removeClass("active"); }); $(this).addClass("active"); var $this = $(this); var img = new Image(); img.src = $this.data("src"); if (! img.complete ) { image_holder.addClass("loading"); img.onload = function () { swap_image(image,$this,image_holder); }; } else { swap_image(image,$this,image_holder); } }); }); //swap the image function swap_image(image,new_image,image_holder){ image.animate({ opacity: 0 }, 200, function() { image.attr("src",new_image.data("src")); image.attr("alt",new_image.data("alt")); image_holder.removeClass("loading"); image.animate({opacity: 1}, 200); $(".masonry").isotope('layout'); }); } }; } if ( $.fn.featured_image_slider ) { $('.featured-image-nav').featured_image_slider(); } /* ******************************************************************************* HORIZONTAL ACCORDION ***********************************************************************************/ if( ! $.fn.rt_horizontal_accordion ){ $.fn.rt_horizontal_accordion = function() { if($(window).width() < 780){ $(this).removeAttr("style"); }else{ $(this).height( $(this).height()+"px" ); } if($(window).width() < 780){ return; } $(this).each(function () { var sections = $(this).find("ol > li"), open_section = $(this).find("ol > li.open"), close_section = $(this).find("ol > li:not(.open):eq(0)"); sections.each(function(){ var article = $(this).find("article"); var text = $(this).find(".text-holder"); var featured_image = $(this).find(".featured_image_holder"); article.removeAttr("style"); text.removeAttr("style"); article.width( open_section.outerWidth() ); text.outerWidth( close_section.width() ); featured_image.height( text.height() ); }); sections.on("mouseover",function(){ var article = $(this).find("article"); sections.removeClass("open"); $(this).addClass("open"); }); }); }; } if ( $.fn.rt_horizontal_accordion ) { Pace.on('hide', function(){ $('.horizontal-accordion').rt_horizontal_accordion(); }); $(window).on('window_width_resize', function() { $('.horizontal-accordion').rt_horizontal_accordion(); }); } /* ******************************************************************************* GLOBAL VARS ***********************************************************************************/ var is_rtl = $("body").hasClass("rtl"); var window_width = $(window).width(); var is_layout1 = $("body").hasClass("layout1"); var is_layout2 = $("body").hasClass("layout2"); var header_sticky_height = 65; /* ******************************************************************************* WINDOW WIDTH RESIZE ONLY ***********************************************************************************/ $(window).smartresize(function(){ if($(this).width() != window_width){ window_width = $(this).width(); $(window).trigger("window_width_resize"); } }); /* ******************************************************************************* CHECK IF THE HIDDEN MOBILE MENU ACTIVE ***********************************************************************************/ if( ! $.fn.is_mobile_menu ){ $.fn.is_mobile_menu = function() { return $(window).width() < 980; }; } /* ******************************************************************************* MOBILE MENU ***********************************************************************************/ function rt_toggle_mobile_menu(menu_button){ menu_button.toggleClass("icon-menu icon-menu-outline"); $("body").toggleClass("mobile-menu-active"); if( $("body").hasClass("mobile-menu-active") ){ $.fn.rt_passive_close(); }else{ $("#main_content").off('touchstart click'); } } //on menu button click $(".mobile-menu-button").on("click",function() { rt_toggle_mobile_menu($(this)); return false; }); //click outside of mobile menu $.fn.rt_passive_close = function(){ $("#main_content").on('touchstart click', function(e) { if( $("body").hasClass("mobile-menu-active") ){ rt_toggle_mobile_menu($(".mobile-menu-button")); return false; } }); }; $(window).on('window_width_resize load', function() { if($.fn.is_mobile_menu()){ $("body").addClass("mobile-menu"); }else{ $("body").removeClass("mobile-menu"); $("body").removeClass("mobile-menu-active"); } if( Modernizr.touchevents && is_layout1 ){ $("body").addClass("mobile-menu"); return false; } }); /* ******************************************************************************* CIRCLE SLIDER ***********************************************************************************/ var change_timeout, animate_circles; if( ! $.fn.rt_circle_slider ){ $.fn.rt_circle_slider = function() { if( $(this).length == 0 ){ return; } $(this).each(function(){ var timeout = 7000,//7 seconds $this = $(this), circles = $this.find("div"), holder = $this.parent(), holder_width = holder.width(), background_images = $(this).attr("data-background-images"), data_interval = $(this).attr("data-interval"), change_effect, timeout, background_images_array; if( background_images.length == 0 ){ return; } $this.css({ "width":holder_width, "height":holder_width }) background_images_array = background_images.split(","); update_circles( circles ); change_effect = function() { $this.addClass("change"); }; change_timeout = setTimeout( change_effect, timeout - 800 ); animate_circles = setInterval(function(circles) { var firstimage = background_images_array[0]; background_images_array.shift(); background_images_array.push(firstimage); update_circles( circles ); $this.removeClass("change"); change_timeout = setTimeout( change_effect, timeout - 800 ); }, timeout, circles ); function update_circles( circles ){ var i=0; circles.each(function(){ if( i == 4 ){ return false; } $(this).css({ "background-image":"url("+background_images_array[i]+")" }); $(this).attr("data-background-image", background_images_array[i] ); i++; }); $this.attr("data-background-images",background_images_array.join(",")); } }); }; $('.circle-slider > div').on('click',{change_timeout: change_timeout, animate_circles: animate_circles}, function() { clearTimeout(change_timeout); clearInterval(animate_circles); var thislider = $(this).parents("div:eq(0)"); var thisimage = $(this).attr("data-background-image"); var firstimage = ""; var background_images = thislider.attr("data-background-images"); var background_images_array = background_images.split(","); thislider.removeClass("change"); if( thisimage == background_images_array[0] ){ return; } var firstimage = background_images_array[0]; var this_image_index = background_images_array.indexOf( thisimage ) ; background_images_array.splice(this_image_index, 1 ); background_images_array.shift(); background_images_array.unshift(thisimage); background_images_array.push(firstimage); thislider.attr("data-background-images",background_images_array.join(",")); thislider.rt_circle_slider(); }); } $(window).on('window_width_resize', {change_timeout: change_timeout, animate_circles: animate_circles}, function() { clearTimeout(change_timeout); clearInterval(animate_circles); $('.circle-slider').rt_circle_slider(); }); Pace.on('hide', function(){ $('.circle-slider').rt_circle_slider(); }); /* ******************************************************************************* STICKY HEADER ********************************************************************************** */ if( ! $.fn.rt_sticky_header ){ $.fn.rt_sticky_header = function() { if( $(this).length == 0 ){ return; } var header = $(this); var site_logo = $(".site-logo a"); var stuck_logoimg = $(".sticky_logo"); var logo_box = $(".site-logo.logo-box"); var logoimg = $(".site-logo img"); var nav_items = $("#navigation > li > a"); site_logo.removeAttr("style"); if( Modernizr.touchevents || $.fn.is_mobile_menu() ){ header.removeClass( "stuck" ); header.css({"position":"absolute"}); return; } var wp_admin_bar_height = $("#wpadminbar").outerHeight(); var header_height = header.outerHeight(); if( header.length > 0 ){ //scroll function $(window).scroll(function(event) { if( $.fn.is_mobile_menu() ){ return; } var y = $(window).scrollTop(); if( y < 0 ){ return; } if( y > header_sticky_height ){ header.addClass( "stuck" ); $(window).trigger("nav_position"); }else{ header.removeClass( "stuck" ); $(window).trigger("nav_position"); } var new_header_height = Math.max( header_sticky_height,header_height-(y/4) ); var linefix = y == 0 ? 0 : Math.min( 10, (y/4) ) ; var padding = y == 0 ? 30 : Math.max( 0, 30 - (y/8) ) ; var new_header_height = y == 0 ? header_height + 10 : new_header_height ; new_header_height = logo_box.length > 0 ? new_header_height : new_header_height - 10 ; new_header_height = Math.max( header_sticky_height, new_header_height ); logoimg.css({"max-height":new_header_height - ( Math.max(0,rt_theme_params["logo_gap"] - linefix) ) +"px"}); if( logo_box.length > 0 ){ site_logo.css({ "max-height":new_header_height +"px", "line-height":new_header_height +"px", "padding-left": padding +"px", "padding-right": padding +"px", }); nav_items.css({"line-height":new_header_height - ( 10 - linefix ) +"px"}); }else{ site_logo.css({ "max-height":new_header_height +"px", "line-height":new_header_height +"px" }); nav_items.css({"line-height":new_header_height+"px"}); } }); } }; } $(window).on('resize', function() { $(".sticky.top-header").rt_sticky_header(); }); imagesLoaded( "body" ).on('done', function( instance ) { $(".sticky.top-header").rt_sticky_header(); }); /* ******************************************************************************* IMG effects ********************************************************************************** */ if( ! $.fn.rt_image_hover ){ $.fn.rt_image_hover = function() { $(this).each(function(){ var button= $(this).find(".action-button"); if( button.length > 0 ){ return; } $('
').append($(this).find("img")).appendTo($(this)); $(this).append(''); }); }; } $(window).on('resize load', function() { $(".imgeffect").rt_image_hover(); }); /* ******************************************************************************* STICKY SUB-HEADER ********************************************************************************** */ if( ! $.fn.rt_sticky_sub_nav ){ $.fn.rt_sticky_sub_nav = function() { if( $(this).length == 0 ){ return; } var sub_nav = $(this); var sub_nav_top = sub_nav.offset().top; var sub_header = $(".sub_page_header"); var wp_admin_bar_height = $("#wpadminbar").outerHeight(); //scroll function $(window).scroll(function(event) { if( $.fn.is_mobile_menu() ){ return; } var header_height = $(".top-header.stuck").outerHeight() + wp_admin_bar_height; var y = $(window).scrollTop(); if( y > ( sub_nav_top - header_height ) ){ sub_nav.addClass( "stuck" ); sub_nav.css({"top":header_height +"px"}); sub_header.css({"margin-bottom":sub_nav.outerHeight()}); }else{ sub_nav.removeClass( "stuck" ); sub_nav.css({"top":"auto"}); sub_header.css({"margin-bottom":"auto"}); } }); }; } $(window).on('resize load', function() { $(".section-nav-holder").rt_sticky_sub_nav(); }); /* ******************************************************************************* STICKY SIDEBARS ********************************************************************************** */ if( ! $.fn.rt_sticky_sidebar ){ $.fn.rt_sticky_sidebar = function() { if( $(this).length == 0 ){ return; } if( Modernizr.touchevents || $.fn.is_mobile_menu() ){ $(this).each(function(){ $(this).removeAttr("style"); }); return; } var $window = $(window); var $stickyHeaderFields = "#wpadminbar, .sticky.top-header"; $(this).each(function(){ $(this).removeAttr("style"); var $content_block = $(this).parents(".content_row_wrapper:eq(0)"), $content = $content_block.find(".content:eq(0)"), $sidebar = $(this), sidebar_left_position = $sidebar.position().left, sidebarHeight = $sidebar.outerHeight(), sidebarWidth = $sidebar.outerWidth(), contentHeight = $content.outerHeight(), sidebar_position = $sidebar.position().top, padding = 25; if( contentHeight > sidebarHeight ){ $window.scroll(function(event) { if( $.fn.is_mobile_menu() ){ return; } if( ! $sidebar.hasClass('stuck') ){ $sidebar.addClass('stuck'); } var $content_block_top = $content_block.offset().top; var $addHeigth = 0; //sticky fields on top $($stickyHeaderFields).each(function(){ $addHeigth = $addHeigth + $(this).height(); }); //sidebar new position var scrollTop = $window.scrollTop() + $addHeigth, maxposition = contentHeight - ( sidebar_position + sidebarHeight ) + padding, topPosition = -1 * Math.min( 0 , $content_block_top - scrollTop ); topPosition = Math.min( maxposition, topPosition ); if( $content_block_top - scrollTop > 0 ){ $sidebar.removeAttr("style"); } if( $content_block_top - scrollTop < 0 ){ $sidebar.css({ "position": "fixed", 'top': $addHeigth + padding + "px", 'left': sidebar_left_position + "px", 'width': sidebarWidth - 0.5 +"px" }); } if( maxposition == topPosition ){ $sidebar.css({ "position": "absolute", 'top': ( contentHeight - sidebarHeight ) + padding + "px", 'left': sidebar_left_position + "px" }); } }); } }); }; } Pace.on('hide', function(){ $(".sidebar.sticky").rt_sticky_sidebar(); }); $(window).on('resize', function() { $(".sidebar.sticky").rt_sticky_sidebar(); }); /* ******************************************************************************* ON PAGE LOAD ***********************************************************************************/ imagesLoaded( "body" ).on('done', function( instance ) { $("body").removeClass("rt-loading"); $("#loader-wrapper").remove(); if ( ! Modernizr.touchevents ) { $(window).scrollTop(0); } }); Pace.on('hide', function(){ $('.pace').remove(); $("body").removeClass("rt-loading"); $("#loader-wrapper").remove(); }); /* ******************************************************************************* NAV POSITION ********************************************************************************** */ if( ! $.fn.rt_nav_position ){ $.fn.rt_nav_position = function() { var $this = $(this); var nav = $(this).find("nav"); var tools = $(this).find("#tools"); tools.removeAttr("style"); if($.fn.is_mobile_menu()){ $(window).scroll(function(event) { if( $(window).scrollTop() > 0 ){ tools.css({"opacity":0}); }else{ tools.css({"opacity":1}); } }); return; } if( is_rtl ){ tools.css({ "position":"absolute", "left":0, "margin-top":0 }); nav.css({ "margin-left":tools.width() + 20 }); }else{ tools.css({ "position":"absolute", "right":0, "margin-top":0 }); nav.css({ "margin-right":tools.width() + 20 }); } }; } $(window).on('load nav_position resize', function() { $(".header-layout2 .sticky .header-right").rt_nav_position(); }); /* ******************************************************************************* CALCULATE DISTANCE ***********************************************************************************/ if( ! $.fn.rt_calc_distance ){ $.fn.rt_calc_distance = function( target ){ //vars var wp_admin_bar = $("#wpadminbar"); var sticky_nav = $(".top-header.sticky"); var section_nav = $(".section-nav-holder"); //target ofset if( section_nav.length > 0 ){ target = target.parents(".content_row_wrapper:eq(0)"); } var target_ofset = target.offset().top; //reduce position var distance = 0; if( section_nav.length > 0 ){ distance += wp_admin_bar.outerHeight(); } if( target.offset().top > 30 ) { if( sticky_nav.length > 0 ){ distance += header_sticky_height; } } if( target.offset().top > 30 ) { if( section_nav.length > 0 ){ distance += section_nav.outerHeight(); } } return target_ofset - distance; } } /* ******************************************************************************* RT ONE PAGE ***********************************************************************************/ if( ! $.fn.rt_one_page ){ $.fn.rt_one_page = function() { if( window.location.hash ){ if( $(window.location.hash).length > 0 ){ rt_scroll_to( $.fn.rt_calc_distance( $(window.location.hash) ) , window.location.hash ); } } $(this).on("click",function(e){ var cur_url = window.location.host + window.location.pathname + window.location.search; var this_url = this.host + this.pathname + this.search; if( cur_url == this_url ){ e.preventDefault(); if( this.hash == "#top" ){ rt_scroll_to( 0, ""); return ; } var target = $(this.hash); //if target is hidden if( target.hasClass("hidden-element") ){ target = target.parents("*:eq(0)"); } //if target doesn't exists if( target.length == 0 ){ window.location = this.href; return ; } if( $("body").hasClass("mobile-menu-active") ){ $(".mobile-menu-button").trigger("click"); } rt_scroll_to( $.fn.rt_calc_distance(target), this.hash); } }); $(this).each(function(){ var menu_item = $(this), hash = this.hash, section = $(hash); if( ! section.is(":visible") ){ section = section.parents("*:eq(0)"); } menu_item.parent("li").removeClass("current-menu-item current_page_item"); section.waypoint(function(direction) { if (direction === 'down') { rt_remove_active_menu_class(); menu_item.parent("li").addClass("current-menu-item current_page_item"); } }, { offset: '50%' }); section.waypoint(function(direction) { if (direction === 'up') { rt_remove_active_menu_class(); menu_item.parent("li").addClass("current-menu-item current_page_item"); } }, { offset: function() { return 0; } }); section.waypoint(function(direction) { if (direction === 'up') { menu_item.parent("li").removeClass("current-menu-item current_page_item"); } }, { offset: function() { return $.waypoints('viewportHeight'); } }); section.waypoint(function(direction) { if (direction === 'down') { menu_item.parent("li").removeClass("current-menu-item current_page_item"); } }, { offset: function() { return -$(this).height(); } }); }); function rt_remove_active_menu_class(){ $("#navigation > li.current-menu-item, #navigation > li.current_page_item, .section-nav > li.current_page_item").removeClass("current-menu-item current_page_item"); } }; } if ( $.fn.rt_one_page ) { Pace.on('hide', function(){ $($('#navigation a[href*="#"]:not([href="#"]),.section-nav a[href*="#"]:not([href="#"])')).rt_one_page(); }); } /* ******************************************************************************* SCROLLTO LINKS ***********************************************************************************/ $(".scroll").on("click",function(){ if( this.hash == "#top" ){ rt_scroll_to( 0, ""); return ; } if( $(this.hash).length < 1 ){ return ; } rt_scroll_to( $.fn.rt_calc_distance( $(this.hash) ), this.hash); }); /* ******************************************************************************* GO TO TOP LINK ***********************************************************************************/ if( ! $.fn.rt_go_to_top ){ $.fn.rt_go_to_top = function() { var $this = $(this); $(window).scroll(function(event) { var top_distance = 100; var y = $(window).scrollTop(); if( y > top_distance ){ $this.addClass("visible"); }else{ $this.removeClass("visible"); } }); $(this).on("click",function(e){ rt_scroll_to( 0, ""); }); }; } if ( $.fn.rt_go_to_top ) { $('.go-to-top').rt_go_to_top(); } /* ******************************************************************************* RT COUNTER ***********************************************************************************/ if( ! $.fn.rt_counter ){ $.fn.rt_counter = function() { $(this).each(function(){ var number_holder = $(this).find("> .number"), number = number_holder.text(); $(this).waypoint( { triggerOnce: true, offset: "100%", handler: function() { $({ Counter: 0 }).animate({ Counter: number_holder.text() }, { duration: 1200, step: function () { number_holder.text(Math.ceil(this.Counter)); }, complete: function () { number_holder.text(number); } }); } }); }); }; } if ( $.fn.rt_counter ) { Pace.on('hide', function(){ $('.rt_counter').rt_counter(); }); } /* ******************************************************************************* RT SCROLL TO ***********************************************************************************/ function rt_scroll_to( to, hash ){ $('html, body').stop().animate({ 'scrollTop': to }, 900, 'swing', function() { window.location.hash = hash; $('html,body').scrollTop(to); }); } /* ******************************************************************************* FIX FEATURES COLUMN POSITION OF COMPARE TABLES ********************************************************************************** */ if( ! $.fn.rt_tables ){ $.fn.rt_tables = function() { var features, table = $(this); //brings the features column position same with other columns function fix_compare_features( table ){ $(table).each(function(i){ var start_position_element = $(this).find(".start_position"), features_list = $(this).find(".table_wrap.features ul"), new_offset = start_position_element.offset().top - $(this).offset().top; features_list.css("top",new_offset); }); } //copy features to each column for mobile function copy_features( table ){ $(table).each(function(){ features=[]; //createa features array from the first row $(this).find(".table_wrap.features li").each(function(){ features.push( $(this).html() ); }); }); $(table).find(".table_wrap").each(function(i){ if( $(this).hasClass("features") == "" ){ var i = 0; $(this).find("li").each(function(){ $(this).prepend(''); i++; }); } }); } //bind to window resize $(window).bind("resize",table, function( ){ fix_compare_features( table ); }); //start functions fix_compare_features( table ); copy_features( table ); }; } if ( $.fn.rt_tables ) { $('.pricing_table.compare').rt_tables(); } /* ******************************************************************************* TOGGLE - ACCORDION ********************************************************************************** */ $(".rt-toggle .toggle-content").hide(); $(".rt-toggle .open .toggle-content").show(); $(".rt-toggle ol li .toggle-head").click(function(){ clearTimeout("accordion_timeout"); var element = $(this).parent("li"), content = element.find(".toggle-content"); if( element.hasClass("open")){ element.removeClass("open"); content.stop().slideUp(300); }else{ $(this).parents("ol").find("li.open").removeClass("open").find(".toggle-content").stop().slideUp(300); element.addClass("open"); content.stop().slideDown(300,function(){ fix_accordion_pos(); }); //fixed heights content.find('.fixed_heights').rt_fixed_rows("load"); } function fix_accordion_pos(){ if( $(window).scrollTop() > element.offset().top ){ var accordion_timeout = setTimeout(function() { var add = $("#wpadminbar").outerHeight() + $(".top-header.stuck").outerHeight(); rt_scroll_to( element.offset().top - add, ""); }, 100 ); } } }); /* ******************************************************************************* TABS ********************************************************************************** */ if( ! $.fn.rt_tabs ){ $.fn.rt_tabs = function() { $(this).each(function () { var tabs = $(this), tab_nav = $(this).find("> .tab_nav"), desktop_nav_element = $(this).find("> .tab_nav > li"), mobile_nav_element = $(this).find("> .tab_contents > .tab_content_wrapper > .tab_title"), tab_wrappers = $(this).find("> .tab_contents > .tab_content_wrapper"), tab_style = $(this).attr("data-tab-position"); //nav height fix height_fix(1); //mobile nav clicks mobile_nav_element.click(function() { close_all(); open_tab( $(this).attr("data-tab-number") ); }) //desktop nav clicks desktop_nav_element.click(function() { close_all(); open_tab( $(this).attr("data-tab-number") ); }) //close all tabs function close_all(){ tab_wrappers.each(function() { $(this).removeClass("active"); }); desktop_nav_element.each(function() { $(this).removeClass("active"); }); } //open a tab function open_tab( tab_number ){ var nav_item = tabs.find('[data-tab-number="'+tab_number+'"]'), tab_content_wrapper = tabs.find('[data-tab-content="'+tab_number+'"]'); nav_item.addClass("active"); tab_content_wrapper.addClass("active"); height_fix( tab_number ); //fixed heights tab_content_wrapper.find('.fixed_heights').rt_fixed_rows("load"); //fix custom select forms $.fn.rt_customized_selects( tab_content_wrapper ); tab_content_wrapper.find('span.customselect').remove(); tab_content_wrapper.find('select.hasCustomSelect').removeAttr("style"); $.fn.rt_customized_selects( tab_content_wrapper ); if( window_width < 767 ){ rt_scroll_to( tab_content_wrapper.offset().top, "" ); } } //height fix - vertical style function height_fix( tab_number ) { if( tab_style == "tab-position-2" ){ var current_tab_height = tabs.find('[data-tab-content="'+tab_number+'"]').outerHeight(); tab_nav.css({"min-height":current_tab_height+"px"}); } } }); }; } if ( $.fn.rt_tabs ) { $('.rt_tabs').rt_tabs(); } /* ******************************************************************************* START CAROUSELS ********************************************************************************** */ $.fn.rt_start_carousels = function( callbacks ) { //mobile (responsive) heading sizes for the main content carousel //createa a css and append to body for screens only below 768px $(".main-carousel").each(function(){ var create_css = "", unique_class_name = "", mobile_height = $(this).data("mobile-height"); create_css += "#"+$(this).attr("id")+" .item{min-height:"+mobile_height+"px !important;}"; if( $(this).data("mobile-value") != "" || $(this).data("mobile-line-height") != "" ){ $(this).find(".slide_heading").each(function(){ unique_class_name = "heading-" + Math.floor((Math.random() * 100000) + 1); $(this).addClass(unique_class_name); create_css += "."+unique_class_name+"{font-size:"+$(this).data("mobile-value")+"px !important; line-height:"+$(this).data("mobile-line-height")+" !important;}"; }); } if( $(this).data("mobile-value") != "" || $(this).data("mobile-line-height") != "" ){ $(this).find(".slide_sub_heading").each(function(){ unique_class_name = "sub-heading-" + Math.floor((Math.random() * 100000) + 1); $(this).addClass(unique_class_name); create_css += "."+unique_class_name+"{font-size:"+$(this).data("mobile-value")+"px !important; line-height:"+$(this).data("mobile-line-height")+" !important;}"; }); } if( $(this).data("mobile-top-margin") != "" ){ $(this).find(".slide-content").each(function(){ unique_class_name = "content-" + Math.floor((Math.random() * 100000) + 1); $(this).addClass(unique_class_name); create_css += "."+unique_class_name+"{margin-top:"+$(this).data("mobile-top-margin")+"px !important;}"; }); } $("").prependTo($("body")); }); //craete carousels $(this).find(".rt-carousel").each(function(){ var autoHeight_, margin = $(this).data("margin") !== "" ? $(this).data("margin") : 15, carousel_holder = $(this), items = $(this).attr("data-item-width"),//number of items of each slides nav = $(this).attr("data-nav") == "true" ? true : false, dots = $(this).attr("data-dots") == "true" ? true : false, thumbnails = $(this).attr("data-thumbnails") == "true" ? true : false, boxed = $(this).attr("data-boxed") == "true" ? true : false, timeout = typeof $(this).attr("data-timeout") != "undefined" ? $(this).data("timeout") : 5000, autoplay = $(this).data("autoplay") != "undefined" ? $(this).data("autoplay") : false, loop = $(this).data("loop") != "" ? true : false, carousel_id = $(this).attr("id"); //auto height & margin if( items == 1 ){ autoHeight_ = true; margin = 0; }else{ autoHeight_ = false; margin = margin; } //start carousel var carousel = carousel_holder.find(".owl-carousel"); imagesLoaded( carousel ).on('done', function( instance ) { if( instance.images.length == 1 ){ nav = dots = false; } var startover; carousel.on('changed.owl.carousel', function(e) { if( ! autoplay ){ return; } clearTimeout(startover); if (!e.namespace || e.type != 'initialized' && e.property.name != 'position') return; var items = $(this).find('.active').size(); if( e.item.index == e.item.count - items ){ startover = setTimeout(function() { carousel.trigger('to.owl.carousel', [0, 400, true]); }, timeout ); } }); carousel.on('changed.owl.carousel initialized.owl.carousel', function(e) { if( ! thumbnails ){ return; } $('#'+carousel_id +"-thumbnails > a.active").removeClass("active"); $('#'+carousel_id +"-thumbnails > a:eq("+e.item.index+")").addClass("active"); }); carousel.owlCarousel({ rtl: is_rtl ? true : false, //loop:loop, //isues with webkit autoplayTimeout : timeout, autoplay:autoplay, autoplayHoverPause:true, margin:margin, responsiveClass:true, URLhashListener:thumbnails, startPosition: 'URLHash', stagePadding: ( boxed ) ? 5 : 0, navSpeed:700, dotsSpeed:500, autoHeightClass: 'owl-height', navText: ["",""], responsive:{ 0:{ items:1, nav:nav, dots:dots, autoHeight:( items == 1 ), dotsContainer: "#"+carousel_id+"-dots", }, 1024:{ items:( items == 1 ) ? 1 : 2, nav:nav, dots:dots, autoHeight:( items == 1 ), dotsContainer: "#"+carousel_id+"-dots" }, 1025:{ items:items, nav:nav, dots:dots, autoHeight:( items == 1 ), dotsContainer: "#"+carousel_id+"-dots", } }, onInitialized: callbacks ? callbacks._onInitialized : isotope_layout, onChanged: callbacks ? callbacks._onChanged : "", onRefreshed: callbacks ? callbacks._onRefreshed : "", onTranslated: isotope_layout, }); //cosmetic fix for content carousels make_same_height(carousel,items); $(window).on('window_width_resize', function() { setTimeout(function() { carousel.trigger('next.owl.carousel'); reset_carousel_heights(carousel,items); make_same_height(carousel,items); }, 300); }); }); }); //reset isotopes after carousel function isotope_layout(){ var isotope_gallery = $(".masonry"); if( isotope_gallery.length > 0 ){ setTimeout(function() { isotope_gallery.isotope('layout'); }, 1000); } } //get highest item of the carousel function get_highest_item( carousel ){ var heights = []; carousel.find(".owl-item").each(function(){ heights.push($(this).outerHeight()); }); return Math.max.apply(null, heights); } //reset carousel item heights function reset_carousel_heights( carousel, items ){ if( items == 1 ){ return false; } carousel.find(".owl-item > div").each(function(){ $(this).css({"min-height": ""}); }); } //make all carousel items in same height function make_same_height( carousel, items ){ if( items == 1 ){ return false; } var height = get_highest_item( carousel ); carousel.find(".owl-item > div").each(function(){ $(this).css({"min-height": height +"px"}); }); } }; $("body").rt_start_carousels(); /* ******************************************************************************* FIXED SIDEBAR POSITION ***********************************************************************************/ if( ! $.fn.rt_left_height ){ $.fn.rt_left_height = function() { var left_side = $("#left_side"); if( Modernizr.touchevents ){ left_side.removeClass("fixed_position scroll"); return ; } $(window).off(".rt_sidebar"); if( ! left_side.hasClass("fixed_position")){ return ; } var side_content = $("#side_content").removeAttr("style"), side_content_height = side_content.innerHeight(), content_height = $("body").height(), side_content_top_pos = side_content.offset().top, $window = $(window), window_height = $window.height(), window_scrollTop = $window.scrollTop(), diff = window_height - ( ( side_content_top_pos - window_scrollTop ) + side_content_height ); if( diff > 0 ){ return false; } //make two side heights are equal if ( side_content_height > content_height ) { $("#right_side").css( { "min-height" : side_content_height+side_content_top_pos+"px"}); } //scroll $(window).on("scroll.rt_sidebar", function( event ){ var y = -1 * $window.scrollTop(); y = Math.max( y, diff ); $(side_content).css({ "-webkit-transform": "translateY("+y+"px)", "-moz-transform": "translateY("+y+"px)", "-ms-transform": "translateY("+y+"px)", "-o-transform": "translateY("+y+"px)", "transform": "translateY("+y+"px)" }); $(side_content).attr("data-position-y",y); }); }; } if ( $.fn.rt_left_height && is_layout1 ) { $(window).on('resize', function() { $.fn.rt_left_height(); }); Pace.on('hide', function(){ $.fn.rt_left_height(); }); } /* ******************************************************************************* SHORTCUT BUTTONS OPEN/CLOSE ********************************************************************************** */ $("#tools > ul:last-child > li > span").on("click",function(e){ if( ! $(this).hasClass("active") ){ $(this).addClass("active"); $("#tools > ul:first-child").addClass("active"); if( window_width < 979 ){ $("#logo a > *").css({"opacity":0}); }else{ $(".header-right").css({"opacity":0}); } }else{ $(this).removeClass("active"); $("#tools > ul:first-child").removeClass("active"); if( window_width < 979 ){ $("#logo a > *").css({"opacity":1}); }else{ $(".header-right").css({"opacity":1}); } } }); /* ******************************************************************************* WOOCOMMERCE SKAKE THE CART ICON ********************************************************************************** */ if ( ! $.fn.rt_sake_the_cart ) { $.fn.rt_sake_the_cart = function() { if( typeof wc_cart_fragments_params == 'undefined' ){ return ; } if( $(".product_holder.woocommerce").length == 0 ){ return ; } $( '.add_to_cart_button' ).on( 'click', function() { $("#tools .icon-line-bag").removeClass("shake"); //bind to added_to_cart $( 'body' ).bind( 'added_to_cart', function() { $("#tools .icon-line-bag").addClass("shake"); $(this).unbind('added_to_cart'); }); }); } } $(window).on("load",function(){ $.fn.rt_sake_the_cart(); }); /* ******************************************************************************* SEARCH WIDGET ********************************************************************************** */ $(".wp-search-form span").on('click', function() { $(this).parents("form:eq(0)").submit(); }); /* ******************************************************************************* SOCIAL SHARE ********************************************************************************** */ $(".social_media.share a").click(function( event ) { //if email button clicked do nothing if( $(this).hasClass("icon-mail") ){ return ; } //for other buttons open a popup window newwindow=window.open($(this).attr("data-url"),'name','height=400,width=400'); if (newwindow == null || typeof(newwindow)=='undefined') { alert( rt_theme_params["popup_blocker_message"] ); }else{ newwindow.focus(); } event.preventDefault(); }); /* ******************************************************************************* Tooltips ********************************************************************************** */ $('[data-toggle="tooltip"]').tooltip(); /* ******************************************************************************* DROP DOWN MENU ********************************************************************************** */ if( ! $.fn.rt_drop_down ){ $.fn.rt_drop_down = function() { if( $.fn.is_mobile_menu() ){ return ; } var $this = $(this); $this.each(function(){ var menu_items_with_sub = $(this).find(".menu-item-has-children"), max_depth = 0; menu_items_with_sub.each(function(){ max_depth = Math.max( max_depth, $(this).data("depth") ); }); if( ! is_rtl ){ if( window_width < $(this).offset().left + ( ( max_depth + 1 ) * 240 ) ){ $(this).addClass("o-direction"); } }else{ if( 0 > ( $(this).offset().left - ( ( max_depth + 1 ) * 240 ) ) ){ $(this).addClass("o-direction"); } } }); }; } $("#navigation > li:not(.multicolumn).menu-item-has-children").rt_drop_down(); /* ******************************************************************************* MOBILE DROP DOWN MENU ********************************************************************************** */ if( ! $.fn.rt_mobile_drop_down ){ $.fn.rt_mobile_drop_down = function() { $(this).on("click",function(e){ if( ! $("body").hasClass("mobile-menu") ){ return ; } var $this = $(this).parent("li"); if( ! is_rtl ){ if( ! $this.hasClass("menu-item-has-children") || window_width - e.pageX > 65 ){ return ; } }else{ if( ! $this.hasClass("menu-item-has-children") || e.pageX > 65 ){ return ; } } e.preventDefault(); $this.toggleClass("current-menu-item"); return false; }); }; } $(window).on('load', function() { $('#navigation li a,#navigation li > span').rt_mobile_drop_down(); }); /* ******************************************************************************* TABLET NAVIGATION FIX FOR DEACTIVE STATE ********************************************************************************** */ $("#container").on("click",function() { return true; }); /* ******************************************************************************* RT Fixed Rows ********************************************************************************** */ $.fn.rt_fixed_rows = function( action ) { function fix_heights(row) { row.each(function(){ var this_row_height = $(this).height(); var $this = $(this); //check if any of the rows is 12 var full_width_columns = $this.find(".vc_col-sm-12,.col-sm-12"); var reduce_height = 0; if( full_width_columns.length > 0 ){ full_width_columns.each(function(){ reduce_height = reduce_height + $(this).height(); }); this_row_height = this_row_height - reduce_height; } if( Modernizr.csstransforms3d ){ $this.find(" > .wpb_column:not(.vc_col-sm-12), > .col:not(.col-sm-12)").css({ 'min-height': this_row_height }); }else{//ie9 or before $(this).find("> .wpb_column:not(.vc_col-sm-12), > .col:not(.col-sm-12)").css({ 'height': this_row_height }); } setTimeout(function() { $this.find(".blog_list:not(.masonry) .col:not(.col-sm-12) .post_data").css({"position":"absolute"}); }, 50); }); } function reset_heights(row) { row.each(function(){ var $this = $(this); $this.find(".blog_list:not(.masonry) .col:not(.col-sm-12) .post_data").css({"position":"relative"}); if( Modernizr.csstransforms3d ){ $this.find(" > .wpb_column:not(.vc_col-sm-12), > .col:not(.col-sm-12)").css({'min-height': "auto" }); }else{//ie9 or before $this.find(" > .wpb_column:not(.vc_col-sm-12), > .col:not(.col-sm-12)").css({ 'height': "auto" }); } }); fix_custom_min_heights(row); row.rt_fixed_rows("load"); } function fix_custom_min_heights(row) { var custom_min_heights = row.find(".custom-min-height"); custom_min_heights.each(function(){ var this_min_height = $(this).data("custom-min-height"); $(this).css({'min-height': this_min_height +"px" }); }); } if( action == "reset"){ $(this).each(function(){ if( $(this).children(".content_row_wrapper").length > 0 ){ reset_heights( $(this).children(".content_row_wrapper") ); } if( $(this).find(".content_row").length > 0 ){ reset_heights( $(this).find(".content_row") ); } if( $(this).find(".row").length > 0 ){ reset_heights( $(this).find(".row") ); } reset_heights( $(this) ); }); } if( $(window).width() < 767 ){ return false; } if( action == "load"){ $(this).each(function(){ if( $(this).children(".content_row_wrapper").length > 0 ){ fix_heights( $(this).children(".content_row_wrapper") ); } if( $(this).find(".content_row").length > 0 ){ fix_heights( $(this).find(".content_row") ); } if( $(this).find(".row").length > 0 ){ fix_heights( $(this).find(".row") ); } fix_heights( $(this) ); }); } }; //run the script Pace.on('hide', function(){ $('.fixed_heights').rt_fixed_rows("load"); //run the script $(window).on('window_width_resize', function() { setTimeout(function() { $('.fixed_heights').rt_fixed_rows("reset"); }, 700); }); }); /* ******************************************************************************* RT Full Scrween Rows ********************************************************************************** */ $.fn.rt_full_screen_rows = function() { $(this).each(function(){ var $this = $(this), window_height = $(window).height(), wp_admin_bar_height = $("#wpadminbar").outerHeight(), offset = $this.offset().top; if( ( offset - wp_admin_bar_height ) == 0 && Modernizr.cssvhunit ){ return; } if( offset < window_height || ! Modernizr.cssvhunit ){ $this.css({"min-height": window_height - offset +"px" }); } }); }; //run the script imagesLoaded( "body" ).on('done', function( instance ) { $('.full-height-row').rt_full_screen_rows(); }); $(window).on('resize', function() { $('.full-height-row').rt_full_screen_rows(); }); /* ******************************************************************************* PARALLAX BACKGROUNDS ********************************************************************************** */ if( ! $.fn.rt_parallax_backgrounds ){ $.fn.rt_parallax_backgrounds = function(options) { if( Modernizr.touchevents ){ return ; } $(this).each(function(){ var row = $(this).parents("div:eq(0)"), row_height = row.outerHeight() , row_width = row.outerWidth() , row_inheight = row.height(), row_paddings = row_height - row_inheight, speed = ( row_height / $(window).height() ) + 0.8, holder_height = row_height * speed, holder_width = row_width * speed, effect = $(this).attr("data-rt-parallax-effect"), // vertical, horizontal direction = $(this).attr("data-rt-parallax-direction"); // -1 down/right , 1 up/left if( effect == "horizontal" ){ $(this).css({ "height":"calc( 100% + 4px )", "width":holder_width+"px" }); }else{ $(this).css({ "height":holder_height+"px", "width":row_width+4+"px" }); } if( effect == "horizontal" ){ $(this).rt_horizontal_parallax_effect({ row: row, row_width: row_width, holder_width: holder_width, direction: direction }); }else{ $(this).rt_vertical_parallax_effect({ row: row, row_height: row_height, holder_height: holder_height, direction: direction }); } }); } $.fn.rt_horizontal_parallax_effect = function( options ) { var $this = $(this), $window = $(window), invisible_part = options["holder_width"] - options["row_width"], posTop = options["row"].offset().top, start_position = options["direction"] == -1 ? -1 * invisible_part : 0; //start position of the parallax layer $this.rt_parallax_apply_css(start_position, 0 ); //scroll function $(window).scroll(function(event) { if( ( posTop - $window.height() ) > $window.scrollTop() ){ return ; } var move_rate = ( $window.scrollTop() * invisible_part ) / ( posTop + options["row_width"] ); var xPos = options["direction"] == 1 ? -1 * move_rate : -1 * invisible_part + move_rate ; if( xPos < -1 * invisible_part ) xPos = -1 * invisible_part; //max left position if( xPos > 0 ) xPos = 0; //max right position $this.rt_parallax_apply_css(xPos, 0); }); } $.fn.rt_vertical_parallax_effect = function( options ) { var $this = $(this), $window = $(window), invisible_part = options["holder_height"] - options["row_height"], posTop = options["row"].offset().top, start_position = options["direction"] == -1 ? -1 * invisible_part : 0; //start position of the parallax layer $this.rt_parallax_apply_css(0, start_position ); //scroll function $(window).scroll(function(event) { if( (posTop - $window.height() ) > $window.scrollTop() ){ return ; } var move_rate = ( $window.scrollTop() * invisible_part ) / ( posTop + options["row_height"] ); var yPos = options["direction"] == 1 ? -1 * move_rate : -1 * invisible_part + move_rate ; if( yPos < -1 * invisible_part ) yPos = -1 * invisible_part; //max bottom position if( yPos > 0 ) yPos = 0; //max top position $this.rt_parallax_apply_css(0, yPos); //sub page headers if( $this.parent(".content_row").hasClass("sub_page_header") ){ $this.next(".content_row_wrapper").find(".page-title").rt_parallax_apply_css( 0, $window.scrollTop() / 6 ); } }); } $.fn.rt_parallax_apply_css = function( x, y ) { var is_rtl = $("body").hasClass("rtl"); //if it is rtl language make it reverse x = is_rtl ? -1 * x : x; $(this).css({ "-webkit-transform": "translate("+x+"px, "+y+"px)", "-moz-transform": "translate("+x+"px, "+y+"px)", "-ms-transform": "translate("+x+"px, "+y+"px)", "-o-transform": "translate("+x+"px, "+y+"px)", "transform": "translate("+x+"px, "+y+"px)" }); } } if ( $.fn.rt_parallax_backgrounds ) { $(window).on('resize', function() { $('.rt-parallax-background').rt_parallax_backgrounds(); if( ! Modernizr.touchevents ){ window.scrollTo(0,0); } }); //start parallax effects when everything loaded Pace.on('hide', function(){ $('.rt-parallax-background').rt_parallax_backgrounds(); }); } /* ******************************************************************************* LOAD MORE ********************************************************************************** */ $(".load_more").on("click",function(e){ e.preventDefault(); var button = $(this), listid = button.attr("data-listid"), page_count = parseInt(button.attr("data-page_count")) , current_page = parseInt(button.attr("data-current_page")) ; //prevent multiple clicks before loading elements button.attr("disabled", "disabled"); //check if there is more posts to display if( page_count == 1 ){ return ; } //load more button classes button.children("span").removeClass("icon-angle-double-down").addClass("icon-spin1 animate-spin"); //start ajax $.ajax({ type: 'POST', url: rt_theme_params.ajax_url, data : { 'action': 'rt_ajax_loader', 'atts': $(this).attr("data-atts"), 'wpml_lang': rt_theme_params.wpml_lang, 'page': current_page + 1 }, success: function(response, textStatus, XMLHttpRequest){ var response = $(response), elems, wrapper, masonry; wrapper = $("#"+listid); if( wrapper.hasClass("masonry") ){ masonry = true; } if( masonry ){ elems = response.find(".isotope-item"); }else{ elems = response.find("> div, > article"); } // wait the images imagesLoaded( response ).on('done', function( instance ) { //append the elements and rebuild the masonry layout if( masonry ){ wrapper.isotope().append( elems ).isotope( 'appended', elems ); }else{ wrapper.append( elems ); } //img effects for new loaded elements elems.find(".imgeffect").rt_image_hover(); //media player elems.rt_mediaelementplayer(); //append isotope elements if( masonry ){ wrapper.isotope('layout'); } //lightboxes $.jackBox.available(function() { elems.rt_lightbox("newItem"); }); //start featured image sliders elems.find('.featured-image-nav').featured_image_slider(); //start carousels elems.rt_start_carousels( { '_onRefreshed' : function _onRefreshed(){ if( masonry ){ wrapper.isotope('layout'); } }}); //the load more button button.children("span").removeClass("icon-spin1 animate-spin").addClass("icon-angle-double-down"); //decrease the page count button.attr("data-page_count",page_count-1); //increase the current page count button.attr("data-current_page", current_page+1 ); //remove the button if there is no page left if( page_count -1 <= 1 ){ button.attr("disabled", "disabled").hide(); }else{ button.removeAttr("disabled"); } //fix left side $.fn.rt_left_height(); $(window).trigger("scroll"); }); }, error: function( MLHttpRequest, textStatus, errorThrown ){ console.log(errorThrown); } }); }); /* ******************************************************************************* CUSTOM DESIGNED SELECT FORMS ********************************************************************************** */ if( ! $.fn.rt_customized_selects ){ $.fn.rt_customized_selects = function( wrapper ) { if ( $.isFunction($.fn.customSelect) ) { var selectors = '.orderby, .variations select:not([multiple]), .widget .menu.dropdown-menu, .gfield:not(.notcustomselect) .ginput_container select:not([multiple]), .wpcf7-form select:not([multiple])'; if( wrapper ){ wrapper.find(selectors).customSelect( { customClass: "customselect" } ); }else{ $(selectors).customSelect( { customClass: "customselect" } ); } } }; }; $(window).load(function(){ $.fn.rt_customized_selects(); //bind to gravity ajax load $(document).bind('gform_post_render', function(){ $.fn.rt_customized_selects(); }); }); /* ******************************************************************************* WC REVIEWS ********************************************************************************** */ $(".woocommerce-review-link").click(function( event ){ var review_tab = $("#reviews-title"); review_tab.trigger("click"); }); /* ******************************************************************************* FORM VALIDATION ********************************************************************************** */ $.fn.rt_contact_form = function() { $(this).each(function(){ var the_form = $(this); the_form.find(".submit").click(function( event ){ //vars var loading = the_form.find(".loading"), error = false; //check required fields the_form.find(".required").each(function(){ if( $(this).val() == "" ){ $(this).addClass("error"); error = true; }else{ $(this).removeClass("error"); } }); //there is an error if(error){ return ; } //show loading icon loading.show(); //searialize the form var serialize_form = $(the_form).serialize(); //ajax form data var data = serialize_form +'&action=rt_ajax_contact_form'; //post $.post(rt_theme_params.ajax_url, data, function(response) { var response = $(response); response.prependTo(the_form); loading.hide(); }); //close warnings the_form.find(".info_box").remove(); }); }); }; $('.validate_form').rt_contact_form(); /* ******************************************************************************* INFO BOX CLOSE ********************************************************************************** */ $(document.body).on("click",".info_box .icon-cancel",function() { $(this).parent(".info_box").fadeOut(); }); /* ******************************************************************************* LIGHTBOX PLUGIN ********************************************************************************** */ $.fn.rt_lightbox = function(event) { if ($.jackBox){ $(this).find(".lightbox_[data-group]").jackBox(event, { preloadGraphics: false, baseName: rt_theme_params["rttheme_template_dir"] +"/js/lightbox", className: ".lightbox_", deepLinking : false, socialMedia : false, showInfoByDefault: true}); } }; $(document).rt_lightbox("init"); /* ******************************************************************************* RT GOOGLE MAPS ********************************************************************************** */ $.rt_maps = function(el, locations, zoom){ var base = this; base.init = function(){ // initialize google map if(locations.length>0) google.maps.event.addDomListener(window, 'load', $.fn.rt_maps()); }; if(locations.length>0) base.init(); }; $.fn.rt_maps = function(locations, zoom){ var map_id = $(this).attr("id"); //holder height var height = $('[data-scope="#'+map_id+'"]').attr("data-height"); if ( height > 0 ){ $(this).css({'height':height+"px"}); } //api options var myOptions = { zoom: zoom, panControl: true, zoomControl: true, scaleControl: true, streetViewControl: false, overviewMapControl: false, scrollwheel : false, navigationControl: true, center: new google.maps.LatLng(0, 0), mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map( document.getElementById(map_id), myOptions); //B&W Map var bwmap = $('[data-scope="#'+map_id+'"]').attr("data-bw"); if ( typeof bwmap !== "undefined" && bwmap != "" ){ // Create an array of styles. var styles = [ { stylers: [ { hue: "#fff" }, { saturation: -100 }, { lightness: 0 }, { gamma: 1 } ] } ]; // Create a new StyledMapType object, passing it the array of styles, // as well as the name to be displayed on the map type control. var styledMap = new google.maps.StyledMapType(styles, {name: "Styled Map"}); //Associate the styled map with the MapTypeId and set it to display. map.mapTypes.set('map_style', styledMap); map.setMapTypeId('map_style'); } $.fn.setMarkers(map, locations); $.fn.fixTabs(map,map_id,zoom); $.fn.fixAccordions(map,map_id,zoom); }; $.fn.setMarkers = function (map, locations) { if(locations.length>1){ var bounds = new google.maps.LatLngBounds(); }else{ var center = new google.maps.LatLng(locations[0][1], locations[0][2]); map.panTo(center); } for (var i = 0; i < locations.length; i++) { if (locations[i] instanceof Array) { var location = locations[i]; var myLatLng = new google.maps.LatLng(location[1], location[2]); var marker = new google.maps.Marker({ position: myLatLng, map: map, animation: google.maps.Animation.DROP, draggable: false, title: location[0] }); $.fn.add_new_event(map,marker,location[4]); if(locations.length>1) bounds.extend(myLatLng); } } if(locations.length>1) map.fitBounds(bounds); }; $.fn.add_new_event = function (map,marker,content) { if(content){ var infowindow = new google.maps.InfoWindow({ content: content, maxWidth: 300 }); google.maps.event.addListener(marker, 'click', function() {; infowindow.open(map,marker); }); } }; $.fn.fixTabs = function (map,map_id,zoom) { var tabs = $("#"+map_id).parents(".rt_tabs:eq(0)"), desktop_nav_element = tabs.find("> .tab_nav > li"), mobile_nav_element = tabs.find("> .tab_contents > .tab_content_wrapper > .tab_title"); desktop_nav_element.on("click", { map: map } , function() { var c = map.getCenter(); google.maps.event.trigger(map, 'resize'); map.setZoom(zoom); map.setCenter(c); }); mobile_nav_element.on("click", { map: map } , function() { var c = map.getCenter(); google.maps.event.trigger(map, 'resize'); map.setZoom(zoom); map.setCenter(c); }); }; $.fn.fixAccordions = function (map,map_id,zoom) { var panes = $("#"+map_id).parents(".rt-toggle:eq(0) > ol > li"); panes.on("click", { map: map } , function() { var c = map.getCenter(); google.maps.event.trigger(map, 'resize'); map.setZoom(zoom); map.setCenter(c); }); }; /* ******************************************************************************* SLIDER PARALLAX EFFECT ********************************************************************************** */ $.fn.rt_slider_position = function() { var slider = $('#main_content > .content_row:first-child .main-carousel[data-parallax="true"]'); if( slider.length == 0 || Modernizr.touchevents ){ return ; } var parallax_effect = ! Modernizr.touchevents ? true : false, wp_admin_bar_height = $("#wpadminbar").outerHeight(), offsetTop = slider.offset().top, sliderHeight = slider.outerHeight(), gap = offsetTop - wp_admin_bar_height, carousel = slider.find(".owl-stage-outer"), $window = $(window); //parallax effect $(window).on("scroll", function( event ){ var scrollTop = $window.scrollTop() - gap ; if( sliderHeight < scrollTop ){ return ; } var y = Math.max( 0, scrollTop ), cy = 0.4*y; carousel.css({ "-webkit-transform": "translateY("+cy+"px)", "-moz-transform": "translateY("+cy+"px)", "-ms-transform": "translateY("+cy+"px)", "-o-transform": "translateY("+cy+"px)", "transform": "translateY("+cy+"px)" }); if( cy > 90 ){ carousel.addClass("scrolled"); }else{ carousel.removeClass("scrolled"); } }); } $(window).on('resize', function() { $.fn.rt_slider_position(); }); Pace.on('hide', function(){ $.fn.rt_slider_position(); }); /* ******************************************************************************* MEDIA PLAYER ********************************************************************************** */ $.fn.rt_mediaelementplayer = function() { $(this).find(".rt-hosted-media video, .rt-hosted-media audio").mediaelementplayer(); }; $(document).rt_mediaelementplayer(); /* ******************************************************************************* MASONRY LAYOUTS ********************************************************************************** */ $.fn.rt_run_masonry_isotope = function(options) { $(this).each(function(){ var $container = $(this), $filter_navigation = $('[data-list-id="'+$(this).attr("id")+'"]'), colWidth = function () { var w = $container.width(), columnNum = $container.attr("data-column-width"), columnWidth = Math.floor( w / columnNum ); //fix column width if( w === (columnWidth * columnNum)){ columnWidth = columnWidth - 0.5; } return columnWidth; }, isotope = function () { $container.isotope({ resizable: false, itemSelector: '.isotope-item', masonry: { columnWidth: colWidth(), gutterWidth: 0 } }); }; isotope(); //filter nativation $filter_navigation.rt_filter_nav( $container ); }); }; $.fn.rt_run_grid_isotope = function(options) { var $container = $(this), $filter_navigation = $(".filter-holder"), colWidth = function () { var w = $container.width(), columnNum = $container.attr("data-column-width"), columnWidth = Math.floor( w/columnNum ); //fix column width if( w === (columnWidth * columnNum)){ columnWidth = columnWidth - 0.5; } return columnWidth; }, isotope = function () { $container.isotope({ resizable: false, itemSelector: '.col', layoutMode: 'fitRows' }); }; isotope(); //filter nativation $filter_navigation.rt_filter_nav( $container ); }; //a function for filter navigation classes on click $.fn.rt_filter_nav = function( $container ) { var $optionLinks = $(this).find('a'); $optionLinks.click(function(){ var $this = $(this), selector = $(this).attr('data-filter'); //filter items $container.isotope({ filter: selector }); // add active class to the navigation item if ( $this.hasClass('active') ) { // don't proceed if the current item already selected return false; } var $optionSet = $this.parents('.filter_navigation'); $optionSet.find('.active').removeClass('active'); $this.addClass('active'); return false; }); }; //start isotopes $(window).on('load window_width_resize', function() { $('.masonry').rt_run_masonry_isotope(); $('.border_grid.filterable').rt_run_grid_isotope(); }); /* ******************************************************************************* MEGA MENU ********************************************************************************** */ $('#navigation .multicolumn > ul > li.menu-item-has-children > a').each(function(){ if( $(this).attr("href") == "#" || $(this).attr("href") == "" ){ var $this = $(this); $(''+$(this).text()+'').insertAfter($this); $this.remove(); } }); /* ******************************************************************************* RETINA LOGO ? check if the browser supports srcsets ? check if the device screen high dpi = replace the 2x image with the 1x one ********************************************************************************** */ imagesLoaded( "body" ).on('done', function( instance ) { if( $("html").hasClass("no-srcset") && window.devicePixelRatio > 1.4 ){ //main logo retina var main_logo = $("#logo .main_logo"), main_logo_srcset = main_logo.attr("srcset"); if( main_logo_srcset != "" ){ var main_logo_retina = main_logo_srcset.split(" 2x"); main_logo.attr("src",main_logo_retina[0]); } //sticky logo retina var sticky_logo = $("#logo .sticky_logo"), sticky_logo_srcset = sticky_logo.attr("srcset"); if( sticky_logo_srcset != "" ){ var sticky_logo_retina = sticky_logo_srcset.split(" 2x"); sticky_logo.attr("src",sticky_logo_retina[0]); } } }); /* ******************************************************************************* FULL WIDTH HORIZONTAL TABS BACKGROUND ********************************************************************************** */ $.fn.rt_tabs_background = function() { var tab_nav = $('#main_content > .content_row > .content_row_wrapper > .vc_col-sm-12:not(.with_sidebar) .rt_tabs.style-4 .tab_nav, #main_content > .content_row > .content_row_wrapper > .col-sm-12:not(.with_sidebar) .rt_tabs.style-4 .tab_nav'); if( tab_nav.length == 0 ){ return ; } //the tab background var tab_background = tab_nav.prev(); tab_background.css({ "height" : tab_nav.outerHeight()+"px", "width" :( window_width ) +"px", "left" : -1 * tab_nav.offset().left + 15 +"px", "position" : "absolute" }); } $(window).on('resize', function() { $.fn.rt_tabs_background(); }); Pace.on('hide', function(){ $.fn.rt_tabs_background(); }); /* ******************************************************************************* TOOL ICONS ********************************************************************************** */ if( ! $.fn.rt_tool_icons ){ $.fn.rt_tool_icons = function() { var $this = $(this), all = $("#tools > ul > li"); $(this).on("click",function( e ){ var parent = $(this).parent("li:eq(0)"); if( ! parent.hasClass("active") ){ all.removeClass("active"); parent.addClass("active"); $("body").addClass("tools-active"); }else{ all.removeClass("active"); $("body").removeClass("tools-active"); } }); $("html").on("click", "body.tools-active", function( e ){ if( $(e.target).parents(".tool-icon").length == 0 ){ $("body").removeClass("tools-active"); all.removeClass("active"); e.preventDefault(); } }); } } $("#tools > ul > li > span").rt_tool_icons(); /* ******************************************************************************* FIX TOOLS MENU POSITION fixes the tools menu position on mobile screens (ios8) for header layout 2 ********************************************************************************** */ $.fn.rt_fix_tools_menu_pos = function(){ console.log($(".header-right > #tools").length); if( ! $.fn.is_mobile_menu() ){ if( $(".header-right > #tools").length == 1 ){ return; } $(this).appendTo(".header-right"); }else{ if( $(".header-elements > #tools").length == 1 ){ return; } $(this).appendTo(".header-elements"); } } var tools_menu = $(".header-layout2 #tools"); tools_menu.rt_fix_tools_menu_pos(); $(window).on('resize', function() { tools_menu.rt_fix_tools_menu_pos(); }); /* ******************************************************************************* NO FLEXBOX flexbox fix for browsers like ie9 ********************************************************************************** */ $.fn.rt_no_flexbox_support = function() { //there are many bugs so we consider no flexbox support for IE11 also var isIE11 = !!navigator.userAgent.match(/Trident.*rv\:11\./); if( isIE11 ){ $(html).addClass("ie11-flexbox"); } var column_alignments = $('.no-flexbox .content_row.align-columns, .ie11-flexbox .content_row.align-columns'); var content_alignments = $('.no-flexbox .content_row_wrapper.align-contents'); //columns column_alignments.each(function(){ var $this = $(this); var row_height = $this.innerHeight(); var item = $this.find(".content_row_wrapper:eq(0)"); var item_height = item.innerHeight(); if( $this.hasClass("column-align-bottom") ){ item.css({"margin-top":row_height-item_height+"px"}); }else if( $this.hasClass("full-height-row") && !$this.hasClass("column-align-middle") ){ item.css({"margin-top":(row_height-item_height)/2+"px"}); } }); //contents content_alignments.each(function(){ var $this = $(this); var row_height = window.getComputedStyle( $this[0] , null) ; row_height = parseInt(row_height.getPropertyValue("height")); var columns = $this.find("> .wpb_column"); columns.each(function(){ var $thiscol = $(this); var item_height = $thiscol.outerHeight(); if( $this.hasClass("content-align-bottom") ){ $thiscol.css({"margin-top":row_height-item_height+"px"}); }else if( $this.hasClass("content-align-middle") ){ $thiscol.css({"margin-top":(row_height-item_height)/2+"px"}); } }); }); } $(window).on('load resize', function() { $.fn.rt_no_flexbox_support(); }); })(jQuery);