PageSourceSearch

https://playtents.in/wp-content/themes/toyup/assets/js/main.js?ver=3.0

js playtents.in collected 2026-10-04 03:20:48 UTC 21,195 bytes, 586 lines download raw bytes

1jQuery(document).ready(function ($) {
2    "use strict";
3
4    $('a[href=\\#]').on('click', function (e) {
5        e.preventDefault();
6    })
7
8    $('#myTab a').on('click', function (e) {
9	  e.preventDefault()
10	  $(this).tab('show')
11	})
12
13	/* Page scroll Bottom To Top */
14    if ($(".scroll-wrap").length) {
15        var offset = 150;
16        var duration = 10;
17        $(window).on('scroll', function() {
18            if ($(this).scrollTop() > offset) {
19                $('.scroll-wrap').addClass('active-scroll');
20            } else {
21                $('.scroll-wrap').removeClass('active-scroll');
22            }
23        });
24        $('.scroll-wrap').on('click', function(event) {
25            event.preventDefault();
26            $('html, body').animate({
27                scrollTop: 0
28            }, duration);
29            return false;
30        })
31    }
32
33	//Intersection Observer
34	if (!!window.IntersectionObserver) {
35		let observer = new IntersectionObserver((entries, observer) => {
36		  entries.forEach(entry => {
37			if (entry.isIntersecting) {
38			  entry.target.classList.add("active-animation");
39			  observer.unobserve(entry.target);
40			}
41		  });
42		}, {
43		  rootMargin: "0px 0px -100px 0px"
44		});
45		document.querySelectorAll('.has-animation').forEach(block => {
46		  observer.observe(block)
47		});
48	} else {
49		document.querySelectorAll('.has-animation').forEach(block => {
50		  block.classList.remove('has-animation')
51		});
52	}
53
54    // product cat menu
55    var classHandler = true;
56    $("#cat-button").on('click', function(){
57        if(classHandler){
58            $(".cat-menu-close").addClass('cat-menu-open');
59        }else {
60            $(".cat-menu-close").removeClass('cat-menu-open');
61        }
62        classHandler = !classHandler;
63    });
64
65    /*---------------------------------------
66    Background Parallax
67    --------------------------------------- */
68    if ($(".rt-parallax-bg-yes").length) {
69        $(".rt-parallax-bg-yes").each(function () {
70            var speed = $(this).data('speed');
71            $(this).parallaxie({
72                speed: speed ? speed : 0.5,
73                offset: 0,
74            });
75        })
76    }
77
78    /*-------------------------------------
79    Buble Background On Hover
80    -------------------------------------*/
81    $('.animated-bg-wrap').on('mouseenter', function(e) {
82        var parentOffset = $(this).offset(),
83          relX = e.pageX - parentOffset.left,
84          relY = e.pageY - parentOffset.top;
85        if ($(this).find('.animated-bg-wrap .animated-bg')) {
86          $('.animated-bg-wrap .animated-bg').css({
87            top: relY,
88            left: relX,
89          });
90        }
91    });
92    $('.animated-bg-wrap').on('mouseout', function(e) {
93        var parentOffset = $(this).offset(),
94          relX = e.pageX - parentOffset.left,
95          relY = e.pageY - parentOffset.top;
96        if ($(this).find('.animated-bg-wrap .animated-bg')) {
97          $('.animated-bg-wrap .animated-bg').css({
98            top: relY,
99            left: relX,
100          });
101        }
102    });
103
104    /* Header Search */
105    $('a[href="#header-search"]').on("click", function (event) {
106        event.preventDefault();
107        $("#header-search").addClass("open");
108        $('#header-search > form > input[type="search"]').focus();
109    });
110
111    $("#header-search, #header-search button.close").on("click keyup", function (event) {
112        if (
113            event.target === this ||
114            event.target.className === "close" ||
115            event.keyCode === 27
116        ) {
117            $(this).removeClass("open");
118        }
119    });
120
121    /* masonary */
122    var galleryIsoContainer = $(".rt-masonry-grid");
123    if (galleryIsoContainer.length) {
124        var imageGallerIso = galleryIsoContainer.imagesLoaded(function () {
125            imageGallerIso.isotope({
126                itemSelector: ".rt-grid-item",
127                percentPosition: true,
128                isAnimated: true,
129                masonry: {
130                    columnWidth: ".rt-grid-item",                        
131                },
132                animationOptions: {
133                    duration: 700,
134                    easing: 'linear',
135                    queue: false
136                }
137            });
138        });
139    }
140    
141    /* Mobile menu */
142    $(window).on('scroll', function () {
143        if ($(this).scrollTop() > 100) {
144            $("body").addClass("not-top");
145            $("body").removeClass("top");
146        } else {
147            $("body").addClass("top");
148            $("body").removeClass("not-top");
149        }
150    });
151
152    /*Social print*/
153    $(document).on('click', '.print-share-button', function (e) {
154        console.log();
155        e.preventDefault();
156        window.print();
157        return false;
158    });
159
160    /* Search Box */
161    $(".search-box-area").on('click', '.search-button, .search-close', function (event) {
162        event.preventDefault();
163        if ($('.search-text').hasClass('active')) {
164            $('.search-text, .search-close').removeClass('active');
165        } else {
166            $('.search-text, .search-close').addClass('active');
167        }
168        return false;
169    });
170
171    // Advanced Search Revel
172    $(".advanced-btn").on("click", function () {
173        $(this).toggleClass("collapsed");
174        $("#advanced-search").toggleClass("show");
175
176    });
177
178    /* Header Right Menu */
179    var menuArea = $('.additional-menu-area');
180    menuArea.on('click', '.side-menu-trigger', function (e) {
181        e.preventDefault();
182        var self = $(this);
183        if (self.hasClass('side-menu-open')) {
184            if( toyupObj.rtl =='rtl'  ) {
185                $('.sidenav').css('transform', 'translateX(0%)');
186            }else {
187                $('.sidenav').css('transform', 'translateX(0%)');
188            }
189            if (!menuArea.find('> .rt-cover').length) {
190                menuArea.append("<div class='rt-cover'></div>");
191            }
192            self.removeClass('side-menu-open').addClass('side-menu-close');
193        }
194    });
195	
196	/*-------------------------------------
197	Offcanvas Menu activation code
198	-------------------------------------*/
199    function closeMenuArea() {
200        var trigger = $('.side-menu-trigger', menuArea);
201        trigger.removeClass('side-menu-close').addClass('side-menu-open');
202        if (menuArea.find('> .rt-cover').length) {
203            menuArea.find('> .rt-cover').css('animation', 'slideInLeft 0.31s');
204            setTimeout(()=>{
205                menuArea.find('> .rt-cover').remove();    
206            },500)            
207        }
208
209        if( toyupObj.rtl =='rtl'  ) {
210            $('.sidenav').css('transform', 'translateX(120%)');
211        }else {
212            $('.sidenav').css('transform', 'translateX(-120%)');
213        }
214    }
215
216    menuArea.on('click', '.closebtn', function (e) {
217        e.preventDefault();
218        closeMenuArea();
219    });
220
221    $(document).on('click', '.rt-cover', function () {
222        closeMenuArea();
223    });
224	
225    /*-------------------------------------
226    MeanMenu activation code
227    --------------------------------------*/
228    var a = $('.offscreen-navigation .menu');
229    if (a.length) {
230        $(".menu-item-has-children").append("<span></span>");
231        $(".page_item_has_children").append("<span></span>");
232
233        a.children("li").addClass("menu-item-parent");
234
235        $('.menu-item-has-children > span').on('click', function () {
236            var _self = $(this),
237                sub_menu = _self.parent().find('>.sub-menu');
238            if (_self.hasClass('open')) {
239                sub_menu.slideUp();
240                _self.removeClass('open');
241            } else {
242                sub_menu.slideDown();
243                _self.addClass('open');
244            }
245        });
246        $('.page_item_has_children > span').on('click', function () {
247            var _self = $(this),
248                sub_menu = _self.parent().find('>.children');
249            if (_self.hasClass('open')) {
250                sub_menu.slideUp();
251                _self.removeClass('open');
252            } else {
253                sub_menu.slideDown();
254                _self.addClass('open');
255            }
256        });
257    }
258
259    $('.mean-bar .sidebarBtn').on('click', function (e) {
260        e.preventDefault();
261        $('body').toggleClass('slidemenuon');
262    });
263
264    /*Header and mobile menu stick*/
265    $(window).on('scroll', function () {
266        if ($('body').hasClass('sticky-header')) {
267            // Sticky header
268            var stickyPlaceHolder = $("#sticky-placeholder"),
269                menu = $("#header-menu"),
270                menuH = menu.outerHeight(),
271                topHeaderH = $('#tophead').outerHeight() || 0,
272                middleHeaderH = $('#header-middlebar').outerHeight() || 0,
273                targrtScroll = topHeaderH + middleHeaderH;
274            if ($(window).scrollTop() > targrtScroll) {
275                menu.addClass('rt-sticky');
276                stickyPlaceHolder.height(menuH);
277            } else {
278                menu.removeClass('rt-sticky');
279                stickyPlaceHolder.height(0);
280            }
281
282            // Sticky mobile header
283            var stickyPlaceHolder = $("#mobile-sticky-placeholder"),
284                menu = $(".mobile-mene-bar"),
285                menuH = menu.outerHeight(),
286                topAdminH = $('#wpadminbar').outerHeight() || 0,
287                targrtScroll = topAdminH;
288            if ($(window).scrollTop() > targrtScroll) {
289                menu.addClass('mobile-sticky');
290               stickyPlaceHolder.height(menuH);
291            } else {
292                menu.removeClass('mobile-sticky');
293                stickyPlaceHolder.height(0);
294            }
295        }
296    });
297
298    // Popup - Used in video
299    if (typeof $.fn.magnificPopup == 'function') {
300        $('.rt-video-popup').magnificPopup({
301            type: 'iframe',
302            mainClass: 'mfp-fade',
303            removalDelay: 160,
304            preloader: false,
305            fixedContentPos: false
306        });
307        $('.open-popup-link').magnificPopup({
308            type: 'inline',
309            midClick: true,
310            mainClass: 'mfp-fade'
311        });
312    }
313
314    /* when product quantity changes, update quantity attribute on add-to-cart button */
315    $("form.cart").on("change", "input.qty", function () {
316        var isgroup = $(this).parents('.woocommerce-grouped-product-list');
317        if (this.value === "0"){
318            if( ! isgroup.length > 0 ){
319                this.value = "1";
320            }
321        }
322        $(this.form).find("button[data-quantity]").data("quantity", this.value);
323    });
324
325    /* remove old "view cart" text, only need latest one thanks! */
326    $(document.body).on("adding_to_cart", function () {
327        $("a.added_to_cart").remove();
328    });
329
330    /*Quantity Product*/
331    $(document).on('click', '.quantity .input-group-btn .quantity-btn', function () {
332        var $input = $(this).closest('.quantity').find('.input-text');
333        if ($(this).hasClass('quantity-plus')) {
334            $input.trigger('stepUp').trigger('change');
335        }
336        if ($(this).hasClass('quantity-minus')) {
337            $input.trigger('stepDown').trigger('change');
338        }
339    });
340
341    $('.quantity-btn').on('click', function(){
342        $("button[name='update_cart']").prop('disabled', false);
343    });
344
345});
346
347//function Load
348function toyup_content_load_scripts() {
349    var $ = jQuery;
350    // Preloader
351    $('#preloader').fadeOut('slow', function () {
352        $(this).remove();
353    });
354
355    var windowWidth = $(window).width();
356
357    imageFunction();
358    function imageFunction() {
359        $("[data-bg-image]").each(function () {
360        let img = $(this).data("bg-image");
361            $(this).css({
362                backgroundImage: "url(" + img + ")",
363            });
364        });
365    }
366
367    // pricing table
368    const pricingWrapper = $(".rt-pricing-tab");
369    if (pricingWrapper) {
370        $(".rt-pricing-tab").each(function() {
371            $(".pricing-switch-container").on("click", function() {
372                $(".pricing-switch")
373                    .parents(".price-switch-box")
374                    .toggleClass("price-switch-box--active"),
375                    $(".pricing-switch").toggleClass("pricing-switch-active"),
376                    $(".rt-tab-content").toggleClass("rt-active");
377            });
378        });
379    }
380
381    /* Wow Js Init */
382    var wow = new WOW({
383        boxClass: 'wow',
384        animateClass: 'animated',
385        offset: 0,
386        mobile: false,
387        live: true,
388        scrollContainer: null,
389    });
390    new WOW().init();
391
392    /* Swiper slider */
393    $('.rt-swiper-slider').each(function() {
394        var $this = $(this);
395        var settings = $this.data('xld');
396        var autoplayconditon= settings['auto'];
397        var $pagination = $this.find('.swiper-pagination')[0];
398        var $next = $this.find('.swiper-button-next')[0];
399        var $prev = $this.find('.swiper-button-prev')[0];
400        var swiper = new Swiper( this, {
401                autoplay: autoplayconditon ? { delay:settings['autoplay']['delay'] } : false,
402                speed: settings['speed'],
403                loop:  settings['loop'],
404                pauseOnMouseEnter :true,
405                slidesPerView: settings['slidesPerView'],
406                spaceBetween:  settings['spaceBetween'],
407                centeredSlides:  settings['centeredSlides'], 
408                slidesPerGroup: settings['slidesPerGroup'],
409                pagination: {
410                    el: $pagination,
411                    clickable: true,
412                    type: 'bullets',
413                },
414                navigation: {
415                    nextEl: $next,
416                    prevEl: $prev,
417                },
418                breakpoints: {
419                0: {
420                    slidesPerView: settings['breakpoints']['0']['slidesPerView'],
421                },
422                425: {
423                    slidesPerView: settings['breakpoints']['425']['slidesPerView'],
424                },
425                576: {
426                    slidesPerView: settings['breakpoints']['576']['slidesPerView'],
427                },
428                768: {
429                    slidesPerView: settings['breakpoints']['768']['slidesPerView'],
430                },
431                992: {
432                    slidesPerView: settings['breakpoints']['992']['slidesPerView'],
433                },
434                1200: {
435                    slidesPerView:  settings['breakpoints']['1200']['slidesPerView'],
436                },
437                1600: {
438                    slidesPerView: settings['breakpoints']['1600']['slidesPerView'],
439                },
440            },
441            on: {
442                afterInit: function (slider) {
443                    if(settings['centeredSlides']){
444                        $(slider.$wrapperEl).find('.swiper-slide').removeClass('visible-first visible-last');
445                        $(slider.$wrapperEl).find('.swiper-slide.swiper-slide-prev').prev(".
445swiper-slide").addClass('visible-first');
446                        $(slider.$wrapperEl).find('.swiper-slide.swiper-slide-next').next(".swiper-slide").addClass('visible-last');
447                    }
448                },
449                slideChangeTransitionStart: function (slider) {
450                    if(settings['centeredSlides']){
451                        $(slider.$wrapperEl).find('.swiper-slide').removeClass('visible-first visible-last');
452                        $(slider.$wrapperEl).find('.swiper-slide.swiper-slide-prev').prev(".swiper-slide").addClass('visible-first');
453                        $(slider.$wrapperEl).find('.swiper-slide.swiper-slide-next').next(".swiper-slide").addClass('visible-last');
454                    }
455                },        
456            }
457        });
458        swiper.init();
459    });
460
461    /*-------------------------------------
462    Countdown activation code
463    -------------------------------------*/
464
465    if ('function' === typeof $.fn.countdown) {
466        $('.rt-countdown').each(function () {
467            var date = $(this).data('date');
468            $(this).countdown(date, function (event) {
469                var $this = $(this).html(event.strftime("<div class='countdown-section'><div class='countdown-number'>%D</div> <div class='countdown-unit'>"+toyupObj.day+"</div> </div><div class='countdown-section'><div class='countdown-number'>%H</div> <div class='countdown-unit'>"+toyupObj.hour+"</div> </div><div class='countdown-section'><div class='countdown-number'>%M</div> <div class='countdown-unit'>"+toyupObj.minute+"</div> </div><div class='countdown-section'><div class='countdown-number'>%S</div> <div class='countdown-unit'>"+toyupObj.second+"</div> </div>"));
470            });
471        });
472    }
473}
474
475(function ($) {
476    "use strict";
477
478    // Window Load+Resize
479    $(window).on('load resize', function () {
480
481        // Define the maximum height for mobile menu
482        var wHeight = $(window).height();
483        wHeight = wHeight - 50;
484        $('.mean-nav > ul').css('max-height', wHeight + 'px');
485
486        // Elementor Frontend Load
487        $(window).on('elementor/frontend/init', function () {
488            if (elementorFrontend.isEditMode()) {
489                elementorFrontend.hooks.addAction('frontend/element_ready/widget', function () {
490                    toyup_content_load_scripts();
491                });
492            }
493        });
494
495    });
496
497    // product cat advanced search
498    function category_search_dropdown() {
499        $('.category-search-dropdown-js .dropdown-menu li').on('click', function (e) {
500            var root_parent = $(this).parents('.product-search');
501            var $parent = $(this).closest('.category-search-dropdown-js'),
502              slug = $(this).data('slug'),
503              name = $(this).text();
504            $parent.find('.cat-toggle .cat-label').text($.trim(name));
505            $parent.find('input[name="product_cat"]').val(slug);
506            root_parent.find('.product-autocomplete-js').data('tax', slug);
507            root_parent.find('.product-autocomplete-js').trigger('keyup');
508          });
509    
510          $(document).on('keyup', '.product-autocomplete-js', function () {
511    
512            var root_parent = $(this).parents('.product-search');
513            var keyword = root_parent.find('.product-autocomplete-js').val();
514            var taxonomy = root_parent.find('.product-autocomplete-js').data('tax');
515    
516            if ( keyword.length > 1 ) {
517              $.ajax({
518                url: toyupObj.ajaxURL,
519                type: 'POST',
520                data: {
521                  'action': 'toyup_product_search_autocomplete',
522                  'category_val': taxonomy,
523                  'keyword': keyword,
524                },
525                beforeSend: function () {
526                  root_parent.find('.product-autoaomplete-spinner').css('opacity', '1');
527                },
528                success: function (data) {              
529                  root_parent.find('.result').html(data);
530                },
531                complete: function () {
532                  root_parent.find('.product-autoaomplete-spinner').css('opacity', '0');
533                }
534              });
535            } else {
536                root_parent.find('.result').empty();
537            }
538        });
539    
540        $(document).on('click', function (e) {
541            var t = e.srcElement || e.target;
542            if ($(t).attr('class')) {
543              $('.result-wrap').remove();
544            } else {
545    
546            }    
547        });
548    
549    } 
550      
551    $(document).ready(function(){
552        category_search_dropdown();
553    });
554
555    // Window Load
556    $(window).on('load', function () {
557        toyup_content_load_scripts();
558    });
559
560    //single progress bar
561    $(window).on('scroll', scrollFunction);
562    function scrollFunction() {
563        var target = $('#contentHolder');        
564        if ( target.length > 0 ) {
565            var contentHeight = target.outerHeight();
566            var documentScrollTop = $(document).scrollTop();
567            var targetScrollTop = target.offset().top;
568            var scrolled = documentScrollTop - targetScrollTop;
569            
570            if (0 <= scrolled) {
571                var scrolledPercentage = (scrolled / contentHeight) * 100;
572                if (scrolledPercentage >= 0 && scrolledPercentage <= 100) {
573                    scrolledPercentage = scrolledPercentage >= 90 ? 100 : scrolledPercentage;
574                    $("#toyupBar").css({
575                        width: scrolledPercentage + "%"
576                    });
577                }
578            } else {
579                $("#toyupBar").css({
580                    width: "0%"
581                });
582            }
583        }
584    }
585
586})(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.