PageSourceSearch

https://spbindia.com/wp-content/themes/wp-giving/assets/js/main.js?ver=1.0.0

js spbindia.com collected 2026-09-25 02:11:46 UTC 24,933 bytes, 631 lines download raw bytes

1(function($) { 
2	var window_width, window_height, scroll_top;
3	var adminbar;
4    var _adminBarHeight;
5	var _lastScrollTop;
6	var header;
7	var header_top = 0;
8	var scroll_status = '';
9	var trigger_phone = false;
10	var _e_countdown = [];
11
12	var WpGiving = {
13		onReady: function() { 
14			scroll_top = $(window).scrollTop();
15			/** current window width */
16			window_width = $(window).width();
17			_adminBarHeight = $( 'body' ).is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
18            _lastScrollTop = $( window ).scrollTop();
19			/** current window height */
20			window_height = $(window).height();
21			/* get admin bar height */
22			adminbar_height = $('body').is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
23			/* get top header menu */
24			header_top = $('.site-header').length > 0 ? $('.site-header').offset().top - adminbar_height : 0 ;
25
26			this.backToTop();
27            this.stickyNavigation();
28            this.cmsCarousel();
29
30			/* Back to top */
31			$('body').on('click', '.ef3-back-to-top', function () {
32				$('body, html').animate({scrollTop:0}, '1000');
33			});
34
35			/* Onepage */
36			if(typeof(one_page_options) != "undefined"){
37				one_page_options.speed = parseInt(one_page_options.speed);
38				$('#site-navigation').singlePageNav(one_page_options);
39			}
40
41			/* Fit video */
42			$('.gv-blog-loop, .gv-blog-single').fitVids();
43
44			/* Wow animate */
45			if ( $('.wow').length ) {
46			    this.initWow(); 
47			};
48
49			$('[data-toggle="tooltip"]').tooltip();
50			$('[data-toggle="popover"]').popover();
51
52            this.rowParallax();
53            this.countDownTime();
54            this.primaryMenu();
55            this.initCircleCounter('.circle-bar-wrap');
56            this.givingPopup();
57            this.cmsEventMap();
58            this.givingXCarousel();
59            this.searchPopup();
60            this.miniCartSearch();
61            this.removeCartItem();
62
63            /* page title parallax */
64            /*$('.site-header').parallax('50%', 0.6);*/
65
66            $('.widget, .woocommerce-ordering, .variations').each(function() {
67                $(this).find('select').wrap('<div class="giving-select-wrap"></div>');
68            });
69
70            /*Woo button*/
71            $('input.minus').click(function(){
72                $(this).parent().find('input.input-text').get(0).stepDown();
73            });
74            $('input.plus').click(function(){
75                $(this).parent().find('input.input-text').get(0).stepUp();
76            });
77		},
78
79		onResize: function() {
80		
81		},
82
83        primaryMenu: function() { 
84            if($(window).width() > 991){
85                var $menu = $('.nav-menu');
86                $menu.find('ul.sub-menu > li').each(function(){
87                    var $submenu = $(this).find('>ul');
88                    if($submenu.length == 1){
89                        $(this).hover(function(){
90                            if($submenu.offset().left + $submenu.width() > $(window).width()){
91                                $submenu.addClass('back');
92                            }else if($submenu.offset().left < 0){
93                                $submenu.addClass('back');
94                            }
95                        }, function(){
96                            $submenu.removeClass('back');
97                        });
98                    }
99                });
100            }
101            /* Menu drop down*/
102
103            $('.nav-menu li.menu-item-has-children').append('<span class="cs-menu-toggle"><i class="fa fa-angle-down"></i></span>');
104            $('.cs-menu-toggle').on('click', function(){
105                $(this).prev().toggleClass('submenu-open').slideToggle();
106            });
107            /* Page Fixed Menu */
108            $('.header-fixed-page').parents('body').addClass('remove-margin-top');
109            $('#cshero-header.no-sticky').parents('body').addClass('remove-margin-top');
110        },
111
112        cmsCarousel: function() {
113            if ( $('.cms-carousel-wrapper .cms-owl-carousel').length ) {
114                $('.cms-carousel-wrapper .cms-owl-carousel').each(function() {
115                    var owl = $(this),
116                        options = owl.data( 'carousel' );
117
118                    owl.owlCarousel(options);
119                });
120            }
121        },
122
123        givingXCarousel: function() {
124            $( '.cms-carousel' ).each( function() {
125                var owl = $(this),
126                    options = owl.data( 'carousel-options' );
127
128                owl.on('initialize.owl.carousel', function () {
129                    setTimeout(function(){
130                        owl.trigger('refresh.owl.carousel')
131                    }, 100)
132                })
133                .owlCarousel(options);
134            });
135        },
136
137        countDownTime: function() {
138            if ( $('.countdown').length ) {
139                $('.countdown').each(function(i, el) {
140                    $(el).final_countdown();
141                });
142            }
143        },
144
145        searchPopup: function() {
146            $(document).on('click touchstart',function(e) {
147                if(e.target.className == 'cshero-popup-search open')
148                $('.cshero-popup-search').removeClass('open');
149            });
150
151            $('.header-search-cart .icon-search').on('click', function(){
152                $('.cshero-popup-search').toggleClass('open');
153                setTimeout(function() {$('.cshero-search-inner .searchform  .s').focus();}, 500);
154            });
155        },
156
157        removeCartItem: function() {
158            $('.mini_cart_item .pull-left > a.remove').click(function() {
159                $(this).html('<i class="fa fa-spinner fa-spin"></i>');
160                var product_id = $(this).attr("data-product_id");
161                $.ajax({
162                    type: 'POST',
163                    dataType: 'json',
164                    url: wc_add_to_cart_params.ajax_url,
165                    data: { action: "product_remove", 
166                            product_id: product_id
167                    },success: function(data){
168                        WpGiving.updateCartFragment();
169                    }
170                });
171                return false;
172            });
173        },
174
175        updateCartFragment: function() {
176            var $fragment_refresh = {
177                url: wc_add_to_cart_params.ajax_url,
178                type: 'POST',
179                data: { action: 'woocommerce_get_refreshed_fragments' },
180                success: function( data ) {console.log(data);
181                    if ( data && data.fragments ) {          
182                        jQuery.each( data.fragments, function( key, value ) {
183                            jQuery(key).replaceWith(value);
184                        });             
185                        //jQuery('body').trigger( 'wc_fragments_refreshed' );
186                    }
187                }
188            };
189
190            //Always perform fragment refresh
191            jQuery.ajax( $fragment_refresh );  
192        },
193
194        miniCartSearch: function() {
195            var display;
196            var no_display;
197            $('body').click(function (e) {
198                var target = $(e.target);
199                if (target.parents('.shopping_cart_dropdown').length == 0 && !target.hasClass('shopping_cart_dropdown')) {
200                    $('.widget_searchform_content,.shopping_cart_dropdown').removeClass('active').slideUp();
201                }
202            });
203            $('.widget_searchform_content,.shopping_cart_dropdown').click(function (e) {
204                e.stopPropagation();
205            });
206            $('.widget_cart_search_wrap [data-display]').click(function (e) {
207                var container = $(this).parents('.widget_cart_search_wrap');
208                e.stopPropagation();
209                var _this = $(this);
210                display = _this.attr('data-display');
211                no_display = _this.attr('data-no_display');
212                $(display, container).css({
213                    right: 0
214                });
215                if ($(display, container).hasClass('active')) {
216                    $(display, container).removeClass('active').slideUp();
217                } else {
218                    if (display == '.widget_searchform_content') {
219                        $(display, container).addClass('active').css('display', 'block');
220                        $(no_display, container).removeClass('active').slideUp();    
221                    }
222                    $(display, container).addClass('active').slideDown().css('display', 'block');
223                    $(no_display, container).removeClass('active').slideUp();
224
225                    var offset = $(display, container).offset().left + $(display).outerWidth() - $(window).width()
226                    if (offset > 0) {
227                        $(display, container).css({
228                            right: 0 - offset
229                        });
230                    } else {
231                        $(display, container).css({
232                            right: 0
233                        });
234
235                    }
236                }
237            });
238
239            /*Scroll on cart*/
240            setTimeout(function () {
241                $('.shopping_cart_dropdown_inner').css({
242                    maxHeight: '300px',
243                    overflow: 'hidden'
244                }).bind('mousewheel', function (event) {
245                    event.preventDefault();
246                    var scrollTop = this.scrollTop;
247                    this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
248                });
249            }, 1000);
250            
251            $('.shopping_cart_dropdown_inner').css({maxHeight:'300px'}).bind('mousewheel', function (event) {
252                event.preventDefault();
253                var scrollTop = this.scrollTop;
254                this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
255            });
256        },
257
258        givingPopup: function() { 
259            /* gallery */
260            $('.cause-gallery, .images.width-1lit').magnificPopup({
261                delegate: '.lightbox, .zoom',
262                type: 'image',
263                tLoading: 'Loading image #%curr%...',
264                mainClass: 'mfp-3d-unfold',
265                removalDelay: 500, /*delay removal by X to allow out-animation*/
266                callbacks: {
267                    beforeOpen: function() {
268                        /*just a hack that adds mfp-anim class to markup */
269                        this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
270                        /*this.st.mainClass = this.st.el.attr('data-effect');*/
271                    }
272                },
273                gallery: {
274                    enabled: true,
275                    navigateByImgClick: true,
276                    preload: [0,1] /* Will preload 0 - before current, and 1 after the current image*/
277                },
278                image: {
279                    tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
280                    /*titleSrc: function(item) {
281                    return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';
282                    }*/
283                }
284            });
285        
286            /*$('.cms-video-popup, .cms-lightbox-map').magnificPopup({
287                type: 'iframe',
288                mainClass: 'mfp-fade',
289                removalDelay: 160,
290                preloader: false,
291                fixedContentPos: false
292            });*/
293        },
294
295        initCircleCounter: function(selector, callback) {
296            if ( $(selector).length ) {
297
298                $(selector).each(function() {
299                    var $this = $(this).find('.circle-inner');
300
301                    var _barcolor = $this.data('barcolor'),
302                        _trackcolor = $this.data('trackcolor'),
303                        _size = $this.data('size'),
304                        _linewidth = $this.data('linewidth');
305
306                    $this.easyPieChart({
307                        animate: 3000,
308                        barColor: _barcolor,
309                        trackColor: _trackcolor,
310                        /*easing: 'easeOutBounce',*/
311                        size: _size,
312                        lineWidth: _linewidth,
313                        lineCap: 'rectAngle', // rectAngle or round
314                        scaleColor: false,
315                        onStep: function(from, to, percent) {
316                            $this.parents('.cause-loop, .gv-zodonations-single, .cms-cause-single').find('.cause-circle-status .status-bar div').css('width', Math.round(percent)+'%');
317                        }
318                    });
319                });
320            }
321        },
322
323        cmsCarousel: function() {
324            if ( $('.cms-carousel-wrapper .cms-owl-carousel').length ) {
325                $('.cms-carousel-wrapper .cms-owl-carousel').each(function() {
326                    var owl = $(this),
327                        options = owl.data( 'carousel' );
328
329                    owl.owlCarousel(options);
330                });
331            }
332        },
333
334        cmsEventMap: function() {
335            if ( $('#_eventMap').length ) {
336                google.maps.event.addDomListener(window, 'load', _eventMap);
337                function _eventMap() {
338                    var map = new google.maps.Map(document.getElementById('_eventMap'), {
339                        zoom: 16,
340                        scrollwheel: false,
341                        scaleControl: false,
342                        draggable: true,
343                        center: {lat: -34.397, lng: 150.644},
344                        styles: [{"stylers":[{"hue":"#ff1a00"},{"invert_lightness":true},{"saturation":-100},{"lightness":33},{"gamma":0.5}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#2D333C"}]}]
345                    });
346                    var geocoder = new google.maps.Geocoder();
347                    var address = jQuery(document).find('.gv-event-single .meta-info .event-local').html();
348                    geocodeAddress(address, geocoder, map);
349                }  
350
351                function geocodeAddress(address, geocoder, resultsMap) {
352                    geocoder.geocode({'address': address}, function(results, status) {
353                      if (status === 'OK') {
354                        resultsMap.setCenter(results[0].geometry.location);
355                        var marker = new google.maps.Marker({
356                          map: resultsMap,
357                          //icon: CMSOptions.map_marker,
358                          position: results[0].geometry.location
359                        });
360                      } else {
361                        console.log('Geocode was not successful for the following reason: ' + status);
362                      }
363                    });
364                }    
365            }
366        },
367
368        rowParallax: function() {
369            var isMobile = {
370                Android: function() {
371                    return navigator.userAgent.match(/Android/i);
372                },
373                BlackBerry: function() {
374                    return navigator.userAgent.match(/BlackBerry/i);
375                },
376                iOS: function() {
377                    return navigator.userAgent.match(/iPhone|iPad|iPod/i);
378                },
379                Opera: function() {
380                    return navigator.userAgent.match(/Opera Mini/i);
381                },
382                Windows: function() {
383                    return navigator.userAgent.match(/IEMobile/i);
384                },
385                any: function() {
386                    return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
387                }
388            };
389
390            var testMobile = isMobile.any();
391
392            $('.vc_parallax_row').each(function() {
393                var $this = $(this),
394                    _bg = $this.find('.wpc_parallax_bg'),
395                    _image_url = $this.data('vc-parallax-image');
396
397                if ( _image_url == undefined || _image_url == null ) {
398                    _image_url = $this.css('background-image');
399
400                    $(_bg).css('backgroundImage', _image_url);
401                } else {
402                    $(_bg).css('backgroundImage', 'url(' + _image_url + ')');
403                }
404
405                $this.find('.wpc_parallax_overlay').addClass('hidden');
406
407                if (testMobile == null) {
408                    $(_bg).addClass('not-mobile').removeClass('is-mobile');
409
410                    setTimeout(function(){
411                        $this.find('.wpc_parallax_overlay').removeClass('hidden');
412                        $(_bg).parallax('50%', 0.4);
413                    }, 100);
414                }
415                else {
416                    $(_bg).removeClass('not-mobile').addClass('is-mobile');
417                }
418            });
419        },
420
421		pieChart: function() {
422			/*pie char*/
423			$('.vc_pie_chart').each(function() {
424				$(this).waypoint(
425					function() {
426						$(this).circliful();
427					}, {
428						offset : '95%',
429						triggerOnce : true
430				});	
431			});
432		},
433
434        initWow: function() {
435            var wow = new WOW( {
436                mobile: false, 
437                live : true,
438                offset: 0,
439            } );
440            
441            wow.init();
442        },
443
444        backToTop: function() {
445            /* back to top */
446            if (scroll_top < window_height) {
447                $('.ef3-back-to-top').addClass('off').removeClass('on');
448            } else {
449                $('.ef3-back-to-top').removeClass('off').addClass('on');
450            }
451        },
452
453		/* Primary Menu Sticky */
454		stickyNavigation: function() {
455            // Fixed navigation init
456            var navFixed = {
457                desktop: true,
458                mobile: false,
459                height: 70
460            };
461            var navContainer = $( '.cshero-main-header' );
462            $.extend( navFixed, navContainer.data( 'fixed' ) );
463
464            if ( navFixed.desktop || navFixed.mobile )
465            {
466                var navPlaceHolder = navContainer.outerHeight( false ),
467                    navContainerTop = navContainer.offset().top - _adminBarHeight,
468                    navClass = '',
469                    navHolder;
470
471                navContainerTop = navContainerTop > 0 ? navContainerTop : 0;
472
473                if ( navFixed.desktop )
474                {
475                    navClass += ' fixed-big';
476                }
477                if ( navFixed.mobile )
478                {
479                    navClass += ' fixed-small';
480                }
481                navClass = $.trim( navClass );
482
483                navContainer.attr( 'data-sticked', 'false' );
484                navContainer.after( '<div id="nav-holder" class="main-navigation-placeholder" style="height:' + navPlaceHolder + 'px;"></div>' );
485                navHolder = $( '#nav-holder');
486                navHolder.hide();
487
488                var scrollHandler = function()
489                {
490                    if ( window.innerWidth < 992 )
491                    {
492                        if ( ! navFixed.mobile )
493                            return;
494                    }
495                    if ( window.innerWidth >= 992 )
496                    {
497                        if ( ! navFixed.desktop )
498                            return;
499                    }
500
501                    var scrollPos = $( window ).scrollTop(),
502                        calculatedHeight = 0;
503
504                    if ( 'true' == navContainer.attr( 'data-sticked' ) && scrollPos < navContainer.outerHeight( false ) + navContainerTop && scrollPos - _lastScrollTop < 0 )
505                    {
506                        navContainer.attr( 'data-sticked', 'false' );
507                    }
508                    
509                    if ( scrollPos > navContainerTop )
510                    {
511                        if ( 'true' == navContainer.attr( 'data-sticked' ) )
512                        {
513                            return;
514                        }
515
516                        if ( ! navHolder.is( ':visible' ) )
517                        {
518                            navHolder.show();
519                        }
520
521                        if ( navFixed.height < navPlaceHolder )
522                        {
523                            calculatedHeight = navPlaceHolder - ( scrollPos - navContainerTop );
524                            if ( calculatedHeight <= navFixed.height )
525                            {
526                                navContainer.css( { height: navFixed.height } );
527                                navContainer.attr( 'data-sticked', 'true' );
528                            }
529                            else
530                            {
531                                navContainer.css( { height: calculatedHeight } );
532                            }
533                        }
534                        else if ( navFixed.height > navPlaceHolder )
535                        {
536                            calculatedHeight = navPlaceHolder + ( scrollPos - navContainerTop );
537                            if ( calculatedHeight <= navFixed.height )
538                            {
539                                navContainer.css( { height: calculatedHeight } );
540                            }
541                            else
542                            {
543                                navContainer.css( { height: navFixed.height } );
544                                navContainer.attr( 'data-sticked', 'true' );
545                            }
546                        }
547                        else
548                        {
549                            navContainer.css( { height: '' } );
550                            navContainer.attr( 'data-sticked', 'true' );
551                        }
552
553                        navContainer.css( { top: _adminBarHeight } );
554                        navContainer.addClass( navClass );
555                    }
556                    else {
557                        navContainer.css( { top: '', height: '' } );
558                        navContainer.attr( 'data-sticked', 'false' );
559                        navContainer.removeClass( navClass );
560                        navHolder.hide();
561                    }
562
563                    _lastScrollTop = scrollPos;
564                };
565
566                scrollHandler();
567
568                $( window ).on( 'resize', function()
569                {
570                    if ( ( navFixed.desktop && window.innerWidth < 1230 ) || ( navFixed.mobile && window.innerWidth > 1230 ) )
571                    {
572                        if ( navHolder.is( ':visible' ) )
573                        {
574                            navHolder.hide();
575                        }
576                        navContainer.css( { height: '', top: '' } );
577                        navContainer.removeClass( navClass );
578                    }
579                    else
580                    {
581                        scrollHandler();
582                    }
583                } );
584
585                
586                $( window ).on( 'scroll', function() {
587                    scrollHandler();
588                } );
589            }
590        },
591	};
592
593	$( document ).ready( function() {
594		"use strict";
595		WpGiving.onReady();
596
597		$(window).resize(function () {
598			WpGiving.onResize();	
599		});
600
601		$(window).scroll(function() {
602			scroll_top = $(window).scrollTop();
603			WpGiving.backToTop();
604		});
605
606		$(document).ajaxComplete(function(event, xhr, settings){
607			$('.gv-blog-loop, .gv-blog-single').fitVids();
608            WpGiving.removeCartItem();
609            WpGiving.initCircleCounter('.circle-bar-wrap');
610		});
611
612        //Scroll on cart
613        setTimeout(function () {
614            $('.shopping_cart_dropdown_inner').css({
615                maxHeight: '300px',
616                overflow: 'hidden'
617            }).bind('mousewheel', function (event) {
618                event.preventDefault();
619                var scrollTop = this.scrollTop;
620                this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
621            });
622        }, 1000);
623        
624        $('.shopping_cart_dropdown_inner').css({maxHeight:'300px'}).bind('mousewheel', function (event) {
625            event.preventDefault();
626            var scrollTop = this.scrollTop;
627            this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
628        });
629	});
630	
631})(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.