PageSourceSearch

https://practicalmind.net/wp-content/themes/pma-theme/js/functions.js?ver=20150330

js practicalmind.net collected 2026-10-05 03:42:35 UTC 27,873 bytes, 708 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    if (!$.apusThemeExtensions)
5        $.apusThemeExtensions = {};
6    
7    function ApusThemeCore() {
8        var self = this;
9        // self.init();
10    };
11
12    ApusThemeCore.prototype = {
13        /**
14         *  Initialize
15         */
16        init: function() {
17            var self = this;
18            
19            self.preloadSite();
20
21            self.activeAccordion();
22            
23            // slick init
24            self.initSlick($("[data-carousel=slick]"));
25
26            // isoto
27            self.initIsotope();
28
29            // Unveil init
30            setTimeout(function(){
31                self.layzyLoadImage();
32            }, 200);
33
34            self.initHeaderSticky('main-sticky-header');
35
36            // back to top
37            self.backToTop();
38            
39            // popup image
40            self.popupImage();
41
42            $('[data-bs-toggle="tooltip"]').tooltip();
43
44            self.initMobileMenu();
45
46            self.mainMenuInit();
47
48            self.initVerticalMenu();
49            
50            setTimeout(function(){
51                self.changePaddingTopContent();
52            }, 200);
53
54            $(window).resize(function(){
55                setTimeout(function(){
56                    self.changePaddingTopContent();
57                }, 50);
58            });
59            
60            $(document.body).on('click', '.nav [data-toggle="dropdown"]', function(e){
61                e.preventDefault();
62                if ( this.href && this.href != '#' ){
63                    if ( this.target && this.target == '_blank' ) {
64                        window.open(this.href, '_blank');
65                    } else {
66                        window.location.href = this.href;
67                    }
68                }
69            });
70
71            $('.navbar-wrapper .show-navbar-sidebar').on('click', function(){
72                $(this).closest('.navbar-wrapper').find('.navbar-sidebar-wrapper').addClass('active');
73                $(this).closest('.navbar-wrapper').find('.navbar-sidebar-overlay').addClass('active');
74            });
75            
76            $('.close-navbar-sidebar, .navbar-sidebar-overlay').on('click', function(){
77                $(this).closest('.navbar-wrapper').find('.navbar-sidebar-wrapper').removeClass('active');
78                $(this).closest('.navbar-wrapper').find('.navbar-sidebar-overlay').removeClass('active');
79            });
80
81            if ( $('#course-tabs-spy').length ) {
82                var scrollSpy = new bootstrap.ScrollSpy(document.body, {
83                  target: '#course-tabs-spy'
84                });
85            }
86            
87            self.loadExtension();
88        },
89        /**
90         *  Extensions: Load scripts
91         */
92        loadExtension: function() {
93            var self = this;
94            
95            if ($.apusThemeExtensions.quantity_increment) {
96                $.apusThemeExtensions.quantity_increment.call(self);
97            }
98
99            if ($.apusThemeExtensions.shop) {
100                $.apusThemeExtensions.shop.call(self);
101            }
102
103            if ($.apusThemeExtensions.course) {
104                $.apusThemeExtensions.course.call(self);
105            }
106
107        },
108        initSlick: function(element) {
109            var self = this;
110            element.each( function(){
111                var config = {
112                    infinite: false,
113                    arrows: $(this).data( 'nav' ),
114                    dots: $(this).data( 'pagination' ),
115                    slidesToShow: 4,
116                    slidesToScroll: 4,
117                    prevArrow:"<button type='button' class='slick-arrow slick-prev'><i class='flaticon-back'></i></span><span class='textnav'>"+ educrat_opts.previous +"</span></button>",
118                    nextArrow:"<button type='button' class='slick-arrow slick-next'><span class='textnav'>"+ educrat_opts.next +"</span><i class='flaticon-next'></i></button>",
119                };
120                var slick = $(this);
121                if( $(this).data('items') ){
122                    config.slidesToShow = $(this).data( 'items' );
123                    var slidestoscroll = $(this).data( 'items' );
124                }
125                if( $(this).data('infinite') ){
126                    config.infinite = true;
127                }
128                if( $(this).data('autoplay') ){
129                    config.autoplay = true;
130                    config.autoplaySpeed = 2500;
131                }
132                if( $(this).data('disable_draggable') ){
133                    config.touchMove = false;
134                    config.draggable = false;
135                    config.swipe = false;
136                    config.swipeToSlide = false;
137                }
138                if( $(this).data('centermode') ){
139                    config.centerMode = true;
140                }
141                if( $(this).data('centerpadding') ){
142                    config.centerPadding = $(this).data( 'centerpadding' );
143                }
144                if( $(this).data('vertical') ){
145                    config.vertical = true;
146                }
147                if( $(this).data('rows') ){
148                    config.rows = $(this).data( 'rows' );
149                }
150                if( $(this).data('asnavfor') ){
151                    config.asNavFor = $(this).data( 'asnavfor' );
152                }
153                if( $(this).data('slidestoscroll') ){
154                    var slidestoscroll = $(this).data( 'slidestoscroll' );
155                }
156                if( $(this).data('focusonselect') ){
157                    config.focusOnSelect = $(this).data( 'focusonselect' );
158                }
159                config.slidesToScroll = slidestoscroll;
160
161
162                if ($(this).data('smalldesktop')) {
163                    var smalldesktop = $(this).data('smalldesktop');
164                } else {
165                    var smalldesktop = config.items;
166                }
167                if ($(this).data('large')) {
168                    var large = $(this).data('large');
169                } else {
170                    var large = 4;
171                }
172                if ($(this).data('medium')) {
173                    var medium = $(this).data('medium');
174                } else {
175                    var medium = 3;
176                }
177                if ($(this).data('small')) {
178                    var small = $(this).data('small');
179                } else {
180                    var small = 2;
181                }
182                if ($(this).data('smallest')) {
183                    var smallest = $(this).data('smallest');
184                } else {
185                    if ($(this).data('small')) {
186                        var smallest = $(this).data('small');
187                    } else{
188                        var smallest = 2;
189                    }
190                }
191
192
193                if ($(this).data('slidestoscroll_smalldesktop')) {
194                    var slidestoscroll_smalldesktop = $(this).data('slidestoscroll_smalldesktop');
195                } else {
196                    var slidestoscroll_smalldesktop = config.items;
197                }
198                if ($(this).data('slidestoscroll_large')) {
199                    var slidestoscroll_large = $(this).data('slidestoscroll_large');
200                } else {
201                    var slidestoscroll_large = large;
202                }
203                if ($(this).data('slidestoscroll_medium')) {
204                    var slidestoscroll_medium = $(this).data('slidestoscroll_medium');
205                } else {
206                    var slidestoscroll_medium = medium;
207                }
208                if ($(this).data('slidestoscroll_small')) {
209                    var slidestoscroll_small = $(this).data('slidestoscroll_small');
210                } else {
211                    var slidestoscroll_small = small;
212                }
213                if ($(this).data('slidestoscroll_smallest')) {
214                    var slidestoscroll_smallest = $(this).data('slidestoscroll_smallest');
215                } else {
216                    var slidestoscroll_smallest = smallest;
217                }
218
219                config.responsive = [
220
221                    {
222                        breakpoint: 576,
223                        settings: {
224                            slidesToShow: smallest,
225                            slidesToScroll: slidestoscroll_smallest,
226                        }
227                    },
228                    {
229                        breakpoint: 768,
230                        settings: {
231                            slidesToShow: small,
232                            slidesToScroll: slidestoscroll_small
233                        }
234                    },
235                    {
236                        breakpoint: 992,
237                        settings: {
238                            slidesToShow: medium,
239                            slidesToScroll: slidestoscroll_medium
240                        }
241                    },
242                    {
243                        breakpoint: 1200,
244                        settings: {
245                            slidesToShow: large,
246                            slidesToScroll: slidestoscroll_large
247                        }
248                    },
249                    {
250                        breakpoint: 1400,
251                        settings: {
252                            slidesToShow: smalldesktop,
253                            slidesToScroll: slidestoscroll_smalldesktop
254                        }
255                    }
256                ];
257
258                if ( $('html').attr('dir') == 'rtl' ) {
259                    config.rtl = true;
260                }
261
262                $(this).slick( config );
263
264            } );
265
266            // Fix owl in bootstrap tabs
267            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
268                var target = $(e.target).attr("href");
269                var $slick = $(".slick-carousel", target);
270
271                if ($slick.length > 0 && $slick.hasClass('slick-initialized')) {
272                    $slick.slick('refresh');
273                }
274                self.layzyLoadImage();
275            });
276
277            // Fix owl in bootstrap 5 tabs
278            $('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
279                var target = $(e.target).attr("href");
280                var $slick = $(".slick-carousel", target);
281
282                if ($slick.length > 0 && $slick.hasClass('slick-initialized')) {
283                    $slick.slick('refresh');
284                }
285                self.layzyLoadImage();
286            });
287        },
288        layzyLoadImage: function() {
289            $(window).off('scroll.unveil resize.unveil lookup.unveil');
290            var $images = $('.image-wrapper:not(.image-loaded) .unveil-image'); // Get un-loaded images only
291            if ($images.length) {
292                $images.unveil(1, function() {
293                    $(this).load(function() {
294                        $(this).parents('.image-wrapper').first().addClass('image-loaded');
295                        $(this).removeAttr('data-src');
296                        $(this).removeAttr('data-srcset');
297                        $(this).removeAttr('data-sizes');
298                    });
299                });
300            }
301
302            var $images = $('.product-image:not(.image-loaded) .unveil-image'); // Get un-loaded images only
303            if ($images.length) {
304                $images.unveil(1, function() {
305                    $(this).load(function() {
306                        $(this).parents('.product-image').first().addClass('image-loaded');
307                    });
308                });
309            }
310        },
311        initIsotope: function() {
312            $('.isotope-items').each(function(){  
313                var $container = $(this);
314                
315                $container.imagesLoaded( function(){
316                    $container.isotope({
317                        itemSelector : '.isotope-item',
318                        transformsEnabled: true,         // Important for videos
319                        masonry: {
320                            columnWidth: $container.data('columnwidth')
321                        }
322                    }); 
323                });
324            });
325
326            /*---------------------------------------------- 
327             *    Apply Filter        
328             *----------------------------------------------*/
329            $('.isotope-filter li a').on('click', function(){
330               
331                var parentul = $(this).parents('ul.isotope-filter').data('related-grid');
332                $(this).parents('ul.isotope-filter').find('li a').removeClass('active');
333                $(this).addClass('active');
334                var selector = $(this).attr('data-filter'); 
335                $('#'+parentul).isotope({ filter: selector }, function(){ });
336                
337                return(false);
338            });
339        },
340        initHeaderSticky: function(main_sticky_class) {
341            if ( $('.' + main_sticky_class).length ) {
342                if ( typeof Waypoint !== 'undefined' ) {
343                    if ( $('.' + main_sticky_class) && typeof Waypoint.Sticky !== 'undefined' ) {
344                        var sticky = new Waypoint.Sticky({
345                            element: $('.' + main_sticky_class)[0],
346                            wrapper: '<div class="main-sticky-header-wrapper">',
347                            offset: '-10px',
348                            stuckClass: 'sticky-header'
349                        });
350                    }
351                }
352            }
353        },
354        backToTop: function () {
355            $(window).scroll(function () {
356                if ($(this).scrollTop() > 400) {
357                    $('#back-to-top').addClass('active');
358                } else {
359                    $('#back-to-top').removeClass('active');
360                }
361            });
362            $('#back-to-top').on('click', function () {
363                $('html, body').animate({scrollTop: '0px'}, 800);
364                return false;
365            });
366        },
367            
368        popupImage: function() {
369            // popup
370            $(".popup-image").magnificPopup({type:'image'});
371            $('.popup-video').magnificPopup({
372                disableOn: 700,
373                type: 'iframe',
374                mainClass: 'mfp-fade',
375                removalDelay: 160,
376                preloader: false,
377                fixedContentPos: false
378            });
379
380            $('.widget-gallery').each(function(){
381                var tagID = $(this).attr('id');
382                $('#' + tagID).magnificPopup({
383                    delegate: '.popup-image-gallery',
384                    type: 'image',
385                    tLoading: 'Loading image #%curr%...',
386                    mainClass: 'mfp-img-mobile',
387                    gallery: {
388                        enabled: true,
389                        navigateByImgClick: true,
390                        preload: [0,1] // Will preload 0 - before current, and 1 after the current image
391                    }
392                });
393            });
394        },
395        preloadSite: function() {
396            // preload page
397            setTimeout(function(){
398                if ( $('body').hasClass('apus-body-loading') ) {
399                    $('body').removeClass('apus-body-loading');
400                    $('.apus-page-loading').fadeOut(100);
401                }
402            }, 100);
403        },
404        
405        activeAccordion: function() {
406            $('.panel-collapse').on('show.bs.collapse', function () {
407                $(this).siblings('.panel-heading').addClass('active');
408            });
409
410            $('.panel-collapse').on('hide.bs.collapse', function () {
411                $(this).siblings('.panel-heading').removeClass('active');
412            });
413        },
414
415        initMobileMenu: function() {
416
417            // stick mobile
418            var self = this;
419
420            // mobile menu
421            $('.btn-toggle-canvas,.btn-showmenu').on('click', function (e) {
422                e.stopPropagation();
423                $('.apus-offcanvas').toggleClass('active');           
424                $('.over-dark').toggleClass('active');
425
426                $("#mobile-menu-container").slidingMenu({
427                    backLabel: educrat_opts.menu_back_text
428                });
429            });
430            $('body').on('click', function() {
431                if ($('.apus-offcanvas').hasClass('active')) {
432                    $('.apus-offcanvas').toggleClass('active');
433                    $('.over-dark').toggleClass('active');
434                }
435            });
436            $('.apus-offcanvas').on('click', function(e) {
437                e.stopPropagation();
438            });
439            
440            // sidebar mobile       
441            $('body').on('click', '.mobile-sidebar-btn.btn-left', function(){
442                $('.sidebar-left').toggleClass('active');
443            });
444            $('body').on('click', '.mobile-sidebar-btn.btn-right', function(){
445                $('.sidebar-right').toggleClass('active');
446            });
447
448            $('body').on('click', '.mobile-sidebar-btn', function(){
449                $('.mobile-sidebar-panel-overlay').toggleClass('active');
450                $('.mobile-sidebar-btn i').toggleClass('ti-menu-alt ti-close');
451            });
452            $('body').on('click', '.mobile-sidebar-panel-overlay, .close-sidebar-btn', function(){
453                $('.sidebar').removeClass('active');
454                $('.mobile-sidebar-panel-overlay').removeClass('active');
455                $('.mobile-sidebar-btn i').toggleClass('ti-menu-alt ti-close');
456            });
457
458            $(window).scroll(function () {
459                if ($(window).width() <= 600) {
460                    if ( $('#wpadminbar').length ) {
461                        var admin_bar_h = $('#wpadminbar').outerHeight();
462                        var mobile = $('.header-mobile').outerHeight();
463                        var scroll_h = $(this).scrollTop();
464                        if (scroll_h > admin_bar_h) {
465                            $('.admin-bar .header-mobile').css({'top': 0});
466                            $('.admin-bar .wrapper-menu-dashboard').css({'top': mobile });
467                        } else {
468                            var top = admin_bar_h - scroll_h;
469                            $('.admin-bar .header-mobile').css({'top': top});
470                            $('.admin-bar .wrapper-menu-dashboard').css({'top': top + mobile });
471                        }
472                    }
473                }
474            });
475        },
476        mainMenuInit: function() {
477            $('.apus-megamenu .megamenu .has-mega-menu.aligned-fullwidth').each(function(e){
478                var $this = $(this),
479                    i = $this.closest(".elementor-container"),
480                    a = $this.closest('.apus-megamenu');
481                $this.on('hover', function(){
482                    var m = $(this).find('> .dropdown-menu .dropdown-menu-inner'),
483                        w = i.width();
484
485                    m.css({
486                        width: w,
487                        marginLeft: i.offset().left - a.offset().left
488                    });
489                });
490
491                $this.find('.elementor-element').addClass('no-transparent');
492            });
493        },
494        initVerticalMenu: function() {
495            // mobile menu
496            $('.show-hover').on('click', function (e) {
497                e.stopPropagation();
498                $('.show-hover .content-vertical').toggle(350);           
499            });
500            $('body').on('click', function() {
501                $('.show-hover .content-vertical').slideUp(350);
502            });
503            $('.content-vertical').on('click', function(e) {
504                e.stopPropagation();
505            });
506            
507
508            // show vertical layout1
509            $('#vertical-menu-layout1 .has-submenu > .icon-toggle').on('click', function (e) {
510                e.stopPropagation();
511                $(this).parent().find('> .sub-menu').toggle(350);
512                if ( $(this).find('i').hasClass('ti-angle-down') ) {
513                    $(this).find('i').removeClass('ti-angle-down').addClass('ti-angle-up');
514                } else {
515                    $(this).find('i').removeClass('ti-angle-up').addClass('ti-angle-down');
516                }
517            });
518        },
519        changePaddingTopContent: function() {
520
521            var header_h = 0;
522            var admin_bar_h = 0;
523
524            if ( $('#wpadminbar').length ) {
525                var admin_bar_h = $('#wpadminbar').outerHeight();
526            }
527
528            if ($(window).width() >= 1200) {
529                if ( $('#apus-header').length ) {
530                    var header_h = $('#apus-header').outerHeight();
531                }
532                $('#apus-main-content').css({ 'padding-top': 0 });
533
534                var top = 0;
535                if ( $('#wpadminbar').length ) {
536                    top = $('#wpadminbar').outerHeight();
537                }
538                if ( $('.main-sticky-header-wrapper').length ) {
539                    top = top + header_h;
540                }
541                
542                $('.sidebar.sticky-top').css({
543                    top: top
544                });
545                $('#course-tabs-spy.sticky-top').css({
546                    top: top
547                });
548
549            } else {
550                if ( $('#apus-header-mobile').length ) {
551                    var header_h = $('#apus-header-mobile').outerHeight();
552                }
553                $('#apus-main-content').css({ 'padding-top': header_h });
554            }
555
556            // page sidebar
557            if ($(window).width() >= 1200) {
558                if ( $('#apus-header').length ) {
559                    $('.main-page-sidebar .sidebar-wrapper').css({ 'top': $('#apus-header').outerHeight() + admin_bar_h });
560                }
561            } else {
562                $('.main-page-sidebar .sidebar-wrapper').css({ 'top': 0 });
563            }
564            
565        },
566
567        setCookie: function(cname, cvalue, exdays) {
568            var d = new Date();
569            d.setTime(d.getTime() + (exdays*24*60*60*1000));
570            var expires = "expires="+d.toUTCString();
571            document.cookie = cname + "=" + cvalue + "; " + expires+";path=/";
572        },
573        getCookie: function(cname) {
574            var name = cname + "=";
575            var ca = document.cookie.split(';');
576            for(var i=0; i<ca.length; i++) {
577                var c = ca[i];
578                while (c.charAt(0)==' ') c = c.substring(1);
579                if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
580            }
581            return "";
582        }
583    }
584
585    $.apusThemeCore = ApusThemeCore.prototype;
586
587    $(document).ready(function() {
588        // Initialize script
589        var apusthemecore_init = new ApusThemeCore();
590        apusthemecore_init.init();
591    });
592
593    jQuery(window).on("elementor/frontend/init", function() {
594        
595        var apusthemecore_init = new ApusThemeCore();
596
597        // General element
598        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_brands.default",
599            function($scope) {
600                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
601            }
602        );
603
604        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_features_box.default",
605            function($scope) {
606                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
607            }
608        );
609
610        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_posts.default",
611            function($scope) {
612                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
613            }
614        );
615
616        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_testimonials.default",
617            function($scope) {
618                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
619            }
620        );
621
622        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_banners.default",
623            function($scope) {
624                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
625            }
626        );
627
628        // Woo elements
629        
630        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_element_woo_products.default",
631            function($scope) {
632                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
633                apusthemecore_init.layzyLoadImage();
634            }
635        );
636
637        // Course elements
638        
639        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_learnpress_courses.default",
640            function($scope) {
641                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
642                apusthemecore_init.layzyLoadImage();
643            }
644        );
645
646        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_learnpress_courses_tabs.default",
647            function($scope) {
648                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
649                apusthemecore_init.layzyLoadImage();
650            }
651        );
652
653        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_learnpress_instructors.default",
654            function($scope) {
655                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
656                apusthemecore_init.layzyLoadImage();
657            }
658        );
659
660        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_categories_banner.default",
661            function($scope) {
662                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
663                apusthemecore_init.layzyLoadImage();
664            }
665        );
666
667        // Tutor Course elements
668        
669        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_tutor_courses.default",
670            function($scope) {
671                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
672                apusthemecore_init.layzyLoadImage();
673            }
674        );
675
676        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_tutor_courses_tabs.default",
677            function($scope) {
678                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
679                apusthemecore_init.layzyLoadImage();
680            }
681        );
682
683        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_tutor_instructors.default",
684            function($scope) {
685                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
686                apusthemecore_init.layzyLoadImage();
687            }
688        );
689        
690        elementorFrontend.hooks.addAction( "frontend/element_ready/apus_tutor_categories_banner.default",
691            function($scope) {
692                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
693                apusthemecore_init.layzyLoadImage();
694            }
695        );
696
697
698        
699        elementorFrontend.hooks.addAction( "frontend/element_ready/educrat_events.default",
700            function($scope) {
701                apusthemecore_init.initSlick($scope.find('.slick-carousel'));
702                apusthemecore_init.layzyLoadImage();
703            }
704        );
705    });
706
707})(jQuery);
708

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.