PageSourceSearch

https://losruralistas.com/wp-content/themes/remons/assets/js/script.js

js losruralistas.com collected 2026-10-06 02:19:07 UTC 12,706 bytes, 430 lines download raw bytes

1(function($){
2	"use strict";
3
4	function remons_menu(){
5
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" aria-label="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 remons_set_menu_direction($item) {
27        var sub = $item.children('.sub-menu').filter(':not(.ova-mega-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 remons_hover_submenu() {
45        $('.primary-navigation .menu-item-has-children').hover(function (event) {
46            var $item = $(event.currentTarget);
47            remons_set_menu_direction($item);
48        });
49    }
50
51		
52	/* Click scroll button at bottom */	
53	function remons_scrollUp(options) {
54	       
55		var defaults = {
56		    scrollName: 'scrollUp', 
57		    topDistance: 600, 
58		    topSpeed: 800, 
59		    animation: 'fade', 
60		    animationInSpeed: 200, 
61		    animationOutSpeed: 200, 
62		    scrollText: '<i class="ovaicon-up-arrow"></i>', 
63		    scrollImg: false, 
64		    activeOverlay: false 
65		};
66
67		var o = $.extend({}, defaults, options),
68		        scrollId = '#' + o.scrollName;
69
70
71		$('<a/>', {
72		    id: o.scrollName,
73		    href: '#top',
74		    title: ScrollUpText.value
75		}).appendTo('body');
76
77
78		if (!o.scrollImg) {
79
80		    $(scrollId).html(o.scrollText);
81		}
82
83
84		$(scrollId).css({'display': 'none', 'position': 'fixed', 'z-index': '2147483647'});
85
86
87		if (o.activeOverlay) {
88		    $("body").append("<div id='" + o.scrollName + "-active'></div>");
89		    $(scrollId + "-active").css({'position': 'absolute', 'top': o.topDistance + 'px', 'width': '100%', 'border-top': '1px dotted ' + o.activeOverlay, 'z-index': '2147483647'});
90		}
91
92
93		$(window).scroll(function () {
94		    switch (o.animation) {
95		        case "fade":
96		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).fadeIn(o.animationInSpeed) : $(scrollId).fadeOut(o.animationOutSpeed));
97		            break;
98		        case "slide":
99		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).slideDown(o.animationInSpeed) : $(scrollId).slideUp(o.animationOutSpeed));
100		            break;
101		        default:
102		            $(($(window).scrollTop() > o.topDistance) ? $(scrollId).show(0) : $(scrollId).hide(0));
103		    }
104		});
105
106
107		$(scrollId).on( "click", function (event) {
108		    $('html, body').animate({scrollTop: 0}, o.topSpeed);
109		    event.preventDefault();
110		});
111
112	}
113
114	
115	// Post Format - Gallery
116	$('.slide_gallery').each( function() {
117   		if ( typeof Swiper !== 'function' ) return;
118
119   		const that = $(this);
120		
121		// Slider options
122        const sliderOpts = that.data('options');
123
124        // Slider element
125        const sliderEl = that.find('.swiper')[0];
126
127        // Swiper wrap
128        const swiperWrapper = $(sliderEl).find('.swiper-wrapper');
129
130        // Slider
131        const slides = swiperWrapper.find('.swiper-slide');
132
133        // Slider data
134        let sliderData = {
135        	autoHeight: sliderOpts.autoHeight,
136            loop: sliderOpts.loop,
137            speed: sliderOpts.speed || 500,
138            slidesPerGroup: sliderOpts.slidesPerGroup,
139            slidesPerView: sliderOpts.slidesPerView,
140            spaceBetween: sliderOpts.spaceBetween,
141            rtl: sliderOpts.rtl,
142            breakpoints: sliderOpts.breakpoints,
143            on: {
144                beforeInit(swiper) {
145                    if ( sliderOpts.loop ) {
146                        // Get number of items
147                        let numberOfItems = slides.length;
148
149                        // Flag
150                        let flag = ( slides.length > 1 && numberOfItems == swiper.params.slidesPerView ) ? 1 : 0;
151
152                        // Loop
153                        while ( numberOfItems <= swiper.params.slidesPerView ) {
154                            if ( flag == slides.length ) flag = 0;
155
156                            // Clone item
157                            swiperWrapper.append(slides[flag].cloneNode(true));
158
159                            // Update number of items
160                            numberOfItems = swiper.el.querySelectorAll('.swiper-slide').length;
161
162                            flag++;
163                        }
164                    }
165                },
166                init(swiper) {
167                    // Remove class 'swiper-loading'
168                    $(sliderEl).removeClass('swiper-loading');
169                }
170            }
171        };
172
173        // Autoplay
174        if ( sliderOpts.autoplay ) {
175            sliderData['autoplay'] = {
176                delay: sliderOpts.delay || 3000,
177                disableOnInteraction: false,
178                pauseOnMouseEnter: sliderOpts.pauseOnMouseEnter
179            };
180        }
181
182        // Navigation
183        if ( sliderOpts.nav ) {
184            sliderData['navigation'] = {
185                nextEl: that.find('.button-next')[0],
186                prevEl: that.find('.button-prev')[0],
187            };
188        }
189
190        // Pagination
191        if ( sliderOpts.dots ) {
192            sliderData['pagination'] = {
193                el: that.find('.button-dots')[0],
194                clickable: true,
195                dynamicBullets: true,
196                dynamicMainBullets: 3
197            };
198        }
199
200        // New swiper
201        const swiper = new Swiper(sliderEl, sliderData);
202	});
203	
204
205	if( $('.header_sticky').length ){
206
207		function sticky_menu(menu, sticky) {
208		    if (typeof sticky === 'undefined' || !jQuery.isNumeric(sticky)) sticky 
208= 0;
209		    if ($(window).scrollTop() >= sticky) {
210		        if ($('#just-for-height').length === 0) {
211
212		        	if( $('.above_menu').length > 0 && $(window).width() > 767 ){
213		        		var menuoutheight = menu.outerHeight() + $('.above_menu').outerHeight(); 
214		        	}else{
215		        		var menuoutheight = menu.outerHeight();	
216		        	}
217		        	
218		            menu.after('<div id="just-for-height" style="height:' + menuoutheight + 'px"></div>')
219		        }
220		        menu.addClass("active_sticky");
221		    } else {
222		        menu.removeClass("active_sticky");
223		        $('#just-for-height').remove();
224		    }
225		}
226
227		$(document).ready(function () {
228		    var menu = $(".header_sticky");
229		    if (menu.length) {
230		        var sticky = menu.offset().top + 100;
231		        if( $(".header_sticky").hasClass('mobile_sticky') ){
232		        	
233		            sticky_menu(menu, sticky);
234		        	$(window).on('scroll', function () {
235		                sticky_menu(menu, sticky);
236		            });    
237			        	
238		        }else{
239		        	if ($(window).width() > 767) {
240			            sticky_menu(menu, sticky);
241			            $(window).on('scroll', function () {
242			                sticky_menu(menu, sticky);
243			            });
244			        }
245		        }
246
247		        
248		    }
249		});
250
251	}
252		
253
254	// Check link has Hash (#about) in landing page
255	if( $( 'ul.menu' ).length ){
256
257		var url = $( 'ul.menu li a' ).attr('href');
258	    var hash = url.substring(url.indexOf("#")+1);
259
260	    if( hash ){
261	    	$( 'ul.menu li a' ).on( 'click', function(){
262		    	$( 'ul.menu li' ).removeClass( 'current-menu-item' );
263		    	$(this).parent().addClass( 'current-menu-item' );
264		    	$(this).closest( '.menu-canvas' ).toggleClass('toggled');
265		    });	
266	    }
267	}
268
269	// Geometry appear - Banner Scooter
270	$('.ova-geometry').appear(function(){
271		
272		var move      =  $(this);
273		var div       =  "<div class='geometry'></div>"; 
274		move.prepend(div);
275
276		// add class for animation
277		var geometry =  move.find('.geometry');
278		geometry.addClass('animate__animated animate__fadeInBottomLeft');
279
280	});
281	
282
283	// Mansory Blog
284    $('.blog_masonry').each( function() {
285
286        var grid = $(this);
287        var run  = grid.masonry({
288          itemSelector: '.post-wrap',
289          gutter: 0,
290          percentPosition: true,
291          transitionDuration: 0,
292        });
293
294        run.imagesLoaded().progress( function() {
295          run.masonry();
296        });
297        
298    });
299
300    $('.ovabrw-product-images').each( function() {
301        product_video_popup($(this));
302    });
303
304    /* Product Video */
305    function product_video_popup( that ) {
306        var video = that.find('.ovabrw-product-video-link');
307        var modal_container = $('.product-video-modal-container');
308        var modal_close     = modal_container.find('.modal-close');
309        var modal_video     = modal_container.find('.modal-video');
310
311        video.each( function() {
312            $(this).on('click', function(){
313                var url = product_video_get_url( $(this).data('src') );
314                var option      = '?autoplay=1;&loop=1;&controls=1;&showinfo=1;&modestbranding=1';
315                if ( url != 'error' ) {
316                    modal_video.attr('src', "https://www.youtube.com/embed/" + url + option );
317                    modal_container.css('display', 'flex');
318                }
319            });
320        });
321
322        // close video
323        modal_close.on('click', function() {
324            modal_container.hide();
325            modal_video.removeAttr('src');
326        });
327
328        // window click
329        $(window).click( function(e) {
330            if ( e.target.className == 'product-video-modal-container' ) {
331                modal_container.hide();
332                modal_video.removeAttr('src');
333            }
334        });
335    }
336
337    function product_video_get_url( url ) {
338        var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
339        var match = url.match(regExp);
340
341        if (match && match[2].length == 11) {
342            return match[2];
343        } else {
344            return 'error';
345        }
346    }
347
348    
349	$('.remons_stretch_column_left').each( function() {
350		var that = $(this);
351		if ( that.length != null ) {
352			remons_calculate_width( that );
353		}
354	});
355
356	$('.remons_stretch_column_right').each( function() {
357		var that = $(this);
358		if ( that.length != null ) {
359			remons_calculate_width( that );
360		}
361	});
362
363	/* Calculate width with special class */
364	function remons_calculate_width( directly ){
365
366		if( $(directly).length ){
367
368			var col_offset = $(directly).offset();
369			var dom 	   = directly.closest('.elementor-element').find('.elementor-widget-container');
370
371			if( directly.hasClass('remons_stretch_column_left') ){
372
373				var ending_left = col_offset.left;
374				var width_left 	= $(directly).outerWidth() + ending_left;
375
376				var ending_right 	= ($(window).width() - (col_offset.left + $(directly).outerWidth()));
377				var width_right 	= $(directly).outerWidth() + ending_right;
378				
379
380				if ( $('body').hasClass('rtl') ) {
381					dom.css('width', width_right);
382					dom.css('margin-right', -ending_right);
383				} else {
384					dom.css('width', width_left);
385					dom.css('margin-left', -ending_left);
386				}
387			}
388
389			if( directly.hasClass('remons_stretch_column_right') ){
390
391				var ending_left = col_offset.left;
392				var width_left 	= $(directly).outerWidth() + ending_left;
393
394				var ending_right 	= ($(window).width() - (col_offset.left + $(directly).outerWidth()));
395				var width_right 	= $(directly).outerWidth() + ending_right;
396				
397				if ( $('body').hasClass('rtl') ) {
398					dom.css('width', width_left);
399					dom.css('margin-left', -ending_left);
400				} else {
401					dom.css('width', width_right);
402					dom.css('margin-right', -ending_right);
403				}
404			}
405		}
406	}
407
408	$(window).resize(function () {
409		$('.remons_stretch_column_left').each( function() {
410			var that = $(this);
411			if ( that.length != null ) {
412				remons_calculate_width( that );
413			}
414		});
415
416		$('.remons_stretch_column_right').each( function() {
417			var that = $(this);
418			if ( that.length != null ) {
419				remons_calculate_width( that );
420			}
421		});
422	});
423
424    remons_hover_submenu();
425	remons_menu();
426	
427	/* Scroll to top */
428	remons_scrollUp();
429
430})(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.