PageSourceSearch

https://amorati.me/wp-content/themes/buddyboss-theme/assets/js/plugins/learndash.js?ver=2.22.0

js amorati.me collected 2026-10-02 02:01:42 UTC 35,943 bytes, 1,176 lines download raw bytes

1// import learndash_sidebar from "./learndash-sidebar";
2/* global bs_data, BBGetUrlParameter */
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.bbStickyLdSidebar();
22			// this.StyleInputQuestion();
23			this.singleLesson();
24			this.singleTopic();
25			this.singleQuiz();
26			this.showMoreParticipants();
27			this.inforBarStatus();
28		},
29
30		switchLdGridList: function() {
31
32			var courseLoopSelector = $( '.bb-course-items:not(.is-cover)' );
33			$( document ).on(
34				'click',
35				'.grid-filters .layout-view-course:not(.active)',
36				function(e) {
37					e.preventDefault();
38
39					if (
40						'undefined' === typeof $( this ).parent().attr( 'data-view' ) ||
41						'ld-course' !== $( this ).parent().attr( 'data-view' )
42					) {
43						return;
44					}
45
46					var main = $( this ).parents( 'form' );
47
48					if ( BBLMS.ajax_request ) {
49						BBLMS.ajax_request.abort();
50					}
51
52					courseLoopSelector = $( this ).parents( 'form' ).find( '.bb-course-items:not(.is-cover)' );
53					if ( $( this ).hasClass( 'layout-list-view' ) ) {
54						main.find( '.layout-view-course' ).removeClass( 'active' );
55						courseLoopSelector.removeClass( 'grid-view' );
56						courseLoopSelector.removeClass( 'bb-grid' );
57						courseLoopSelector.removeClass( 'list-view' );
58						courseLoopSelector.removeClass( 'bb-list' );
59						$( this ).addClass( 'active' );
60						courseLoopSelector.addClass( 'list-view' );
61						courseLoopSelector.addClass( 'bb-list' );
62						BBLMS.ajax_request = $.ajax(
63							{
64								method  : 'POST',
65								url     : bs_data.ajaxurl,
66								nonce   : bs_data.nonce_list_grid,
67								data    : 'action=buddyboss_lms_save_view&option=bb_layout_view&object=' + $( this ).parent().attr( 'data-view' ) + '&type=list&nonce=' + bs_data.nonce_list_grid,
68								success : function ( response ) {
69								}
70							}
71						);
72					} else {
73						main.find( '.layout-view-course' ).removeClass( 'active' );
74						courseLoopSelector.removeClass( 'grid-view' );
75						courseLoopSelector.removeClass( 'bb-grid' );
76						courseLoopSelector.removeClass( 'list-view' );
77						courseLoopSelector.removeClass( 'bb-list' );
78						$( this ).addClass( 'active' );
79						courseLoopSelector.addClass( 'grid-view' );
80						courseLoopSelector.addClass( 'bb-grid' );
81						BBLMS.ajax_request = $.ajax(
82							{
83								method  	: 'POST',
84								url     	: bs_data.ajaxurl,
85								nonce       : bs_data.nonce_list_grid,
86								data    	: 'action=buddyboss_lms_save_view&option=bb_layout_view&object=' + $( this ).parent().attr( 'data-view' ) + '&type=grid&nonce=' + bs_data.nonce_list_grid,
87								success 	: function ( response ) {
88								}
89							}
90						);
91					}
92				}
93			);
94		},
95
96		showMoreParticipants: function() {
97
98			var total            = $( '.lms-course-members-list .lms-course-sidebar-heading .lms-count' ).text();
99			var paged            = 2;
100			var course           = $( '.lms-course-members-list #buddyboss_theme_learndash_course_participants_course_id' ).val();
101			var spinnerSelector  = $( '.lms-course-members-list .bb-course-member-wrap .lme-more i' );
102			var viewMoreSelector = $( '.lms-course-members-list .bb-course-member-wrap .lme-more' );
103
104			$( '.lms-course-members-list' ).on(
105				'click',
106				'.bb-course-member-wrap .lme-more',
107				function() {
108
109					if ( $( this ).hasClass( 'loading-members' ) ) {
110						return;
111					}
112
113					$( this ).addClass( 'loading-members' );
114
115					spinnerSelector.removeClass( 'bb-icon-angle-down' );
116					spinnerSelector.addClass( 'bb-icon-spin' );
117					spinnerSelector.addClass( 'animate-spin' );
118					$( '.lms-course-members-list .bb-course-member-wrap .lme-less' ).hide();
119
120					$.ajax(
121						{
122							method  : 'GET',
123							url     : bs_data.ajaxurl,
124							data    : 'action=buddyboss_lms_get_course_participants&_wpnonce=' + bs_data.learndash.nonce_get_courses + '&total=' + total + '&page=' + paged + '&course=' + course,
125							success : function ( response ) {
126								$( '.lms-course-members-list .bb-course-member-wrap .course-members-list.course-members-list-extra' ).show();
127								$( '.lms-course-members-list .bb-course-member-wrap .course-members-list-extra' ).append( response.data.html );
128								$( window ).trigger( 'resize' );
129								if ( 'false' === response.data.show_more ) {
130									$( '.lms-course-members-list .bb-course-member-wrap .lme-more' ).remove();
131								}
132								paged = response.data.page;
133								if ( $( '.ld-sidebar-widgets' ).length === 0 ) {
134									$( '.lms-topic-sidebar-wrapper .lms-topic-sidebar-data' ).animate( { scrollTop: $( document ).height() }, 1000 );
135								}
136								spinnerSelector.addClass( 'bb-icon-angle-down' );
137								spinnerSelector.removeClass( 'bb-icon-spin' );
138								spinnerSelector.removeClass( 'animate-spin' );
139								viewMoreSelector.removeClass( 'loading-members' );
140							}
141						}
142					);
143				}
144			);
145
146		},
147
148		fetchCourses: function( target ) {
149			var $form = $( '#bb-courses-directory-form' );
150			if ( typeof target !== 'undefined' && $( target ).length > 0 ) {
151				$form = $( target ).closest( 'form.bb-courses-directory' );
152			}
153
154			var reset_pagination = false;
155
156			// reset pagintion if categories or instructor filters are changed.
157			// reset pagination if search term has changed.
158			var resetting_fields = [ 'filter-categories', 'filter-instructors', 'search' ];
159			for ( var i = 0; i < resetting_fields.length; i++ ) {
160				var prev_val = BBGetUrlParameter( window.location.search, resetting_fields[ i ] );
161				var new_val  = $form.find( '[name="' + resetting_fields[ i ] + '"]' ).val();
162
163				if ( prev_val !== new_val ) {
164
165					switch ( resetting_fields[ i ] ) {
166						case 'filter-categories':
167						case 'filter-instructors':
168							if ( ! prev_val && new_val === 'all' ) {
169								// hasn't really changed.
170							} else {
171								reset_pagination = true;
172							}
173							break;
174						default:
175							reset_pagination = true;
176							break;
177					}
178
179				}
180
181				if ( reset_pagination ) {
182					break;
183				}
184			}
185
186			if ( reset_pagination ) {
187				$form.find( '[name="current_page"]' ).val( 1 );
188			}
189
190			var data = $form.serialize();
191
192			// update url.
193			var new_url = bs_data.learndash.course_archive_url;
194			if ( $form.hasClass( 'bb-elementor-widget' ) ) {
195				new_url = $form.data( 'current_page_url' );
196			}
197
198			data += '&request_url=' + encodeURIComponent( new_url );
199
200			BBLMS.ajax_request = $.ajax(
201				{
202					method  : 'GET',
203					url     : bs_data.ajaxurl,
204					data    : data + '&action=buddyboss_lms_get_courses&_wpnonce=' + bs_data.learndash.nonce_get_courses,
205					success : function ( response ) {
206						if ( !_.isUndefined( response.data.layout ) ) {
207							$( '.layout-view' ).removeClass( 'active' );
208							$( '.layout-' + response.data.layout + '-view' ).addClass( 'active' );
209						}
210						var current_page = $form.find( '[name="current_page"]' ).val();
211						if ( isNaN( current_page ) ) {
212							current_page = 1;
213						}
214						if ( current_page > 1 && ! $( 'body' ).hasClass( 'bp-user' ) ) {
215							new_url += 'page/' + current_page + '/';
216						}
217
218						new_url += '?' + data;
219
220						window.history.pushState( { 'bblms_has_changes' : true, 'courses_html' : response.data.html, 'type' : $form.find( '[name="type"]' ).val() }, "", new_url );
221
222						// update html.
223						$form.find( '.bs-dir-list' ).html( response.data.html );
224
225						// update count.
226						$form.find( 'li.selected a span' ).text( response.data.count );
227
228						var course_label = $form.data( 'courses_label' );
229						if ( 1 === parseInt( response.data.count ) ) {
230							course_label = $form.data( 'course_label' );
231						}
232
233						$form.find( '.bb-item-count' ).html( '<span class="bb-count">' + response.data.count + '</span> ' + course_label );
234
235						if ( response.data.scopes ) {
236							for (var i in response.data.scopes) {
237								$form.find( 'li#courses-' + i + ' a span' ).text( response.data.scopes[i] ).show();
238							}
239						}
240
241						$( '.courses-nav' ).find( '.bb-icon-loader' ).remove();
242					}
243				}
244			);
245
246			return false;
247			// $( '#bb-courses-directory-form' ).submit();
248		},
249
250		fetchCoursesPagination: function( target ) {
251			var $form = $( '#bb-courses-directory-form' );
252			if ( typeof target !== 'undefined' && $( target ).length > 0 ) {
253				$form = $( target ).closest( 'form.bb-courses-directory' );
254			}
255			var data = $form.serialize();
256
257			// update url.
258			var new_url = $form.attr( 'action' );
259			if ( $form.hasClass( 'bb-elementor-widget' ) ) {
260				new_url = $form.data( 'current_page_url' );
261			}
262
263			if ( '' === new_url ) {
264				new_url = bs_data.learndash.course_archive_url;
265			}
266
267			data += '&request_url=' + encodeURIComponent( new_url );
268
269			var order = $form.data( 'order' );
270			if ( typeof order !== 'undefined' && order !== false ) {
271				data = data + '&order=' + order;
272			}
273
274			var orderby = $form.data( 'orderby' );
275			if ( typeof orderby !== 'undefined' && orderby !== false ) {
276				data = data + '&orderby=' + orderby;
277			}
278
279			$.ajax(
280				{
281					method  : 'GET',
282					url     : bs_data.ajaxurl,
283					data    : data + '&action=buddyboss_lms_get_courses&_wpnonce=' + bs_data.learndash.nonce_get_courses,
284					success : function ( response ) {
285						if ( !_.isUndefined( response.data.layout ) ) {
286							$( '.layout-view' ).removeClass( 'active' );
287							$( '.layout-' + response.data.layout + '-view' ).addClass( 'active' );
288						}
289
290						var current_page = $form.find( '[name="current_page"]' ).val();
291						if ( isNaN( current_page ) ) {
292							current_page = 1;
293						}
294						if ( '/' !== new_url.substr( -1 ) ) {
295							new_url += '/';
296						}
297						if ( current_page > 1 && ! $( 'body' ).hasClass( 'bp-user' ) ) {
298							new_url += 'page/' + current_page + '/';
299						}
300
301						new_url += '?' + data;
302
303						window.history.pushState( { 'bblms_has_changes' : true, 'courses_html' : response.data.html, 'type' : $form.find( '[name="type"]' ).val() }, "", new_url );
304
305						// update html.
306						$form.find( '.bs-dir-list' ).html( response.data.html );
307
308						// update count.
309						$form.find( 'li.selected a span' ).text( response.data.count );
310
311						if ( response.data.scopes ) {
312							for (var i in response.data.scopes) {
313								$form.find( 'li#courses-' + i + ' a span' ).text( response.data.scopes[i] ).show();
314							}
315						}
316						$( '.courses-nav' ).find( '.bb-icon-loader' ).remove();
317
318
319						var topOffset = null, additionalOffset = 0, isMobile = $( 'body.bb-is-mobile' ).length;
320						if ( $( '#wpadminbar' ).length ) {
321							additionalOffset = additionalOffset + $( '#wpadminbar' ).height();
322						}
323
324						if ( $( '.sticky-header .site-header--bb' ).length ) {
325							additionalOffset = additionalOffset + $( '.sticky-header .site-header--bb' ).height();
326						}
327
328						if ( ! isMobile ) {
329							var $mainNavs = $( '.main-navs.bp-navs' );
330							if (
331								(
332									$mainNavs.hasClass( 'courses-type-navs' ) &&
333									$mainNavs.hasClass( 'dir-navs' )
334								) ||
335								$mainNavs.hasClass( 'users-nav' )
336							) {
337								topOffset = $mainNavs.offset().top;
338							}
339						}
340
341						if ( ! topOffset ) {
342							if ( $form.find( '.bs-dir-list' ).length ) {
343								topOffset = $form.find( '.bs-dir-list' ).offset().top;
344							} else {
345								topOffset = $form.offset().top;
346							}
347						}
348						// Scroll to course listing top.
349						$( 'html, body' ).animate( {
350							scrollTop: topOffset - additionalOffset
351						}, 400 );
352					}
353				}
354			);
355
356			return false;
357			// $( '#bb-courses-directory-form' ).submit();
358		},
359
360		course_archive_js: function() {
361
362			$( document ).on(
363				'change',
364				'#bb-courses-directory-form input[type=checkbox]',
365				function ( e ) {
366					e.preventDefault();
367					window.BBLMS.fetchCourses();
368				}
369			);
370
371			window.onpopstate = function(e) {
372				if ( ! e.state ) {
373					return;
374				}
375
376				var has_changes = e.state.hasOwnProperty( 'bblms_has_changes' ) ? e.state.bblms_has_changes : false;
377				if ( has_changes ) {
378					var $form = $( '#bb-courses-directory-form' );
379
380					// update courses html.
381					$form.find( '.bs-dir-list' ).html( e.state.courses_html );
382
383					// highlight correct nav.
384					$form.find( '[name="type"]' ).val( e.state.type );
385
386					$form.find( '.component-navigation > li' ).each(
387						function(){
388							$( this ).removeClass( 'selected' );
389							var type = BBGetUrlParameter( $( this ).find( ' > a' ).attr( 'href' ), 'type' );
390							if ( type === e.state.type ) {
391								$( this ).addClass( 'selected' );
392							}
393						}
394					);
395				}
396			};
397
398			$( document ).on(
399				'click',
400				'#bb-course-list-grid-filters .grid-filters a:not(.active)',
401				function ( e ) {
402					e.preventDefault();
403
404					if ( BBLMS.ajax_request ) {
405						BBLMS.ajax_request.abort();
406					}
407
408					$( '#bb-course-list-grid-filters .grid-filters a' ).removeClass( 'active' );
409					$( e.currentTarget ).addClass( 'active' );
410					var view     = $( e.currentTarget ).data( 'view' );
411					var selector = $( '.ld-course-list-content' );
412					if ( selector.hasClass( 'list-view' ) ) {
413						selector.removeClass( 'list-view' );
414					}
415
416					if ( selector.hasClass( 'grid-view' ) ) {
417						selector.removeClass( 'grid-view' );
418					}
419
420					selector.addClass( view + '-view' );
421
422					BBLMS.ajax_request = $.ajax(
423						{
424							method  : 'POST',
425							url     : bs_data.ajaxurl,
426							nonce   : bs_data.nonce_list_grid,
427							data    : 'action=buddyboss_lms_save_view&option=bb_layout_view&object=' + $( this ).parent().attr( 'data-view' ) + '&type=' + view + '&nonce=' + bs_data.nonce_list_grid,
428							success : function ( response ) {
429							}
430						}
431					);
432
433				}
434			);
435
436			$( document ).ready(
437				function() {
438					if ( $( 'body #bb-course-list-grid-filters' ).length ) {
439						var active = '';
440						if ($( '#bb-course-list-grid-filters .grid-filters .layout-grid-view' ).hasClass( 'active' )) {
441							active = 'grid-view';
442						} else {
443							active = 'list-view';
444						}
445						$( '.ld-course-list-content' ).addClass( active );
446					}
447				}
448			);
449
450			$( document ).on(
451				'change',
452				'#bb-courses-directory-form [name=\'orderby\'], #bb-courses-directory-form [name=\'filter-categories\'], #bb-courses-directory-form [name=\'filter-instructors\']',
453				function ( e ) {
454					e.preventDefault();
455					window.BBLMS.fetchCourses( e.target );
456				}
457			);
458
459			$( document ).on(
460				'click',
461				'#bb-courses-directory-form .bs-sort-button',
462				function ( e ) {
463					e.preventDefault();
464					e.currentTarget.classList.toggle( 'active' );
465					$( '#bs-courses-order-by' ).toggleClass( 'open' );
466				}
467			);
468
469			$( document ).on(
470				'click',
471				'#bb-courses-directory-form .bb-lms-pagination a.page-numbers',
472				function ( e ) {
473					e.preventDefault();
474					var page_number = 1;
475					var url_parts   = $( this ).attr( 'href' ).split( '/' );
476					if ( url_parts.length > 0 ) {
477						for ( var i = 0; i < url_parts.length; i++ ) {
478							if ( 'page' === url_parts[i] ) {
479								page_number = url_parts[ i + 1 ];
480								break;
481							}
482						}
483					}
484
485					if ( 0 === $( this ).closest( 'form' ).find( '[name="current_page"]' ).length ) {
486						$( '<input>' ).attr(
487							{
488								type: 'hidden',
489								name: 'current_page'
490							}
491						).appendTo( $( this ).closest( 'form' ) );
492					}
493					$( this ).closest( 'form' ).find( '[name="current_page"]' ).val( page_number );
494					window.BBLMS.fetchCoursesPagination( e.target );
495				}
496			);
497
498			$( document ).on(
499				'click',
500				'#bb-courses-directory-form .component-navigation a:not(.more-button)',
501				function ( e ) {
502					e.preventDefault();
503
504					if ( BBLMS.ajax_request ) {
505						BBLMS.ajax_request.abort();
506					}
507
508					$( this ).closest( '.component-navigation' ).find( '> li' ).removeClass( 'selected' );
509					$( this ).closest( 'li' ).addClass( 'selected' ).append( '<i class="bb-icon-loader animate-spin"></i>' );
510
511					var type = BBGetUrlParameter( $( this ).attr( 'href' ), 'type' );
512					$( this ).closest( 'form' ).find( '[name="type"]' ).val( type );
513
514					// resetting the page number if important, as sometimes 'all courses' can have more items than 'my courses'.
515					$( this ).closest( 'form' ).find( '[name="current_page"]' ).val( 1 );
516					window.BBLMS.fetchCourses( e.target );
517				}
518			);
519
520			document.addEventListener(
521				'click',
522				function ( e ) {
523					var openFilterDropdown = $( '#course-order-dropdown' );
524					var target             = e.target;
525					if ( openFilterDropdown === target && openFilterDropdown.contains( target ) ) {
526						return false;
527					}
528
529					var dropdowns     = $( '#bb-courses-directory-form .bs-dropdown' );
530					var download_link = $( '#bb-courses-directory-form .bs-dropdown-link' );
531
532					for ( var i = 0; i < download_link.length; i++ ) {
533						if ( download_link[i] !== target && ! download_link[i].contains( target ) ) {
534							download_link[i].classList.remove( 'active' );
535						}
536					}
537
538					for ( var i = 0; i < dropdowns.length; i++ ) {
539						if ( dropdowns[i] != target.parentElement.nextElementSibling ) {
540							dropdowns[i].classList.remove( 'open' );
541						}
542					}
543				}
544			);
545
546			$( 'form.bb-courses-directory' ).on(
547				'submit',
548				function(e){
549					e.preventDefault();
550
551					if ( BBLMS.ajax_request ) {
552						BBLMS.ajax_request.abort();
553					}
554
555					window.BBLMS.fetchCourses( e.target );
556					return false;
557				}
558			);
559
560			$( '#bb-courses-directory-form #bs_members_search' ).on(
561				'keypress' ,
562				function(e){
563					if ( e.which == 13 ) {
564						$( e.target ).closest( 'form.bb-courses-directory' ).submit();
565					}
566				}
567			);
568
569		},
570
571		toggleTheme: function() {
572
573			$( document ).on(
574				'click',
575				'#bb-toggle-theme',
576				function ( e ) {
577					e.preventDefault();
578					var color = '';
579					if ( ! $( 'body' ).hasClass( 'bb-dark-theme' ) ) {
580						$.cookie( 'bbtheme', 'dark', { path: '/' } );
581						$( 'body' ).addClass( 'bb-dark-theme' );
582						color = 'dark';
583					} else {
584						$.removeCookie( 'bbtheme', { path: '/' } );
585						$( 'body' ).removeClass( 'bb-dark-theme' );
586					}
587
588					if ( typeof( toggle_theme_ajax ) != 'undefined' && toggle_theme_ajax != null ) {
589						toggle_theme_ajax.abort();
590					}
591
592					var data = {
593						'action': 'buddyboss_lms_toggle_theme_color',
594						'color': color
595					};
596
597					// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php.
598					if ( typeof( toggle_theme_ajax ) != 'undefined' && toggle_theme_ajax != null ) {
599						toggle_theme_ajax = $.post( ajaxurl, data, function ( response ) {} );
600					}
601				}
602			);
603		},
604
605		learnDashSidePanel: function() {
606
607			/* Resize elementor header */
608            function elementorHeaderTriggerResize() {
609                if ( $( '.bb-buddypanel.bb-sfwd-aside .site-header--elementor' ).length > 0 ) {
610                    setTimeout(
611                        function () {
612                            $( window ).trigger( 'resize' );
613                        },
614                        300
615                    );
616                    setTimeout(
617                        function () {
618                            $( window ).trigger( 'resize' );
619                        },
620                        500
621                    );
622                }
623            }
624
625			$( document ).on(
626				'click',
627				'.header-maximize-link',
628				function ( e ) {
629					e.preventDefault();
630					$( 'body' ).addClass( 'lms-side-panel-close' );
631					$( '.lms-topic-sidebar-wrapper' ).addClass( 'lms-topic-sidebar-close' );
632					$.cookie( 'lessonpanel', 'closed', { path: '/' } );
633					elementorHeaderTriggerResize();
634				}
635			);
636
637			$( document ).on(
638				'click',
639				'.header-minimize-link',
640				function ( e ) {
641					e.preventDefault();
642					$( 'body' ).removeClass( 'lms-side-panel-close' );
643					$( '.lms-topic-sidebar-wrapper' ).removeClass( 'lms-topic-sidebar-close' );
644					$.removeCookie( 'lessonpanel', { path: '/' } );
645					elementorHeaderTriggerResize();
646				}
647			);
648
649			if ( $( window ).width() < 768 ) {
650				$( 'body' ).addClass( 'lms-side-panel-close' );
651				$( '.lms-topic-sidebar-wrapper' ).addClass( 'lms-topic-sidebar-close show-in-mobile' );
652
653				$( document ).on(
654					'click',
655					'.header-minimize-link',
656					function ( e ) {
657						e.preventDefault();
658						$( 'body' ).addClass( 'lms-side-panel-close-sm' );
659					}
660				);
661
662				$( document ).click(
663					function(e) {
664						var container = $( '.header-minimize-link' );
665						if ( ! container.is( e.target ) && container.has( e.target ).length === 0 ) {
666							  $( 'body' ).removeClass( 'lms-side-panel-close-sm' );
667						}
668					}
669				);
670			}
671
672			$( window ).on(
673				'resize',
674				function () {
675					if ( $( window ).width() < 768 ) {
676						$( document ).click(
677							function(e) {
678								var container = $( '.header-minimize-link' );
679								if ( ! container.is( e.target ) && container.has( e.target ).length === 0 ) {
680									  $( 'body' ).removeClass( 'lms-side-panel-close-sm' );
681								}
682							}
683						);
684					}
685				}
686			);
687		},
688
689		lms_course_single_js: function() {
690			$( document ).on(
691				'click',
692				'.learndash-course-single-nav',
693				function ( e ) {
694					e.preventDefault();
695					$( 'ul.learndash-course-single-main-nav' ).find( 'li.current.selected' ).removeClass( 'current' ).removeClass( 'selected' );
696
697					var li = $( e.currentTarget ).closest( 'li' );
698					li.addClass( 'current' );
699					li.addClass( 'selected' );
700
701					var currentTab    = $( e.currentTarget );
702					var tab_to_change = currentTab.data( 'tab' );
703
704					var content_elems = $( '.learndash-course-single-tab-content' );
705					$.each(
706						content_elems,
707						function ( elem ) {
708							var _this = $( this );
709							if ( _this.data( 'tab' ) == tab_to_change ) {
710								_this.removeClass( 'hide' );
711							} else {
712								_this.addClass( 'hide' );
713							}
714						}
715					);
716
717				}
718			);
719		},
720
721		lms_single_course: function() {
722			$( '.bb-course-video-overlay' ).magnificPopup(
723				{
724					fixedBgPos: true,
725					fixedContentPos: true,
726					items: {
727						src: '.bb_course_video_details',
728						type: 'inline'
729					},
730					callbacks: {
731						open: function () {
732							// Pause the video if someone click on the close button of the magnificPopup.
733							$.magnificPopup.instance.close = function () {
734								if ($( '.mfp-container .mfp-content .bb_course_video_details video'.length )) {
735									$( 'video' ).trigger( 'pause' );
736									$.magnificPopup.proto.close.call( this );
737								}
738							};
739						}
740					}
741				}
742			);
743
744			function sideBarPosition() {
745				var courseBannerHeight = $( '.bb-learndash-banner' ).height();
746				var courseBannerVideo  = $( '.bb-thumbnail-preview .bb-preview-course-link-wrap' );
747				if ( courseBannerVideo.length ) {
748					var thumbnailContainerHeight = courseBannerVideo.height();
749				} else {
750					var thumbnailContainerHeight = 0;
751				}
752				var sidebarOffset = ( courseBannerHeight / 2 ) + ( thumbnailContainerHeight / 2 );
753				if ( $( window ).width() > 820 ) {
754					$( '.bb-single-course-sidebar.bb-preview-wrap' ).css( { 'margin-top' : '-' + sidebarOffset + 'px' } );
755				}
756			}
757
758			function courseBanner() {
759				var mainWidth = $( '#main' ).width();
760				$( '.bb-learndash-banner .bb-course-banner-info.container' ).width( mainWidth );
761			}
762
763			sideBarPosition();
764			courseBanner();
765
766			$( window ).on(
767				'resize',
768				function () {
769					courseBanner();
770					sideBarPosition();
771				}
772			);
773
774			$( '.bb-toggle-panel' ).on(
775				'click',
776				function(e) {
777					e.preventDefault();
778
779					setTimeout(
780						function(){
781							courseBanner();
782						},
783						300
784					);
785					setTimeout(
786						function(){
787							courseBanner();
788						},
789						600
790					);
791				}
792			);
793
794			$( '.lms-topic-sidebar-wrapper .lms-toggle-lesson' ).on(
795				'click',
796				function() {
797					setTimeout( function(){ $( window ).trigger( 'resize' ); }, 300 );
798				}
799			);
800		},
801
802		lms_user_profile_js: function() {
803			$( document ).on(
804				'click',
805				'.bb-lms-user-profile-tab',
806				function ( e ) {
807					e.preventDefault();
808					$( 'ul.bb-lms-user-profile-tabs' ).find( 'li.current.selected' ).removeClass( 'current' ).removeClass( 'selected' );
809
810					var li = $( e.currentTarget ).closest( 'li' );
811					li.addClass( 'current' );
812					li.addClass( 'selected' );
813
814					var currentTab    = $( e.currentTarget );
815					var tab_to_change = currentTab.data( 'tab' );
816
817					var content_elems = $( '.bb-lms-user-profile-tab-content' );
818					$.each(
819						content_elems,
820						function ( elem ) {
821							var _this = $( this );
822							if ( _this.data( 'tab' ) == tab_to_change ) {
823								_this.removeClass( 'hide' );
824							} else {
825								_this.addClass( 'hide' );
826							}
827						}
828					);
829
830				}
831			);
832		},
833
834		quizDetails: function() {
835
836			if ( $( '#bb-lms-quiz-id' ).length ) {
837				var quiz_id = $( '#bb-lms-quiz-id' ).val();
838
839				$( 'div.quiz_progress_container' ).insertBefore( $( '.wpProQuiz_results .wpProQuiz_resultTable' ) );
840
841				$( '#wpProQuiz_' + quiz_id ).on(
842					'learndash-quiz-init',
843					function () {
844						// $( document ).find( 'input[name="startQuiz"]' ).click( function () {
845						// BBLMS.showQuizNavigation();
846						// } );
847						//
848						// $( document ).on( 'click', '.bb-lms-quiz-questions', function ( e ) {
849						// e.preventDefault();
850						// var index = $( e.currentTarget ).data( 'index' );
851						// if ( typeof index !== 'undefined' ) {
852						// $( '#wpProQuiz_' + quiz_id ).data( "wpProQuizFront" ).methode.showQuestion( index );
853						// }
854						// } );
855					}
856				);
857			}
858		},
859
860		ajaxCompleteProcess: function () {
861			$( document ).ajaxComplete(
862				function (event, request, settings) {
863					if (settings.data.indexOf( 'action=wp_pro_quiz_load_quiz_data' ) || settings.data.indexOf( 'action=wp_pro_quiz_completed_quiz' )) {
864						if (settings.data && settings.data != '') {
865							var splitted = settings.data.split( '&' );
866							var action   = '';
867							for (var i in splitted) {
868								if (splitted[i].indexOf( 'action' ) != -1) {
869									action = splitted[i].split( '=' );
870									action = typeof action[1] !== 'undefined' ? action[1] : '';
871									break;
872								}
873							}
874							if (action != '' && action == 'wp_pro_quiz_load_quiz_data') {
875								if ($( '.wpProQuiz_resultTable' ).length) {
876									$( '.bb_avg_progress' ).show();
877
878									var pathAvg = new ProgressBar.Path(
879										"#bb_avg_shape",
880										{
881											duration: 3000,
882											from: {
883												color: "#ECCBFF",
884												width: 8
885											},
886											to: {
887												color: "#ECCBFF",
888												width: 8
889											},
890											easing: "easeInOut",
891											step: function (state, shape) {
892												shape.path.setAttribute( "stroke", state.color );
893												shape.path.setAttribute( "stroke-width", state.width );
894											}
895										}
896									);
897
898									var avarage = request.responseJSON.averageResult;
899									if (avarage > 0) {
900										avarage = -avarage / 100;
901									} else {
902										avarage = 0;
903									}
904									pathAvg.animate( avarage );
905								}
906							}
907							if (action != '' && action == 'wp_pro_quiz_completed_quiz') {
908								if ($( '.wpProQuiz_resultTable' ).length) {
909
910									var data     = decodeURIComponent( settings.data );
911									var splitted = data.split( '&' );
912									var result   = '';
913									for (var i in splitted) {
914										if (splitted[i].indexOf( 'results' ) != -1) {
915											result = splitted[i].split( '=' );
916											result = typeof result[1] !== 'undefined' ? result[1] : '';
917											result = JSON.parse( result );
918											break;
919										}
920									}
921
922									if (typeof result.comp.result !== 'undefined') {
923										result = result.comp.result;
924									}
925
926									var path = new ProgressBar.Path(
927										"#quiz_shape_progress",
928										{
929											duration: 3000,
930											from: {
931												color: "#00A2FF",
932												width: 8
933											},
934											to: {
935												color: "#7FE0FF",
936												width: 8
937											},
938											easing: "easeInOut",
939											step: function (state, shape) {
940												shape.path.setAttribute( "stroke", state.color );
941												shape.path.setAttribute( "stroke-width", state.width );
942											}
943										}
944									);
945
946									jQuery( '.bb_progressbar_label' ).text( result + '%' );
947									jQuery( '.bb_progressbar_points' ).text( jQuery( '.wpProQuiz_points' ).text() );
948
949									if (result > 0) {
950										result = -result / 100;
951									}
952
953									path.animate( result );
954								}
955							}
956						}
957					}
958				}
959			);
960		},
961
962		quizUpload: function() {
963			function inputFileStyle() {
964				$( 'input.wpProQuiz_upload_essay[type=file]:not(.styled)' ).each(
965					function () {
966						var $fileInput    = $( this );
967						var $fileInputFor = $fileInput.attr( 'id' );
968						$fileInput.addClass( 'styled' );
969						$fileInput.after( '<label for="' + $fileInputFor + '">' + bs_data.translation.choose_a_file_label + '</label>' );
970					}
971				);
972
973				$( 'input.wpProQuiz_upload_essay[type=file]' ).change(
974					function ( e ) {
975						var $in    = $( this );
976						var $inval = $in.next().html( $in.val() );
977						if ( $in.val().length === 0 ) {
978							  $in.next().html( bs_data.translation.choose_a_file_label );
979						} else {
980							$in.next().html( $in.val().replace( /C:\\fakepath\\/i, '' ) );
981						}
982					}
983				);
984			}
985
986			inputFileStyle();
987			$( document ).ajaxComplete(
988				function() {
989					inputFileStyle();
990				}
991			);
992		},
993
994		bbStickyLdSidebar: function () {
995			function ldSaidebarPosition() {
996				var bbHeaderHeight = $( '#masthead' ).outerHeight();
997
998				if ( $( window ).width() > 820 && $( '.bb-ld-sticky-sidebar .ld-sidebar-widgets' ).length == 0 ) {
999					$( '.bb-ld-sticky-sidebar' ).stick_in_parent( {offset_top: bbHeaderHeight + 45} );
1000
1001					var adminBarHeight = 0;
1002					if ( $( 'body' ).hasClass( 'admin-bar' ) ) {
1003						adminBarHeight = 32;
1004					}
1005					$( '.lms-topic-sidebar-data' ).css( {'max-height': 'calc(100vh - ' + ( bbHeaderHeight + adminBarHeight ) + 'px', 'top': ( bbHeaderHeight + adminBarHeight ) + 'px' } );
1006					/* Learndash single lesson/topic/quiz pages - header always sticky */
1007					/*if( !$('body').hasClass( 'sticky-header' ) ) {
1008						if( $(window).scrollTop() >= $('#masthead').outerHeight() ) {
1009							bbHeaderHeight = 0;
1010						} else {
1011							bbHeaderHeight = $('#masthead').outerHeight();
1012						}
1013						$('.lms-topic-sidebar-data').css({'max-height': 'calc(100vh - '+ ( bbHeaderHeight + adminBarHeight ) +'px', 'top': ( bbHeaderHeight + adminBarHeight ) +'px' });
1014					}*/
1015
1016				} else {
1017					$( '.bb-ld-sticky-sidebar' ).trigger( "sticky_kit:detach" );
1018					// $('.lms-topic-sidebar-data').trigger("sticky_kit:detach");
1019				}
1020			}
1021
1022			ldSaidebarPosition();
1023
1024			$( window ).on(
1025				'resize',
1026				function () {
1027					ldSaidebarPosition();
1028				}
1029			);
1030
1031			$(window).on('scroll', function () {
1032				if ( $( '#learndash-payment-button-dropdown' ).length ) {
1033					$( '#learndash-payment-button-dropdown' ).fadeOut( 'fast' );
1034					$( '.learndash_checkout_buttons .learndash_checkout_button' ).removeClass( 'jq-dropdown-open' ).blur();
1035				}
1036			});
1037
1038			/* Learndash single lesson/topic/quiz pages - header always sticky */
1039			/*$(window).on('scroll', function () {
1040				if( !$('body').hasClass( 'sticky-header' ) ) {
1041					if( $(window).scrollTop() >= $('#masthead').outerHeight() ) {
1042						bbHeaderHeight = 0;
1043					} else {
1044						bbHeaderHeight = $('#masthead').outerHeight();
1045					}
1046					$('.lms-topic-sidebar-data').css({'max-height': 'calc(100vh - '+ ( bbHeaderHeight + adminBarHeight ) +'px', 'top': ( bbHeaderHeight + adminBarHeight ) +'px' });
1047				}
1048
1049			});*/
1050
1051			if ($( '.wpProQuiz_matrixSortString' ).length > 0) {
1052				$( 'html' ).addClass( 'quiz-sort' );
1053			}
1054		},
1055
1056		setElementorSpacing: function() {
1057			if ( $( '.elementor-location-header' ).length > 0 ) {
1058				var setHeight = $( '.elementor-location-header' ).outerHeight();
1059				$( '.lms-topic-sidebar-wrapper, #learndash-page-content' ).css( {'min-height': 'calc(100vh - ' + setHeight + 'px)'} );
1060			}
1061		},
1062
1063		showQuizNavigation: function() {
1064			var question_list = $( '.wpProQuiz_list' ).find( '.wpProQuiz_listItem' );
1065			var nav_wrapper   = $( '#bb-lms-quiz-navigation' );
1066			if ( question_list.length && nav_wrapper.length ) {
1067				var str = '<ul>';
1068				for ( var i = 1; i <= question_list.length; i++ ) {
1069					str += '<li><a href="#" class="bb-lms-quiz-questions" data-index="' + ( i - 1 ) + '">' + i + '</a></li>';
1070				}
1071				str += '</ul>';
1072				nav_wrapper.html( str );
1073			}
1074		},
1075
1076		StyleInputQuestion: function() {
1077			function styleInputs() {
1078				$( '.wpProQuiz_questionInput:not([type="text"]):not([type="email"]):not([type="tel"]):not([type="date"])' ).each(
1079					function() {
1080						if ( ! $( this ).hasClass( 'bbstyled' ) ) {
1081							$( this ).addClass( 'bbstyled' ).after( '<span class="input-style"></span>' );
1082						}
1083					}
1084				);
1085			}
1086
1087			styleInputs();
1088
1089			$( document ).ajaxComplete(
1090				function() {
1091					styleInputs();
1092				}
1093			);
1094		},
1095
1096		singleLesson: function() {
1097			var lsPageContent = document.getElementById( 'learndash-page-content' );
1098			if ( lsPageContent ) {
1099				$( '#learndash-page-content' ).scroll(
1100					function() {
1101						$( window ).trigger( 'resize' );
1102					}
1103				);
1104			}
1105		},
1106
1107		singleTopic: function() {
1108			var lsPageContent = $( 'body.single-sfwd-topic .lms-topic-item.current' );
1109			if ( lsPageContent.length ) {
1110				lsPageContent.closest( 'div' ).show();
1111				lsPageContent.parents().closest( 'li' ).removeClass( 'lms-lesson-turnover' );
1112			}
1113			// Remove comment system added by shortcodes.
1114			var learndash_pages = ['.sfwd-lessons-template-default', '.sfwd-topic-template-default', '.sfwd-quiz-template-default'];
1115			for (var i = 0; i < learndash_pages.length; i++) {
1116				if ($( learndash_pages[i] + ' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap #comments.comments-area' ).length > 0) {
1117					$( learndash_pages[i] + ' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap #comments.comments-area' ).remove();
1118				}
1119				if ($( learndash_pages[i] + ' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap .ld-focus-comments' ).length > 0) {
1120					$( learndash_pages[i] + ' #learndash-page-content #learndash-content #learndash-page-content .learndash_content_wrap .ld-focus-comments' ).remove();
1121				}
1122			}
1123		},
1124
1125		singleQuiz: function() {
1126			var lsPageContent = $( 'body.single-sfwd-quiz .lms-quiz-item.current' );
1127			if ( lsPageContent.length ) {
1128				lsPageContent.closest( 'div' ).show();
1129				lsPageContent.parents().closest( 'li' ).removeClass( 'lms-lesson-turnover' );
1130			}
1131			if ( $( window ).width() > 768 && $( '.wpProQuiz_quiz #bbpress-forums .bs-topic-sidebar-inner' ).length > 0 ) {
1132				// https://developers.learndash.com/snippet/hook-into-quiz-start-button-logic/
1133				var triggerElements = [
1134					'.wpProQuiz_content input.wpProQuiz_button[name="startQuiz"]',
1135					'.wpProQuiz_content .wpProQuiz_QuestionButton[value="Next"]',
1136					'.wpProQuiz_content .wpProQuiz_QuestionButton[value="Back"]' ];
1137				triggerElements.forEach(
1138					function ( el ) {
1139						$( el ).click(
1140							function () {
1141								setTimeout(
1142									function () {
1143										// Trigger scroll to initiate sidebar stick_in_parent script.
1144										$( window ).trigger( 'scroll' );
1145									},
1146									0
1147								);
1148							}
1149						);
1150					}
1151				);
1152			}
1153		},
1154
1155		inforBarStatus: function () {
1156			if ( $( '.ld-course-status-segment' ).length ) {
1157				$( '.ld-course-status-segment' ).each(
1158					function () {
1159						if ( $( this ).find( '.ld-course-status-label' ).text().trim() == '' ) {
1160							$( this ).find( '.ld-course-status-label' ).addClass( 'no-label' );
1161						}
1162					}
1163				);
1164			}
1165		},
1166
1167	};
1168
1169	$( document ).ready(
1170		function () {
1171			window.BBLMS.ajax_request = null;
1172			window.BBLMS.init();
1173		}
1174	);
1175
1176} )( 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.