PageSourceSearch

https://cyclotour.es/wp-content/themes/tripgo/assets/js/script.js

js cyclotour.es collected 2026-10-09 00:01:32 UTC 8,468 bytes, 291 lines download raw bytes

1(function($){
2	"use strict";
3
4	/* Menu */
5	function tripgo_menu(){
6		var $btn = $('.main-navigation .menu-toggle'),
7        $menu = $('.main-navigation');
8        $btn.on('click', function () {
9            $menu.toggleClass('toggled');
10        });
11
12        if ($menu.length > 0) {
13            $menu.find('.menu-item-has-children > a, .page_item_has_children > a').each((index, element) => {
14                var $dropdown = $('<button class="dropdown-toggle"></button>');
15                $dropdown.insertAfter(element);
16
17            });
18            $(document).on('click', '.main-navigation .dropdown-toggle', function (e) {
19                e.preventDefault();
20                $(e.target).toggleClass('toggled-on');
21                $(e.target).siblings('ul').stop().toggleClass('show');
22            });
23        }
24	}
25
26	function tripgo_set_menu_direction($item) {
27        var sub = $item.children('.sub-menu'),
28            offset = $item.offset(),
29            width = $item.outerWidth(),
30            screen_width = $(window).width(),
31            sub_width = sub.outerWidth();
32        var align_delta = offset.left + width + sub_width - screen_width;
33        if (align_delta > 0) {
34            if ($item.parents('.menu-item-has-children').length) {
35                sub.css({ left: 'auto', right: '100%' });
36            }else {
37                sub.css({ left: 'auto', right: '0' });
38            }
39        } else {
40            sub.css({ left: '', right: '' });
41        }
42    }
43
44    function tripgo_hover_submenu() {
45        $('.primary-navigation .menu-item-has-children').hover(function (event) {
46            var $item = $(event.currentTarget);
47            tripgo_set_menu_direction($item);
48        });
49    }
50
51	/* Click scroll button at bottom */	
52	function tripgo_scrollUp(options) {
53	       
54		var defaults = {
55		    scrollName: 'scrollUp', 
56		    topDistance: 600, 
57		    topSpeed: 800, 
58		    animation: 'fade', 
59		    animationInSpeed: 200, 
60		    animationOutSpeed: 200, 
61		    scrollText: '<i class="ovaicon-up-arrow"></i>', 
62		    scrollImg: false, 
63		    activeOverlay: false 
64		};
65
66		var o = $.extend({}, defaults, options),
67		        scrollId = '#' + o.scrollName;
68
69		$('<a/>', {
70		    id: o.scrollName,
71		    href: '#top',
72		    title: o.scrollText
73		}).appendTo('body');
74
75		if (!o.scrollImg) {
76		    $(scrollId).html(o.scrollText);
77		}
78
79		$(scrollId).css({'display': 'none', 'position': 'fixed', 'z-index': '2147483647'});
80
81		if (o.activeOverlay) {
82		    $("body").append("<div id='" + o.scrollName + "-active'></div>");
83		    $(scrollId + "-active").css({'position': 'absolute', 'top': o.topDistance + 'px', 'width': '100%', 'border-top': '1px dotted ' + o.activeOverlay, 'z-index': '2147483647'});
84		}
85
86		$(window).scroll(function () {
87		    switch (o.animation) {
88		        case "fade":
89		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).fadeIn(o.animationInSpeed) : $(scrollId).fadeOut(o.animationOutSpeed));
90		            break;
91		        case "slide":
92		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).slideDown(o.animationInSpeed) : $(scrollId).slideUp(o.animationOutSpeed));
93		            break;
94		        default:
95		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).show(0) : $(scrollId).hide(0));
96		    }
97		});
98
99		$(scrollId).on( "click", function (event) {
100		    $('html, body').animate({scrollTop: 0}, o.topSpeed);
101		    event.preventDefault();
102		});
103	}
104
105	/* Post Format - Gallery */
106	$('.slide_gallery').each(function(){
107		
108		var autoplay = $(this).data('autoplay');
109		var autoplayTimeout = $(this).data('autoplaytimeout');
110		var autoplaySpeed = $(this).data('autoplayspeed');
111		var stopOnHover = $(this).data('stoponhover');
112		var loop = $(this).data('loop');
113		var dots = $(this).data('dots');
114		var nav = $(this).data('nav');
115		var items = $(this).data('items');
116		
117
118		$(this).owlCarousel({
119			autoplayTimeout: parseInt( autoplayTimeout ),
120		    autoplay: autoplay,
121		    autoplaySpeed: parseInt( autoplaySpeed ),
122		    stopOnHover : stopOnHover,
123		    loop:loop,
124		    dots:dots,
125		    nav: nav,
126		    items: parseInt( items ),
127		});
128	});
129	
130	/* Header sticky */
131	if( $('.header_sticky').length ){
132
133		function sticky_menu(menu, sticky) {
134		    if (typeof sticky === 'undefined' || !jQuery.isNumeric(sticky)) sticky 
134= 0;
135		    if ($(window).scrollTop() >= sticky) {
136		        if ($('#just-for-height').length === 0) {
137		            menu.after('<div id="just-for-height" style="height:' + menu.outerHeight() + 'px"></div>')
138		        }
139		        menu.addClass("active_sticky");
140		    } else {
141		        menu.removeClass("active_sticky");
142		        $('#just-for-height').remove();
143		    }
144		}
145
146		$(document).ready(function () {
147		    var menu = $(".header_sticky");
148		    if (menu.length) {
149		        var sticky = menu.offset().top + 100;
150		        if( $(".header_sticky").hasClass('mobile_sticky') ){
151		        	
152		            sticky_menu(menu, sticky);
153		        	$(window).on('scroll', function () {
154		                sticky_menu(menu, sticky);
155		            });    
156			        	
157		        }else{
158		        	if ($(window).width() > 767) {
159			            sticky_menu(menu, sticky);
160			            $(window).on('scroll', function () {
161			                sticky_menu(menu, sticky);
162			            });
163			        }
164		        }
165
166		        
167		    }
168		});
169	}
170
171	/* Check link has Hash (#about) in landing page */
172	if( $( 'ul.menu' ).length ){
173		var url = $( 'ul.menu li a' ).attr('href');
174	    var hash = url.substring(url.indexOf("#")+1);
175	    if( hash ){
176	    	$( 'ul.menu li a' ).on( 'click', function(){
177		    	$( 'ul.menu li' ).removeClass( 'current-menu-item' );
178		    	$(this).parent().addClass( 'current-menu-item' );
179		    	$(this).closest( '.menu-canvas' ).toggleClass('toggled');
180	    	});	
181	    } 
182	}
183
184	/* Mansory Blog */
185    $('.blog_masonry').each( function() {
186        var grid = $(this);
187        var run  = grid.masonry({
188          itemSelector: '.post-wrap',
189          gutter: 0,
190          percentPosition: true,
191          transitionDuration: 0,
192        });
193
194        run.imagesLoaded().progress( function() {
195          run.masonry();
196        });
197    });
198
199    $('.tripgo_stretch_column_left').each( function() {
200		var that = $(this);
201		if ( that.length != null ) {
202			tripgo_calculate_width( that );
203		}
204	});
205
206    $('.tripgo_stretch_column_right').each( function() {
207		var that = $(this);
208		if ( that.length != null ) {
209			tripgo_calculate_width( that );
210		}
211	});
212
213	/* Calculate width with special class */
214	function tripgo_calculate_width( directly ){
215
216		if( $(directly).length ){
217
218			var col_offset = $(directly).offset();
219
220			if( directly.hasClass('tripgo_stretch_column_left') ){
221
222				var ending_left = col_offset.left;
223				var width_left 	= $(directly).outerWidth() + ending_left;
224				
225				$('.tripgo_stretch_column_left .elementor-widget-wrap').css('width', width_left);
226				$('.tripgo_stretch_column_left .elementor-widget-wrap').css('margin-left', -ending_left);
227			}
228
229			if( directly.hasClass('tripgo_stretch_column_right') ){
230
231				var ending_right 	= ($(window).width() - (col_offset.left + $(directly).outerWidth()));
232				var width_right 	= $(directly).outerWidth() + ending_right;
233
234				directly.find('.elementor-widget-wrap').css('width', width_right);
235				directly.find('.elementor-widget-wrap').css('margin-right', -ending_right);
236			}
237		}
238	}
239
240	$(window).resize(function () {
241		$('.tripgo_stretch_column_left').each( function() {
242			var that = $(this);
243			if ( that.length != null ) {
244				tripgo_calculate_width( that );
245			}
246		});
247
248		$('.tripgo_stretch_column_right').each( function() {
249			var that = $(this);
250			if ( that.length != null ) {
251				tripgo_calculate_width( that );
252			}
253		});
254	});
255
256    tripgo_hover_submenu();
257	tripgo_menu();
258	
259	/* Scroll to top */
260	tripgo_scrollUp();
261
262	// Accordion customize
263	$(".ova-accordion-custom").each(function(){
264			
265		//init
266		var that = $(this).find('.elementor-accordion');
267		that.find('.elementor-accordion-item').first().addClass('ova-active');
268
269		var btn = that.find('.elementor-accordion-item');
270
271		btn.each( function() {
272			
273			$(this).find('.elementor-tab-title').on('click', function(){
274				var that = $(this);
275				var pa = that.parent();
276				var check = pa.hasClass('ova-active');
277				if( check === true ) {
278					pa.removeClass('ova-active');
279
280				} else {
281					
282					pa.parent().find('.elementor-accordion-item').removeClass('ova-active');
283					pa.addClass('ova-active');
284				}
285			});	
286
287		});
288		
289	});
290
291})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.