PageSourceSearch

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

js practicalmind.net collected 2026-10-05 03:43:02 UTC 9,421 bytes, 225 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    $.extend($.apusThemeCore, {
5        /**
6         *  Initialize
7         */
8        course_init: function() {
9            var self = this;
10            
11            self.coursesFilter();
12
13            self.courseDetail();
14
15            self.mixesFc();
16            
17            self.wishlistInit();
18
19
20            var scrollspy_top = 0;
21            var nav_height = 0;
22
23            scrollspy_top = nav_height = self.courseChangeMarginTopAffix();
24            
25            if ($(window).width() >= 1200) {
26                if ($('.main-sticky-header').length > 0) {
27                    header_height = $('.main-sticky-header').outerHeight();
28                    scrollspy_top = nav_height + header_height;
29                }
30            } else {
31                header_height = 0;
32                scrollspy_top = nav_height + header_height;
33            }
34            scrollspy_top = scrollspy_top + 10;
35
36            setTimeout(function(){
37                $('body').scrollspy({
38                    target: "#ourse-tabs-spy",
39                    offset: scrollspy_top
40                });
41            }, 100);
42
43            $('.tutor-nav-item-tab a').on('click', function(e){
44                var parent = $(this).closest('.tutor-nav');
45                parent.find('.tutor-nav-item-tab a').removeClass('is-active');
46                $(this).addClass('is-active');
47            });
48        },
49        courseChangeMarginTopAffix: function() {
50            var affix_height = 0;
51            if ( $('#course-tabs-spy').length > 0 ) {
52                affix_height = $('#course-tabs-spy').height();
53            }
54            return affix_height;
55        },
56        coursesFilter: function() {
57            var self = this;
58
59            $(document).on('change', '.filter-categories-widget form input, .filter-categories-widget form select', function(){
60                $(this).closest('.filter-categories-widget form').trigger('submit');
61            });
62            $(document).on('change', '.filter-instructors-widget form input, .filter-instructors-widget form select', function(){
63                $(this).closest('.filter-instructors-widget form').trigger('submit');
64            });
65            $(document).on('change', '.filter-price-widget form input, .filter-price-widget form select', function(){
66                $(this).closest('.filter-price-widget form').trigger('submit');
67            });
68            $(document).on('change', '.filter-levels-widget form input, .filter-levels-widget form select', function(){
69                $(this).closest('.filter-levels-widget form').trigger('submit');
70            });
71            $(document).on('change', '.filter-rating-widget form input, .filter-rating-widget form select', function(){
72                $(this).closest('.filter-rating-widget form').trigger('submit');
73            });
74
75            $(document).on('change', 'form.tutor-course-filter-form select', function(){
76                $(this).closest('form.tutor-course-filter-form').trigger('submit');
77            });
78
79            $(document).on('click', '.filter-offcanvas-btn', function(e){
80                e.preventDefault();
81                $('.filter-offcanvas-sidebar').addClass('active');
82                $('.filter-offcanvas-sidebar-overlay').addClass('active');
83            });
84            $(document).on('click', '.filter-top-btn', function(e){
85                e.preventDefault();
86                $('.tutor-filter-top-sidebar').toggle(300);
87            });
88            $(document).on('click', '.filter-offcanvas-sidebar-overlay', function(e){
89                e.preventDefault();
90                $('.filter-offcanvas-sidebar').removeClass('active');
91                $('.filter-offcanvas-sidebar-overlay').removeClass('active');
92            });
93
94
95            $('select.tutor-filter-select').on('change', function(){
96                $(this).closest('form').trigger('submit');
97            });
98        },
99        courseDetail: function() {
100            var self = this;
101            
102            if ( $('.comment-form-rating').length > 0 ) {
103
104                var $star = $('.comment-form-rating .filled');
105                var $review = $('#apus_input_rating');
106                $star.find('li').on('mouseover', function () {
107                    $(this).nextAll().addClass('active');
108                    $(this).prevAll().removeClass('active');
109                    $(this).removeClass('active');
110                });
111                $star.on('mouseout', function(){
112                    var current = $review.val() - 1;
113                    var current_e = $star.find('li').eq(current);
114
115                    current_e.nextAll().addClass('active');
116                    current_e.prevAll().removeClass('active');
117                    current_e.removeClass('active');
118                });
119                $star.find('li').on('click', function () {
120                    $(this).nextAll().addClass('active');
121                    $(this).prevAll().removeClass('active');
122                    $(this).removeClass('active');
123                    
124                    $review.val($(this).index() + 1);
125                } );
126            }
127
128            $(document).on('click', '.share-wrapper .course-share', function(){
129                $(this).parent().toggleClass('active');
130            });
131        },
132        mixesFc: function() {
133            var self = this;
134            $( '.courses-ordering' ).on( 'change', 'select.orderby', function() {
135                $( this ).closest( 'form' ).submit();
136            });
137
138            $('.apus-search-form-course .search-button, .apus-search-form-course .close-search, .apus-search-form-course .over-dark').on('click', function(){
139                $(this).closest('.apus-search-form-course').find('.search-form-popup').toggle('100');
140                $(this).closest('.apus-search-form-course').find('.over-dark').toggleClass('active');
141            });
142        },
143        wishlistInit: function() {
144            var self = this;
145            // wishlist
146            $( document ).on( "click", ".apus-wishlist-add", function( e ) {
147                e.preventDefault();
148
149                var $self = $(this);
150                $self.addClass('loading');
151                $.ajax({
152                    url: educrat_course_opts.ajaxurl,
153                    type:'POST',
154                    data: {
155                        action: 'educrat_add_wishlist',
156                        post_id: $(this).data('id'),
157                        security: educrat_course_opts.ajax_nonce,
158                    },
159                    dataType: 'json',
160                }).done(function(reponse) {
161                    if (reponse.status === 'success') {
162                        $self.removeClass('apus-wishlist-add').addClass('apus-wishlist-added');
163                        $self.find('.wishlist-text').html(reponse.text);
164                    }
165                    $self.removeClass('loading');
166                });
167            });
168            
169            // wishlist remove
170            $( document ).on( "click", ".apus-wishlist-added", function( e ) {
171                e.preventDefault();
172
173                var $self = $(this);
174                $self.addClass('loading');
175                $.ajax({
176                    url: educrat_course_opts.ajaxurl,
177                    type:'POST',
178                    data: {
179                        action: 'educrat_remove_wishlist',
180                        post_id: $(this).data('id'),
181                        security: educrat_course_opts.ajax_nonce,
182                    },
183                    dataType: 'json',
184                }).done(function(reponse) {
185                    if (reponse.status === 'success') {
186                        $self.removeClass('apus-wishlist-added').addClass('apus-wishlist-add');
187                        $self.find('.wishlist-text').html(reponse.text);
188                    }
189                    $self.removeClass('loading');
190                });
191            });
192            $( document ).on( "click", ".apus-wishlist-remove", function( e ) {
193                e.preventDefault();
194
195                var $self = $(this);
196                var post_id = $(this).data('id');
197                $self.addClass('loading');
198                $.ajax({
199                    url: educrat_course_opts.ajaxurl,
200                    type:'POST',
201                    data: {
202                        action: 'educrat_remove_wishlist',
203                        post_id: post_id,
204                        security: educrat_course_opts.ajax_nonce,
205                    },
206                    dataType: 'json',
207                }).done(function(reponse) {
208                    $self.addClass('loading');
209                    if (reponse.status === 'success') {
210                        var parent = $('#wishlist-course-' + post_id).parent();
211                        if ( $('.my-course-item-wrapper', parent).length <= 1 ) {
212                            location.reload();
213                        } else {
214                            $('#wishlist-course-' + post_id).remove();
215                        }
216                    }
217                });
218            });
219        }
220    });
221
222    $.apusThemeExtensions.course = $.apusThemeCore.course_init;
223    
224})(jQuery);
225

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.