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