PageSourceSearch

https://www.norskedalen.org/wp-content/plugins/sfwd-lms/themes/ld30/assets/js/learndash.js?ver=4.6.0.1

js norskedalen.org collected 2026-09-24 23:58:14 UTC 38,238 bytes, 1,461 lines download raw bytes

1/* eslint-disable no-var */
2jQuery(function ($) {
3	var hash = window.location.hash;
4
5	learndashFocusModeSidebarAutoScroll();
6
7	initLoginModal();
8	if ('#login' == hash) {
9		openLoginModal();
10	}
11
12	if ('undefined' !== typeof ldGetUrlVars().login) {
13		var loginStatus = ldGetUrlVars().login;
14
15		if ('failed' == loginStatus) {
16			openLoginModal();
17		}
18	}
19
20	if ('undefined' !== typeof ldGetUrlVars()['ld-topic-page']) {
21		var topicPage = ldGetUrlVars()['ld-topic-page'];
22		var topicIds = topicPage.split('-');
23		var topicId = Object.values(topicIds)[0];
24
25		var lesson = $('#ld-expand-' + topicId);
26		var button = $(lesson).find('.ld-expand-button');
27
28		ld_expand_element(button);
29
30		$('html, body').animate(
31			{
32				scrollTop: $(lesson).offset().top,
33			},
34			500
35		);
36	}
37
38	$('body').on('click', 'a[href="#login"]', function (e) {
39		e.preventDefault();
40		openLoginModal();
41	});
42
43	$('body').on('click', '.ld-modal-closer', function (e) {
44		e.preventDefault();
45		closeLoginModal();
46	});
47
48	$('body').on('click', '#ld-comments-post-button', function (e) {
49		$(this).addClass('ld-open');
50		$('#ld-comments-form').removeClass('ld-collapsed');
51		$('textarea#comment').focus();
52	});
53
54	// Close modal if clicking away
55	/*
56	$('body').on('click', function(e) {
57		if ($('.learndash-wrapper').hasClass('ld-modal-open')) {
58			if ( ! $(e.target).parents('.ld-modal').length && (! $(e.target).is('a'))) {
59				closeLoginModal();
60			}
61		}
62	});
63	*/
64
65	// Close modal on Esc key
66	$(document).on('keyup', function (e) {
67		if (27 === e.keyCode) {
68			closeLoginModal();
69		}
70	});
71
72	$('.learndash-wrapper').on(
73		'click',
74		'a.user_statistic',
75		learndash_ld30_show_user_statistic
76	);
77
78	focusMobileCheck();
79
80	$('body').on('click', '.ld-focus-sidebar-trigger', function (e) {
81		if ($('.ld-focus').hasClass('ld-focus-sidebar-collapsed')) {
82			openFocusSidebar();
83		} else {
84			closeFocusSidebar();
85		}
86	});
87
88	$('body').on('click', '.ld-mobile-nav a', function (e) {
89		e.preventDefault();
90		if ($('.ld-focus').hasClass('ld-focus-sidebar-collapsed')) {
91			openFocusSidebar();
92		} else {
93			closeFocusSidebar();
94		}
95	});
96
97	$('.ld-js-register-account').on('click', function (e) {
98		e.preventDefault();
99
100		$('.ld-login-modal-register .ld-modal-text').slideUp('slow');
101		$('.ld-login-modal-register .ld-alert').slideUp('slow');
102		$(this).slideUp('slow', function () {
103			$('#ld-user-register').slideDown('slow');
104		});
105	});
106
107	// If registration login link filter not defined, allow to replace the register form with login form
108	if ('' == $('.registration-login-link').attr('href')) {
109		$('.registration-login-link').on('click', function (e) {
110			e.preventDefault();
111			$('#learndash_registerform, .registration-login').hide();
112			$(
113				'.registration-login-form, .show-register-form, .show-password-reset-link'
114			).show();
115		});
116		$('.show-register-form').on('click', function (e) {
117			e.preventDefault();
118			$(
119				'.registration-login-form, .show-register-form, .show-password-reset-link'
120			).hide();
121			$('#learndash_registerform, .registration-login').show();
122		});
123	}
124
125	var windowWidth = $(window).width();
126
127	$(window).on('orientationchange', function () {
128		windowWidth = $(window).width();
129	});
130
131	$(window).on('resize', function () {
132		if ($(this).width() !== windowWidth && 1024 >= $(this).width()) {
133			setTimeout(function () {
134				focusMobileResizeCheck();
135			}, 50);
136		}
137	});
138
139	if ($('.ld-course-status-content').length) {
140		var tallest = 0;
141
142		$('.ld-course-status-content').each(function () {
143			if ($(this).height() > tallest) {
144				tallest = $(this).height();
145			}
146		});
147
148		$('.ld-course-status-content').height(tallest);
149	}
150
151	function focusMobileCheck() {
152		if (1024 > $(window).width()) {
153			closeFocusSidebarPageLoad();
154		}
155	}
156
157	function focusMobileResizeCheck() {
158		if (
159			1024 > $(window).width() &&
160			!$('.ld-focus').hasClass('ld-focus-sidebar-collapsed')
161		) {
162			closeFocusSidebar();
163		} else if (
164			1024 <= $(window).width() &&
165			$('.ld-focus').hasClass('ld-focus-sidebar-filtered')
166		) {
167			closeFocusSidebar();
168		} else if (
169			1024 <= $(window).width() &&
170			!$('.ld-focus').hasClass('ld-focus-sidebar-filtered') &&
171			$('.ld-focus').hasClass('ld-focus-sidebar-collapsed')
172		) {
173			openFocusSidebar();
174		}
175	}
176
177	function focusMobileHandleOrientationChange(e) {
178		if (e.matches) {
179			if (
180				1024 <= $(window).width() &&
181				!$('.ld-focus').hasClass('ld-focus-sidebar-filtered') &&
182				$('.ld-focus').hasClass('ld-focus-sidebar-collapsed')
183			) {
184				openFocusSidebar();
185			}
186		}
187	}
188	window
189		.matchMedia('(orientation: landscape)')
190		.addListener(focusMobileHandleOrientationChange);
191
192	function closeFocusSidebarPageLoad() {
193		$('.ld-focus').addClass('ld-focus-sidebar-collapsed');
194		$('.ld-focus').removeClass('ld-focus-initial-transition');
195		$('.ld-mobile-nav').removeClass('expanded');
196		positionTooltips();
197	}
198
199	function closeFocusSidebar() {
200		$('.ld-focus').addClass('ld-focus-sidebar-collapsed');
201		$('.ld-mobile-nav').removeClass('expanded');
202
203		if (
204			$('.ld-focus-sidebar-trigger .ld-icon').hasClass(
205				'ld-icon-arrow-left'
206			)
207		) {
208			$('.ld-focus-sidebar-trigger .ld-icon').removeClass(
209				'ld-icon-arrow-left'
210			);
211			$('.ld-focus-sidebar-trigger .ld-icon').addClass(
212				'ld-icon-arrow-right'
213			);
214		} else if (
215			$('.ld-focus-sidebar-trigger .ld-icon').hasClass(
216				'ld-icon-arrow-right'
217			)
218		) {
219			$('.ld-focus-sidebar-trigger .ld-icon').removeClass(
220				'ld-icon-arrow-right'
221			);
222			$('.ld-focus-sidebar-trigger .ld-icon').addClass(
223				'ld-icon-arrow-left'
224			);
225		}
226
227		positionTooltips();
228	}
229
230	function openFocusSidebar() {
231		focusMobileCheck();
232		$('.ld-focus').removeClass('ld-focus-sidebar-collapsed');
233		$('.ld-mobile-nav').addClass('expanded');
234
235		if (
236			$('.ld-focus-sidebar-trigger .ld-icon').hasClass(
237				'ld-icon-arrow-left'
238			)
239		) {
240			$('.ld-focus-sidebar-trigger .ld-icon').removeClass(
241				'ld-icon-arrow-left'
242			);
243			$('.ld-focus-sidebar-trigger .ld-icon').addClass(
244				'ld-icon-arrow-right'
245			);
246		} else if (
247			$('.ld-focus-sidebar-trigger .ld-icon').hasClass(
248				'ld-icon-arrow-right'
249			)
250		) {
251			$('.ld-focus-sidebar-trigger .ld-icon').removeClass(
252				'ld-icon-arrow-right'
253			);
254			$('.ld-focus-sidebar-trigger .ld-icon').addClass(
255				'ld-icon-arrow-left'
256			);
257		}
258
259		positionTooltips();
260	}
261
262	$('.ld-file-input').each(function () {
263		var $input = $(this),
264			$label = $input.next('label'),
265			labelVal = $label.html();
266
267		$input.on('change', function (e) {
268			var fileName = '';
269			if (this.files && 1 < this.files.length) {
270				fileName = (
271					this.getAttribute('data-multiple-caption') || ''
272				).replace('{count}', this.files.length);
273			} else if (e.target.value) {
274				fileName = e.target.value.split('\\').pop();
275			}
276			if (fileName) {
277				$label.find('span').html(fileName);
278				$label.addClass('ld-file-selected');
279				$('#uploadfile_btn').attr('disabled', false);
280			} else {
281				$label.html(labelVal);
282				$label.removeClass('ld-file-selected');
283				$('#uploadfile_btn').attr('disabled', true);
284			}
285		});
286
287		$('#uploadfile_form').on('submit', function () {
288			$label.removeClass('ld-file-selected');
289			$('#uploadfile_btn').attr('disabled', true);
290		});
291
292		// Firefox bug fix
293		$input
294			.on('focus', function () {
295				$input.addClass('has-focus');
296			})
297			.on('blur', function () {
298				$input.removeClass('has-focus');
299			});
300	});
301
302	$('body').on('click', '.ld-expand-button', function (e) {
303		e.preventDefault();
304
305		ld_expand_element($(this));
306
307		positionTooltips();
308	});
309
310	$('body').on('click', '.ld-search-prompt', function (e) {
311		e.preventDefault();
312
313		$('#course_name_field').focus();
314
315		ld_expand_element($(this));
316	});
317
318	function ld_expand_button_state(state, elm) {
319		var $expandText = $(elm)[0].hasAttribute('data-ld-expand-text')
320			? $(elm).attr('data-ld-expand-text')
321			: 'Expand';
322		var $collapseText = $(elm)[0].hasAttribute('data-ld-collapse-text')
323			? $(elm).attr('data-ld-collapse-text')
324			: 'Collapse';
325
326		if ('collapse' == state) {
327			$(elm).removeClass('ld-expanded');
328			if ('false' !== $collapseText) {
329				$(elm).find('.ld-text').text($expandText);
330			}
331		} else {
332			$(elm).addClass('ld-expanded');
333			if ('false' !== $collapseText) {
334				$(elm).find('.ld-text').text($collapseText);
335			}
336		}
337	}
338
339	function ld_expand_element(elm, collapse) {
340		if (collapse === undefined) {
341			collapse = false;
342		}
343
344		var elmParentWrapper = elm.parents('.ld-focus-sidebar');
345		if (
346			'undefined' === typeof elmParentWrapper ||
347			!elmParentWrapper.length
348		) {
349			var elmParentWrapper = elm.parents('.learndash-wrapper');
350		}
351		if (
352			'undefined' === typeof elmParentWrapper ||
353			!elmParentWrapper.length
354		) {
355			return;
356		}
357
358		// Get the button's state
359		var $expanded = $(elm).hasClass('ld-expanded');
360
361		// Get the element to expand
362		if ($(elm)[0] && $(elm)[0].hasAttribute('data-ld-expands')) {
363			var $expands = $(elm).attr('data-ld-expands');
364			if ('undefined' === typeof $expands || !$expands.length) {
365				return;
366			}
367
368			var $expandElm = $(elmParentWrapper).find(
369				'[data-ld-expand-id="' + $expands + '"]'
370			);
371			if ('undefined' === typeof $expandElm || !$expandElm.length) {
372				return;
373			}
374
375			var $expandsChild = $($expandElm).find(
376				'.ld-item-list-item-expanded'
377			);
378
379			if ($expandsChild.length) {
380				$expandElm = $expandsChild;
381			}
382
383			var totalHeight = 0;
384
385			$expandElm.find('> *').each(function () {
386				totalHeight += $(this).outerHeight();
387			});
388
389			$expandElm.attr('data-height', '' + (totalHeight + 50) + '');
390
391			// If the element expands a list
392
393			if (
394				$(elmParentWrapper)
395					.find('[data-ld-expand-id="' + $expands + '"]')[0]
396					.hasAttribute('data-ld-expand-list')
397			) {
398				var $container = $(elmParentWrapper).find(
399					'[data-ld-expand-id="' + $expands + '"]'
400				);
401				var innerButtons = $container.find('.ld-expand-button');
402				if ($expanded) {
403					ld_expand_button_state('collapse', elm);
404					innerButtons.each(function () {
405						ld_expand_element($(this), true);
406					});
407				} else {
408					ld_expand_button_state('expand', elm);
409					innerButtons.each(function () {
410						ld_expand_element($(this));
411					});
412				}
413
414				// If the element expands an item
415			} else if (
416				$(elmParentWrapper).find(
417					'[data-ld-expand-id="' + $expands + '"]'
418				).length
419			) {
420				if ($expanded || true == collapse) {
421					ld_expand_singular_item(
422						elm,
423						$(elmParentWrapper).find(
424							'[data-ld-expand-id="' + $expands + '"]'
425						),
426						$expandElm
427					);
428				} else {
429					ld_collapse_singular_item(
430						elm,
431						$(elmParentWrapper).find(
432							'[data-ld-expand-id="' + $expands + '"]'
433						),
434						$expandElm
435					);
436				}
437			} else {
438				console.log('LearnDash: No expandable content was found');
439			}
440			positionTooltips();
441		}
442	}
443
444	function ld_expand_singular_item(elm, $containerElm, $expandElm) {
445		$containerElm.removeClass('ld-expanded');
446		ld_expand_button_state('collapse', elm);
447
448		$expandElm.css({
449			'max-height': 0,
450		});
451	}
452
453	function ld_collapse_singular_item(elm, $containerElm, $expandElm) {
454		$containerElm.addClass('ld-expanded');
455
456		ld_expand_button_state('expand', elm);
457
458		$expandElm.css({
459			'max-height': $expandElm.data('height'),
460		});
461	}
462
463	$('body').on('click', '.ld-closer', function (e) {
464		ld_expand_element($('.ld-search-prompt'), true);
465	});
466
467	$('body').on('click', '.ld-tabs-navigation .ld-tab', function () {
468		var $tab = $('#' + $(this).attr('data-ld-tab'));
469		if ($tab.length) {
470			$('.ld-tabs-navigation .ld-tab.ld-active').removeClass('ld-active');
471			$('.ld-tabs-navigation .ld-tab').removeAttr('aria-selected');
472			$(this).addClass('ld-active');
473			$(this).attr('aria-selected', 'true');
474			$('.ld-tabs-content .ld-tab-content.ld-visible').removeClass(
475				'ld-visible'
476			);
477			$tab.addClass('ld-visible');
478		}
479		positionTooltips();
480	});
481
482	var $tooltips = $('*[data-ld-tooltip]');
483
484	initTooltips();
485
486	function initTooltips() {
487		// Clear out old tooltips
488
489		if ($('#learndash-tooltips').length) {
490			$('#learndash-tooltips').remove();
491			$tooltips = $('*[data-ld-tooltip]');
492		}
493
494		if ($tooltips.length) {
495			$('body').prepend('<div id="learndash-tooltips"></div>');
496			var $ctr = 1;
497			$tooltips.each(function () {
498				var anchor = $(this);
499				if (anchor.hasClass('ld-item-list-item')) {
500					anchor = anchor.find('.ld-item-title');
501				}
502
503				/**
504				 * Prevent calendar icon from being clickable.
505				 */
506				if (
507					'undefined' !== typeof anchor &&
508					$(anchor).hasClass('ld-status-waiting')
509				) {
510					$(anchor).on('click', function (e) {
511						e.preventDefault();
512						return false;
513					});
514
515					// Also prevent parent <a> from being clickable.
516					var parent_anchor = $(anchor).parents('a');
517					if ('undefined' !== typeof parent_anchor) {
518						$(parent_anchor).on('click', function (e) {
519							e.preventDefault();
520							return false;
521						});
522					}
523				}
524
525				var elementOffsets = {
526					top: anchor.offset().top,
527					left: anchor.offset().left + anchor.outerWidth() / 2,
528				};
529				var $content = $(this).attr('data-ld-tooltip');
530				var $rel_id = Math.floor(Math.random() * 99999);
531
532				//var $tooltip = '<span id="ld-tooltip-' + $rel_id + '" class="ld-tooltip" style="top:' + elementOffsets.top + 'px; left:' + elementOffsets.left + 'px;">' + $content + '</span>';
533				var $tooltip =
534					'<span id="ld-tooltip-' +
535					$rel_id +
536					'" class="ld-tooltip">' +
537					$content +
538					'</span>';
539				$(this).attr('data-ld-tooltip-id', $rel_id);
540				$('#learndash-tooltips').append($tooltip);
541				$ctr++;
542				var $tooltip = $('#ld-tooltip-' + $rel_id);
543				$(this)
544					.on('mouseenter', function () {
545						$tooltip.addClass('ld-visible');
546					})
547					.on('mouseleave', function () {
548						$tooltip.removeClass('ld-visible');
549					});
550			});
551
552			$(window).on('resize', function () {
553				// Reposition tooltips after resizing
554				positionTooltips();
555			});
556
557			$(window)
558				.add('.ld-focus-sidebar-wrapper')
559				.on('scroll', function () {
560					// Hide tooltips so they don't persist while scrolling
561					$('.ld-visible.ld-tooltip').removeClass('ld-visible');
562
563					// Reposition tooltips after scrolling
564					positionTooltips();
565				});
566
567			positionTooltips();
568		}
569	}
570
571	function initLoginModal() {
572		var modal_wrapper = $('.learndash-wrapper-login-modal');
573		if ('undefined' !== typeof modal_wrapper && modal_wrapper.length) {
574			// Move the model to be first element of the body. See LEARNDASH-3503
575			$(modal_wrapper).prependTo('body');
576		}
577	}
578
579	function openLoginModal() {
580		var modal_wrapper = $('.learndash-wrapper-login-modal');
581		if ('undefined' !== typeof modal_wrapper && modal_wrapper.length) {
582			$(modal_wrapper).addClass('ld-modal-open');
583			$(modal_wrapper).removeClass('ld-modal-closed');
584
585			// Removed LEARNDASH-3867 #4
586			$('html, body').animate(
587				{
588					scrollTop: $('.ld-modal', modal_wrapper).offset().top,
589				},
590				50
591			);
592		}
593	}
594
595	function closeLoginModal() {
596		var modal_wrapper = $('.learndash-wrapper-login-modal');
597		if ('undefined' !== typeof modal_wrapper && modal_wrapper.length) {
598			$(modal_wrapper).removeClass('ld-modal-open');
599			$(modal_wrapper).addClass('ld-modal-closed');
600		}
601	}
602
603	function positionTooltips() {
604		if ('undefined' !== typeof $tooltips) {
605			setTimeout(function () {
606				$tooltips.each(function () {
607					var anchor = $(this);
608					var $rel_id = anchor.attr('data-ld-tooltip-id');
609					$tooltip = $('#ld-tooltip-' + $rel_id);
610
611					if (anchor.hasClass('ld-item-list-item')) {
612						//anchor = anchor.find('.ld-item-title');
613						anchor = anchor.find('.ld-status-icon');
614					}
615
616					var parent_focus =
617						jQuery(anchor).parents('.ld-focus-sidebar');
618					var left_post =
619						anchor.offset().left + (anchor.outerWidth() + 10);
620					if (parent_focus.length) {
621						left_post =
622							anchor.offset().left + (anchor.outerWidth() - 18);
623					}
624
625					// Get the main content height
626					var focusModeMainContentHeight =
627						$('.ld-focus-main').height();
628
629					// Current tooltip height
630					var focusModeCurrentTooltipHeight =
631						anchor.offset().top + -3;
632
633					// Position tooltip depending on focus mode or not
634					if (!focusModeMainContentHeight) {
635						var anchorTop = anchor.offset().top + -3;
636						var anchorLeft = anchor.offset().left;
637					} else {
638						anchorTop =
639							focusModeCurrentTooltipHeight <
640							focusModeMainContentHeight
641								? focusModeCurrentTooltipHeight
642								: focusModeMainContentHeight;
643						anchorLeft = left_post;
644					}
645
646					$tooltip
647						.css({
648							top: anchorTop,
649
650							//'left' : anchor.offset().left + (anchor.outerWidth() / 2),
651							//'left': left_post, //anchor.offset().left + (anchor.outerWidth() +10),
652							left: anchorLeft, //anchor.offset().left + (anchor.outerWidth() +10),
653							'margin-left': 0,
654							'margin-right': 0,
655						})
656						.removeClass('ld-shifted-left ld-shifted-right');
657					if ($tooltip.offset().left <= 0) {
658						$tooltip
659							.css({
660								'margin-left': Math.abs($tooltip.offset().left),
661							})
662							.addClass('ld-shifted-left');
663					}
664					var $tooltipRight =
665						$(window).width() -
666						($tooltip.offset().left + $tooltip.outerWidth());
667					if (0 >= $tooltipRight && 360 < $(window).width()) {
668						$tooltip
669							.css({ 'margin-right': Math.abs($tooltipRight) })
670							.addClass('ld-shifted-right');
671					}
672				});
673			}, 500);
674		}
675	}
676
677	$('body').on('click', '#ld-profile .ld-reset-button', function (e) {
678		e.preventDefault();
679
680		$('#ld-profile #course_name_field').val('');
681
682		var searchVars = {
683			shortcode_instance: $('#ld-profile').data('shortcode_instance'),
684		};
685
686		searchVars['ld-profile-search'] = $(this)
687			.parents('.ld-item-search-wrapper')
688			.find('#course_name_field')
689			.val();
690		searchVars['ld-profile-search-nonce'] = $(this)
691			.parents('.ld-item-search-wrapper')
692			.find('form.ld-item-search-fields')
693			.data('nonce');
694
695		$('#ld-profile #ld-main-course-list').addClass('ld-loading');
696
697		$.ajax({
698			type: 'GET',
699			url: ldVars.ajaxurl + '?action=ld30_ajax_profile_search',
700			data: searchVars,
701			success(response) {
702				if ('undefined' !== typeof response.data.markup) {
703					$('#ld-profile').html(response.data.markup);
704					ld_expand_element('#ld-profile .ld-search-prompt', false);
705				}
706			},
707		});
708	});
709
710	$('body').on('submit', '.ld-item-search-fields', function (e) {
711		e.preventDefault();
712
713		var searchVars = {
714			shortcode_instance: $('#ld-profile').data('shortcode_instance'),
715		};
716
717		searchVars['ld-profile-search'] = $(this)
718			.parents('.ld-item-search-wrapper')
719			.find('#course_name_field')
720			.val();
721		searchVars['ld-profile-search-nonce'] = $(this)
722			.parents('.ld-item-search-wrapper')
723			.find('form.ld-item-search-fields')
724			.data('nonce');
725
726		$('#ld-profile #ld-main-course-list').addClass('ld-loading');
727
728		$.ajax({
729			type: 'GET',
730			url: ldVars.ajaxurl + '?action=ld30_ajax_profile_search',
731			data: searchVars,
732			success(response) {
733				if ('undefined' !== typeof response.data.markup) {
734					$('#ld-profile').html(response.data.markup);
735					ld_expand_element('#ld-profile .ld-search-prompt', false);
736				}
737			},
738		});
739	});
740
741	$('body').on('click', '.ld-pagination a', function (e) {
742		e.preventDefault();
743
744		var linkVars = {};
745		var parentVars = {};
746
747		$(this)
748			.attr('href')
749			.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
750				linkVars[key] = value;
751			});
752
753		linkVars.pager_nonce = $(this)
754			.parents('.ld-pagination')
755			.data('pager-nonce');
756
757		linkVars.pager_results = $(this)
758			.parents('.ld-pagination')
759			.data('pager-results');
760
761		linkVars.context = $(this).data('context');
762		console.log('linkVars[%o]', linkVars);
763
764		parentVars.currentTarget = e.currentTarget;
765
766		if ('profile' != linkVars.context) {
767			linkVars.lesson_id = $(this).data('lesson_id');
768			linkVars.course_id = $(this).data('course_id');
769
770			if ($('.ld-course-nav-' + linkVars.course_id).length) {
771				linkVars.widget_instance = $(
772					'.ld-course-nav-' + linkVars.course_id
773				).data('widget_instance');
774			}
775		}
776
777		if ('course_topics' == linkVars.context) {
778			$('#ld-topic-list-' + linkVars.lesson_id).addClass('ld-loading');
779			$('#ld-nav-content-list-' + linkVars.lesson_id).addClass(
780				'ld-loading'
781			);
782		}
783
784		if ('course_content_shortcode' == linkVars.context) {
785			parentVars.parent_container = $(parentVars.currentTarget).closest(
786				'.ld-course-content-' + linkVars.course_id
787			);
788			if (
789				'undefined' !== typeof parentVars.parent_container &&
790				parentVars.parent_container.length
791			) {
792				$(parentVars.parent_container).addClass('ld-loading');
793				linkVars.shortcode_instance = $(
794					parentVars.parent_container
795				).data('shortcode_instance');
796			} else {
797				$('.ld-course-content-' + linkVars.course_id).addClass(
798					'ld-loading'
799				);
800				linkVars.shortcode_instance = $(
801					'.ld-course-content-' + linkVars.course_id
802				).data('shortcode_instance');
803			}
804		} else if ('course_lessons' == linkVars.context) {
805			var parent_container;
806
807			// Check if we are within the Course Navigation Widget.
808			if (
809				'undefined' === typeof parentVars.parent_container ||
810				!parentVars.parent_container.length
811			) {
812				parent_container = $(parentVars.currentTarget).parents(
813					'.ld-lesson-navigation'
814				);
815				if (
816					'undefined' !== typeof parent_container &&
817					parent_container.length
818				) {
819					parentVars.context_sub = 'course_navigation_widget';
820					parentVars.parent_container = $(
821						parentVars.currentTarget
822					).parents('#ld-lesson-list-' + linkVars.course_id);
823				}
824			}
825
826			// Check if we are within the Focus Mode Sidebar.
827			if (
828				'undefined' === typeof parentVars.parent_container ||
829				!parentVars.parent_container.length
830			) {
831				parent_container = $(parentVars.currentTarget).parents(
832					'.ld-focus-sidebar-wrapper'
833				);
834				if (
835					'undefined' !== typeof parent_container &&
836					parent_container.length
837				) {
838					parentVars.context_sub = 'focus_mode_sidebar';
839					parentVars.parent_container = $(
840						parentVars.currentTarget
841					).parents('#ld-lesson-list-' + linkVars.course_id);
842				}
843			}
844
845			if (
846				'undefined' === typeof parentVars.parent_container ||
847				!parentVars.parent_container.length
848			) {
849				parentVars.parent_container = $(
850					parentVars.currentTarget
851				).closest(
852					'#ld-item-list-' + linkVars.course_id,
853					'#ld-lesson-list-' + linkVars.course_id
854				);
855			}
856			if (
857				'undefined' !== typeof parentVars.parent_container &&
858				parentVars.parent_container.length
859			) {
860				$(parentVars.parent_container).addClass('ld-loading');
861			} else {
862				// Fallback solution.
863				$('#ld-item-list-' + linkVars.course_id).addClass('ld-loading');
864				$('#ld-lesson-list-' + linkVars.course_id).addClass(
865					'ld-loading'
866				);
867			}
868		}
869
870		if ('profile' == linkVars.context) {
871			$('#ld-profile #ld-main-course-list').addClass('ld-loading');
872			linkVars.shortcode_instance =
873				$('#ld-profile').data('shortcode_instance');
874		}
875
876		if ('profile_quizzes' == linkVars.context) {
877			$(
878				'#ld-course-list-item-' +
879					linkVars.pager_results.quiz_course_id +
880					' .ld-item-contents'
881			).addClass('ld-loading');
882		}
883
884		if ('course_info_courses' == linkVars.context) {
885			$('.ld-user-status').addClass('ld-loading');
886			linkVars.shortcode_instance =
887				$('.ld-user-status').data('shortcode-atts');
888		}
889
890		if ('group_courses' == linkVars.context) {
891			linkVars.group_id = $(this).data('group_id');
892			if ('undefined' !== typeof linkVars.group_id) {
893				parent_container = $(parentVars.currentTarget).parents(
894					'.ld-group-courses-' + linkVars.group_id
895				);
896				if (
897					'undefined' !== typeof parent_container &&
898					parent_container.length
899				) {
900					$(parent_container).addClass('ld-loading');
901					parentVars.parent_container = parent_container;
902				}
903			}
904		}
905
906		$.ajax({
907			type: 'GET',
908			url: ldVars.ajaxurl + '?action=ld30_ajax_pager',
909			data: linkVars,
910			success(response) {
911				// If we have a course listing, update
912
913				if ('course_topics' == linkVars.context) {
914					if ($('#ld-topic-list-' + linkVars.lesson_id).length) {
915						if ('undefined' !== typeof response.data.topics) {
916							$('#ld-topic-list-' + linkVars.lesson_id).html(
917								response.data.topics
918							);
919						}
920
921						if ('undefined' !== typeof response.data.pager) {
922							$('#ld-expand-' + linkVars.lesson_id)
923								.find('.ld-table-list-footer')
924								.html(response.data.pager);
925						}
926
927						learndashSetMaxHeight(
928							$('.ld-lesson-item-' + linkVars.lesson_id).find(
929								'.ld-item-list-item-expanded'
930							)
931						);
932
933						$('#ld-topic-list-' + linkVars.lesson_id).removeClass(
934							'ld-loading'
935						);
936					}
937
938					if (
939						$('#ld-nav-content-list-' + linkVars.lesson_id).length
940					) {
941						if ('undefined' !== typeof response.data.nav_topics) {
942							$('#ld-nav-content-list-' + linkVars.lesson_id)
943								.find('.ld-table-list-items')
944								.html(response.data.topics);
945						}
946
947						if ('undefined' !== typeof response.data.pager) {
948							$('#ld-nav-content-list-' + linkVars.lesson_id)
949								.find('.ld-table-list-footer')
950								.html(response.data.pager);
951						}
952
953						$(
954							'#ld-nav-content-list-' + linkVars.lesson_id
955						).removeClass('ld-loading');
956					}
957				}
958
959				if ('course_content_shortcode' == linkVars.context) {
960					if ('undefined' !== typeof response.data.markup) {
961						if (
962							'undefined' !==
963								typeof parentVars.parent_container &&
964							parentVars.parent_container.length
965						) {
966							$(parentVars.parent_container).replaceWith(
967								response.data.markup
968							);
969						} else {
970							$(
971								'#learndash_post_' + linkVars.course_id
972							).replaceWith(response.data.markup);
973						}
974					}
975				} else if ('course_lessons' == linkVars.context) {
976					if (
977						'undefined' !== typeof parentVars.parent_container &&
978						parentVars.parent_container.length
979					) {
980						if (
981							'course_navigation_widget' == parentVars.context_sub
982						) {
983							if (
984								'undefined' !== typeof response.data.nav_lessons
985							) {
986								$(parentVars.parent_container)
987									.html(response.data.nav_lessons)
988									.removeClass('ld-loading');
989							}
990						} else if (
991							'focus_mode_sidebar' == parentVars.context_sub
992						) {
993							if (
994								'undefined' !== typeof response.data.nav_lessons
995							) {
996								$(parentVars.parent_container)
997									.html(response.data.nav_lessons)
998									.removeClass('ld-loading');
999							}
1000						} else if (
1001							'undefined' !== typeof response.data.lessons
1002						) {
1003							$(parentVars.parent_container)
1004								.html(response.data.lessons)
1005								.removeClass('ld-loading');
1006						}
1007					} else {
1008						if ($('#ld-item-list-' + linkVars.course_id).length) {
1009							if ('undefined' !== typeof response.data.lessons) {
1010								$('#ld-item-list-' + linkVars.course_id)
1011									.html(response.data.lessons)
1012									.removeClass('ld-loading');
1013							}
1014						}
1015
1016						if ($('#ld-lesson-list-' + linkVars.course_id).length) {
1017							if (
1018								'undefined' !== typeof response.data.nav_lessons
1019							) {
1020								$('#ld-lesson-list-' + linkVars.course_id)
1021									.html(response.data.nav_lessons)
1022									.removeClass('ld-loading');
1023							}
1024						}
1025					}
1026				}
1027
1028				if ('group_courses' == linkVars.context) {
1029					if (
1030						'undefined' !== typeof parentVars.parent_container &&
1031						parentVars.parent_container.length
1032					) {
1033						if ('undefined' !== typeof response.data.markup) {
1034							$(parentVars.parent_container)
1035								.html(response.data.markup)
1036								.removeClass('ld-loading');
1037						}
1038					}
1039				}
1040
1041				if ('profile' == linkVars.context) {
1042					if ('undefined' !== typeof response.data.markup) {
1043						$('#ld-profile').html(response.data.markup);
1044					}
1045				}
1046
1047				if ('profile_quizzes' == linkVars.context) {
1048					if ('undefined' !== typeof response.data.markup) {
1049						$(
1050							'#ld-course-list-item-' +
1051								linkVars.pager_results.quiz_course_id +
1052								' .ld-item-list-item-expanded .ld-item-contents'
1053						).replaceWith(response.data.markup);
1054						$(
1055							'#ld-course-list-item-' +
1056								linkVars.pager_results.quiz_course_id
1057						)
1058							.get(0)
1059							.scrollIntoView({ behavior: 'smooth' });
1060					}
1061				}
1062
1063				if ('course_info_courses' == linkVars.context) {
1064					if ('undefined' !== typeof response.data.markup) {
1065						$('.ld-user-status').replaceWith(response.data.markup);
1066					}
1067				}
1068
1069				$('body').trigger('ld_has_paginated');
1070
1071				initTooltips();
1072			},
1073		});
1074	});
1075
1076	if ($('#learndash_timer').length) {
1077		var timer_el = jQuery('#learndash_timer');
1078		var timer_seconds = timer_el.attr('data-timer-seconds');
1079		var timer_button_el = jQuery(timer_el.attr('data-button'));
1080
1081		var cookie_key = timer_el.attr('data-cookie-key');
1082
1083		if ('undefined' !== typeof cookie_key) {
1084			var cookie_name = 'learndash_timer_cookie_' + cookie_key;
1085		} else {
1086			var cookie_name = 'learndash_timer_cookie';
1087		}
1088
1089		cookie_timer_seconds = jQuery.cookie(cookie_name);
1090
1091		if ('undefined' !== typeof cookie_timer_seconds) {
1092			timer_seconds = parseInt(cookie_timer_seconds);
1093		}
1094
1095		if (0 == timer_seconds) {
1096			$(timer_el).hide();
1097		}
1098
1099		$(timer_button_el).on('learndash-time-finished', function () {
1100			$(timer_el).hide();
1101		});
1102	}
1103
1104	$(document).on('learndash_video_disable_assets', function (event, status) {
1105		if ('undefined' === typeof learndash_video_data) {
1106			return false;
1107		}
1108
1109		if ('BEFORE' == learndash_video_data.videos_shown) {
1110			if (true == status) {
1111				$('.ld-lesson-topic-list').hide();
1112				$('.ld-lesson-navigation')
1113					.find('#ld-nav-content-list-' + ldVars.postID)
1114					.addClass('user_has_no_access');
1115				$('.ld-quiz-list').hide();
1116			} else {
1117				$('.ld-lesson-topic-list').slideDown();
1118				$('.ld-quiz-list').slideDown();
1119				$('.ld-lesson-navigation')
1120					.find('#ld-nav-content-list-' + ldVars.postID)
1121					.removeClass('user_has_no_access');
1122			}
1123		}
1124	});
1125
1126	$('.learndash-wrapper').on(
1127		'click',
1128		'.wpProQuiz_questionListItem input[type="radio"]',
1129		function (e) {
1130			$(this)
1131				.parents('.wpProQuiz_questionList')
1132				.find('label')
1133				.removeClass('is-selected');
1134			$(this).parents('label').addClass('is-selected');
1135		}
1136	);
1137
1138	$('.learndash-wrapper').on(
1139		'click',
1140		'.wpProQuiz_questionListItem input[type="checkbox"]',
1141		function (e) {
1142			if (jQuery(e.currentTarget).is(':checked')) {
1143				$(this).parents('label').addClass('is-selected');
1144			} else {
1145				$(this).parents('label').removeClass('is-selected');
1146			}
1147		}
1148	);
1149
1150	function learndash_ld30_show_user_statistic(e) {
1151		e.preventDefault();
1152
1153		var refId = jQuery(this).data('ref-id');
1154		var quizId = jQuery(this).data('quiz-id');
1155		var userId = jQuery(this).data('user-id');
1156		var statistic_nonce = jQuery(this).data('statistic-nonce');
1157		var post_data = {
1158			action: 'wp_pro_quiz_admin_ajax_statistic_load_user',
1159			func: 'statisticLoadUser',
1160			data: {
1161				quizId,
1162				userId,
1163				refId,
1164				statistic_nonce,
1165				avg: 0,
1166			},
1167		};
1168
1169		jQuery('#wpProQuiz_user_overlay, #wpProQuiz_loadUserData').show();
1170		var content = jQuery('#wpProQuiz_user_content').hide();
1171
1172		//console.log('- learndash.js');
1173
1174		jQuery.ajax({
1175			type: 'POST',
1176			url: ldVars.ajaxurl,
1177			dataType: 'json',
1178			cache: false,
1179			data: post_data,
1180			error(jqXHR, textStatus, errorThrown) {},
1181			success(reply_data) {
1182				if ('undefined' !== typeof reply_data.html) {
1183					content.html(reply_data.html);
1184					jQuery('#wpProQuiz_user_content').show();
1185
1186					//console.log('trigger event change - learndash.js');
1187					jQuery('body').trigger(
1188						'learndash-statistics-contentchanged'
1189					);
1190
1191					jQuery('#wpProQuiz_loadUserData').hide();
1192
1193					content.find('.statistic_data').on('click', function () {
1194						jQuery(this).parents('tr').next().toggle('fast');
1195
1196						return false;
1197					});
1198				}
1199			},
1200		});
1201
1202		jQuery('#wpProQuiz_overlay_close').on('click', function () {
1203			jQuery('#wpProQuiz_user_overlay').hide();
1204		});
1205	}
1206
1207	function learndashSetMaxHeight(elm) {
1208		var totalHeight = 0;
1209
1210		elm.find('> *').each(function () {
1211			totalHeight += $(this).outerHeight();
1212		});
1213
1214		elm.attr('data-height', '' + (totalHeight + 50) + '');
1215
1216		elm.css({
1217			'max-height': totalHeight + 50,
1218		});
1219	}
1220
1221	/**
1222	 * Will scroll the position of the Focus Mode sidebar
1223	 * to the active step.
1224	 */
1225	function learndashFocusModeSidebarAutoScroll() {
1226		if (jQuery('.learndash-wrapper .ld-focus').length) {
1227			var sidebar_wrapper = jQuery(
1228				'.learndash-wrapper .ld-focus .ld-focus-sidebar-wrapper'
1229			);
1230
1231			var sidebar_current_topic = jQuery(
1232				'.learndash-wrapper .ld-focus .ld-focus-sidebar-wrapper .ld-is-current-item'
1233			);
1234			if (
1235				'undefined' !== typeof sidebar_current_topic &&
1236				sidebar_current_topic.length
1237			) {
1238				var sidebar_scrollTo = sidebar_current_topic;
1239			} else {
1240				var sidebar_current_lesson = jQuery(
1241					'.learndash-wrapper .ld-focus .ld-focus-sidebar-wrapper .ld-is-current-lesson'
1242				);
1243				if (
1244					'undefined' !== typeof sidebar_current_lesson &&
1245					sidebar_current_lesson.length
1246				) {
1247					var sidebar_scrollTo = sidebar_current_lesson;
1248				}
1249			}
1250
1251			if (
1252				'undefined' !== typeof sidebar_scrollTo &&
1253				sidebar_scrollTo.length
1254			) {
1255				var offset_top = 0;
1256				if (
1257					jQuery('.learndash-wrapper .ld-focus .ld-focus-header')
1258						.length
1259				) {
1260					var logo_height = jQuery(
1261						'.learndash-wrapper .ld-focus .ld-focus-header'
1262					).height();
1263					offset_top += logo_height;
1264				}
1265				if (
1266					jQuery(
1267						'.learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation-heading'
1268					).length
1269				) {
1270					var heading_height = jQuery(
1271						'.learndash-wrapper .ld-focus .ld-focus-sidebar .ld-course-navigation-heading'
1272					).height();
1273					offset_top += heading_height;
1274				}
1275				if (
1276					jQuery(
1277						'.learndash-wrapper .ld-focus .ld-focus-sidebar .ld-focus-sidebar-wrapper'
1278					).length
1279				) {
1280					var container_height = jQuery(
1281						'.learndash-wrapper .ld-focus .ld-focus-sidebar .ld-focus-sidebar-wrapper'
1282					).height();
1283					offset_top += container_height;
1284				}
1285
1286				var current_item_height = jQuery(sidebar_scrollTo).height();
1287				offset_top -= current_item_height;
1288
1289				sidebar_wrapper.animate(
1290					{
1291						scrollTop: sidebar_scrollTo.offset().top - offset_top,
1292					},
1293					1000
1294				);
1295			}
1296		}
1297	}
1298
1299	// Coupon processing.
1300
1301	function update_payment_forms(data) {
1302		$('#total-row').attr('data-total', data.total.value);
1303
1304		// Update PayPal form amount.
1305		$('form[name="buynow"] input[name="amount"]').val(data.total.value);
1306
1307		// Update Stripe form amount.
1308		$('form.learndash-stripe-checkout input[name="stripe_price"]').val(
1309			data.total.stripe_value
1310		);
1311
1312		// Remove Stripe Connect session to respect the new amount.
1313		const stripe_course_id = $(
1314			'.learndash-stripe-checkout input[name="stripe_course_id"]'
1315		).val();
1316
1317		if (stripe_course_id) {
1318			LD_Cookies.remove('ld_stripe_session_id_' + stripe_course_id); // Stripe Plugin (Checkout).
1319			LD_Cookies.remove(
1320				'ld_stripe_connect_session_id_' + stripe_course_id
1321			); // Stripe Connect in core.
1322		}
1323
1324		// Re-init Stripe Plugin (Legacy) to respect the new amount.
1325		if (typeof ld_init_stripe_legacy === 'function') {
1326			ld_init_stripe_legacy();
1327		}
1328	}
1329
1330	$('.btn-join').on('click', function (e) {
1331		const total = parseFloat($('#total-row').attr('data-total'));
1332
1333		if (0 === total) {
1334			$.ajax({
1335				type: 'POST',
1336				url: ldVars.ajaxurl,
1337				dataType: 'json',
1338				cache: false,
1339				data: {
1340					action: 'learndash_enroll_with_zero_price',
1341					nonce: $('#apply-coupon-form').data('nonce'),
1342					post_id: $('#apply-coupon-form').data('post-id'),
1343				},
1344				success(response) {
1345					if (response.success) {
1346						window.location.replace(response.data.redirect_url);
1347					} else {
1348						alert(response.data.message);
1349					}
1350				},
1351			});
1352
1353			e.preventDefault();
1354			return false;
1355		}
1356	});
1357
1358	$('#apply-coupon-form').on('submit', function (e) {
1359		e.preventDefault();
1360
1361		$.ajax({
1362			type: 'POST',
1363			url: ldVars.ajaxurl,
1364			dataType: 'json',
1365			cache: false,
1366			data: {
1367				action: 'learndash_apply_coupon',
1368				nonce: $(this).data('nonce'),
1369				coupon_code: $(this).find('#coupon-field').val(),
1370				post_id: $(this).data('post-id'),
1371			},
1372			success(response) {
1373				$('#coupon-alerts .coupon-alert').hide();
1374
1375				const $alert = $('#coupon-alerts').find(
1376					response.success
1377						? '.coupon-alert-success'
1378						: '.coupon-alert-warning'
1379				);
1380
1381				const $coupon_row = $('#coupon-row');
1382
1383				if (response.success) {
1384					$coupon_row
1385						.find('.purchase-label > span')
1386						.html(response.data.coupon_code); // Set coupon code in totals.
1387					$coupon_row
1388						.find('.purchase-value span')
1389						.html(response.data.discount); // Set discount value in totals.
1390					$coupon_row.css('display', 'flex').hide().fadeIn(); // Show a coupon row in totals.
1391					$('#total-row .purchase-value').html(
1392						response.data.total.formatted
1393					); // Update Total.
1394					$('#totals').show();
1395
1396					update_payment_forms(response.data);
1397				}
1398
1399				$alert.find('.ld-alert-messages').html(response.data.message);
1400				$alert.fadeIn();
1401			},
1402		});
1403	});
1404
1405	$('#remove-coupon-form').on('submit', function (e) {
1406		e.preventDefault();
1407
1408		$.ajax({
1409			type: 'POST',
1410			url: ldVars.ajaxurl,
1411			dataType: 'json',
1412			cache: false,
1413			data: {
1414				action: 'learndash_remove_coupon',
1415				nonce: $(this).data('nonce'),
1416				post_id: $(this).data('post-id'),
1417			},
1418			success(response) {
1419				$('#coupon-alerts .coupon-alert').hide();
1420
1421				const $alert = $('#coupon-alerts').find(
1422					response.success
1423						? '.coupon-alert-success'
1424						: '.coupon-alert-warning'
1425				);
1426
1427				if (response.success) {
1428					$('#coupon-row').hide(); // Hide a coupon row in totals.
1429					$('#coupon-field').val(''); // Set coupon field empty.
1430					$('#price-row .purchase-value').html(
1431						response.data.total.formatted
1432					); // Update Price.
1433					$('#subtotal-row .purchase-value').html(
1434						response.data.total.formatted
1435					); // Update Subtotal.
1436					$('#total-row .purchase-value').html(
1437						response.data.total.formatted
1438					); // Update Total.
1439					$('#totals').hide();
1440
1441					update_payment_forms(response.data);
1442				}
1443
1444				$alert.find('.ld-alert-messages').html(response.data.message);
1445				$alert.fadeIn();
1446			},
1447		});
1448	});
1449});
1450
1451function ldGetUrlVars() {
1452	var vars = {};
1453	var parts = window.location.href.replace(
1454		/[?&]+([^=&]+)=([^&]*)/gi,
1455		function (m, key, value) {
1456			vars[key] = value;
1457		}
1458	);
1459
1460	return vars;
1461}

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.