1/** 2 * Main JS 3 */ 4// phpcs:ignoreFile 5jQuery(document).ready(function ($) { 6 /** 7 * Conversation 8 */ 9 var $conv = $('.conversation'); 10 11 // Check if conversation is present on this page. 12 if ($conv.length > 0) { 13 /** 14 * Toggle Submit Button 15 * @param {Object} $el jQuery element object. 16 */ 17 var toggleSubmit = function toggleSubmit($el) 18 { 19 if ($el.val() !== '') { 20 $convSubmit.removeAttr('disabled'); 21 $convSubmit.removeClass('disabled'); 22 } else { 23 $convSubmit.attr('disabled', 'disabled'); 24 $convSubmit.addClass('disabled'); 25 } 26 }; 27 28 var $convField = $('#conversationMessageField'), 29 $convSubmit = $('#conversationMessageSubmit'); 30 31 // Apply autogrow functionality to the textarea message field. 32 $convField.autogrow(); 33 34 // Event: On keyup 35 $convField.on('keyup', debounce(function (e) { 36 toggleSubmit($(this)); 37 }, 200)); 38 } 39 40 /** 41 * Checkable Table 42 */ 43 checkableTable(); 44 45 function checkableTable() 46 { 47 // Define variables. 48 var $table = $(this), 49 $rows = $table.find('tbody > tr'), 50 $mainCheckbox = $table.find('thead input[type=checkbox]'), 51 $mainTitle = $table.find('thead .table-col-title'), 52 mainOrigTitle = $mainTitle.text(), 53 $checkboxes = $rows.find('input[type=checkbox]'); 54 55 // Event: On click 56 $rows.on('click', function (e) { 57 if (e.target.type !== 'checkbox') { 58 $(':checkbox', this).trigger('click'); 59 } 60 }); 61 62 // Event: On change 63 $checkboxes.on('change', function (e) { 64 var $checkbox = $(this); 65 66 if ($checkbox) { 67 } 68 }); 69 70 // On change of the checkboxes. 71 $checkboxes.on('change', function () { 72 var $checkbox = $(this), 73 checkedLength = getCheckedLength($rows); 74 75 // Check if any of the checkbox in this table is checked. 76 if (checkedLength > 0) { 77 if (!$mainCheckbox.is(':checked')) { 78 checkMainCheckbox(); 79 } 80 81 $mainTitle.text(checkedLength + ' selected'); 82 } else { 83 if ($mainCheckbox.is(':checked')) { 84 uncheckMainCheckbox(); 85 } 86 87 $mainTitle.text(mainOrigTitle); 88 } 89 }); 90 91 // Event: On click 92 $mainCheckbox.on('click', function (e) { 93 // Traversing: Run through each item 94 $checkboxes.each(function (i, el) { 95 el.checked = e.target.checked; 96 }); 97 98 // Check if any of the checkbox in this table is checked. 99 if (e.target.checked) { 100 $mainTitle.text($checkboxes.length + ' selected'); 101 } else { 102 $mainTitle.text(mainOrigTitle); 103 } 104 }); 105 106 // Event: On click 107 $mainTitle.on('click', function (e) { 108 $mainCheckbox.click(); 109 }); 110 111 /** 112 * Is Any Checkbox Checked 113 * @param {object} $el element to find all the checkbox in 114 */ 115 function getCheckedLength($el) 116 { 117 return $el.find('input[type=checkbox]').filter(':checked').length; 118 } 119 120 /** 121 * Check Main Checkbox 122 */ 123 function checkMainCheckbox() 124 { 125 $mainCheckbox[0].checked = true; 126 } 127 128 /** 129 * Uncheck Main Checkbox 130 */ 131 function uncheckMainCheckbox() 132 { 133 $mainCheckbox[0].checked = false; 134 } 135 136 /** 137 * Uncheck Main Checkbox 138 */ 139 function toggleMainCheckbox() 140 { 141 if (!$mainCheckbox.is(':checked')) { 142 checkMainCheckbox(); 143 } else { 144 uncheckMainCheckbox(); 145 } 146 } 147 } 148 149 /** 150 * Custom jQuery Code 151 */ 152 // Header Explore dropdown: Cancel dropdown menu closing when tabs inside it are clicked. 153 $('.top-icon-explore .nav-link').on({ 154 'click': function (e) { 155 e.stopPropagation(); 156 } 157 }); 158 159 /** 160 * Smooth Anchor Links
161 * This works with the anchor links in the URL too. It also changes the 162 * URL hash 163 * Replace .offset_element_selector with the offset element, e.g., .navbar 164 */ 165 var hash = window.location.hash, 166 $links = $('a[href^="#"]'), 167 $wpadminbar = $('#wpadminbar'), 168 offset = 0, 169 $navbar = $('.navbar:not(.navbar--is-transparent):not(.navbar--is-sticky)'); 170 171 // Check if URL has hash and smooth scroll to that. 172 173 if (hash && false) { 174 var $hashEl = $(hash); 175 176 if ($hashEl.length) { 177 scrollToAnchor($hashEl); 178 $(window).load(function () { 179 scrollToAnchor($hashEl); 180 }); 181 } 182 } 183 184 $links.on('click', function (e) { 185 var $this = $(this), 186 thisHref = $this.attr('href'); 187 188 if (thisHref !== '#') { 189 if ($(thisHref).length) { 190 e.preventDefault(); 191 scrollToAnchor($(thisHref)); 192 } 193 } 194 }); 195 196 function scrollToAnchor($el) 197 { 198 offset = $wpadminbar.outerHeight() + $navbar.outerHeight(); 199 $('html, body').animate({ 200 scrollTop: $el.offset().top - offset 201 }, 500); 202 } 203 204 /** 205 * Clear localStoragte on logout 206 */ 207 $('a[href="/logout/"]').on('click', function () { 208 localStorage.clear(); 209 }); 210 211 /** 212 * FullScreen Navbar 213 */ 214 var $body = $('body'), 215 $navbar = $('.navbar-nav'), 216 $navbarBtn = $('.navbar__btn'), 217 $navbarClose = $('.navbar-nav__close'); 218 219 // $navbar.hide(); 220 221 $navbarBtn.on('click', function (e) { 222 e.preventDefault(); 223 224 if ($navbar.hasClass('navbar-nav--active')) { 225 $navbar.removeClass('navbar-nav--active').fadeOut(); 226 $body.removeClass('navbar-active'); 227 $navbarBtn.removeClass('navbar__btn--active'); 228 } else { 229 $navbar.addClass('navbar-nav--active').fadeIn(); 230 $body.addClass('navbar-active'); 231 $navbarBtn.addClass('navbar__btn--active'); 232 } 233 }); 234 235 $navbarClose.on('click', function (e) { 236 e.preventDefault(); 237 238 if ($navbar.hasClass('navbar-nav--active')) { 239 $navbar.removeClass('navbar-nav--active').fadeOut(); 240 $body.removeClass('navbar-active'); 241 $navbarBtn.removeClass('navbar__btn--active'); 242 } 243 }); 244}); 245 246jQuery(document).ready(function ($) { 247 // Large click area 248 $('.large-click-area').click(function () { 249 var url = $(this).attr('data-large-click-url'); 250 251 window.location.href = url; 252 253 return false; 254 }); 255 256 // Force numbers on field 257 $('.filterme-numbers').on('input', function () { 258 this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1'); 259 }); 260 261 // Scroll to section 262 $('.scroll-to-class').click(function () { 263 var scroll_to_class = $(this).attr('data-scroll-to-class'); 264 265 $('html, body').animate({ 266 scrollTop: $('.' + scroll_to_class).offset().top - 30 267 }, 500); 268 269 return false; 270 }); 271 272 // Toggle checkbox switch, on/off 273 $(document).on('click', '.toggle', function (e) { 274 var checkbox = $(this).find('input[type=checkbox]'); 275 var toggle_name = checkbox.attr('name'); 276 277 if (checkbox.prop('checked')) { 278 checkbox.val('0'); 279 checkbox.removeAttr('checked'); 280 281 // Show donor behalf field 282 if (toggle_name == 'donor_behalf') { 283 $('.toggle-behalf-field').hide(); 284 } 285 } else { 286 checkbox.val('1'); 287 checkbox.prop('checked', true); 288 289 // Hide donor behalf field 290 if (toggle_name == 'donor_behalf') { 291 $('.toggle-behalf-field').show(); 292 } 293 } 294 }); 295 296 // Ajax Email Notifications 297 /** 298 * Read more 299 */ 300 $('.read-more--extend').on('click', function (e) { 301 e.preventDefault(); 302 303 var $this = $(this); 304 var $parent = $this.closest('.__text_excerpt'); 305 306 if ($parent.length) { 307 $parent.addClass('__hidden'); 308 $parent.prev().removeClass('__hidden'); 309 } else { 310 $parent = $this.prev('.__text_excerpt'); 311 $parent.addClass('__hidden'); 312 $parent.prev().removeClass('__hidden'); 313 $this.remove(); 314 } 315 }); 316 317 /** 318 * Component Dropdown 319 */ 320 321 // Open dropdown 322 $(document).on('click', '.component-dropdown-selected', function (e) { 323 e.preventDefault(); 324 $(this).closest('.component-dropdown').toggleClass('active'); 325 }); 326 327 // When item is selected 328 $(document).on('click', '.component-dropdown-dropdown-item', function (e) { 329 330 var $this = $(this); 331 var $parent = $this.closest('.component-dropdown'); 332 333 $parent.find('.component-dropdown-selected').html($this.attr('data-value')); 334 335 $(this).addClass('selected').siblings().removeClass('selected'); 336 337 $parent.find('[type="hidden"]').val($this.attr('data-key')).trigger('change'); 338 }); 339 340 // Close when clicked outside 341 $(document).on('click', function (e) { 342 343 var $this = $(e.target); 344 345 if (!$this.is('.component-dropdown-selected')) { 346 $('.component-dropdown').removeClass('active'); 347 } 348 }); 349 350 // Only allow numbers 351 function numbers_only(event) 352 { 353 var key = window.event ? event.keyCode : event.which; 354 355 if (event.keyCode === 8 || event.keyCode === 9 || event.keyCode === 46) { 356 return true; 357 } else { 358 if (key < 48 || key > 57) { 359 return false;
360 } else { 361 return true; 362 } 363 } 364 } 365 366 // Class to trigger numbers only field 367 $('.numbers-only').keypress(numbers_only); 368 369 // Facebook share window 370 $('.invite-fb').click(function (e) { 371 e.preventDefault(); 372 373 // Get the URL to share 374 var url = $(this).attr('data-url'); 375 376 // Open FB share window 377 window.open('https://facebook.com/sharer.php?display=popup&u=' + url, 'sharer', 'toolbar=0,status=0,resizable=1,width=626,height=436'); 378 }); 379 380 // Change invite type when opening modal 381 $('.footer-modal-invite').click(function (e) { 382 e.preventDefault(); 383 var invite_type = $(this).attr('data-invite-type'); 384 385 // Set the invite type 386 $('#inviteFriendModal input[name=invite_type]').val(invite_type); 387 388 // Set labels 389 if (invite_type == 'friend') { 390 $('.modal-invite-type-label').text('friend'); 391 $('.modal-invite-type-label-uc').text('Friend'); 392 } else if (invite_type == 'individual') { 393 $('.modal-invite-type-label').text('individual'); 394 $('.modal-invite-type-label-uc').text('Individual'); 395 } 396 }); 397 398 // Form handling for invite modal 399 $('input[name=submit_invite_friend]').click(function (e) { 400 e.preventDefault(); 401 402 var errors = false; 403 var invite_type = $('input[name=invite_type]'); 404 var sender_name = $('#inviteFriendSenderName'); 405 var sender_email = $('#inviteFriendSenderEmail'); 406 var recipient_name = $('#inviteFriendRecipientName'); 407 var recipient_email = $('#inviteFriendRecipientEmail'); 408 var recaptcha = grecaptcha.getResponse(captchaObj.captcha_1); 409 $('#inviteFriendModal .form-notice').hide(); 410 411 if (recipient_email.val() == '') { 412 recipient_email.addClass('error'); 413 recipient_email.focus(); 414 errors = true; 415 } else { 416 recipient_email.removeClass('error'); 417 } 418 419 if (recipient_name.val() == '') { 420 recipient_name.addClass('error'); 421 recipient_name.focus(); 422 errors = true; 423 } else { 424 recipient_name.removeClass('error'); 425 } 426 427 if (sender_email.val() == '') { 428 sender_email.addClass('error'); 429 sender_email.focus(); 430 errors = true; 431 } else { 432 sender_email.removeClass('error'); 433 } 434 435 if (sender_name.val() == '') { 436 sender_name.addClass('error'); 437 sender_name.focus(); 438 errors = true; 439 } else { 440 sender_name.removeClass('error'); 441 } 442 443 if (recaptcha == '') { 444 $('.recaptcha-error').show(); 445 errors = true; 446 } else { 447 $('.recaptcha-error').hide(); 448 } 449 450 if (!errors) { 451 $.post('/', { 452 recaptcha: recaptcha, 453 invite_type: invite_type.val(), 454 sender_name: sender_name.val(), 455 sender_email: sender_email.val(), 456 recipient_name: recipient_name.val(), 457 recipient_email: recipient_email.val() 458 }, function (data) { 459 if (data == 1) { 460 // Show notice 461 $('#inviteFriendModal .form-notice').show(); 462 463 // Clear form values 464 sender_name.val(''); 465 sender_email.val(''); 466 recipient_name.val(''); 467 recipient_email.val(''); 468 469 // Scroll to notice 470 $('html,body').animate({ 471 scrollTop: $('#inviteFriendModal .form-notice').offset().top 472 }); 473 } 474 }); 475 } 476 }); 477 478 // Component dates select 479 $('.component-dates-select select').on('change', function (e) { 480 var $this = $(this); 481 location.href = $this.val(); 482 }); 483 484 // Component date 485 try { 486 var hcDate = $('.tf-component-date .hcd-datepicker'); 487 488 hcDate.datepicker({ 489 dateFormat: 'mm/dd/yy', 490 changeMonth: true, 491 changeYear: true, 492 //showButtonPanel: true, 493 //show: true, 494 onSelect: function (str, instance) { 495 var _self = $(this); 496 _self.parent().find('> input').val(str).trigger('input'); 497 hcDate.closest('.tf-component-date').removeClass('show-datepicker'); 498 }, 499 }); 500 501 // Toggle datepicker 502 $('.tf-component-date .hcd-input').on('click', function (e) { 503 e.preventDefault(); 504 505 var $this = $(this); 506 507 $this.blur(); 508 509 // Close all except the current one 510 $('.tf-component-date').removeClass('current'); 511 512 var $parent = $this.closest('.tf-component-date'); 513 514 $parent.addClass('current'); 515 516 $('.tf-component-date:not(.current)').removeClass('show-datepicker'); 517 518 // Positioning 519 var documentHeight = $(document).outerHeight(true); 520 var offsetTop = $this.offset().top; 521 var offset = documentHeight - offsetTop; 522 523 if (offset <= 370) { 524 $parent.find('.hcd-datepicker').css({'top': 'unset', 'bottom': '100%'}); 525 } else { 526 $parent.find('.hcd-datepicker').css({'top': '100%', 'bottom': 'unset'}); 527 } 528 529 // Update time 530 $parent.find('.hcd-datepicker').datepicker('setDate', $this.val()); 531 532 // Show/Hide 533 $parent.toggleClass('show-datepicker'); 534 }); 535 536 $(document).on('click', function (e) { 537 538 var $this = $(e.target); 539 var isTarget = $this.is('.hcd-datepicker') || $this.closest('.hcd-datepicker').length || $this.is('.hcd-input'); 540 541 if (!isTarget) { 542 $('.tf-component-date').removeClass('show-datepicker'); 543 } 544 }); 545 } catch (e) { 546 } 547 548 // New date component 549 try { 550 var new_date_comp = $('.tf-date-component'); 551 var new_date_comp_min_date = null; 552 var new_date_comp_max_date = null; 553 554 if (new_date_comp.attr('data-mindate')) { 555 new_date_comp_min_date = new Date(); 556 new_date_comp_min_date.setTime(parseInt(new_date_comp.attr('data-mindate'))); 557 } 558 559 if (new_date_comp.attr('data-maxdate')) { 560 new_date_comp_max_date = new Date(); 561 new_date_comp_max_date.setTime(parseInt(new_date_comp.attr('data-maxdate'))); 562 } 563 564 new_date_comp.find('.tf-date-component-datepicker').datepicker({ 565 dateFormat: 'yy-mm-dd', 566 minDate: new_date_comp_min_date, 567 maxDate: new_date_comp_max_date, 568 show: true, 569 // onSelect: function (str, instance){}, 570 }); 571 572 // Toggle datepicker 573 new_date_comp.find('.tf-date-component-trigger').on('click', function (e) { 574 575 e.preventDefault(); 576 577 var $this = $(this); 578 var $parent = $this.closest('.tf-date-component'); 579 var date_parts; 580 581 $this.trigger('blur'); 582 583 // Update time 584 date_parts = $parent.find('.tf-date-component-input').val().split('-'); 585 $parent.find('.tf-date-component-datepicker').datepicker('setDate', new Date(parseInt(date_parts[0]), parseInt(date_parts[1]) - 1, parseInt(date_parts[2]))); 586 587 // Show modal 588 $parent.find('#modal-select-date').modal('show'); 589 }); 590 591 // Delete date 592 new_date_comp.find('.tf-date-component-selected img').on('click', function (e) { 593 594 e.preventDefault(); 595 e.stopPropagation(); 596 597 var $this = $(this).parent(); 598 var $parent = $this.closest('.tf-date-component'); 599 600 // Update time 601 $parent.find('.tf-date-component-datepicker').datepicker('setDate', new Date()); 602 $parent.find('.tf-date-component-input').val('').trigger('input'); 603 $this.addClass('__hidden'); 604 }); 605 606 new_date_comp.find('.tf-date-component-selected').on('click', function (e) { 607 e.preventDefault(); 608 }); 609 610 // Add date 611 new_date_comp.find('[data-action="tf-date-component-add-date"]').on('click', function (e) { 612 613 e.preventDefault(); 614 615 var $this = $(this); 616 var $parent = $this.closest('.tf-date-component'); 617 var date = $parent.find('.tf-date-component-datepicker').datepicker('getDate'); 618 619 $parent.find('input[type="hidden"]').val(date.format('Y-m-d')).trigger('input'); 620 $parent.find('.tf-date-component-selected').removeClass('__hidden').find('span').text(date.format('M jS, Y')); 621 $parent.find('#modal-select-date').modal('hide'); 622 }); 623 624 } catch (error) { 625 // console.log(error); 626 } 627}); 628 629/** 630 * Google Recaptcha 631 */ 632var captchaObj = {
633 captcha_1: null, // modal invite friend 634 captcha_2: null, // modal invite school leader 635 captcha_3: null, // /support contact modal 636 captcha_4: null, // report modal 637}; 638 639function CaptchaCallback() 640{ 641 if (document.querySelector('#g-recaptcha')) { 642 captchaObj.captcha_1 = grecaptcha.render('g-recaptcha', {'sitekey': box_google_recaptcha_callback.recaptcha_key}); 643 } 644 645 if (document.querySelector('#g-recaptcha2')) { 646 captchaObj.captcha_2 = grecaptcha.render('g-recaptcha2', {'sitekey': box_google_recaptcha_callback.recaptcha_key}); 647 } 648 649 if (document.querySelector('#g-recaptcha3')) { 650 captchaObj.captcha_3 = grecaptcha.render('g-recaptcha3', {'sitekey': box_google_recaptcha_callback.recaptcha_key}); 651 } 652 653 if (document.querySelector('#g-recaptcha4')) { 654 captchaObj.captcha_4 = grecaptcha.render('g-recaptcha4', {'sitekey': box_google_recaptcha_callback.recaptcha_key}); 655 } 656} 657 658(function ($) { 659 const $doc = $(document); 660 661 /** 662 * Header navigation and search 663 */ 664 const $mobileMenuFullscreen = jQuery('#menu-mobile-fullscreen'); 665 const $footerMobileNav = jQuery('.portal__navbar-mobile.sitewide'); 666 667 $("#show-menu-panel").on('click', function () { 668 if ($mobileMenuFullscreen.hasClass('show')) { 669 //close the menu 670 $('body').removeClass('no-overflow'); 671 $mobileMenuFullscreen.removeClass('show').css('z-index', ''); 672 } else { 673 //Open the menu 674 $('body').addClass('no-overflow'); 675 $mobileMenuFullscreen.addClass('show').css('z-index', 999999); 676 $footerMobileNav.addClass('d-none').css('z-index', 9999999); 677 } 678 }); 679 680 $(".portal__navbar-mobile").on('click', function () { 681 var $modalNotifications = jQuery('#modal-notifications'); 682 683 if ($modalNotifications.hasClass('show')) { 684 $modalNotifications.find('[data-bs-dismiss="modal"]').trigger('click'); 685 } 686 }); 687 688 $("#close-mobile-menu").on('click', function () { 689 if (!$mobileMenuFullscreen.hasClass('show')) { 690 return false; 691 } 692 693 //Close the menu 694 $('body').removeClass('no-overflow'); 695 $mobileMenuFullscreen.removeClass('show').css('z-index', ''); 696 $footerMobileNav.removeClass('d-none').addClass('d-block'); 697 }); 698 699 // Hide dropdowns if click on other parts of the page 700 $('.overlay-clickable').on('click', function () { 701 $(this).removeClass('active'); 702 }); 703 704 // Adjust textarea height on message input. 705 $doc.on("input change", ".textarea-dynamic-height", function () { 706 this.style.height = "40px"; 707 this.style.height = `${this.scrollHeight}px`; 708 }); 709 710 // Post/Announcement Modals: Load website meta on add button click 711 $('.website-input-with-preview [name="website"]').on("keydown", function (event) { 712 const keycode = event.keyCode ? event.keyCode : event.which; 713 714 if (keycode === 13) { 715 // Prevent form being submitted. 716 event.preventDefault(); 717 } 718 }); 719 720 $('.website-input-with-preview [name="website"]').on("keyup", function (event) { 721 const $btn = $(this) 722 .closest(".website-input-with-preview") 723 .find(".btn"); 724 725 if ($(this).val()) { 726 $btn.removeClass("disabled"); 727 } else { 728 $btn.addClass("disabled"); 729 } 730 731 const keycode = event.keyCode ? event.keyCode : event.which; 732 733 if (keycode === 13) { 734 $btn.trigger("click"); 735 } 736 }); 737 738 $(".website-input-with-preview .btn").on("click", function (e) { 739 e.preventDefault(); 740 const $btn = $(this); 741 if ($btn.hasClass("disabled")) { 742 return; 743 } 744 745 const $input = $btn.prev('[name="website"]'); 746 const url = $input.val(); 747 748 $.ajax({ 749 url: "/ajax/dashboard.php", 750 method: "POST", 751 data: { 752 action: "get_meta", 753 url, 754 }, 755 cache: false, 756 beforeSend: () => { 757 $btn.addClass("disabled"); 758 $input.prop("disabled", true); 759 }, 760 }) 761 .done(function (response) { 762 if (response && response !== "null") { 763 try { 764 const obj = JSON.parse(response); 765 const $preview = $btn 766 .next(".website-preview") 767 .removeClass("d-none"); 768 update_website_preview($preview, { 769 url, 770 img: obj["og:image"] || obj["twitter:image"] || "", 771 title: obj.title, 772 meta: response, 773 }); 774 } catch (error) { 775 $btn.removeClass("disabled"); 776 $input.prop("disabled", false); 777 } 778 } 779 }) 780 .always(function (error) { 781 $btn.removeClass("disabled"); 782 $input.prop("disabled", false); 783 }); 784 }); 785 786 $(".website-input-with-preview .reset").on("click", function (e) { 787 e.preventDefault(); 788 const $preview = $(this).closest(".website-preview"); 789 update_website_preview($preview, null); 790 791 // Focus 792 $preview 793 .closest(".website-input-with-preview") 794 .find("[name=website]") 795 .focus(); 796 }); 797 798 /* ====events-page==== */ 799 800 /* =======create-event-page====== */ 801 $doc.on("click", ".clone-me", function (e) { 802 e.preventDefault(); 803 let formGroup = $(this).parents(".form-group"); 804 let cont = formGroup.find(".clone-cont"); 805 let max = cont.data("max"); 806 807 if (typeof max == "undefined") { 808 max = 9999; 809 } 810 811 if (cont.find(".append-input").length + 1 <= max) { 812 let select2 = cont.find("select.select2"); 813 if (select2.length > 0) { 814 select2.select2("destroy"); 815 } 816 817 let htm = $(this) 818 .parents(".form-group") 819 .find(".append-input:first") 820 .clone(); 821 822 // Remove the 'faq-question-focused' class from the cloned field 823 htm.find('.faq-question').removeClass('faq-question-focused'); 824 825 // Clear the values of inputs in the cloned field 826 htm.find("input, select, textarea").val('').removeData('text-entered'); 827 828 cont.append(htm); 829 830 if (select2.length > 0) { 831 cont.find("select.select2").select2({ 832 multiple: false, 833 allowClear: true, 834 placeholder: "Please select", 835 }); 836 } 837 } 838 }); 839 840 $doc.on("click", ".remove-current-row", function (e) { 841 e.preventDefault(); 842 $(this).closest(".append-input").remove(); 843 $(this) 844 .parents(".form-group") 845 .find("input, select, textarea") 846 .trigger("change"); 847 }); 848 849 850 $doc.on("change", ".address-type", function () { 851 var value = $(this).is(":checked") ? 1 : 0; 852 853 $(".address-container").hide(); 854 855 if (value === 1) { 856 $(".address-container").show(); 857 } 858 }); 859 /* =======create-event-page====== */ 860 861 $(".collapse").on("show.bs.collapse", function () { 862 $(".collapse.in").collapse("hide"); 863 }); 864 865 $(".open-modal").on("click", function (ev) { 866 ev.preventDefault(); 867 $("#" + $(this).data("modal")).modal("show"); 868 }); 869 870 if ($.fn.select2) { 871 $("#teacher_job_id").select2({ 872 multiple: false, 873 minimumInputLength: 3, 874 ajax: { 875 url: window.hasOwnProperty("app") 876 ? app.ajaxurl 877 : tf_ajax.ajax_url, 878 dataType: "json", 879 type: "GET", 880 data: function (params) { 881 return { 882 q: params.term, 883 action: "load_teacher_jobs", 884 }; 885 }, 886 processResults: function (result) { 887 var options = []; 888 889 if (result.data) { 890 $.each(result.data, function (index, item) { 891 options.push({ 892 id: item.job_id, 893 text: item.job_name, 894 }); 895 }); 896 } 897 return { 898 results: options, 899 }; 900 }, 901 }, 902 }); 903 904 $(".select2").select2({ 905 multiple: false, 906 allowClear: true, 907 placeholder: "Please select", 908 }); 909 } 910 911 $(".search-results").on("click", ".unblock_user", function (e) { 912 e.preventDefault(); 913 914 let elem = $(this); 915 let unblock_id = $(this).data("unblock_id"); 916 let page = $(this).data("page"); 917 let s = $("#search-blocked").val(); 918 919 if (!window.confirm("Are you sure?")) { 920 return; 921 } 922 923 $.ajax({ 924 type: "POST", 925 url: window.hasOwnProperty("app") 926 ? app.ajaxurl 927 : tf_ajax.ajax_url, 928 data: { 929 action: "cs_unblock_user", 930 unblock_id: unblock_id, 931 page: page, 932 search: s, 933 }, 934 beforeSend: function (xhr) { 935 $(elem).html( 936 '<i class="fa fa-spinner fa-pulse"></i> Unblock' 937 ); 938 }, 939 complete: function (xhr, status) { 940 }, 941 success: function (response) { 942 if (response.success == true) { 943 $("#blocked-list").html(response.data.html); 944 if (response.data.pages <= 1) { 945 $(".template-pagination").hide(); 946 } 947 } 948 949 if (page == "search") { 950 $("#search-blocked").val(""); 951 $(".search-results").hide(); 952 } 953 }, 954 error: function (data, textStatus, errorThrown) { 955 }, 956 }); 957 }); 958 959 $("form#search-products-form a.close").on("click", function (ev) { 960 if ( 961 $("#search-blocked").val() != "" && 962 $(".search-results").is(":visible") 963 ) { 964 ev.preventDefault(); 965 $("#search-products").val(""); 966 $(".search-results").hide(); 967 $(this).hide(); 968 } else { 969 return true; 970 } 971 }); 972 973 // Footer Newsletter Signup 974 $("#newsletter-signup-form").on("submit", function (event) { 975 event.preventDefault(); 976 event.stopPropagation(); 977 978 const form = this; 979 form.classList.add("was-validated"); 980 981 if (!form.checkValidity()) { 982 return; 983 } 984 985 const $form = $(form); 986 const $button = $form.find('[type="submit"]'); 987 const $error_message = $form.find( 988 ".newsletter-signup-form-notice-error" 989 ); 990 const $error_message_inner = $form.find( 991 ".newsletter-signup-form-notice-error .span-message-inner" 992 ); 993 const $success_message = $form.find( 994 ".newsletter-signup-form-notice-success" 995 ); 996 997 $.ajax({ 998 url: `${tf_ajax.ajax_url}?action=newsletter_signup`, 999 method: "POST", 1000 data: $form.serialize(), 1001 dataType: "json", 1002 beforeSend: () => { 1003 $button.prop("disabled", true); 1004 $error_message.addClass("d-none"); 1005 $error_message_inner.text(""); 1006 }, 1007 }) 1008 .done(function () { 1009 $success_message.removeClass("d-none"); 1010 $button.remove(); 1011 }) 1012 .fail(function (error) { 1013 $error_message.removeClass("d-none"); 1014 $error_message_inner.text(error.responseJSON.data); 1015 }) 1016 .always(function () { 1017 $button.prop("disabled", false); 1018 }); 1019 }); 1020 1021 /* Dropdown menu */ 1022 // Show dropdown menu 1023 $doc.on("click", ".cf-dropdown__toggle", function () { 1024 const btn = $(this); 1025 const dropdown = btn.parent(); 1026 if (!dropdown.hasClass("active")) { 1027 $(".cf-dropdown").removeClass("active"); 1028 } 1029 dropdown.toggleClass("active"); 1030 }); 1031 1032 // Close dropdown 1033 $doc.on("click", function (e) { 1034 const dropdown = $(".cf-dropdown"); 1035 1036 if ( 1037 dropdown.hasClass("active") && 1038 !$(e.target).parents(".cf-dropdown").length 1039 ) { 1040 dropdown.removeClass("active"); 1041 } 1042 }); 1043 1044 $doc.on("click", '.cf-dropdown__menu [data-action="cancel"]', function () { 1045 $(this).closest(".cf-dropdown").removeClass("active"); 1046 }); 1047 /* -- Dropdown menu -- */ 1048 1049 /* Report Modal */ 1050 // Set User ID 1051 const reportModal = document.getElementById("reportModal"); 1052 1053 if (reportModal) { 1054 // On show 1055 reportModal.addEventListener("show.bs.modal", function (event) { 1056 const $modal = $(reportModal); 1057 const button = event.relatedTarget; 1058 const id = button.dataset.postId; 1059 1060 $modal.find('[name="report_post_id"]').val(id); 1061 }); 1062 1063 // On hide 1064 reportModal.addEventListener("hidden.bs.modal", function (event) { 1065 const $modal = $(reportModal); 1066 1067 $modal.find('[name="user_id"]').val(""); 1068 $modal 1069 .find('[name="report_reason"]:checked') 1070 .prop("checked", false) 1071 .trigger("change"); 1072 $modal.removeClass("step-2").addClass("step-1"); 1073 }); 1074 } 1075 1076 // Enable next button 1077 $('#reportModal [name="report_reason"]').on("change", function () { 1078 if (this.checked) { 1079 $("#reportModal .modal-footer .next") 1080 .removeClass("disabled") 1081 .removeAttr("disabled"); 1082 } else { 1083 $("#reportModal .modal-footer .next") 1084 .addClass("disabled") 1085 .prop("disabled", true); 1086 } 1087 }); 1088 1089 // Show next step 1090 $doc.on("click", "#reportModal .modal-footer .next:not([disabled])", function () { 1091 if ($('#reportModal [name="report_reason"]:checked').length) { 1092 $("#reportModal").removeClass("step-1").addClass("step-2"); 1093 } 1094 }); 1095 1096 // Submit 1097 $doc.on('click', '#report-modal-submit', function (e) { 1098 e.preventDefault(); 1099 1100 const $this = $(this); 1101 const $modal = $this.closest('#reportModal'); 1102 1103 $.ajax({ 1104 url: '/', 1105 type: 'post', 1106 data: { 1107 send_report: 1, 1108 report_post_id: $modal.find('[name="report_post_id"]').val(), 1109 report_reason: $modal.find('[name="report_reason"]:checked').val(), 1110 additional_information: $modal.find('[name="additional_information"]').val(), 1111 recaptcha_response: grecaptcha.getResponse(captchaObj.captcha_4), 1112 url: encodeURIComponent(location.href), 1113 }, 1114 beforeSend: function () { 1115 $this.find('span').hide(); 1116 $this.find('.ajax-spinner').show(); 1117 $('#report-errors-wrapper').hide(); 1118 $('#g-recaptcha4-error').hide(); 1119 }, 1120 success: function (response) { 1121 if (!response.success) { 1122 grecaptcha.reset(captchaObj.captcha_4); 1123 $this.find('span').show(); 1124 $this.find('.ajax-spinner').hide(); 1125 1126 if (response.data.hasOwnProperty('input') && response.data.input === 'captcha') { 1127 // Error 1128 $('#g-recaptcha4-error').show(); 1129 } 1130 else { 1131 $('#report-errors-wrapper').text(response.data.message).show(); 1132 } 1133 } 1134 else { 1135 location.href = response.data.url; 1136
1136 } 1137 }, 1138 error: function (error) { 1139 $this.find('span').hide(); 1140 $this.find('.ajax-spinner').show(); 1141 } 1142 }); 1143 }); 1144 1145 /* -- Report Modal -- */ 1146 1147 /* Link back */ 1148 (function () { 1149 const referrer = document.referrer; 1150 const domain = document.domain; 1151 const btn = $(".js-cf-link-back"); 1152 1153 try { 1154 const referrerURL = new URL(referrer); 1155 1156 if (referrerURL.host.includes(domain)) { 1157 btn.attr("href", referrer); 1158 } 1159 } catch (error) { 1160 } 1161 })(); 1162 /* -- Link back -- */ 1163 1164 /* Processing following/unfollowing via AJAX */ 1165 $doc.on("submit", ".js-set-user-follow", function (e) { 1166 e.preventDefault(); 1167 1168 const $form = $(this); 1169 1170 $.post(tf_ajax.ajax_url, $form.serialize(), function (resp) { 1171 let $account_box = $form.parents(".account-box"); 1172 1173 if ($form.hasClass("request-form")) { 1174 const request_id = $form.find('[name="request_id"]').val(); 1175 $account_box = $( 1176 `.account-box__actions .request[data-id="${request_id}"]` 1177 ).parents(".account-box"); 1178 } 1179 1180 $("#acceptRequest").modal("hide"); 1181 $account_box.find(".cf-dropdown").removeClass("active"); 1182 1183 // Update counters 1184 if (resp.hasOwnProperty('data') && resp.data.hasOwnProperty('friends_count')) { 1185 $('.template-head .nav-item:nth-child(1) .nav-link span').text(resp.data.friends_count.all); 1186 $('.template-head .nav-item:nth-child(2) .nav-link span').text(resp.data.friends_count.following); 1187 $('.template-head .nav-item:nth-child(3) .nav-link span').text(resp.data.friends_count.followers); 1188 $('.template-head .nav-item:nth-child(4) .nav-link span').text(resp.data.friends_count.requests); 1189 } 1190 1191 if (resp.data.code == "request") { 1192 $account_box.hide(); 1193 1194 // Redirect to message 1195 const action = $form.find('[name="follow_action"]').val(); 1196 const url = new URL(location.href); 1197 url.searchParams.set("msg", action == "add" ? 3 : 4); 1198 location.href = url.href; 1199 } else { 1200 $account_box 1201 .find(".account-box__actions") 1202 .removeClass("request follow unfollow") 1203 .addClass(resp.data.code); 1204 $account_box 1205 .find(".account-box__notice") 1206 .text(resp.data.message); 1207 } 1208 }); 1209 }); 1210 /* -- Processing following/unfollowing via AJAX -- */ 1211 1212 var ALLOWED_FILE_MIMES = [ 1213 'application/pdf', 1214 'application/msword', // doc 1215 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // docx 1216 'video/mp4', // mp4, m4v 1217 'video/webm', 1218 'video/avi', 1219 'video/quicktime', // mov 1220 'audio/mpeg', // mp3, m4a, m4b 1221 'audio/wav', 1222 'audio/aac', 1223 'text/plain', 1224 'video/x-msvideo', 1225 'application/octet-stream', 1226 'application/msword', 1227 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1228 'application/msword', 1229 'application/octet-stream', 1230 'application/epub+zip', 1231 'application/octet-stream', 1232 'video/x-flv', 1233 'application/octet-stream', 1234 'text/html', 1235 'text/htm', 1236 'application/inkml+xml', 1237 'image/bmp', 1238 'image/gif', 1239 'image/jpeg', 1240 'image/jpeg', 1241 'image/tif', 1242 'image/tiff', 1243 'image/png', 1244 'application/vnd.apple.keynote', 1245 'application/octet-stream', 1246 'video/quicktime', 1247 'audio/mpeg', 1248 'video/mpeg', 1249 'video/mpeg', 1250 'video/mp4', 1251 'audio/mp4', 1252 'video/x-m4v', 1253 'application/octet-stream', 1254 'application/vnd.oasis.opendocument.spreadsheet', 1255 'application/pdf', 1256 'application/vnd.ms-powerpoint', 1257 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 1258 'application/vnd.ms-powerpoint', 1259 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 1260 'application/x-mspublisher', 1261 'audio/x-pn-realaudio', 1262 'application/vnd.rn-realmedia', 1263 'application/rtf', 1264 'application/x-shockwave-flash', 1265 'text/plain', 1266 'audio/wave', 1267 'application/vnd.wordperfect', 1268 'video/x-ms-wmv', 1269 'application/vnd.ms-excel', 1270 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 1271 'application/vnd.ms-excel', 1272 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 1273 'application/zip', 1274 'application/vnd.google-apps.document', 1275 'application/vnd.google-apps.form', 1276 'application/vnd.google-apps.spreadsheet', 1277 'application/vnd.google-apps.presentation', 1278 'application/vnd.google-apps.folder', 1279 ]; 1280 1281 // Init uploader 1282 var uploader_1 = new FileManagerClass({ 1283 selector: '#post_update_image', 1284 ajaxUrl: tf_ajax.ajax_url, 1285 allowedMimes: ALLOWED_FILE_MIMES, 1286 isMultiple: false, 1287 isSort: true, 1288 isAS3: true, 1289 onOriginalFileUpload: function (file, data) { 1290 1291 // Do stuff after image upload 1292 files_json = uploader_1.getFiles(); 1293 localStorage.setItem('tmp_uploader_files', JSON.stringify(files_json)) 1294 1295 document.getElementById("attachment_post_id").value = data.id; 1296 $('#postImageModal .filem-upload-area').hide(); 1297 }, 1298 onDelete: function (deletedFile) { 1299 1300 // Do stuff after delete 1301 files_json = uploader_1.getFiles(); 1302 localStorage.setItem('tmp_uploader_files', JSON.stringify(files_json)) 1303 1304 document.getElementById("attachment_post_id").value = ''; 1305 $('#postImageModal .filem-upload-area').show(); 1306 } 1307 }); 1308 1309 /*Custom Dynamic Alert Modal*/ 1310 function showDynamicModal(title, message) { 1311 $('#dynamicModalLabel').text(title); 1312 $('.modal-body').text(message); 1313 let modal = new bootstrap.Modal(document.getElementById('dynamicModal'), { 1314 keyboard: false // Optional: specifies if the modal should be closed when the escape key is pressed 1315 }); 1316 modal.show(); 1317 } 1318 1319 // Make it available globally 1320 window.showDynamicModal = showDynamicModal; 1321 1322})(jQuery); 1323 1324 1325var toggleCollapse; 1326 1327jQuery(document).ready(function ($) { 1328 1329 // global collapsible toggle 1330 toggleCollapse = function (el) { 1331 el.classList.toggle("active"); 1332 } 1333 1334});
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.