PageSourceSearch

https://www.drumchannel.com/b4744271-64d1-4a48-a4c3-9d7fe290edfb/1…/assets/js/plugins/learndash.js

js drumchannel.com collected 2026-10-02 09:54:46 UTC 41,652 bytes, 909 lines download raw bytes

1//import learndash_sidebar from "./learndash-sidebar";
2
3( function ( $ ) {
4
5    "use strict";
6
7    window.BBLMS = {
8        init: function () {
9            this.switchLdGridList();
10            this.toggleTheme();
11            this.learnDashSidePanel();
12            this.lms_user_profile_js();
13            //this.lms_course_single_js();
14            this.lms_single_course();
15            this.course_archive_js();
16            //this.quiz_progress();
17            this.quizDetails();
18            //this.ajaxCompleteProcess();
19            this.quizUpload();
20            this.setElementorSpacing();
21            this.courseViewCookie();
22            this.bbStickyLdSidebar();
23            //this.StyleInputQuestion();
24            this.singleLesson();
25            this.singleTopic();
26            this.singleQuiz();
27            this.showMoreParticipants();
28        },
29
30        switchLdGridList: function() {
31
32            var courseLoopSelector = $( '.bb-course-items:not(.is-cover)' );
33            if ( window.sessionStorage ) {
34                var getView = sessionStorage.getItem( 'course-view' );
35                if ( typeof getView === 'undefined' || getView === null ) {
36                    sessionStorage.setItem( 'course-view', 'grid' );
37                    getView = sessionStorage.getItem( 'course-view' );
38                }
39
40                $( '.layout-view-course' ).removeClass( 'active' );
41                courseLoopSelector.removeClass( 'grid-view' );
42                courseLoopSelector.removeClass( 'bb-grid' );
43                courseLoopSelector.removeClass( 'list-view' );
44                courseLoopSelector.removeClass( 'bb-list' );
45
46                if ( 'grid' === getView ) {
47                    $( '.layout-view-course.layout-grid-view' ).addClass( 'active' );
48                    courseLoopSelector.addClass( 'grid-view' );
49                    courseLoopSelector.addClass( 'bb-grid' );
50                } else {
51                    $( '.layout-view-course.layout-list-view' ).addClass( 'active' );
52                    courseLoopSelector.addClass( 'list-view' );
53                    courseLoopSelector.addClass( 'bb-list' );
54                }
55            }
56            $( document ).on('click', '.grid-filters .layout-view-course', function(e) {
57                e.preventDefault();
58                courseLoopSelector = $( '.bb-course-items:not(.is-cover)' );
59                if ( $(this).hasClass('layout-list-view') ) {
60                    if ( window.sessionStorage ) {
61                        sessionStorage.setItem('course-view', 'list');
62                    }
63                    $( '.layout-view-course' ).removeClass( 'active' );
64                    courseLoopSelector.removeClass( 'grid-view' );
65                    courseLoopSelector.removeClass( 'bb-grid' );
66                    courseLoopSelector.removeClass( 'list-view' );
67                    courseLoopSelector.removeClass( 'bb-list' );
68                    $( '.layout-view-course.layout-list-view' ).addClass( 'active' );
69                    courseLoopSelector.addClass( 'list-view' );
70                    courseLoopSelector.addClass( 'bb-list' );
71                    $.ajax({
72                        method  : 'GET',
73                        url     : bs_data.ajaxurl,
74                        data    : 'action=buddyboss_lms_save_view&option=bb_theme_learndash_grid_list&type=list',
75                        success : function ( response ) {
76                        }
77                    });
78                } else {
79                    if ( window.sessionStorage ) {
80                        sessionStorage.setItem('course-view', 'grid');
81                    }
82                    $( '.layout-view-course' ).removeClass( 'active' );
83                    courseLoopSelector.removeClass( 'grid-view' );
84                    courseLoopSelector.removeClass( 'bb-grid' );
85                    courseLoopSelector.removeClass( 'list-view' );
86                    courseLoopSelector.removeClass( 'bb-list' );
87                    $( '.layout-view-course.layout-grid-view' ).addClass( 'active' );
88                    courseLoopSelector.addClass( 'grid-view' );
89                    courseLoopSelector.addClass( 'bb-grid' );
90                    $.ajax({
91                        method  : 'GET',
92                        url     : bs_data.ajaxurl,
93                        data    : 'action=buddyboss_lms_save_view&option=bb_theme_learndash_grid_list&type=grid',
94                        success : function ( response ) {
95                        }
96                    });
97                }
98            });
99        },
100
101        showMoreParticipants: function() {
102
103            var total            = $( '.lms-course-members-list .lms-course-sidebar-heading .lms-count' ).text();
104            var paged            = 2;
105            var course           = $( '.lms-course-members-list #buddyboss_theme_learndash_course_participants_course_id' ).val();
106            var spinnerSelector  = $( '.lms-course-members-list .bb-course-member-wrap .lme-more i' );
107            var viewMoreSelector = $( '.lms-course-members-list .bb-course-member-wrap .lme-more' );
108
109            $( '.lms-course-members-list' ).on( 'click', '.bb-course-member-wrap .lme-more', function() {
110
111                if ( $( this ).hasClass( 'loading-members' ) ) {
112                    return;
113                }
114
115                $( this ).addClass( 'loading-members' );
116
117                spinnerSelector.removeClass( 'bb-icon-chevron-down' );
118                spinnerSelector.addClass( 'bb-icon-spin' );
119                spinnerSelector.addClass( 'animate-spin' );
120                $( '.lms-course-members-list .bb-course-member-wrap .lme-less' ).hide();
121
122                $.ajax({
123                    method  : 'GET',
124                    url     : bs_data.ajaxurl,
125                    data    : 'action=buddyboss_lms_get_course_participants&_wpnonce=' + bs_data.learndash.nonce_get_courses + '&total=' + total + '&page=' + paged + '&course=' + course,
126                    success : function ( response ) {
127                        $( '.lms-course-members-list .bb-course-member-wrap .course-members-list.course-members-list-extra' ).show();
128                        $( '.lms-course-members-list .bb-course-member-wrap .course-members-list-extra' ).append( response.data.html );
129                        $(window).trigger('resize');
130                        if ( 'false' === response.data.show_more ) {
131                            $( '.lms-course-members-list .bb-course-member-wrap .lme-more' ).remove();
132                        }
133                        paged = response.data.page;
134                        if ( $( '.ld-sidebar-widgets' ).length === 0 ) {
135                            $( '.lms-topic-sidebar-wrapper .lms-topic-sidebar-data' ).animate({ scrollTop: $(document).height() }, 1000);
136                        }
137                        spinnerSelector.addClass( 'bb-icon-chevron-down' );
138                        spinnerSelector.removeClass( 'bb-icon-spin' );
139                        spinnerSelector.removeClass( 'animate-spin' );
140                        viewMoreSelector.removeClass( 'loading-members' );
141                    }
142                });
143            } );
144
145        },
146
147        fetchCourses: function() {
148            var $form = $( '#bb-courses-directory-form' );
149
150            var reset_pagination = false;
151
152            //reset pagintion if categories or instructor filters are changed.
153            //reset pagination if search term has changed
154            var resetting_fields = [ 'filter-categories', 'filter-instructors', 'search' ];
155            for ( var i = 0; i < resetting_fields.length; i++ ) {
156                var prev_val = BBGetUrlParameter( window.location.search, resetting_fields[ i ] );
157                var new_val = $form.find('[name="'+ resetting_fields[ i ] +'"]').val();
158
159                if ( prev_val !== new_val ) {
160
161                    switch ( resetting_fields[ i ] ) {
162                        case 'filter-categories':
163                        case 'filter-instructors':
164                            if ( !prev_val && new_val === 'all' ) {
165                                //hasn't really changed
166                            } else {
167                                reset_pagination = true;
168                            }
169                            break;
170                        default:
171                            reset_pagination = true;
172                            break;
173                    }
174
175                }
176
177                if ( reset_pagination ) {
178                    break;
179                }
180            }
181
182            if ( reset_pagination ) {
183                $form.find( '[name="current_page"]' ).val(1);
184            }
185
186            var data = $form.serialize();
187
188            //view
189            var view = 'grid';
190            if ( $form.find( '.layout-list-view' ).hasClass( 'active' ) ) {
191                view = 'list';
192            }
193            data += '&view=' + view;
194
195            $.ajax({
196                method  : 'GET',
197                url     : bs_data.ajaxurl,
198                data    : data + '&action=buddyboss_lms_get_courses&_wpnonce=' + bs_data.learndash.nonce_get_courses,
199                success : function ( response ) {
200                    //update url
201                    var new_url = bs_data.learndash.course_archive_url;
202                    if ( $form.hasClass('bb-elementor-widget') ) {
203                        new_url = $form.data('current_page_url');
204                    }
205
206                    var current_page = $form.find( '[name="current_page"]' ).val();
207                    if ( isNaN( current_page ) ) {
208                        current_page = 1;
209                    }
210                    if ( current_page > 1 ) {
211                        new_url += 'page/' + current_page + '/';
212                    }
213
214                    new_url += '?' + data;
215
216                    window.history.pushState( { 'bblms_has_changes' : true, 'courses_html' : response.data.html, 'type' : $form.find( '[name="type"]' ).val() }, "", new_url );
217
218                    //update html
219                    $form.find('.bs-dir-list').html( response.data.html );
220                    //update count
221                    $form.find('li.selected a span').text( response.data.count );
222
223                    if ( response.data.scopes ) {
224                        for (var i in response.data.scopes) {
225                            $form.find('li#courses-' + i + ' a span').text( response.data.scopes[i] ).show();
226                        }
227                    }
228
229                    $('.courses-nav').find('.bb-icon-loader').remove();
230                }
231            });
232
233            return false;
234            //$( '#bb-courses-directory-form' ).submit();
235        },
236
237        fetchCoursesPagination: function() {
238            var $form = $( '#bb-courses-directory-form' );
239            var data = $form.serialize();
240
241            //view
242            var view = 'list';
243            if ( $form.find( '.layout-grid-view' ).hasClass( 'active' ) ) {
244                view = 'grid';
245            }
246            data += '&view=' + view;
247
248            $.ajax({
249                method  : 'GET',
250                url     : bs_data.ajaxurl,
251                data    : data + '&action=buddyboss_lms_get_courses&_wpnonce=' + bs_data.learndash.nonce_get_courses,
252                success : function ( response ) {
253                    //update url
254                    var new_url = bs_data.learndash.course_archive_url;
255                    if ( $form.hasClass('bb-elementor-widget') ) {
256                        new_url = $form.data('current_page_url');
257                    }
258
259                    var current_page = $form.find( '[name="current_page"]' ).val();
260                    if ( isNaN( current_page ) ) {
261                        current_page = 1;
262                    }
263                    if ( current_page > 1 ) {
264                        new_url += 'page/' + current_page + '/';
265                    }
266
267                    new_url += '?' + data;
268
269                    window.history.pushState( { 'bblms_has_changes' : true, 'courses_html' : response.data.html, 'type' : $form.find( '[name="type"]' ).val() }, "", new_url );
270
271                    //update html
272                    $form.find('.bs-dir-list').html( response.data.html );
273
274                    //update count
275                    $form.find('li.selected a span').text( response.data.count );
276
277                    if ( response.data.scopes ) {
278                        for (var i in response.data.scopes) {
279                            $form.find('li#courses-' + i + ' a span').text( response.data.scopes[i] ).show();
280                        }
281                    }
282                    $('.courses-nav').find('.bb-icon-loader').remove();
283                }
284            });
285
286            return false;
287            //$( '#bb-courses-directory-form' ).submit();
288        },
289
290        course_archive_js: function() {
291
292            $( document ).on( 'change', '#bb-courses-directory-form input[type=checkbox]', function ( e ) {
293                e.preventDefault();
294                window.BBLMS.fetchCourses();
295            } );
296
297            window.onpopstate = function(e) {
298                if ( !e.state ) {
299                    return;
300                }
301
302                var has_changes = e.state.hasOwnProperty( 'bblms_has_changes' ) ? e.state.bblms_has_changes : false;
303                if ( has_changes ) {
304                    var $form = $('#bb-courses-directory-form');
305
306                    //update courses html
307                    $form.find( '.bs-dir-list' ).html( e.state.courses_html );
308
309                    //highlight correct nav
310                    $form.find( '[name="type"]' ).val( e.state.type );
311
312                    $form.find( '.component-navigation > li').each(function(){
313                        $(this).removeClass('selected');
314                        var type = BBGetUrlParameter( $(this).find(' > a').attr('href'), 'type' );
315                        if ( type === e.state.type ) {
316                            $(this).addClass('selected');
317                        }
318                    });
319                }
320            };
321
322            $( document ).on( 'click', '#bb-course-list-grid-filters .grid-filters a', function ( e ) {
323                e.preventDefault();
324                $( '#bb-course-list-grid-filters .grid-filters a' ).removeClass( 'active' );
325                $( e.currentTarget ).addClass( 'active' );
326                var view = $( e.currentTarget ).data( 'view' );
327                var selector = $('.ld-course-list-content');
328                if ( selector.hasClass('list-view') ) {
329                    selector.removeClass('list-view');
330                }
331
332                if ( selector.hasClass('grid-view') ) {
333                    selector.removeClass('grid-view');
334                }
335
336                selector.addClass( view + '-view');
337
338                $.ajax({
339                    method  : 'GET',
340                    url     : bs_data.ajaxurl,
341                    data    : 'action=buddyboss_lms_save_view&option=bb_theme_learndash_grid_list&type=' + view,
342                    success : function ( response ) {
343                    }
344                });
345
346            } );
347
348            $( document ).ready(function() {
349                if ( $('body #bb-course-list-grid-filters').length ) {
350                    var active = '';
351                    if ($('#bb-course-list-grid-filters .grid-filters .layout-grid-view').hasClass('active')) {
352                        active = 'grid-view';
353                    } else {
354                        active = 'list-view';
355                    }
356                    $('.ld-course-list-content').addClass(active);
357                }
358            });
359
360            $( document ).on( 'change', '#bb-courses-directory-form [name=\'orderby\'], #bb-courses-directory-form [name=\'filter-categories\'], #bb-courses-directory-form [name=\'filter-instructors\']', function ( e ) {
361                e.preventDefault();
362                window.BBLMS.fetchCourses();
363            } );
364
365            $( document ).on( 'click', '#bb-courses-directory-form .bs-sort-button', function ( e ) {
366                e.preventDefault();
367                e.currentTarget.classList.toggle( 'active' );
368                $( '#bs-courses-order-by' ).toggleClass( 'open' );
369            } );
370
371            $( document ).on( 'click', '#bb-courses-directory-form .bb-lms-pagination a.page-numbers', function ( e ) {
372                e.preventDefault();
373                var page_number = 1;
374                var url_parts = $(this).attr('href').split('/');
375                if ( url_parts.length > 0 ) {
376                    for ( var i = 0; i < url_parts.length; i++ ) {
377                        if ( 'page' === url_parts[i] ) {
378                            page_number = url_parts[ i + 1 ];
379                            break;
380                        }
381                    }
382                }
383
384                $(this).closest( 'form' ).find( '[name="current_page"]' ).val( page_number );
385                window.BBLMS.fetchCoursesPagination();
386            } );
387
388            $( document ).on( 'click', '#bb-courses-directory-form .component-navigation a', function ( e ) {
389                e.preventDefault();
390
391                $(this).closest( '.component-navigation').find( '> li' ).removeClass('selected');
392                $(this).closest( '.component-navigation').find( '> li a span' ).hide();
393                $(this).closest( '.component-navigation').find( '> li a span' ).text('');
394                $(this).closest('li').addClass('selected').append('<i class="bb-icon-loader animate-spin"></i>');
395                $(this).closest('li').find( '> a span' ).text('');
396                $(this).closest('li').find( '> a span' ).show();
397
398                var type = BBGetUrlParameter( $(this).attr('href'), 'type' );
399                $(this).closest( 'form' ).find( '[name="type"]' ).val( type );
400
401                //resetting the page number if important, as sometimes 'all courses' can have more items than 'my courses'
402                $(this).closest( 'form' ).find( '[name="current_page"]' ).val( 1 );
403                window.BBLMS.fetchCourses();
404            } );
405
406            document.addEventListener( 'click', function ( e ) {
407                var openFilterDropdown = $( '#course-order-dropdown' );
408                var target = e.target;
409                if ( openFilterDropdown === target && openFilterDropdown.contains( target ) ) {
410                    return false;
411                }
412
413                var dropdowns = $( '#bb-courses-directory-form .bs-dropdown' );
414                var download_link = $( '#bb-courses-directory-form .bs-dropdown-link' );
415
416                for ( var i = 0; i < download_link.length; i++ ) {
417                    if ( download_link[i] !== target && !download_link[i].contains( target ) ) {
418                        download_link[i].classList.remove( 'active' );
419                    }
420                }
421
422                for ( var i = 0; i < dropdowns.length; i++ ) {
423                    if ( dropdowns[i] != target.parentElement.nextElementSibling ) {
424                        dropdowns[i].classList.remove( 'open' );
425                    }
426                }
427            } );
428
429            $('#bb-courses-directory-form').on( 'submit', function(e){
430                window.BBLMS.fetchCourses();
431                return false;
432            } );
433
434            $( '#bb-courses-directory-form #bs_members_search' ).on( 'keypress' , function(e){
435                if( e.which == 13 ) {
436                    $( '#bb-courses-directory-form' ).submit();
437                }
438            } );
439
440        },
441
442        toggleTheme: function() {
443
444            $( document ).on( 'click', '#bb-toggle-theme', function ( e ) {
445                e.preventDefault();
446                var color = '';
447                if ( !$( 'body' ).hasClass( 'bb-dark-theme' ) ) {
448                    $.cookie( 'bbtheme', 'dark', { path: '/' });
449                    $( 'body' ).addClass( 'bb-dark-theme' );
450                    color = 'dark';
451                } else {
452                    $.removeCookie('bbtheme', { path: '/' });
453                    $( 'body' ).removeClass( 'bb-dark-theme' );
454                }
455
456                if ( typeof( toggle_theme_ajax ) != 'undefined' && toggle_theme_ajax != null ) {
457                    toggle_theme_ajax.abort();
458                }
459
460                var data = {
461                    'action': 'buddyboss_lms_toggle_theme_color',
462                    'color': color
463                };
464
465                // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
466                if ( typeof( toggle_theme_ajax ) != 'undefined' && toggle_theme_ajax != null ) {
467                    toggle_theme_ajax = $.post( ajaxurl, data, function ( response ) {} );
468                }
469            } );
470        },
471
472        learnDashSidePanel: function() {
473
474            $( document ).on( 'click', '.header-maximize-link', function ( e ) {
475                e.preventDefault();
476                $( 'body' ).addClass( 'lms-side-panel-close' );
477                $( '.lms-topic-sidebar-wrapper' ).addClass( 'lms-topic-sidebar-close' );
478                $.cookie( 'lessonpanel', 'closed', { path: '/' });
479            } );
480
481            $( document ).on( 'click', '.header-minimize-link', function ( e ) {
482                e.preventDefault();
483                $( 'body' ).removeClass( 'lms-side-panel-close' );
484                $( '.lms-topic-sidebar-wrapper' ).removeClass( 'lms-topic-sidebar-close' );
485                $.removeCookie('lessonpanel', { path: '/' });
486            } );
487
488            if ( $( window ).width() < 768 ) {
489                $( 'body' ).addClass( 'lms-side-panel-close' );
490                $( '.lms-topic-sidebar-wrapper' ).addClass( 'lms-topic-sidebar-close' );
491
492                $( document ).on( 'click', '.header-minimize-link', function ( e ) {
493                    e.preventDefault();
494                    $( 'body' ).addClass( 'lms-side-panel-close-sm' );
495                } );
496
497                $( document ).click( function(e) {
498                    var container = $( '.header-minimize-link' );
499                    if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) {
500                        $( 'body' ).removeClass( 'lms-side-panel-close-sm' );
501                    }
502                } );
503            }
504
505            $( window ).on( 'resize', function () {
506                if ( $( window ).width() < 768 ) {
507                    $( document ).click( function(e) {
508                        var container = $( '.header-minimize-link' );
509                        if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) {
510                            $( 'body' ).removeClass( 'lms-side-panel-close-sm' );
511                        }
512                    } );
513                }
514            } );
515        },
516
517        lms_course_single_js: function() {
518            $( document ).on( 'click', '.learndash-course-single-nav', function ( e ) {
519                e.preventDefault();
520                $( 'ul.learndash-course-single-main-nav' ).find( 'li.current.selected' ).removeClass( 'current' ).removeClass( 'selected' );
521
522                var li = $( e.currentTarget ).closest( 'li' );
523                li.addClass( 'current' );
524                li.addClass( 'selected' );
525
526                var currentTab = $( e.currentTarget );
527                var tab_to_change = currentTab.data( 'tab' );
528
529                var content_elems = $( '.learndash-course-single-tab-content' );
530                $.each( content_elems, function ( elem ) {
531                    var _this = $( this );
532                    if ( _this.data( 'tab' ) == tab_to_change ) {
533                        _this.removeClass( 'hide' );
534                    } else {
535                        _this.addClass( 'hide' );
536                    }
537                } );
538
539            } );
540        },
541
542        lms_single_course: function() {
543            $( '.bb-course-video-overlay' ).magnificPopup( {
544                fixedBgPos: true,
545                fixedContentPos: true,
546                items: {
547                    src: '.bb_course_video_details',
548                    type: 'inline'
549                },
550                callbacks: {
551                    open: function () {
552                        // Pause the video if someone click on the close button of the magnificPopup.
553                        $.magnificPopup.instance.close = function () {
554                            if ($('.mfp-container .mfp-content .bb_course_video_details video'.length)) {
555                                $('video').trigger('pause');
556                                $.magnificPopup.proto.close.call(this);
557                            }
558                        };
559                    }
560                }
561            } );
562
563            function sideBarPosition() {
564                var courseBannerHeight = $( '.bb-learndash-banner' ).height();
565                var courseBannerVideo = $( '.bb-thumbnail-preview .bb-preview-course-link-wrap' );
566                if ( courseBannerVideo.length ) {
567                    var thumbnailContainerHeight = courseBannerVideo.height();
568                } else {
569                    var thumbnailContainerHeight = 0;
570                }
571                var sidebarOffset = ( courseBannerHeight/2 ) + ( thumbnailContainerHeight/2 );
572                if ( $(window).width() > 820 ) {
573                    $( '.bb-single-course-sidebar.bb-preview-wrap' ).css( { 'margin-top' : '-' + sidebarOffset + 'px' } );
574                }
575            }
576
577            function courseBanner() {
578                var mainWidth = $( '#main' ).width();
579                $( '.bb-learndash-banner .bb-course-banner-info.container' ).width( mainWidth );
580            }
581
582            sideBarPosition();
583            courseBanner();
584
585            $( window ).on( 'resize', function () {
586                courseBanner();
587                sideBarPosition();
588            } );
589
590            $( '.bb-toggle-panel' ).on( 'click', function(e) {
591                e.preventDefault();
592
593                setTimeout(function(){
594                    courseBanner();
595                },300);
596                setTimeout(function(){
597                    courseBanner();
598                },600);
599            } );
600
601            $('.lms-topic-sidebar-wrapper .lms-toggle-lesson').on('click', function() {
602                setTimeout(function(){ $(window).trigger('resize'); }, 300 );
603            });
604        },
605
606        lms_user_profile_js: function() {
607            $( document ).on( 'click', '.bb-lms-user-profile-tab', function ( e ) {
608                e.preventDefault();
609                $( 'ul.bb-lms-user-profile-tabs' ).find( 'li.current.selected' ).removeClass( 'current' ).removeClass( 'selected' );
610
611                var li = $( e.currentTarget ).closest( 'li' );
612                li.addClass( 'current' );
613                li.addClass( 'selected' );
614
615                var currentTab = $( e.currentTarget );
616                var tab_to_change = currentTab.data( 'tab' );
617
618                var content_elems = $( '.bb-lms-user-profile-tab-content' );
619                $.each( content_elems, function ( elem ) {
620                    var _this = $( this );
621                    if ( _this.data( 'tab' ) == tab_to_change ) {
622                        _this.removeClass( 'hide' );
623                    } else {
624                        _this.addClass( 'hide' );
625                    }
626                } );
627
628            } );
629        },
630
631        quizDetails: function() {
632
633            if ( $( '#bb-lms-quiz-id' ).length ) {
634                var quiz_id = $('#bb-lms-quiz-id').val();
635
636                $( 'div.quiz_progress_container' ).insertBefore( $( '.wpProQuiz_results .wpProQuiz_resultTable' ) );
637
638                $('#wpProQuiz_' + quiz_id).on('learndash-quiz-init', function () {
639                    // $( document ).find( 'input[name="startQuiz"]' ).click( function () {
640                    //     BBLMS.showQuizNavigation();
641                    // } );
642                    //
643                    // $( document ).on( 'click', '.bb-lms-quiz-questions', function ( e ) {
644                    //     e.preventDefault();
645                    //     var index = $( e.currentTarget ).data( 'index' );
646                    //     if ( typeof index !== 'undefined' ) {
647                    //         $( '#wpProQuiz_' + quiz_id ).data( "wpProQuizFront" ).methode.showQuestion( index );
648                    //     }
649                    // } );
650                });
651            }
652        },
653
654        ajaxCompleteProcess: function () {
655            $(document).ajaxComplete(function (event, request, settings) {
656                if (settings.data.indexOf('action=wp_pro_quiz_load_quiz_data') || settings.data.indexOf('action=wp_pro_quiz_completed_quiz')) {
657                    if (settings.data && settings.data != '') {
658                        var splitted = settings.data.split('&');
659                        var action = '';
660                        for (var i in splitted) {
661                            if (splitted[i].indexOf('action') != -1) {
662                                action = splitted[i].split('=');
663                                action = typeof action[1] !== 'undefined' ? action[1] : '';
664                                break;
665                            }
666                        }
667                        if (action != '' && action == 'wp_pro_quiz_load_quiz_data') {
668                            if ($('.wpProQuiz_resultTable').length) {
669                                $('.bb_avg_progress').show();
670
671                                var pathAvg = new ProgressBar.Path("#bb_avg_shape", {
672                                    duration: 3000,
673                                    from: {
674                                        color: "#ECCBFF",
675                                        width: 8
676                                    },
677                                    to: {
678                                        color: "#ECCBFF",
679                                        width: 8
680                                    },
681                                    easing: "easeInOut",
682                                    step: function (state, shape) {
683                                        shape.path.setAttribute("stroke", state.color);
684                                        shape.path.setAttribute("stroke-width", state.width);
685                                    }
686                                });
687
688                                var avarage = request.responseJSON.averageResult;
689                                if (avarage > 0) {
690                                    avarage = -avarage / 100;
691                                } else {
692                                    avarage = 0;
693                                }
694                                pathAvg.animate(avarage);
695                            }
696                        }
697                        if (action != '' && action == 'wp_pro_quiz_completed_quiz') {
698                            if ($('.wpProQuiz_resultTable').length) {
699
700                                var data = decodeURIComponent(settings.data);
701                                var splitted = data.split('&');
702                                var result = '';
703                                for (var i in splitted) {
704                                    if (splitted[i].indexOf('results') != -1) {
705                                        result = splitted[i].split('=');
706                                        result = typeof result[1] !== 'undefined' ? result[1] : '';
707                                        result = JSON.parse(result);
708                                        break;
709                                    }
710                                }
711
712                                if (typeof result.comp.result !== 'undefined') {
713                                    result = result.comp.result;
714                                }
715
716                                var path = new ProgressBar.Path("#quiz_shape_progress", {
717                                    duration: 3000,
718                                    from: {
719                                        color: "#00A2FF",
720                                        width: 8
721                                    },
722                                    to: {
723                                        color: "#7FE0FF",
724                                        width: 8
725                                    },
726                                    easing: "easeInOut",
727                                    step: function (state, shape) {
728                                        shape.path.setAttribute("stroke", state.color);
729                                        shape.path.setAttribute("stroke-width", state.width);
730                                    }
731                                });
732
733                                jQuery('.bb_progressbar_label').text(result + '%');
734                                jQuery('.bb_progressbar_points').text(jQuery('.wpProQuiz_points').text());
735
736                                if (result > 0) {
737                                    result = -result / 100;
738                                }
739
740                                path.animate(result);
741                            }
742                        }
743                    }
744                }
745            });
746        },
747
748        quizUpload: function() {
749            function inputFileStyle() {
750                $( 'input.wpProQuiz_upload_essay[type=file]:not(.styled)' ).each( function () {
751                    var $fileInput = $( this );
752                    var $fileInputFor = $fileInput.attr( 'id' );
753                    $fileInput.addClass('styled');
754                    $fileInput.after( '<label for="' + $fileInputFor + '">' + bs_data.translation.choose_a_file_label + '</label>' );
755                } );
756
757                $( 'input.wpProQuiz_upload_essay[type=file]' ).change( function ( e ) {
758                    var $in = $( this );
759                    var $inval = $in.next().html( $in.val() );
760                    if ( $in.val().length === 0 ) {
761                        $in.next().html( bs_data.translation.choose_a_file_label );
762                    } else {
763                        $in.next().html( $in.val().replace( /C:\\fakepath\\/i, '' ) );
764                    }
765                } );
766            }
767
768            inputFileStyle();
769            $( document ).ajaxComplete(function() {
770                inputFileStyle();
771            });
772        },
773
774        courseViewCookie: function () {
775            $( '#bb-courses-directory-form .layout-grid-view' ).click( function () {
776                $.cookie( 'courseview', 'grid' );
777            } );
778
779            $( '#bb-courses-directory-form .layout-list-view' ).click( function () {
780                $.cookie( 'courseview', 'list' );
781            } );
782        },
783
784        bbStickyLdSidebar: function () {
785            var bbHeaderHeight = $('#masthead').outerHeight();
786
787            if ( $(window).width() > 768 && $('.bb-ld-sticky-sidebar .ld-sidebar-widgets').length == 0 ) {
788                $('.bb-ld-sticky-sidebar').stick_in_parent({offset_top: bbHeaderHeight + 45});
789
790                var adminBarHeight = 0;
791                if( $('body').hasClass('admin-bar') ) {
792                    adminBarHeight = 32;
793                }
794                $('.
794lms-topic-sidebar-data').css({'max-height': 'calc(100vh - '+ ( bbHeaderHeight + adminBarHeight ) +'px', 'top': ( bbHeaderHeight + adminBarHeight ) +'px' });
795                if( !$('body').hasClass( 'sticky-header' ) ) {
796                    if( $(window).scrollTop() >= $('#masthead').outerHeight() ) {
797                        bbHeaderHeight = 0;
798                    } else {
799                        bbHeaderHeight = $('#masthead').outerHeight();
800                    }
801                    $('.lms-topic-sidebar-data').css({'max-height': 'calc(100vh - '+ ( bbHeaderHeight + adminBarHeight ) +'px', 'top': ( bbHeaderHeight + adminBarHeight ) +'px' });    
802                }
803
804            }
805
806            $(window).on('resize', function () {
807                if ( $(window).width() > 768 && $('.bb-ld-sticky-sidebar .ld-sidebar-widgets').length == 0 ) {
808                    $('.bb-ld-sticky-sidebar').stick_in_parent({offset_top: bbHeaderHeight + 45});
809                } else {
810                    $('.bb-ld-sticky-sidebar').trigger("sticky_kit:detach");
811                    // $('.lms-topic-sidebar-data').trigger("sticky_kit:detach");
812                }
813            });
814
815            $(window).on('scroll', function () {
816                if( !$('body').hasClass( 'sticky-header' ) ) {
817                    if( $(window).scrollTop() >= $('#masthead').outerHeight() ) {
818                        bbHeaderHeight = 0;
819                    } else {
820                        bbHeaderHeight = $('#masthead').outerHeight();
821                    }
822                    $('.lms-topic-sidebar-data').css({'max-height': 'calc(100vh - '+ ( bbHeaderHeight + adminBarHeight ) +'px', 'top': ( bbHeaderHeight + adminBarHeight ) +'px' });    
823                }
824                
825            });
826
827            if ($('.wpProQuiz_matrixSortString').length > 0) {
828                $('html').addClass('quiz-sort');
829            }
830        },
831
832        setElementorSpacing: function() {
833            if ( $('.elementor-location-header').length > 0 ) {
834                var setHeight = $('.elementor-location-header').outerHeight();
835                $('.lms-topic-sidebar-wrapper, #learndash-page-content').css({'min-height': 'calc(100vh - '+setHeight+'px)'});
836            }
837        },
838
839        showQuizNavigation: function() {
840            var question_list = $( '.wpProQuiz_list' ).find( '.wpProQuiz_listItem' );
841            var nav_wrapper = $( '#bb-lms-quiz-navigation' );
842            if ( question_list.length && nav_wrapper.length ) {
843                var str = '<ul>';
844                for ( var i = 1; i <= question_list.length; i++ ) {
845                    str += '<li><a href="#" class="bb-lms-quiz-questions" data-index="' + ( i - 1 ) + '">' + i + '</a></li>';
846                }
847                str += '</ul>';
848                nav_wrapper.html( str );
849            }
850        },
851
852        StyleInputQuestion: function() {
853            function styleInputs() {
854                $( '.wpProQuiz_questionInput:not([type="text"]):not([type="email"]):not([type="tel"]):not([type="date"])' ).each(function() {
855                    if( ! $(this).hasClass('bbstyled') ) {
856                        $(this).addClass('bbstyled').after('<span class="input-style"></span>');
857                    }
858                });
859            }
860
861            styleInputs();
862
863            $( document ).ajaxComplete( function() {
864                styleInputs();
865            });
866        },
867
868        singleLesson: function() {
869            var lsPageContent = document.getElementById('learndash-page-content');
870            if( lsPageContent ) {
871                $( '#learndash-page-content' ).scroll(function() {
872                    $( window ).trigger('resize');
873                });
874            }
875        },
876
877        singleTopic: function() {
878            var lsPageContent = $( 'body.single-sfwd-topic .lms-topic-item.current' );
879            if( lsPageContent.length ) {
880                lsPageContent.closest( 'div' ).show();
881                lsPageContent.parents().closest( 'li' ).removeClass( 'lms-lesson-turnover' );
882            }
883            //Remove comment system added by shortcodes
884            var learndash_pages = ['.sfwd-lessons-template-default', '.sfwd-topic-template-default', '.sfwd-quiz-template-default'];
885            for(var i=0; i<learndash_pages.length; i++){
886                if($(learndash_pages[i]+' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap #comments.comments-area').length > 0){
887                    $(learndash_pages[i]+' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap #comments.comments-area').remove();
888                }
889                if($(learndash_pages[i]+' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap .ld-focus-comments').length > 0){
890                    $(learndash_pages[i]+' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap .ld-focus-comments').remove();
891                }
892            }
893        },
894
895        singleQuiz: function() {
896            var lsPageContent = $( 'body.single-sfwd-quiz .lms-quiz-item.current' );
897            if( lsPageContent.length ) {
898                lsPageContent.closest( 'div' ).show();
899                lsPageContent.parents().closest( 'li' ).removeClass( 'lms-lesson-turnover' );
900            }
901        }
902
903    };
904
905    $( document ).ready( function () {
906        window.BBLMS.init();
907    } );
908
909} )( 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.