1( function ( $ ) { 2 3 "use strict"; 4 5 window.BuddyBossTheme = { 6 init: function () { 7 this.add_Class(); 8 this.header_search(); 9 this.header_notifications(); 10 this.Menu(); 11 // this.setCounters(); 12 this.inputStyles(); 13 this.sidePanel(); 14 this.bbMasonry(); 15 // this.bbSlider(); 16 this.stickySidebars(); 17 this.bbFitVideo(); 18 this.LoadMorePosts(); 19 this.jsSocial(); 20 this.beforeLogIn(); 21 this.bbRelatedSlider(); 22 this.BuddyPanel_Dropdown(); 23 this.fileUpload(); 24 this.commentsValidate(); 25 this.messageScroll(); 26 if ( $( '.ld-in-focus-mode' ).length <= 0 ) { 27 this.ajax_comment(); 28 } 29 this.DropdownToggle(); 30 this.photoCommentFocus(); 31 this.bpRegRequired(); 32 this.inputFileStyle(); 33 this.primaryNavBar(); 34 this.forumsTopic(); 35 this.heartbeat(); 36 this.unReadNotifications() 37 this.ajaxComplete(); 38 }, 39 40 ajaxComplete: function () { 41 // When user gets new message then heartbeat send request to refresh notifications. 42 $( document ).ajaxComplete( function ( event, xhr, settings ) { 43 if ( typeof settings.data !== 'undefined' && 44 typeof settings.data === 'string' && 45 settings.data.indexOf( "action=messages_get_thread_messages" ) > 0 && 46 typeof wp !== 'undefined' && 47 typeof wp.heartbeat !== 'undefined' 48 ) { 49 wp.heartbeat.connectNow(); 50 } 51 } ); 52 }, 53 54 ajax_comment: function () { 55 56 $( document ).on( 57 "submit", 58 "#commentform", 59 function ( e ) { 60 61 e.preventDefault(); 62 var form = $( "#commentform" ); 63 64 var do_comment = $.post( form.attr( "action" ), form.serialize() ); 65 66 var ori_btn_val = $( "#commentform" ).find( "[type='submit']" ).val(); 67 $( "#comment" ).prop( "disabled", true ); 68 $( "#commentform" ).find( "[type='submit']" ).addClass( 'waiting' ); 69 $( "#commentform" ).find( "[type='submit']" ).prop( "disabled", true ).val( bs_data.translation.comment_btn_loading ); 70 do_comment.success( 71 function ( data, status, request ) { 72 73 var body = $( "<div></div>" ); 74 body.append( data ); 75 var comment_section = "#comments"; 76 var comments = body.find( comment_section ); 77 78 if ( comments.length < 1 ) { 79 comment_section = '.comment-list'; 80 comments = body.find( comment_section ); 81 } 82 83 var commentslists = comments.find( "li" ); 84 85 var new_comment_id = false; 86 87 // catch the new comment id by comparing to old dom. 88 commentslists.each( 89 function ( index ) { 90 var _this = $( commentslists[ index ] ); 91 if ( $( "#" + _this.attr( "id" ) ).length == 0 ) { 92 new_comment_id = _this.attr( "id" ); 93 } 94 } 95 ); 96 97 $( comment_section ).replaceWith( comments ); 98 99 var commentTop = $( "#" + new_comment_id ).offset().top; 100 101 if ( $( 'body' ).hasClass( 'sticky-header' ) ) { 102 commentTop = $( "#" + new_comment_id ).offset().top - $( '#masthead' ).height(); 103 } 104 105 if ( $( 'body' ).hasClass( 'admin-bar' ) ) { 106 commentTop = commentTop - $( '#wpadminbar' ).height(); 107 } 108 109 // scroll to comment 110 if ( new_comment_id ) { 111 $( "body, html" ).animate( 112 { 113 scrollTop: commentTop 114 }, 115 600 116 ); 117 } 118 } 119 ); 120 121 do_comment.fail( 122 function ( data ) { 123 var body = $( "<div></div>" ); 124 body.append( data.responseText ); 125 body.find( "style,meta,title,a" ).remove(); 126 body = body.find( '.wp-die-message p' ).text(); // clean text 127 if ( typeof bb_vue_loader == 'object' && 128 typeof bb_vue_loader.common == 'object' && 129 typeof bb_vue_loader.common.showSnackbar != 'undefined' ) { 130 bb_vue_loader.common.showSnackbar( body ) 131 } else { 132 alert( body ); 133 } 134 } 135 ); 136 137 do_comment.always( 138 function () { 139 $( "#comment" ).prop( "disabled", false ); 140 $( "#commentform" ).find( "[type='submit']" ).removeClass( 'waiting' ); 141 $( "#commentform" ).find( "[type='submit']" ).prop( "disabled", false ).val( ori_btn_val ); 142 } 143 ); 144 145 } 146 ); 147 148 }, 149 150 add_Class: function () { 151 152 // Page load class. 153 if ( document.readyState === 'complete' || document.readyState === 'interactive' ) { 154 document.getElementsByTagName( 'body' )[ 0 ].className += ' bb-page-loaded'; 155 } 156 157 function classToggle( e ) { 158 e.preventDefault(); 159 var elemPanelWrapper = document.querySelector( '.bb-mobile-panel-wrapper' ); 160 elemPanelWrapper.classList.toggle( 'closed' ); 161 } 162 163 var elemPanel = document.querySelector( '.bb-left-panel-mobile' ); 164 165 if ( elemPanel ) { 166 elemPanel.addEventListener( 'click', classToggle ); 167 } 168 169 $( '.bb-close-panel' ).on( 170 'click', 171 function ( e ) { 172 e.preventDefault(); 173 $( '.bb-mobile-panel-wrapper' ).addClass( 'closed' ); 174 } 175 ); 176 177 $( '.bp-template-notice.bp-sitewide-notice' ).insertAfter( '#masthead' ); 178 179 // learndash single page issues 180 var ldContent = document.getElementById( 'learndash-page-content' ); 181 if ( ldContent ) { 182 $( '.bp-template-notice.bp-sitewide-notice' ).prependTo( '#learndash-page-content' ); 183 } 184 185 if ( $( '.btn-new-topic' ).attr( 'data-modal-id' ) === 'bbp-topic-form' ) { 186 $( 'body' ).addClass( 'forum' ); 187 } 188 189 if ( $( '.bb-sfwd-aside #masthead' ).hasClass( 'elementor-header' ) ) { 190 $( '.bb-toggle-panel' ).prependTo( '.ld-course-navigation' ); 191 //Check if Elementor Header has Learndash theme toggle button and learndash corse sidebar toggle button, add only if not 192 if( !$('.site-header--elementor #bb-toggle-theme').length && !$( '.site-header--elementor .course-toggle-view' ).length ) { 193 $( '.bb-elementor-header-items' ).prependTo( '.learndash-content-body' ); 194 } 195 } 196 197 if ( $( '.bb-sfwd-aside #masthead' ).hasClass( 'beaver-header' ) ) { 198 $( '.bb-toggle-panel' ).prependTo( '.ld-course-navigation' ); 199 $( '.bb-elementor-header-items' ).prependTo( '.learndash-content-body' ); 200 } 201 202 if ( $( '.beaver-header > header' ).attr( 'data-sticky' ) === '1' ) { 203 $( 'body' ).addClass( 'beaver-sticky-header' ); 204 } 205 206 $( document ).on( 207 'click', 208 '#members-list.item-list:not(.grid) li .has_hook_content .more-action-button', 209 function ( e ) { 210 $( this ).parents( 'li.item-entry' ).toggleClass( 'active' ).siblings( 'li' ).removeClass( 'active' ); 211 e.preventDefault(); 212 } 213 ); 214 }, 215 216 Menu: function () { 217 var $width = 150; 218 // $( '#primary-menu' ).BossSocialMenu( $width ); 219 $( '#activity-sub-nav' ).BossSocialMenu( 90 ); 220 $( '#object-nav > ul' ).BossSocialMenu( 35 ); 221 $( '.bb-footer ul.footer-menu' ).BossSocialMenu( 90 ); 222 if ( $( '#object-nav > ul' ).length > 0 ) { 223 setTimeout( function () { 224 window.dispatchEvent(new Event('resize')); 225 }, 0 ); 226 } 227 // $( '.widget_bp_groups_widget #alphabetical-groups' ).after( '<div class="bb-widget-dropdown"><a class="bb-toggle-dropdown"><i class="bb-icon-menu-dots-v"></i></a><div class="bb-dropdown"></div></div>' ).appendTo( '.bb-widget-dropdown .bb-dropdown' ); 228 $( '.toggle-button' ).panelslider( { bodyClass: 'ps-active', clickClose: true, onOpen: null } ); 229 230 $( document ).on( 231 'click', 232 '.more-button', 233 function ( e ) { 234 e.preventDefault(); 235 $( this ).toggleClass( 'active' ).next().toggleClass( 'active' ); 236 } 237 ); 238 239 $( document ).on( 240 'click', 241 '.hideshow .sub-menu a', 242 function ( e ) { 243 // e.preventDefault(); 244 $( 'body' ).trigger( 'click' ); 245 246 // add 'current' and 'selected' class 247 var currentLI = $( this ).parent(); 248 currentLI.parent( '.sub-menu' ).find( 'li' ).removeClass( 'current selected' ); 249 currentLI.addClass( 'current selected' ); 250 } 251 ); 252 253 $( document ).on( 254 'click', 255 '.bb-share', 256 function ( e ) { 257 e.preventDefault(); 258 } 259 ); 260 261 $( document ).click( 262 function ( e ) { 263 var container = $( '.more-button, .sub-menu' ); 264 if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) { 265 $( '.more-button' ).removeClass( 'active' ).next().removeClass( 'active' ); 266 } 267 } 268 ); 269 270 var headerHeight = $( '#masthead' ).height(); 271 var headerHeightExt = headerHeight + 55; 272 273 if ( $( window ).width() > 768 ) { 274 $( '.site-content-grid >
274 .bb-share-container' ).stick_in_parent( { offset_top: headerHeightExt, spacer: false } ); 275 } 276 277 $( window ).resize( function () { 278 if ( $( window ).width() > 768 ) { 279 $( '.site-content-grid > .bb-share-container' ).stick_in_parent( { offset_top: headerHeightExt, spacer: false } ); 280 } else { 281 $( '.site-content-grid > .bb-share-container' ).trigger( "sticky_kit:detach" ); 282 } 283 } ); 284 $( '.site-content-grid > .bb-share-container' ).stick_in_parent( { offset_top: headerHeightExt, spacer: false } ); 285 286 var $document = $( document ), 287 $elementHeader = $( '.sticky-header .site-header' ), 288 $elementPanel = $( '.bb-sfwd-aside .buddypanel' ), 289 $LMSlessonsHeader = $( '.single-sfwd-lessons .site-header' ), 290 $LMStopicHeader = $( '.single-sfwd-topic .site-header' ), 291 className = 'has-scrolled'; 292 293 $document.scroll( 294 function () { 295 $elementHeader.toggleClass( className, $document.scrollTop() >= 1 ); 296 $elementPanel.toggleClass( className, $document.scrollTop() >= 5 ); 297 $LMSlessonsHeader.toggleClass( className, $document.scrollTop() >= 1 ); 298 $LMStopicHeader.toggleClass( className, $document.scrollTop() >= 1 ); 299 } 300 ); 301 302 $( document ).on( 303 'click', 304 '.header-aside div.menu-item-has-children > a', 305 function ( e ) { 306 e.preventDefault(); 307 var current = $( this ).closest( 'div.menu-item-has-children' ); 308 current.siblings( '.selected' ).removeClass( 'selected' ); 309 current.toggleClass( 'selected' ); 310 } 311 ); 312 313 $( 'body' ).mouseup( 314 function ( e ) { 315 var container = $( '.header-aside div.menu-item-has-children *' ); 316 if ( !container.is( e.target ) ) { 317 $( '.header-aside div.menu-item-has-children' ).removeClass( 'selected' ); 318 } 319 } 320 ); 321 }, 322 323 inputStyles: function () { 324 var submitButton = $( '.mc4wp-form-fields input[type="submit"]' ); 325 submitButton.attr( 'disabled', true ); 326 327 $( '.mc4wp-form-fields input[type="email"]' ).keyup( 328 function () { 329 if ( $( this ).val().length != 0 ) { 330 submitButton.attr( 'disabled', false ); 331 } else { 332 submitButton.attr( 'disabled', true ); 333 } 334 } 335 ); 336 337 function customRegRadio() { 338 $( '.bs-bp-container-reg .field-visibility-settings input[type=radio]' ).each( 339 function () { 340 var $this = $( this ); 341 $( '<span class="bs-radio"></span>' ).insertAfter( $this ); 342 $this.addClass( 'bs-radio' ); 343 if ( $this.is( ':checked' ) ) { 344 $this.next( 'span.bs-radio' ).addClass( 'on' ); 345 $this.closest( 'label' ).addClass( 'on' ); 346 } 347 348 $this.change( 349 function () { 350 $this.closest( 'div.radio' ).find( 'span.bs-radio' ).removeClass( 'on' ); 351 $this.closest( 'div.radio' ).find( 'label' ).removeClass( 'on' ); 352 $this.next( 'span.bs-radio' ).addClass( 'on' ); 353 $this.closest( 'label' ).addClass( 'on' ); 354 } 355 ); 356 } 357 ); 358 } 359 360 customRegRadio(); 361 }, 362 363 header_search: function () { 364 // Toggle Search 365 $( '.site-header.site-header--bb .header-search-link' ).on( 366 'click', 367 function ( e ) { 368 e.preventDefault(); 369 $( 'body' ).toggleClass( 'search-visible' ); 370 if ( !navigator.userAgent.match( /(iPod|iPhone|iPad)/ ) ) { 371 setTimeout( 372 function () { 373 $( 'body' ).find( '.header-search-wrap .search-field-top' ).focus(); 374 }, 375 90 376 ); 377 } 378 } 379 ); 380 381 $( '.header-search-wrap .search-field-top' ).focus( 382 function () { 383 if ( !navigator.userAgent.match( /(iPod|iPhone|iPad)/ ) ) { 384 var $input = this; 385 setTimeout( 386 function () { 387 $input.selectionStart = $input.selectionEnd = 10000; 388 }, 389 0 390 ); 391 } 392 } 393 ); 394 395 // Hide Search 396 $( '.site-header.site-header--bb .close-search' ).on( 397 'click', 398 function ( e ) { 399 e.preventDefault(); 400 $( 'body' ).removeClass( 'search-visible' ); 401 $( '.header-search-wrap input.search-field-top' ).val( '' ); 402 } 403 ); 404 405 $( document ).click( 406 function ( e ) { 407 var container = $( '.header-search-wrap, .header-search-link' ); 408 if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) { 409 $( 'body' ).removeClass( 'search-visible' ); 410 } 411 } 412 ); 413 414 $( document ).keyup( 415 function ( e ) { 416 417 if ( e.keyCode === 27 ) { 418 $( 'body' ).removeClass( 'search-visible' ); 419 } 420 } 421 ); 422 }, 423 424 unReadNotifications: function () { 425 var notification_queue = []; 426 $( document ).on( 427 "click", 428 ".action-unread", 429 function ( e ) { 430 var data = { 431 'action': 'buddyboss_theme_unread_notification', 432 'notification_id': $( this ).data( 'notification-id' ) 433 };
434 if ( notification_queue.indexOf( $( this ).data( 'notification-id' ) ) !== -1 ) { 435 return false; 436 } 437 notification_queue.push( $( this ).data( 'notification-id' ) ); 438 var notifs = $( '.bb-icon-bell' ); 439 var notif_icons = $( notifs ).parent().children( '.count' ); 440 if ( notif_icons.length > 0 ) { 441 if ( $( this ).data( 'notification-id' ) !== 'all' ) { 442 notif_icons.html( parseInt( notif_icons.html() ) - 1 ); 443 } else { 444 if ( parseInt( $( '#header-notifications-dropdown-elem ul.notification-list li' ).length ) < 25 ) { 445 notif_icons.fadeOut(); 446 } else { 447 notif_icons.html( parseInt( notif_icons.html() ) - parseInt( $( '#header-notifications-dropdown-elem ul.notification-list li' ).length ) ); 448 } 449 } 450 } 451 if ( $( '.notification-wrap.menu-item-has-children.selected ul.notification-list li' ).length !== 'undefined' && $( '.notification-wrap.menu-item-has-children.selected ul.notification-list li' ).length == 1 || $( this ).data( 'notification-id' ) === 'all' ) { 452 $( '#header-notifications-dropdown-elem ul.notification-list' ).html( '<p class="bb-header-loader"><i class="bb-icon-loader animate-spin"></i></p>' ); 453 } 454 if ( $( this ).data( 'notification-id' ) !== 'all' ) { 455 $( this ).parent().parent().fadeOut(); 456 $( this ).parent().parent().remove(); 457 } 458 $.post( 459 ajaxurl, 460 data, 461 function ( response ) { 462 var notifs = $( '.bb-icon-bell' ); 463 var notif_icons = $( notifs ).parent().children( '.count' ); 464 if ( notification_queue.length === 1 && response.success && typeof response.data !== 'undefined' && typeof response.data.contents !== 'undefined' && $( '#header-notifications-dropdown-elem ul.notification-list' ).length ) { 465 $( '#header-notifications-dropdown-elem ul.notification-list' ).html( response.data.contents ); 466 } 467 if ( typeof response.data.total_notifications !== 'undefined' && response.data.total_notifications > 0 && notif_icons.length > 0 ) { 468 $( notif_icons ).text( response.data.total_notifications ); 469 $( '.notification-header .mark-read-all' ).show(); 470 } else { 471 $( notif_icons ).remove(); 472 $( '.notification-header .mark-read-all' ).fadeOut(); 473 } 474 var index = notification_queue.indexOf( $( this ).data( 'notification-id' ) ); 475 notification_queue.splice( index, 1 ); 476 } 477 ); 478 } 479 ); 480 }, 481 482 header_notifications: function () { 483 if ( $( '#header-notifications-dropdown-elem' ).length ) { 484 setTimeout( 485 function () { 486 $( '#header-notifications-dropdown-elem ul.notification-list' ).html( '<p class="bb-header-loader"><i class="bb-icon-loader animate-spin"></i></p>' ); 487 $.get( 488 ajaxurl, 489 { action: 'buddyboss_theme_get_header_notifications' }, 490 function ( response, status, e ) { 491 if ( response.success && typeof response.data !== 'undefined' && typeof response.data.contents !== 'undefined' && $( '#header-notifications-dropdown-elem ul.notification-list' ).length ) { 492 $( '#header-notifications-dropdown-elem ul.notification-list' ).html( response.data.contents ); 493 if ( typeof response.data.total_notifications !== 'undefined' && response.data.total_notifications > 0 ) { 494 $( '.notification-header .mark-read-all' ).fadeIn(); 495 } else { 496 $( '.notification-header .mark-read-all' ).fadeOut(); 497 } 498 } 499 } 500 ); 501 }, 502 3000 503 ); 504 } 505 if ( $( '#header-messages-dropdown-elem' ).length ) { 506 setTimeout( 507 function () { 508 $( '#header-messages-dropdown-elem ul.notification-list' ).html( '<p class="bb-header-loader"><i class="bb-icon-loader animate-spin"></i></p>' ); 509 $.get( 510 ajaxurl, 511 { action: 'buddyboss_theme_get_header_unread_messages' }, 512 function ( response, status, e ) { 513 if ( response.success && typeof response.data !== 'undefined' && typeof response.data.contents !== 'undefined' && $( '#header-messages-dropdown-elem ul.notification-list' ).length ) { 514 $( '#header-messages-dropdown-elem ul.notification-list' ).html( response.data.contents ); 515 } 516 } 517 ); 518 }, 519 3000 520 ); 521 } 522 }, 523 524 sidePanel: function () { 525 var status = ''; 526 527 $( '.bb-toggle-panel' ).on( 528 'click', 529 function ( e ) { 530 e.preventDefault(); 531 532 $( 'body' ).addClass( 'buddypanel-transtioned' ); 533 534 $( '.buddypanel' ).on( 535 'webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', 536 function () { 537 setTimeout( 538 function () { 539 $( 'body' ).removeClass( 'buddypanel-transtioned' ); 540 }, 541 200 542 ); 543 } 544 ); 545 546 if ( $( 'body' ).hasClass( 'buddypanel-open' ) ) { 547 $( 'body' ).removeClass( 'buddypanel-open' ); 548 status = 'closed'; 549 } else { 550 $( 'body' ).addClass( 'buddypanel-open' ); 551 status = 'open'; 552 } 553
554 setCookie( 'buddypanel', status, 30, '/' ); 555 556 if ( $( '.elementor-section-stretched' ).length > 0 ) { 557 setTimeout( 558 function () { 559 $( window ).trigger( 'resize' ); 560 }, 561 300 562 ); 563 setTimeout( 564 function () { 565 $( window ).trigger( 'resize' ); 566 }, 567 500 568 ); 569 } 570 571 /* Elementor edit mode specific case when 'Stretch Section' option is toggled */ 572 if ( $( '.elementor-section[style*=width]' ).length > 0 ) { 573 setTimeout( 574 function () { 575 $( window ).trigger( 'resize' ); 576 }, 577 300 578 ); 579 setTimeout( 580 function () { 581 $( window ).trigger( 'resize' ); 582 }, 583 500 584 ); 585 } 586 587 $( 'side-panel-inner:not(.is_block) .bs-submenu-toggle' ).removeClass( 'bs-submenu-open' ); 588 $( 'side-panel-inner:not(.is_block) .sub-menu' ).removeClass( 'bb-open' ); 589 } 590 ); 591 592 function sidePanelHeight() { 593 if ( $( 'body' ).hasClass( 'buddypanel-header' ) || $( 'body' ).hasClass( 'buddypanel-logo' ) ) { 594 if ( $( '.buddypanel .site-branding' ).length ) { 595 var bbPanelBranding = $( '.buddypanel .site-branding' ).outerHeight(); 596 } else { 597 var bbPanelBranding = 0; 598 } 599 if ( $( '.buddypanel .panel-head' ).length ) { 600 var bbPanelHead = $( '.buddypanel .panel-head' ).outerHeight(); 601 } else { 602 var bbPanelHead = 0; 603 } 604 if ( $( '.buddypanel .buddypanel-site-icon:visible' ).length ) { 605 var bbPanelSiteIcon = $( '.buddypanel .buddypanel-site-icon' ).outerHeight(); 606 } else { 607 var bbPanelSiteIcon = 0; 608 } 609 $( 'body:not(.buddypanel-open) .side-panel-inner:not(.is_block)' ).css( 'height', '100%' ).css( 'height', '-=' + ( bbPanelHead + bbPanelSiteIcon + 40 ) + 'px' ); 610 $( 'body.buddypanel-open .side-panel-inner:not(.is_block)' ).css( 'height', '100%' ).css( 'height', '-=' + ( bbPanelBranding + bbPanelHead + 40 ) + 'px' ); 611 } 612 } 613 614 sidePanelHeight(); 615 616 $( window ).on( 617 'resize', 618 function () { 619 sidePanelHeight(); 620 } 621 ); 622 623 $( '.bb-toggle-panel' ).on( 624 'click', 625 function ( e ) { 626 e.preventDefault(); 627 sidePanelHeight(); 628 629 setTimeout( 630 function () { 631 sidePanelHeight(); 632 }, 633 300 634 ); 635 setTimeout( 636 function () { 637 sidePanelHeight(); 638 }, 639 600 640 ); 641 } 642 ); 643 644 function buddyPanelScroll(){ 645 if(window.matchMedia("(pointer: coarse)").matches) { 646 $('.side-panel-inner:not(.is_block)').addClass( 'touch-only' ); 647 } else { 648 $('.side-panel-inner:not(.is_block)').removeClass( 'touch-only' ); 649 $( '.side-panel-inner:not(.is_block)' ).mousewheel( 650 function ( event ) { 651 event.preventDefault(); 652 $('.side-panel-inner').removeClass( 'touch-only' ); 653 var scrollTop = this.scrollTop; 654 this.scrollTop = ( scrollTop + ( ( event.deltaY * event.deltaFactor ) * -1 ) ); 655
656 $( '#buddypanel-menu:not(.buddypanel-menu-block)' ).addClass( 'side-panel-scroll' ); 657 $( '#buddypanel-menu:not(.buddypanel-menu-block) li a' ).css( 'margin-top', '-' + this.scrollTop + 'px' ); 658 $( '#buddypanel-menu:not(.buddypanel-menu-block) li a:after', '#buddypanel-menu:not(.buddypanel-menu-block) li a:before' ).css( 'display', 'none' ); 659 660 clearTimeout( $.data( this, 'scrollTimer' ) ); 661 $.data( 662 this, 663 'scrollTimer', 664 setTimeout( 665 function () { 666 $( '#buddypanel-menu:not(.buddypanel-menu-block)' ).removeClass( 'side-panel-scroll' ); 667 }, 668 250 669 ) 670 ); 671 } 672 ); 673 674 } 675 }; 676 677 buddyPanelScroll(); 678 679 $( window ).resize( function(){ 680 buddyPanelScroll(); 681 }); 682 683 // Add class wrapper if absent 684 $( '.sub-menu-inner > li' ).each( 685 function () { 686 if ( $( this ).find( '.ab-sub-wrapper' ).length !== 0 ) { 687 $( this ).addClass( 'parent' ); 688 $( this ).find( '.ab-sub-wrapper' ).addClass( 'wrapper' ); 689 } 690 } 691 ); 692 693 // whenever we hover over a menu item that has a submenu 694 $( '.user-wrap li.parent, .user-wrap .menu-item-has-children' ).on( 695 'mouseover', 696 function () { 697 var $menuItem = $( this ), 698 $submenuWrapper = $( '> .wrapper', $menuItem ); 699 700 // grab the menu item's position relative to its positioned parent
701 var menuItemPos = $menuItem.position(); 702 703 // place the submenu in the correct position relevant to the menu item 704 $submenuWrapper.css( 705 { 706 top: menuItemPos.top 707 } 708 ); 709 } 710 ); 711 712 function setCookie ( key, value, expires, path, domain ) { 713 var cookie = key + '=' + escape( value ) + ';'; 714 715 if ( expires ) { 716 // If it's a date 717 if ( expires instanceof Date ) { 718 // If it isn't a valid date 719 if ( isNaN( expires.getTime() ) ) { 720 expires = new Date(); 721 } 722 } else { 723 expires = new Date( new Date().getTime() + parseInt( expires ) * 1000 * 60 * 60 * 24 ); 724 } 725 cookie += 'expires=' + expires.toUTCString() + ';'; 726 } 727 728 if ( path ) { 729 cookie += 'path=' + path + ';'; 730 } 731 if ( domain ) { 732 cookie += 'domain=' + domain + ';'; 733 } 734 735 document.cookie = cookie; 736 } 737 }, 738 739 DropdownToggle: function () { 740 jQuery( document ).on( 741 'click', 742 'a.bs-dropdown-link.bb-reply-actions-button', 743 function ( e ) { 744 e.preventDefault(); 745 if ( jQuery( this ).hasClass( 'active' ) ) { 746 jQuery( this ).removeClass( 'active' ).next( '.bb-reply-actions-dropdown' ).removeClass( 'open' ).closest( 'li' ).removeClass( 'dropdown-open' ); 747 } else { 748 jQuery( 'a.bs-dropdown-link.bb-reply-actions-button' ).removeClass( 'active' ).next( '.bb-reply-actions-dropdown' ).removeClass( 'open' ).closest( 'li' ).removeClass( 'dropdown-open' ); 749 jQuery( this ).toggleClass( 'active' ).next( '.bb-reply-actions-dropdown' ).toggleClass( 'open' ).closest( 'li' ).toggleClass( 'dropdown-open' ); 750 } 751 } 752 ); 753 754 $( document ).click( 755 function ( e ) { 756 var container = $( '.bb-reply-actions-dropdown, a.bs-dropdown-link.bb-reply-actions-button' ); 757 var forumMoreAction = $( '.forum_single_action_more-wrap' ); 758 if ( ! container.is( e.target ) && container.has( e.target ).length === 0) { 759 $( '.bb-reply-actions-dropdown' ).removeClass( 'open' ); 760 $( 'a.bs-dropdown-link.bb-reply-actions-button' ).removeClass( 'active' ).closest( 'li' ).removeClass( 'dropdown-open' ); 761 } 762 if ( ! forumMoreAction.is( e.target ) && forumMoreAction.has( e.target ).length === 0) { 763 $( '.forum_single_action_wrap.is_visible' ).removeClass( 'is_visible' ); 764 } 765 } 766 ); 767 768 $( document ).on( 769 'click', 770 '.bb-reply-actions-dropdown .bbp-reply-to-link', 771 function ( e ) { 772 $( '.bb-reply-actions-dropdown' ).removeClass( 'open' ); 773 $( 'a.bs-dropdown-link.bb-reply-actions-button' ).removeClass( 'active' ); 774 } 775 ); 776 777 $( document ).on( 778 'click', 779 '.bs-forums-items .bbp-reply-to-link', 780 function ( e ) { 781 $( this ).closest( '.bs-reply-list-item' ).addClass( 'in-focus' ); 782 } 783 ); 784 }, 785 786 bbMasonry: function () { 787 $( '.bb-masonry' ).css( "visibility", "visible" ).masonry( 788 { 789 itemSelector: '.bb-masonry .hentry', 790 columnWidth: '.bb-masonry-sizer', 791 } 792 ); 793 }, 794 795 bbSlider: function () { 796 // bs_gallery_slider(); 797 }, 798 799 stickySidebars: function () { 800 var bbHeaderHeight = $( '#masthead' ).outerHeight(), 801 offsetTop = 30; 802 803 if ( $( 'body' ).hasClass( 'sticky-header' ) && $( 'body' ).hasClass( 'admin-bar' ) ) { 804 offsetTop = bbHeaderHeight + 62; 805 } else if ( $( 'body' ).hasClass( 'sticky-header' ) ) { 806 offsetTop = bbHeaderHeight + 30; 807 } else if ( $( 'body' ).hasClass( 'admin-bar' ) ) { 808 offsetTop = 62; 809 } 810 811 if ( $( window ).width() > 1081 ) { 812 $( '.bb-sticky-sidebar' ).stick_in_parent( { spacer: false, offset_top: offsetTop } ); 813 814 // allow smooth scroll if activity list is not loaded 815 if ( $( '.activity #activity-stream #bp-ajax-loader .loading' ).length ) { 816 $( '.bb-sticky-sidebar' ).trigger( "sticky_kit:detach" ); 817 } 818 $( '.activity #buddypress' ).on( 'bp_ajax_request', '[data-bp-list="activity"]', function () { 819 $( '.bb-sticky-sidebar' ).stick_in_parent( { spacer: false, offset_top: offsetTop } ); 820 } ); 821 822 $( '.bb-sticky-sidebar' ).parent( '#secondary' ).css( 'min-height', $( '.bb-sticky-sidebar' ).height() ); 823 } 824 825 $( window ).resize( function () { 826 if ( $( window ).width() > 1081 ) { 827 $( '.bb-sticky-sidebar' ).stick_in_parent( { spacer: false, offset_top: offsetTop } ); 828 } else { 829 $( '.bb-sticky-sidebar' ).trigger( "sticky_kit:detach" ); 830 } 831 $( '.bb-sticky-sidebar' ).parent( '#secondary' ).css( 'min-height', $( '.bb-sticky-sidebar' ).height() ); 832 } ); 833 834 if ( $( '.bb-sticky-sidebar' ).length > 0 ) { 835 $( document ).ajaxComplete( function ( event, request, settings ) { 836 setTimeout( function () { 837 $( document.body ).trigger( 'sticky_kit:recalc' ); 838 }, 150 ); 839 } ); 840 } 841 }, 842 843 bbFitVideo: function () { 844 845 // Thrive Architect background video fix 846 if ( $( '.thrv-page-section .tcb-video-background-el iframe' ).length > 0 ) { 847 $( '.thrv-page-section .tcb-video-background-el iframe' ).addClass( 'fitvidsignore' ); 848 } 849 850 var doFitVids = function () { 851 setTimeout( 852 function () { 853 $( 'iframe[src*="youtube"], iframe[src*="vimeo"]' ).parent().fitVids(); 854 }, 855 300 856 ); 857 }; 858 doFitVids(); 859 $( document ).ajaxComplete( function () { 860 if ( !$( '.elementor-popup-modal .elementor-widget-video' ).length ) { 861 doFitVids(); 862 } 863 $( '.elementor-video-container' ).addClass( 'fitvidsignore' ); 864 } ); 865 866 var doFitVidsOnLazyLoad = function ( event, data ) { 867 if ( typeof data !== 'undefined' && typeof data.element !== 'undefined' ) { 868 // load iframe in correct dimension 869 if ( data.element.getAttribute( 'data-lazy-type' ) == 'iframe' ) { 870 doFitVids(); 871 } 872 } 873 }; 874 $( document ).on( 'bp_nouveau_lazy_load', doFitVidsOnLazyLoad ); 875 }, 876 877 LoadMorePosts: function () { 878 $( document ).on( 879 'click', 880 '.button-load-more-posts', 881 function ( event ) { 882 event.preventDefault(); 883 884 var self = $( this ), 885 href = self.attr( 'href' ), 886 container = $( '.post-grid' ); 887 888 self.addClass( 'loading' ); 889 890 $.get( 891 href, 892 function ( response ) { 893 $( '.pagination-below' ).remove(); // remove old pagination. 894 895 $( response ).find( 'article.status-publish' ).each( 896 function ( i, e ) { 897 898 var elem = $( e ); 899 900 if ( container.hasClass( 'bb-masonry' ) ) { 901 container.append( elem ).masonry( 'appended', elem ).masonry(); 902 } else { 903 container.append( elem ); 904 } 905 906 } 907 ); 908 909 $( '.post-grid' ).after( $( response ).find( '.pagination-below' ) ); 910 911 if ( $( '.post-grid' ).hasClass( 'bb-masonry' ) ) { 912 $( '.bb-masonry' ).masonry( {} ); 913 } 914 915 // scripts to execute? 916 var $script_tags = $( response ).filter( 'script.bb_bookmarks_bootstrap' ); 917 if ( $script_tags.length > 0 ) { 918 $script_tags.each( 919 function () { 920 $( 'body' ).append( $( this ) ); 921 } 922 ); 923 } 924 925 // setTimeout(function () { 926 // bs_gallery_slider(); 927 // }, 600); 928 } 929 ); 930 } 931 ); 932 933 $( document ).on( 934 'scroll', 935 function () { 936 var load_more_posts = $( '.post-infinite-scroll' ); 937 if ( load_more_posts.length ) { 938 var pos = load_more_posts.offset(); 939 if ( $( window ).scrollTop() + $( window ).height() > pos.top ) { 940 if ( !load_more_posts.hasClass( 'loading' ) ) { 941 load_more_posts.trigger( 'click' ); 942 } 943 } 944 } 945 } 946 ); 947 }, 948 949 /** 950 * Generates the sample for loader purpose for post grids. 951 */ 952 postGridLoader: function () { 953 954 var loading = $( 'article.type-post' ).not( ".first" ).first().clone(); 955 956 // remove not needed elements. 957 loading.removeClass( "format-quote" ); 958 loading.find( ".entry-meta" ).remove(); 959 loading.find( ".mejs-offscreen" ).remove(); 960 loading.find( ".mejs-container" ).remove(); 961 loading.find( "img" ).remove(); 962 loading.find( ".post-format-icon" ).remove(); 963 loading.find( ".post-main-link" ).remove(); 964 loading.find( ".bb-gallery-slider" ).replaceWith( '<a href="" class="entry-media entry-img"></a>' ); 965 966 if ( !loading.find( ".entry-img" ).length ) { 967 loading.prepend( '<a href="" class="entry-media entry-img"></a>' ); 968 } 969 970 // Append Dummy Data, 971 972 var spaces = ''; 973 for ( var i = 0; i <= 60; i++ ) {
974 spaces += ' '; 975 } 976 977 loading.find( '.entry-content' ).html( "<span>" + spaces + "</span>" ); 978 979 spaces = ''; 980 for ( var i = 0; i <= 20; i++ ) { 981 spaces += ' '; 982 } 983 984 loading.find( '.entry-title > a' ).html( spaces ); 985 986 // add loading class 987 988 loading.addClass( "loading" ); 989 990 return loading; 991 992 }, 993 994 jsSocial: function () { 995 $( '.bb-shareIcons' ).jsSocials( 996 { 997 showLabel: true, 998 showCount: false, 999 shares: [ 1000 { share: "facebook", label: bs_data.facebook_label }, 1001 { share: "twitter", label: bs_data.twitter_label }, 1002 ] 1003 } 1004 ); 1005 1006 $( '.jssocials-share-link' ).each( 1007 function () { 1008 $( this ).attr( 'data-balloon-pos', 'right' ); 1009 $( this ).attr( 'data-balloon', $( this ).find( '.jssocials-share-label' ).html() ); 1010 } 1011 ); 1012 1013 $( '.post-related-posts' ).find( 'a[data-balloon-pos]' ).attr( 'data-balloon-pos', 'left' ); 1014 }, 1015 1016 beforeLogIn: function () { 1017 var $loginUserName = '#bp-login-widget-user-login'; 1018 var $loginUserPass = '#bp-login-widget-user-pass'; 1019 var $loginUserBtn = $( '#bp-login-widget-submit' ); 1020 1021 function checkLogIn() { 1022 var empty = false; 1023 $( $loginUserName + ',' + $loginUserPass ).each( 1024 function () { 1025 if ( $( this ).val() == '' ) { 1026 empty = true; 1027 } 1028 } 1029 ); 1030 1031 if ( empty ) { 1032 $loginUserBtn.removeClass( 'bp-login-btn-active' ); 1033 } else { 1034 $loginUserBtn.addClass( 'bp-login-btn-active' ); 1035 } 1036 } 1037 1038 checkLogIn(); 1039 1040 $( $loginUserName + ', ' + $loginUserPass ).keyup( 1041 function () { 1042 checkLogIn(); 1043 } 1044 ); 1045 1046 setTimeout( 1047 function () { 1048 $( '#bp-login-widget-user-pass' ).each( 1049 function ( i, element ) { 1050 var el = $( this ); 1051 1052 if ( el.is( "*:-webkit-autofill" ) ) { 1053 $loginUserBtn.addClass( 'bp-login-btn-active' ); 1054 } 1055 } 1056 ); 1057 }, 1058 200 1059 ); 1060 1061 var $bbpLoginUserName = '.bbp-login-form #user_login'; 1062 var $bbpLoginUserPass = '.bbp-login-form #user_pass'; 1063 var $bbpLoginUserBtn = $( '.bbp-login-form #user-submit' ); 1064 1065 function checkbbpLogIn() { 1066 var empty = false; 1067 $( $bbpLoginUserName + ',' + $bbpLoginUserPass ).each( 1068 function () { 1069 if ( $( this ).val() == '' ) { 1070 empty = true; 1071 } 1072 } 1073 ); 1074 1075 if ( empty ) { 1076 $bbpLoginUserBtn.removeClass( 'bp-login-btn-active' ); 1077 } else { 1078 $bbpLoginUserBtn.addClass( 'bp-login-btn-active' ); 1079 } 1080 } 1081 1082 checkbbpLogIn(); 1083 1084 $( $bbpLoginUserName + ', ' + $bbpLoginUserPass ).keyup( 1085 function () { 1086 checkbbpLogIn(); 1087 } 1088 ); 1089 1090 $( 'form.bbp-login-form label[for="user_pass"]' ).append( "<span class='label-switch'></span>" ); 1091 1092 $( document ).on( 1093 'click', 1094 'form.bbp-login-form .label-switch', 1095 function ( e ) { 1096 var $this = $( this ); 1097 var $input = $this.closest( '.bbp-password' ).find( 'input#user_pass' ); 1098 $this.toggleClass( "bb-eye" ); 1099 if ( $this.hasClass( 'bb-eye' ) ) { 1100 $input.attr( "type", "text" ); 1101 } else { 1102 $input.attr( "type", "password" ); 1103 } 1104 } 1105 ); 1106 1107 $( 'form#bp-login-widget-form label[for="bp-login-widget-user-pass"]' ).append( "<span class='label-switch'></span>" ); 1108 1109 $( document ).on( 1110 'click', 1111 'form#bp-login-widget-form .label-switch', 1112 function ( e ) { 1113 var $this = $( this ); 1114 var $input = $this.closest( 'form' ).find( 'input#bp-login-widget-user-pass' ); 1115 $this.toggleClass( "bb-eye" ); 1116 if ( $this.hasClass( 'bb-eye' ) ) { 1117 $input.attr( "type", "text" ); 1118 } else { 1119 $input.attr( "type", "password" ); 1120 } 1121 } 1122 ); 1123 }, 1124 1125 bbRelatedSlider: function () { 1126 if ( $( 'body' ).hasClass( 'has-sidebar' ) ) { 1127 var $break = 900; 1128 } else { 1129 var $break = 544; 1130 } 1131 1132 function runSlickRelated() { 1133 var slickRelated = { 1134 infinite: false, 1135 slidesToShow: 2, 1136 slidesToScroll: 2, 1137 adaptiveHeight: true, 1138 arrows: true, 1139 prevArrow: '<a class="bb-slide-prev"><i class="bb-icon-l bb-icon-angle-right"></i></a>', 1140 nextArrow: '<a class="bb-slide-next"><i class="bb-icon-l bb-icon-angle-right"></i></a>', 1141 appendArrows: '.post-related-posts h3', 1142 responsive: [ 1143 { 1144 breakpoint: $break, 1145 settings: { 1146 slidesToShow: 1, 1147 slidesToScroll: 1, 1148 } 1149 } 1150 ] 1151 } 1152 1153 $( '.post-related-posts .post-grid' ).not( '.slick-initialized' ).slick( slickRelated ); 1154 } 1155 1156 function slickGalleryReinit() { 1157 $( '.post-related-posts .slick-slider' ).slick( 'reinit' ); 1158 /*$( '.slick-slider' ).on( 'reInit', function ( event, slick ) { 1159 $( '.slick-slider' ).slick( 'slickSetOption', { arrows: fal
1159se, dots: false } ); 1160 } );*/ 1161 $( '.post-related-posts .slick-slider' ).slick( 'resize' ); 1162 $( '.post-related-posts .slick-slider' ).slick( 'refresh' ); 1163 } 1164 1165 runSlickRelated(); 1166 1167 // slickGalleryReinit(); 1168 1169 $( window ).on( 1170 'resize', 1171 function () { 1172 runSlickRelated(); 1173 slickGalleryReinit(); 1174 } 1175 ); 1176 1177 $( '.bb-more-courses-list' ).slick( 1178 { 1179 infinite: true, 1180 slidesToShow: 4, 1181 slidesToScroll: 1, 1182 prevArrow: '<a class="bb-slide-prev"><i class="bb-icon-angle-right"></i></a>', 1183 nextArrow: '<a class="bb-slide-next"><i class="bb-icon-angle-right"></i></a>', 1184 responsive: [ 1185 { 1186 breakpoint: 1180, 1187 settings: { 1188 slidesToShow: 3, 1189 slidesToScroll: 3, 1190 } 1191 }, 1192 { 1193 breakpoint: 900, 1194 settings: { 1195 slidesToShow: 2, 1196 slidesToScroll: 2 1197 } 1198 }, 1199 { 1200 breakpoint: 480, 1201 settings: { 1202 slidesToShow: 1, 1203 slidesToScroll: 1 1204 } 1205 } ] 1206 } 1207 ); 1208 }, 1209 1210 BuddyPanel_Dropdown: function () { 1211 $( '.buddypanel-menu .sub-menu' ).each( 1212 function () { 1213 $( this ).closest( 'li.menu-item-has-children' ).find( 'a:first' ).append( '<i class="bb-icon-l bb-icon-angle-down bs-submenu-toggle"></i>' ); 1214 } 1215 ); 1216 1217 $( document ).on( 1218 'click', 1219 '.bs-submenu-toggle', 1220 function ( e ) { 1221 e.preventDefault(); 1222 $( this ).toggleClass( 'bs-submenu-open' ).closest( 'a' ).next( '.sub-menu' ).toggleClass( 'bb-open' ); 1223 $( this ).parent( '.menu-item-has-children' ).toggleClass( 'bb-open-parent' ); 1224 } 1225 ); 1226 /** 1227 * when we select sub menu it will be expand sub menu when page load 1228 */ 1229 1230 $( 'aside.buddypanel .buddypanel-menu .current-menu-parent' ).find( 'ul.sub-menu' ).addClass( 'bb-open' ); 1231 1232 var currentMenu = $( '.bb-mobile-panel-inner .menu-item-has-children.current-menu-ancestor, .bb-mobile-panel-inner .menu-item-has-children.current_page_item, .bb-mobile-panel-inner .menu-item-has-children.current-menu-item, .bb-mobile-panel-inner .menu-item-has-children.current-menu-parent' ); 1233 currentMenu.children( 'ul.sub-menu' ).addClass( 'bb-open' ); 1234 currentMenu.find( '.bs-submenu-toggle' ).addClass( 'bs-submenu-open' ); 1235 }, 1236 1237 fileUpload: function () { 1238 $( '.job-manager-form fieldset input[type=file], .ginput_container_fileupload > input[type=file], .ginput_container_post_image input[type=file]' ).each( 1239 function () { 1240 var $fileInput = $( this ); 1241 var $fileInputFor = $fileInput.attr( 'id' ); 1242 $fileInput.after( '<label for="' + $fileInputFor + '">' + bs_data.translation.choose_a_file_label + '</label>' ); 1243 } 1244 ); 1245 1246 $( '.job-manager-form fieldset input[type=file], .ginput_container_fileupload > input[type=file], .ginput_container_post_image input[type=file]' ).change( 1247 function ( e ) { 1248 var $in = $( this ); 1249 var $inval = $in.next().html( $in.val() ); 1250 if ( $in.val().length === 0 ) { 1251 $in.next().html( bs_data.translation.choose_a_file_label ); 1252 } else { 1253 $in.next().html( $in.val().replace( /C:\\fakepath\\/i, '' ) ); 1254 } 1255 } 1256 ); 1257 }, 1258 1259 commentsValidate: function () { 1260 function resetForm() { 1261 $( '#commentform' ).reset(); 1262 validator.resetForm(); 1263 } 1264 1265 function validateForm() { 1266 if ( validator.form() ) { 1267 $( '#commentform' ).submit(); 1268 } 1269 } 1270 1271 var validator = $( "#commentform" ).validate( 1272 { 1273 rules: { 1274 author: { 1275 required: true, 1276 normalizer: function ( value ) { 1277 return $.trim( value ); 1278 } 1279 }, 1280 email: { 1281 required: true, 1282 email: true 1283 }, 1284 url: { 1285 url: true 1286 }, 1287 comment: { 1288 required: true, 1289 normalizer: function ( value ) { 1290 return $.trim( value ); 1291 } 1292 } 1293 1294 }, 1295 messages: { 1296 author: "Please enter your name", 1297 email: { 1298 required: "Please enter an email address", 1299 email: "Please enter a valid email address" 1300 }, 1301 url: "Please enter a valid URL e.g. http://www.mysite.com", 1302 comment: "Please fill the required field" 1303 }, 1304 errorElement: "div", 1305 errorPlacement: function ( error, element ) { 1306 element.after( error ); 1307 } 1308 } 1309 ); 1310 1311 $( '#comment' ).focus( 1312 function () { 1313 $( this ).parents( '#respond' ).addClass( 'bb-active' ); 1314 } 1315 ); 1316 1317 $( '#comment' ).blur( 1318 function () { 1319 $( this ).parents( '#respond' ).removeClass( 'bb-active' ); 1320 } 1321 ); 1322 }, 1323 1324 messageScroll: function () { 1325 1326 }, 1327 1328 photoCommentFocus: function () { 1329 $( document ).on( 1330 'click', 1331 '.bb-media-model-wrapper .bs-comment-textarea', 1332 function ( e ) { 1333 e.preventDefault(); 1334 1335 $( '.bb-media-model-wrapper' ).animate( 1336 { 1337 scrollTop: $( '.bb-media-model-wrapper' )[ 0 ].scrollHeight 1338 }, 1339 "slow" 1340 ); 1341 } 1342 ); 1343 }, 1344 1345 bpRegRequired: function () { 1346 $( '.bs-bp-container-reg .signup-form input' ).removeAttr( 'required' ); 1347 }, 1348 1349 setCounters: function () { 1350 $( '.user-wrap > .sub-menu' ).find( 'li' ).each( 1351 function () { 1352 var $this = $( this ), 1353 $count = $this.children( 'a' ).children( '.count' ), 1354 id, 1355 $target; 1356 1357 if ( $count.length != 0 ) { 1358 id = $this.attr( 'id' ); 1359 $target = $( '.side-panel-menu .bp-menu.bp-' + id.replace( /w
1359p-admin-bar-my-account-/, '' ) + '-nav' ); 1360 if ( $target.find( '.count' ).length == 0 ) { 1361 $target.find( 'a' ).append( '<span class="count">' + $count.html() + '</span>' ); 1362 } 1363 } 1364 } 1365 ); 1366 }, 1367 1368 inputFileStyle: function () { 1369 var inputs = document.querySelectorAll( '.bb-inputfile' ); 1370 Array.prototype.forEach.call( 1371 inputs, 1372 function ( input ) { 1373 var label = input.nextElementSibling, 1374 labelVal = label.innerHTML; 1375 1376 input.addEventListener( 1377 'change', 1378 function ( e ) { 1379 var fileName = ''; 1380 if ( this.files && this.files.length > 1 ) { 1381 fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); 1382 } else { 1383 fileName = e.target.value.split( '\\' ).pop(); 1384 } 1385 1386 if ( fileName ) { 1387 label.querySelector( 'span' ).innerHTML = fileName; 1388 } else { 1389 label.innerHTML = labelVal; 1390 } 1391 } 1392 ); 1393 } 1394 ); 1395 }, 1396 1397 primaryNavBar: function () { 1398 /* 1399 * Allow use of Array.from in implementations that don't natively support it 1400 function conNavArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } 1401 */ 1402 1403 function conNavArray( arr ) { 1404 if ( Array.isArray( arr ) ) { 1405 for ( var i = 0, arr2 = Array( arr.length ); i < arr.length; i++ ) { 1406 arr2[ i ] = arr[ i ]; 1407 } 1408 return arr2; 1409 } else { 1410 return [].slice.call( arr ); 1411 } 1412 } 1413 1414 var primaryWrap = document.getElementById( 'primary-navbar' ), 1415 primaryNav = document.getElementById( 'primary-menu' ), 1416 extendNav = document.getElementById( 'navbar-extend' ), 1417 navCollapse = document.getElementById( 'navbar-collapse' ); 1418 1419 function navListOrder() { 1420 var eChildren = extendNav.children; 1421 var numW = 0; 1422 1423 [].concat( conNavArray( eChildren ) ).forEach( 1424 function ( item ) { 1425 item.outHTML = ''; 1426 primaryNav.appendChild( item ); 1427 } 1428 ); 1429 1430 var primaryWrapWidth = primaryWrap.offsetWidth, 1431 navCollapseWidth = navCollapse.offsetWidth + 30, 1432 primaryWrapCalc = primaryWrapWidth - navCollapseWidth, 1433 primaryNavWidth = primaryNav.offsetWidth, 1434 pChildren = primaryNav.children; 1435 1436 [].concat( conNavArray( pChildren ) ).forEach( 1437 function ( item ) { 1438 numW += item.offsetWidth + ( $( 'body' ).hasClass( 'header-style-2' ) ? 0 : 5 ); 1439 1440 if ( numW > primaryWrapCalc ) { 1441 item.outHTML = ''; 1442 extendNav.appendChild( item ); 1443 } 1444 1445 } 1446 ); 1447 1448 if ( extendNav.getElementsByTagName( 'li' ).length >= 1 ) { 1449 navCollapse.classList.add( 'hasItems' ); 1450 } else { 1451 navCollapse.classList.remove( 'hasItems' ); 1452 } 1453 1454 primaryNav.classList.remove( 'bb-primary-overflow' ); 1455 } 1456 1457 if ( typeof ( primaryNav ) != 'undefined' && primaryNav != null ) { 1458 window.onresize = navListOrder; 1459 navListOrder(); 1460 1461 setTimeout( 1462 function () { 1463 navListOrder(); 1464 }, 1465 300 1466 ); 1467 setTimeout( 1468 function () { 1469 navListOrder(); 1470 }, 1471 900 1472 ); 1473 1474 $( '.bb-toggle-panel' ).on( 1475 'click', 1476 function ( e ) { 1477 e.preventDefault(); 1478 navListOrder(); 1479 1480 setTimeout( 1481 function () { 1482 navListOrder(); 1483 if ( $( '.post-grid' ).hasClass( 'bb-masonry' ) ) { 1484 $( '.bb-masonry' ).masonry( {} ); 1485 } 1486 }, 1487 300 1488 ); 1489 1490 setTimeout( 1491 function () { 1492 navListOrder(); 1493 }, 1494 600 1495 ); 1496 } 1497 ); 1498 } 1499 }, 1500 1501 forumsTopic: function () { 1502 var bbHeaderHeight = $( '#masthead' ).outerHeight(); 1503 1504 if ( $( window ).width() > 768 ) { 1505 $( '#bbpress-forums .bs-topic-sidebar-inner' ).stick_in_parent( { offset_top: bbHeaderHeight + 45, spacer: false, bottoming: false } ); 1506 } 1507 1508 $( window ).resize( function () { 1509 if ( $( window ).width() > 768 ) { 1510 $( '#bbpress-forums .bs-topic-sidebar-inner' ).stick_in_parent( { offset_top: bbHeaderHeight + 45, spacer: false, bottoming: false } ); 1511 } else { 1512 $( '#bbpress-forums .bs-topic-sidebar-inner' ).trigger( "sticky_kit:detach" ); 1513 } 1514 } ); 1515 1516 if ( $( 'body .bbp-topic-form' ).length ) { 1517 1518 $( document ).on( 1519 'keyup',
1520 '.bbp-topic-form #new-post #bbp_topic_title', 1521 function ( e ) { 1522 if ( e.which == 9 && !e.shiftKey ) { 1523 e.preventDefault(); 1524 $( e.target ).closest( '.bbp-topic-form #new-post .bbp-editor-content' ).focus(); 1525 } 1526 } 1527 ); 1528 1529 $( document ).on( 1530 'keyup', 1531 '.bbp-topic-form #new-post .bbp-editor-content', 1532 function ( e ) { 1533 if ( e.which == 9 && e.shiftKey ) { 1534 e.preventDefault(); 1535 $( e.target ).closest( '.bbp-topic-form #new-post #bbp_topic_title' ).focus(); 1536 } 1537 } 1538 ); 1539 1540 $( document ).on( 1541 'keyup', 1542 '.bbp-topic-form #new-post #bbp_topic_tags', 1543 function ( e ) { 1544 if ( e.which == 9 && e.shiftKey ) { 1545 e.preventDefault(); 1546 $( e.target ).closest( '.bbp-topic-form #new-post #bbp_editor_topic_content' ).focus(); 1547 } 1548 } 1549 ); 1550 } 1551 1552 if ( $( 'body .bbp-reply-form' ).length ) { 1553 1554 $( document ).on( 1555 'keyup', 1556 '.bbp-reply-form #new-post #bbp_topic_tags', 1557 function ( e ) { 1558 if ( e.which == 9 && e.shiftKey ) { 1559 e.preventDefault(); 1560 $( e.target ).closest( '.bbp-reply-form #new-post .bbp-editor-content' ).focus(); 1561 } 1562 } 1563 ); 1564 } 1565 1566 var appendthis = ( '<div class="bb-modal-overlay js-modal-close"></div>' ); 1567 1568 $( document ).on( 1569 'click', 1570 'a[data-modal-id]', 1571 function ( e ) { 1572 e.preventDefault(); 1573 $( 'body' ).addClass( 'bb-modal-overlay-open' ).append( appendthis ); 1574 $( '.bb-modal-overlay' ).fadeTo( 0, 1 ); 1575 // $(".js-modalbox").fadeIn(500); 1576 var $bbpress_forums_element = $( e.target ).closest( '.bb-grid' ); 1577 var modalBox = $( this ).attr( 'data-modal-id' ); 1578 1579 $bbpress_forums_element.find( '.' + modalBox ).fadeIn( 0 ).addClass( 'bb-modal-open' ); 1580 1581 if ( $bbpress_forums_element.find( '.bbp-reply-form' ).length ) { 1582 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp_reply_to' ).val( 0 ); 1583 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp-reply-to-user' ).html( $bbpress_forums_element.find( $bbpress_forums_element.find( '.topic-lead' ).find( '.item-meta' ).get( 0 ) ).find( '.bbp-author-name' ).text() ); 1584 1585 var topic_id = $( '#bbp_topic_id' ).val(); 1586 var reply_exerpt = $( '#topic-' + topic_id + '-replies li.bs-item-wrap #bbp_topic_excerpt' ).val(); 1587 if ( '' != reply_exerpt ) { 1588 reply_exerpt = reply_exerpt + '...'; 1589 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp-reply-exerpt' ).text( reply_exerpt ); 1590 } 1591 1592 var editor_key = $bbpress_forums_element.find( '.bbp-the-content' ).data( 'key' ); 1593 1594 if ( typeof window.forums_medium_reply_editor !== 'undefined' && typeof window.forums_medium_reply_editor[ editor_key ] !== 'undefined' ) { 1595 window.forums_medium_reply_editor[ editor_key ].subscribe( 1596 'editableInput', 1597 function () { 1598 if ( $.trim( window.forums_medium_reply_editor[ editor_key ].getContent() ).replace( '<p><br></p>', '' ) != '' ) { 1599 $bbpress_forums_element.find( '.bbp-the-content' ).removeClass( 'error' ); 1600 } else { 1601 $bbpress_forums_element.find( '.bbp-the-content' ).addClass( 'error' ); 1602 } 1603 } 1604 ); 1605 } 1606 } 1607 1608 if ( typeof window.forums_medium_topic_editor !== 'undefined' && typeof window.forums_medium_topic_editor[ editor_key ] !== 'undefined' ) { 1609 window.forums_medium_topic_editor[ editor_key ].subscribe( 1610 'editableInput', 1611 function () { 1612 if ( $.trim( window.forums_medium_topic_editor[ editor_key ].getContent() ).replace( '<p><br></p>', '' ) != '' ) { 1613 $bbpress_forums_element.find( '.bbp-the-content' ).removeClass( 'error' ); 1614 } else { 1615 $bbpress_forums_element.find( '.bbp-the-content' ).addClass( 'error' ); 1616 } 1617 } 1618 ); 1619 } 1620 1621 $( '.bbp-topic-form' ).trigger( 1622 'bbp_after_load_topic_form', 1623 { 1624 click_event: this, 1625 } 1626 ); 1627 1628 $( '.bbp-reply-form' ).trigger( 1629 'bbp_after_load_reply_form', 1630 { 1631 click_event: this, 1632 } 1633 ); 1634 } 1635 ); 1636 1637 $( document ).on( 1638 'click', 1639 'a[data-modal-id-inline]', 1640 function ( e ) { 1641 e.preventDefault(); 1642 $( 'body' ).addClass( 'bb-modal-overlay-open' ).append( appendthis ); 1643 $( '.bb-modal-overlay' ).fadeTo( 0, 1 ); 1644 // $(".js-modalbox").fadeIn(500); 1645 var modalBox = $( this ).attr( 'data-modal-id-inline' ); 1646 $( '#' + modalBox ).fadeIn( 0 ).addClass( 'bb-modal-open' ); 1647 1648 var $bbpress_forums_element = $( e.target ).closest( '.bb-grid' ); 1649 1650 if ( $bbpress_forums_element.find( '.bbp-reply-form' ).length ) { 1651 1652 // Add author name. 1653 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp-reply-to-user' ).html( $( $( this ).closest( 'li' ).find( '.bs-reply-list-item' ).get( 0 ) ).find( '.item-meta' ).find( '.bbp-author-name' ).text() ); 1654 1655 var reply_to = $( this ).closest( '.bs-reply-list-item' ).find( '.bbp-author-name' ).text().trim(); 1656 var reply_exerpt = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content' ).text().trim().substring( 0, 50 ); 1657 if ( $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bb-activity-media-elem' ).length ) { 1658 var clickToDownloadText = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bb-activity-media-elem .document-helper-text' )[ 0 ]; 1659 clickToDownloadText = $( clickToDownloadText ).text();
1660 if ( '' !== clickToDownloadText ) { 1661 reply_exerpt = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content' ).text().trim().replace( clickToDownloadText, '' ).substring( 0, 50 ); 1662 } 1663 var mediaFileText = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bb-activity-media-elem' ).not('.document-activity'); 1664 mediaFileText = $( mediaFileText ).text().trim(); 1665 if ( '' !== mediaFileText ) { 1666 reply_exerpt = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content' ).text().trim().replace( mediaFileText, '' ); 1667 } 1668 } 1669 if ( $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bb-activity-media-wrap .bp-video-thumbnail-uploader' ).length ) { 1670 var videoFileText = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bb-activity-media-wrap' )[ 0 ]; 1671 videoFileText = $( videoFileText ).text().trim(); 1672 if ( '' !== videoFileText ) { 1673 reply_exerpt = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content' ).text().trim().replace( videoFileText, '' ); 1674 } 1675 } 1676 if( $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bbp-reply-revision-log' ).length ) { 1677 var revisionText = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content .bbp-reply-revision-log' ).text().trim(); 1678 reply_exerpt = $( this ).closest( '.bs-reply-list-item' ).find( '>.bbp-reply-content' ).text().trim().replace( revisionText,'').substring( 0, 50 ).trim(); 1679 } 1680 if( '' !== reply_to ) { 1681 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp-reply-to-user' ).text( reply_to ); 1682 } 1683 if ( '' !== reply_exerpt ) { 1684 reply_exerpt = reply_exerpt + '...'; 1685 } 1686 $bbpress_forums_element.find( '.bbp-reply-form' ).find( '#bbp-reply-exerpt' ).text( reply_exerpt ); 1687 var editor_key = $bbpress_forums_element.find( '.bbp-the-content' ).data( 'key' ); 1688 if ( typeof window.forums_medium_reply_editor !== 'undefined' && typeof window.forums_medium_reply_editor[ editor_key ] !== 'undefined' ) { 1689 window.forums_medium_reply_editor[ editor_key ].subscribe( 1690 'editableInput', 1691 function () { 1692 if ( $.trim( window.forums_medium_reply_editor[ editor_key ].getContent() ).replace( '<p><br></p>', '' ) != '' ) { 1693 $bbpress_forums_element.find( '.bbp-the-content' ).removeClass( 'error' ); 1694 } else { 1695 $bbpress_forums_element.find( '.bbp-the-content' ).addClass( 'error' ); 1696 } 1697 } 1698 ); 1699 } 1700 } 1701 1702 $( '.bbp-reply-form' ).trigger( 1703 'bbp_after_load_inline_reply_form', 1704 { 1705 click_event: this, 1706 } 1707 ); 1708 } 1709 ); 1710 1711 $( document ).on( 1712 'click', 1713 '.js-modal-close', 1714 function ( e ) { 1715 e.preventDefault(); 1716 $( '.bb-modal-box, .bb-modal-overlay' ).fadeOut( 1717 50, 1718 function () { 1719 $( '.bb-modal-overlay' ).remove(); 1720 } 1721 ); 1722 $( 'body' ).removeClass( 'popup-modal-reply bb-modal-overlay-open' ); 1723 $( '.bs-reply-list-item.in-focus' ).removeClass( 'in-focus' ); 1724 $( '.bb-modal-box' ).removeClass( 'bb-modal-open' ); 1725 1726 $( document ).trigger( 1727 'bbp_after_close_topic_reply_form', 1728 { 1729 click_event: this, 1730 } 1731 ); 1732 } 1733 ); 1734 1735 $( document ).on( 1736 'click', 1737 '.bb-modal-overlay', 1738 function ( e ) { 1739 e.preventDefault(); 1740 $( 'body' ).removeClass( 'bb-modal-overlay-open' ); 1741 $( '.bb-modal-box, .bb-modal-overlay' ).fadeOut( 1742 50, 1743 function () { 1744 $( '.bb-modal-overlay' ).remove(); 1745 } 1746 ); 1747 $( '.bb-modal-box' ).removeClass( 'bb-modal-open' ); 1748 1749 $( document ).trigger( 1750 'bbp_after_close_topic_reply_form', 1751 { 1752 click_event: this, 1753 } 1754 ); 1755 } 1756 ); 1757 1758 if ( bs_getUrlParameter( 'bbp_reply_to' ) ) { 1759 if ( bs_getUrlParameter( 'bbp_reply_to' ) ) { 1760 if ( parseInt( bs_getUrlParameter( 'bbp_reply_to' ) ) > 0 && $( document ).find( '.bbp-reply-to-link.' + bs_getUrlParameter( 'bbp_reply_to' ) ).length ) { 1761 $( window ).load( function () { 1762 $( '.bbp-reply-to-link.' + bs_getUrlParameter( 'bbp_reply_to' ) ).trigger( 'click' ); 1763 } ); 1764 } else { 1765 $( '.bbp-topic-reply-link' ).trigger( 'click' ); 1766 } 1767 } 1768 } 1769 1770 if ( $( '.bbp-topic-form form' ).length && $( '.bbp-topic-form form' ).find( '.bp-feedback.error' ).length ) { 1771 $( '.btn-new-topic' ).trigger( 'click' ); 1772 } 1773 1774 $( '.bbp-topic-form form' ).on( 1775 'keyup', 1776 '#bbp_topic_title,#bbp_anonymous_author,#bbp_anonymous_email', 1777 function ( e ) { 1778 e.preventDefault(); 1779 if ( $.trim( $( this ).val() ) === '' ) { 1780 $( this ).addClass( 'error' ); 1781 } else { 1782 $( this ).removeClass( 'error' ); 1783 } 1784 } 1785 ); 1786 1787 $( document ).on( 1788 'click',
1789 '.bbp-topic-form form #bbp_topic_submit', 1790 function ( e ) { 1791 e.preventDefault(); 1792 var $topicForm = $( e.target ).closest( 'form' ); 1793 if ( $topicForm.hasClass( 'submitting' ) ) { 1794 return false; 1795 } 1796 $topicForm.addClass( 'submitting' ); 1797 var valid = true; 1798 var media_valid = true; 1799 1800 if ( $topicForm.find( '.bbp-form-anonymous' ).length ) { 1801 if ( $.trim( $topicForm.find( '#bbp_anonymous_author' ).val() ) === '' ) { 1802 $topicForm.find( '#bbp_anonymous_author' ).addClass( 'error' ); 1803 valid = false; 1804 } else { 1805 $topicForm.find( '#bbp_anonymous_author' ).removeClass( 'error' ); 1806 } 1807 1808 if ( $.trim( $topicForm.find( '#bbp_anonymous_email' ).val() ) === '' ) { 1809 $topicForm.find( '#bbp_anonymous_email' ).addClass( 'error' ); 1810 valid = false; 1811 } else { 1812 $topicForm.find( '#bbp_anonymous_email' ).removeClass( 'error' ); 1813 } 1814 } 1815 1816 if ( $.trim( $topicForm.find( '#bbp_topic_title' ).val() ) === '' ) { 1817 $topicForm.find( '#bbp_topic_title' ).addClass( 'error' ); 1818 valid = false; 1819 } else { 1820 $topicForm.find( '#bbp_topic_title' ).removeClass( 'error' ); 1821 } 1822 1823 var editor_key = $topicForm.find( '.bbp_editor_topic_content' ).data( 'key' ); 1824 1825 var editor = false; 1826 if ( typeof window.forums_medium_topic_editor !== 'undefined' && typeof window.forums_medium_topic_editor[ editor_key ] !== 'undefined' ) { 1827 editor = window.forums_medium_topic_editor[ editor_key ]; 1828 } 1829 1830 if ( 1831 ( 1832 $topicForm.find( '#bbp_media' ).length > 0 1833 && $topicForm.find( '#bbp_document' ).length <= 0 1834 && $topicForm.find( '#bbp_video' ).length <= 0 1835 && $topicForm.find( '#bbp_media_gif' ).length > 0 1836 && $topicForm.find( '#bbp_media' ).val() == '' 1837 && $topicForm.find( '#bbp_media_gif' ).val() == '' 1838 ) 1839 || ( 1840 $topicForm.find( '#bbp_document' ).length > 0 1841 && $topicForm.find( '#bbp_media' ).length <= 0 1842 && $topicForm.find( '#bbp_video' ).length <= 0 1843 && $topicForm.find( '#bbp_media_gif' ).length > 0 1844 && $topicForm.find( '#bbp_document' ).val() == '' 1845 && $topicForm.find( '#bbp_media_gif' ).val() == '' 1846 ) 1847 || ( 1848 $topicForm.find( '#bbp_video' ).length > 0 1849 && $topicForm.find( '#bbp_media' ).length <= 0 1850 && $topicForm.find( '#bbp_document' ).length <= 0 1851 && $topicForm.find( '#bbp_media_gif' ).length > 0 1852 && $topicForm.find( '#bbp_video' ).val() == '' 1853 && $topicForm.find( '#bbp_media_gif' ).val() == '' 1854 ) 1855 || ( 1856 $topicForm.find( '#bbp_document' ).length > 0 1857 && $topicForm.find( '#bbp_media_gif' ).length <= 0 1858 && $topicForm.find( '#bbp_document' ).val() == '' 1859 ) 1860 || ( 1861 $topicForm.find( '#bbp_media' ).length > 0 1862 && $topicForm.find( '#bbp_media_gif' ).length <= 0 1863 && $topicForm.find( '#bbp_media' ).val() == '' 1864 ) 1865 || ( 1866 $topicForm.find( '#bbp_video' ).length > 0 1867 && $topicForm.find( '#bbp_media_gif' ).length <= 0 1868 && $topicForm.find( '#bbp_video' ).val() == '' 1869 ) 1870 || ( 1871 $topicForm.find( '#bbp_media_gif' ).length > 0 1872 && $topicForm.find( '#bbp_media' ).length <= 0 1873 && $topicForm.find( '#bbp_document' ).length <= 0 1874 && $topicForm.find( '#bbp_video' ).length <= 0 1875 && $topicForm.find( '#bbp_media_gif' ).val() == '' 1876 ) 1877 ) { 1878 media_valid = false; 1879 } 1880 1881 if ( 1882 ( editor && $.trim( editor.getContent().replace( '<p><br></p>', '' ) ) === '' ) 1883 && media_valid == false 1884 ) { 1885 $topicForm.find( '#bbp_editor_topic_content' ).addClass( 'error' ); 1886 valid = false; 1887 } else if ( 1888 ( !editor && $.trim( $topicForm.find( '#bbp_topic_content' ).val() ) === '' ) 1889 && media_valid == false 1890 ) { 1891 $topicForm.find( '#bbp_topic_content' ).addClass( 'error' ); 1892 valid = false; 1893 } else { 1894 if ( editor ) { 1895 $topicForm.find( '#bbp_editor_topic_content' ).removeClass( 'error' ); 1896 } 1897 $topicForm.find( '#bbp_topic_content' ).removeClass( 'error' ); 1898 } 1899 1900 if ( valid ) { 1901 $topicForm.submit(); 1902 } else { 1903 $topicForm.removeClass( 'submitting' ); 1904 } 1905 } 1906 ); 1907 1908 $( '.bbp-reply-form form #bbp_reply_submit' ).on( 1909 'click', 1910 function ( e ) { 1911 e.preventDefault(); 1912
1913 var valid = true; 1914 var $replyForm = $( e.target ).closest( 'form' ); 1915 1916 if ( $replyForm.find( '.bbp-form-anonymous' ).length ) { 1917 if ( $.trim( $replyForm.find( '#bbp_anonymous_author' ).val() ) === '' ) { 1918 $replyForm.find( '#bbp_anonymous_author' ).addClass( 'error' ); 1919 valid = false; 1920 } else { 1921 $replyForm.find( '#bbp_anonymous_author' ).removeClass( 'error' ); 1922 } 1923 1924 if ( $.trim( $replyForm.find( '#bbp_anonymous_email' ).val() ) === '' ) { 1925 $replyForm.find( '#bbp_anonymous_email' ).addClass( 'error' ); 1926 valid = false; 1927 } else { 1928 $replyForm.find( '#bbp_anonymous_email' ).removeClass( 'error' ); 1929 } 1930 } 1931 1932 if ( valid ) { 1933 var topic_id = $replyForm 1934 .find( 'input[name="bbp_topic_id"]' ) 1935 .val(); 1936 $replyForm.submit(); 1937 } 1938 $( 'body' ).removeClass( 'popup-modal-reply' ); 1939 $( '.bs-reply-list-item.in-focus' ).removeClass( 'in-focus' ); 1940 $replyForm.find( '.bbp_topic_tags_wrapper tags tag' ).remove(); 1941 } 1942 ); 1943 $( document ).keydown( 1944 function ( e ) { 1945 if ( e.ctrlKey && 13 === e.keyCode ) { 1946 var bb_topic = $( '.bbp-topic-form form' ), bb_reply = $( '.bbp-reply-form form' ); 1947 if ( bb_reply.length ) { 1948 bb_reply.find( '#bbp_reply_submit' ).trigger( 'click' ); 1949 } 1950 if ( bb_topic.length ) { 1951 bb_topic.find( '#bbp_topic_submit' ).trigger( 'click' ); 1952 } 1953 } 1954 } 1955 ); 1956 window.addReply = { 1957 moveForm: function ( replyId, parentId, respondId, postId ) { 1958 $( '.bbp-reply-form' ).find( '#bbp_reply_to' ).val( parentId ); 1959 var t = this, div, reply = t.I( replyId ), respond = t.I( respondId ), 1960 cancel = t.I( 'bbp-cancel-reply-to-link' ), parent = t.I( 'bbp_reply_to' ), 1961 post = t.I( 'bbp_topic_id' ); 1962 1963 if ( !reply || !respond || !cancel || !parent ) { 1964 return; 1965 } 1966 1967 t.respondId = respondId; 1968 postId = postId || false; 1969 1970 if ( !t.I( 'bbp-temp-form-div' ) ) { 1971 div = document.createElement( 'div' ); 1972 div.id = 'bbp-temp-form-div'; 1973 div.style.display = 'none'; 1974 respond.parentNode.insertBefore( div, respond ); 1975 } 1976 1977 respond.classList.remove( 'mfp-hide' ); 1978 reply.parentNode.appendChild( respond ); 1979 1980 if ( typeof tinyMCE !== 'undefined' ) { 1981 1982 // Remove existing instances of tinyMCE. 1983 tinyMCE.remove(); 1984 1985 // magnificPopup reinitialize tinyMCE. 1986 tinyMCE.init( 1987 { 1988 selector: 'textarea.bbp-the-content', 1989 menubar: false, 1990 branding: false, 1991 plugins: "image,lists,link", 1992 toolbar: "bold italic bullist numlist blockquote link", 1993 } 1994 ); 1995 } 1996 1997 if ( post && postId ) { 1998 post.value = postId; 1999 } 2000 parent.value = parentId; 2001 cancel.style.display = ''; 2002 2003 cancel.onclick = function () { 2004 var t = addReply, temp = t.I( 'bbp-temp-form-div' ), respond = t.I( t.respondId ); 2005 2006 if ( !temp || !respond ) { 2007 return; 2008 } 2009 2010 t.I( 'bbp_reply_to' ).value = '0'; 2011 respond.classList.add( 'mfp-hide' ); 2012 temp.parentNode.insertBefore( respond, temp ); 2013 temp.parentNode.removeChild( temp ); 2014 this.style.display = 'none'; 2015 this.onclick = null; 2016 return false; 2017 }; 2018 2019 try { 2020 t.I( 'bbp_reply_content' ).focus(); 2021 } catch ( e ) { 2022 } 2023 2024 return false; 2025 }, 2026 2027 I: function ( e ) { 2028 return document.getElementById( e ); 2029 } 2030 }; 2031 2032 }, 2033 2034 heartbeat: function () { 2035 if ( ( typeof bs_data.show_notifications !== 'undefined' && bs_data.show_notifications == '1' ) || ( typeof bs_data.show_messages !== 'undefined' && bs_data.show_messages == '1' ) ) { 2036 // HeartBeat Send and Receive. 2037 $( document ).on( 'heartbeat-send', this.bpHeartbeatSend.bind( this ) ); 2038 $( document ).on( 'heartbeat-tick', this.bpHeartbeatTick.bind( this ) ); 2039 } 2040 }, 2041 2042 /** 2043 * [heartbeatSend description] 2044 * 2045 * @param {[type]} event [description] 2046 * @param {[type]} data [description] 2047 * @return {[type]} [description] 2048 */ 2049 bpHeartbeatSend: function ( event, data ) { 2050 data.customfield = ''; 2051 2052 // Add an heartbeat send event to possibly any BuddyPress pages. 2053 $( '#buddypress' ).trigger( 'bp_heartbeat_send', data ); 2054 }, 2055 2056 /** 2057 * [heartbeatTick description] 2058 * 2059 * @param {[type]} event [description] 2060 * @param {[type]} data [description] 2061 * @return {[type]} [description] 2062 */ 2063 bpHeartbeatTick: function ( event, data ) { 2064 this.bpInjectNotifications( event, data ); 2065 2066 // Add an heartbeat send event to possibly any BuddyPress pages. 2067 $( '#buddypress' ).trigger( 'bp_heartbeat_tick', data ); 2068 }, 2069 2070 /** 2071 * Injects all unread notifications 2072 */ 2073 bpInjectNotifications: function ( event, data ) { 2074 if ( typeof data.unread_notifications !== 'undefined' && data.unread_notifications !== '' ) { 2075 $( '#header-notifications-dropdown-elem .notification-dropdown .n
2075otification-list' ).empty().html( data.unread_notifications ); 2076 } 2077 2078 // inject all unread messages notifications. 2079 if ( typeof data.unread_messages !== 'undefined' && data.unread_messages !== '' ) { 2080 $( '#header-messages-dropdown-elem .notification-dropdown .notification-list' ).empty().html( data.unread_messages ); 2081 } 2082 2083 if ( typeof data.total_notifications !== 'undefined' && data.total_notifications > 0 ) { 2084 var notifs = $( '.bb-icon-bell' ); 2085 var notif_icons = $( notifs ).parent().children( '.count' ); 2086 $( '.notification-header .mark-read-all' ).show(); 2087 2088 if ( notif_icons.length > 0 ) { 2089 $( notif_icons ).text( data.total_notifications ); 2090 } else { 2091 $( notifs ).parent().append( '<span class="count"> ' + data.total_notifications + ' </span>' ); 2092 } 2093 } else { 2094 var notifs = $( '.bb-icon-bell' ); 2095 var notif_icons = $( notifs ).parent().children( '.count' ); 2096 $( notif_icons ).remove(); 2097 $( '.notification-header .mark-read-all' ).fadeOut(); 2098 } 2099 2100 if ( typeof data.total_unread_messages !== 'undefined' && parseInt( data.total_unread_messages ) === 0 ) { 2101 var msg = $( '.bb-icon-inbox' ); 2102 var msg_icons = $( msg ).parent().children( '.count' ); 2103 if ( msg_icons.length > 0 ) { 2104 $( msg_icons ).remove(); 2105 } 2106 2107 var menu_item = $( '.bp-messages-nav' ); 2108 var menu_count = menu_item.find( '.count' ); 2109 if ( menu_count.length > 0 ) { 2110 menu_count.text( data.total_unread_messages ).addClass( 'bp-hide' ); 2111 } 2112 } 2113 2114 if ( typeof data.total_unread_messages !== 'undefined' && data.total_unread_messages > 0 ) { 2115 var msg = $( '.bb-icon-inbox' ); 2116 var msg_icons = $( msg ).parent().children( '.count' ); 2117 2118 if ( msg_icons.length > 0 ) { 2119 $( msg_icons ).text( data.total_unread_messages ); 2120 } else { 2121 $( msg ).parent().append( '<span class="count"> ' + data.total_unread_messages + ' </span>' ); 2122 } 2123 2124 var menu_item = $( '.bp-messages-nav' ); 2125 var menu_count = menu_item.find( '.count' ); 2126 if ( menu_count.length > 0 ) { 2127 menu_count.text( data.total_unread_messages ).removeClass( 'bp-hide' ); 2128 } 2129 } 2130 }, 2131 }; 2132 2133 $( document ).on( 2134 'ready', 2135 function () { 2136 BuddyBossTheme.init(); 2137 2138 $( '.bp-personal-sub-tab #compose' ).on( 2139 'click', 2140 function () { 2141 $( this ).parent().toggleClass( 'current selected' ); 2142 } 2143 ); 2144 } 2145 ); 2146 2147 function bs_gallery_slider() { 2148 if ( $( 'body' ).hasClass( 'has-sidebar' ) ) { 2149 var $break = 900; 2150 } else { 2151 var $break = 544; 2152 } 2153 2154 var index = 0; 2155 $( '.gallery' ).each( 2156 function () { 2157 if ( !$( this ).hasClass( 'slick-initialized' ) ) { // Prevent error on loading more posts. 2158 index++; 2159 $( this ).attr( 'data-slider', index ); 2160 $( this ).slick( 2161 { 2162 arrows: true, 2163 prevArrow: '<a class="bb-slide-prev"><i class="bb-icon-angle-right"></i></a>', 2164 nextArrow: '<a class="bb-slide-next"><i class="bb-icon-angle-right"></i></a>', 2165 dots: true, 2166 fade: true, 2167 slidesToShow: 1, 2168 slidesToScroll: 1, 2169 // customPaging: function ( slider, i ) { // example. 2170 customPaging: function () { 2171 return '<span></span>'; // Remove button, customize content of "li". 2172 }, 2173 mobileFirst: true, 2174 responsive: [ 2175 { 2176 breakpoint: $break, 2177 settings: { 2178 slidesToShow: 1, 2179 slidesToScroll: 1, 2180 } 2181 } 2182 ] 2183 } 2184 ); 2185 } 2186 } 2187 ); 2188 } 2189 2190 function bs_getUrlParameter( sParam ) { 2191 var sPageURL = window.location.search.substring( 1 ), 2192 sURLVariables = sPageURL.split( '&' ), 2193 sParameterName, 2194 i; 2195 2196 for ( i = 0; i < sURLVariables.length; i++ ) { 2197 sParameterName = sURLVariables[ i ].split( '=' ); 2198 2199 if ( sParameterName[ 0 ] === sParam ) { 2200 return sParameterName[ 1 ] === undefined ? true : decodeURIComponent( sParameterName[ 1 ] ); 2201 } 2202 } 2203 } 2204 2205 function GamiPressWidgetData() { 2206 $( '.buddypress.widget .gamipress-buddypress-user-details-listing:not(.is_loaded)' ).each ( function() { 2207 if( $( this ).text().trim() !== '' ) { 2208 $( this ).parent().append('<span class="showGamipressData"></span>'); 2209 if( $( this ).find( 'img' ).length ) { 2210 $( this ).parent().find( '.showGamipressData' ).append( '<img src="' + $( this ).find( 'img' ).attr('src') +'"/>'); 2211 } else { 2212 $( this ).parent().find( '.showGamipressData' ).append( '<i class="bb-icon-l bb-icon-award"></i>'); 2213 } 2214 $( this ).parent().find( '.gamipress-buddypress-user-details-listing' ).wrap( '<div class="GamiPress-data-popup"></div>' ); 2215 $( this ).parent().find( '.gamipress-buddypress-user-details-listing' ).append( '<i class="bb-icon-l bb-icon-times hideGamipressData"></i>' ); 2216 } 2217 $( this ).addClass( 'is_loaded' ); 2218 }); 2219 } 2220 2221 /** 2222 * Learndash Gutenberg 2223 */ 2224 2225 $( ".ld-entry-content > .entry-content-wrap .entry-content" ).addClass( "ld-gb-content" ); 2226 2227 /** 2228 * LifterLMS 2229 */ 2230 2231 $( ".llms-notice > a" ).click( 2232 function () { 2233 2234 if ( $( ".llms-person-login-form-wrapper" ).hasClass( "llms-person-login-aktif" ) ) { 2235 $( ".llms-login" ).css( "display", "none" ); 2236 $( ".llms-person-login-form-wrapper" ).removeClass( "llms-person-login-aktif" ); 2237 } else { 2238 $( ".llms-person-login-form-wrapper" ).addClass( "llms-person-login-aktif" ); 2239 } 2240 } 2241 ); 2242 2243 $.fn.wrapStart = function ( numWords ) { 2244 var node = this.contents().filter( 2245 function () { 2246 return this.nodeType == 3 2247 } 2248 ).first(), 2249 text = node.text().replace( /\s+/g, " " ).replace( /^\s|\s$/g, "" ), 2250 first = text.split( " ", numWords ).join( " " ); 2251 2252 if ( !node.length ) { 2253 return; 2254 } 2255 2256 node[ 0 ].nodeValue = text.slice( first.length ); 2257 node.before( '<span>' + first + '</span>' ); 2258 }; 2259 2260 $( '.mepr-price-box-price' ).each( 2261 function () { 2262 $( this ).wrapStart( 1 ) 2263 } 2264 ); 2265 2266 /** 2267 * Profile Dropdown Menu 2268 */ 2269 2270 if ( $( '#header-my-account-menu' ).length ) { 2271 2272 $( '#header-my-account-menu > li' ).each( 2273 function () { 2274 if ( $( this ).hasClass( 'icon-added' ) ) { 2275 $( this ).closest( 'ul' ).addClass( 'has-icon' ); 2276 return false; // Break loop as we know this menu item has icon. 2277 } 2278 } 2279 ); 2280 2281 $( '#header-my-account-menu ul' ).each( 2282 function () { 2283 $( this ).children( 'li' ).each( function () { 2284 if ( $( this ).hasClass( 'icon-added' ) ) { 2285 $( this ).closest( 'ul' ).addClass( 'has-icon' ); 2286 return false; // Break loop as we know this menu item has icon. 2287 } 2288 } ); 2289 } 2290 ); 2291 2292 } 2293
2294 /** 2295 * WP Profile Dropdown Menu 2296 */ 2297 2298 if ( $( '.admin-bar #wp-admin-bar-my-account-default' ).length ) { 2299 $( '.admin-bar #wp-admin-bar-my-account-default > li' ).each( function () { 2300 if ( $( this ).hasClass( 'menupop' ) ) { 2301 $( this ).closest( 'ul' ).addClass( 'has-menupop' ); 2302 return false; // Break loop as we know this menu item has icon. 2303 } 2304 } ); 2305 } 2306 2307 /** 2308 * Show More Option Dropdown 2309 */ 2310 $( document ).on( 'click', '.forum_single_action_wrap .forum_single_action_more-wrap', function( event ) { 2311 var $this = $( event.currentTarget ).closest( '.forum_single_action_wrap' ); 2312 if( $this.hasClass( 'is_visible' ) ) { 2313 $this.removeClass( 'is_visible' ); 2314 } else { 2315 $this.addClass( 'is_visible' ); 2316 } 2317 }); 2318 2319 /** 2320 * Show Gamipress Widget data in popup 2321 */ 2322 2323 if( $( '.buddypress.widget .gamipress-buddypress-user-details-listing' ).length ) { 2324 var tempStyles; 2325 2326 GamiPressWidgetData(); 2327 2328 $( document ).on('click', '.buddypress.widget .showGamipressData', function() { 2329 $( this ).parent().find( '.GamiPress-data-popup' ).addClass( 'is_active' ); 2330 if( $( this ).closest( '.bb-sticky-sidebar' ).length ) { //Check if parent is sticky 2331 tempStyles = $( this ).closest( '.bb-sticky-sidebar' ).attr( 'style' ); //Store parent's fixed styling and remove to avoid issue 2332 $( this ).closest( '.bb-sticky-sidebar' ).attr( 'style', '' ); 2333 $('body').addClass( 'hide-overflow' ); 2334 } 2335 }); 2336 2337 $( document ).on( 'heartbeat-tick', function ( event, data ) { // When heartbeat called re-run function for widgets 2338 setTimeout( function(){ 2339 GamiPressWidgetData(); 2340 }, 1000); 2341 }); 2342 2343 $( '.widget div#members-list-options a' ).on('click', function() { 2344 setTimeout( function(){ 2345 GamiPressWidgetData(); 2346 }, 3000); 2347 }); 2348 2349 $( document ).on('click', '.buddypress.widget .GamiPress-data-popup .hideGamipressData', function() { 2350 $( this ).closest( '.GamiPress-data-popup' ).removeClass( 'is_active' ); 2351 if( $( this ).closest( '.bb-sticky-sidebar' ).length ) { 2352 $( this ).closest( '.bb-sticky-sidebar' ).attr( 'style', tempStyles ); //add parent's fixed styling back 2353 tempStyles = ''; 2354 $('body').removeClass( 'hide-overflow' ); 2355 } 2356 }); 2357 2358 } 2359 2360 /** 2361 * Set reply title and topic id after load the reply form in user timeline. 2362 * 2363 * Using jQuery trigger 'bbp_after_load_reply_form' 2364 */ 2365 $( 'body' ).on( 'bbp_after_load_reply_form', function( event, button ) { 2366 if ( ! $( 'div[data-component="activity"]' ).length ) { 2367 return; 2368 } 2369 2370 var self = $( button.click_event ), 2371 form = self 2372 .closest( '.bb-grid' ) 2373 .find( '.bbp-reply-form' ); 2374 2375 if ( form.length ) { 2376 var topic_id = self.data( 'topic-id' ), 2377 authorName = self.data( 'author-name' ), 2378 reply_exerpt = self.closest( 'li' ) 2379 .find( '.activity-discussion-title-wrap a' ) 2380 .text(); 2381 2382 form 2383 .closest( '.bb-quick-reply-form-wrap' ) 2384 .show(); 2385 2386 form 2387 .css( { 'display': 'block' } ); 2388 2389 form 2390 .addClass( 'bb-modal bb-modal-box' ); 2391 2392 form 2393 .closest( '.bb-quick-reply-form-wrap' ) 2394 .show(); 2395 2396 form 2397 .find( '#bbp_reply_to' ) 2398 .val( 0 ); 2399 2400 form 2401 .find( '#bbp-reply-exerpt' ) 2402 .text( reply_exerpt + '...' ); 2403 2404 form
2405 .find( 'input[name="bbp_topic_id"]' ) 2406 .val( topic_id ); 2407 } 2408 }); 2409 2410 /** 2411 * Show success message after submit reply form. 2412 * 2413 * Using jQuery trigger 'bbp_after_submit_reply_form' 2414 */ 2415 $( document ).on( 'bbp_after_submit_reply_form', '.bbp-reply-form', function( event, data ) { 2416 if ( !data.response.success ) { 2417 return; 2418 } 2419 2420 if ( !$( 'div[data-component="activity"]' ).length ) { 2421 return; 2422 } 2423 2424 var reply_exerpt = $( 'a[data-topic-id=' + data.topic_id + ']' ) 2425 .closest( 'li' ) 2426 .find( '.activity-discussion-title-wrap' ) 2427 .clone(); 2428 2429 var reply_view = $( 'a[data-topic-id=' + data.topic_id + ']' ) 2430 .closest( 'li' ) 2431 .find( '.activity-discussion-title-wrap' ) 2432 .find( 'a' ) 2433 .attr( 'href' ); 2434 2435 $( '.bbp-reply-form-success-modal' ) 2436 .find( '.activity-list' ) 2437 .html( reply_exerpt ); 2438 2439 setTimeout( function () { 2440 $( '.bbp-reply-form-success-modal .view-reply-button a' ).attr( 'href', data.response.redirect_url ); 2441 $( '.bbp-reply-form-success-modal' ).removeAttr( 'style' ); 2442 $( '.bbp-reply-form-success-modal .bb-modal' ).css( 'z-index', 999992 ); 2443 $( '.bbp-reply-form-success' ).fadeIn( 100 ); 2444 }, 200 ); 2445 }); 2446 2447})( jQuery ); 2448 2449/** 2450 * 2451 * @param {String} query 2452 * @param {String} variable 2453 * @returns {String|Boolean} 2454 */ 2455var BBGetQueryVariable = BBGetQueryVariable || function ( query, variable ) { 2456 if ( typeof query !== 'string' || query == '' || typeof variable == 'undefined' || variable == '' ) { 2457 return ''; 2458 } 2459 2460 var vars = query.split( "&" ); 2461 2462 for ( var i = 0; i < vars.length; i++ ) { 2463 var pair = vars[ i ].split( "=" ); 2464 2465 if ( pair[ 0 ] == variable ) { 2466 return pair[ 1 ]; 2467 } 2468 } 2469 return ( false ); 2470}; 2471 2472var BBGetUrlParameter = BBGetUrlParameter || function ( url, parameter_name ) { 2473 parameter_name = parameter_name.replace( /[\[]/, '\\[' ).replace( /[\]]/, '\\]' ); 2474 var regex = new RegExp( '[\\?&]' + parameter_name + '=([^&#]*)' ); 2475 var results = regex.exec( url ); 2476 return results === null ? '' : decodeURIComponent( results[1].replace( /\+/g, ' ' ) ); 2477}; 2478 2479//Add Class to member card which is last of type in section after member ajax completes 2480jQuery( '#members-group-list' ).on("DOMSubtreeModified", function() { 2481 jQuery('#members-list.item-list:not(.grid) li.item-entry-header').prev('li').addClass('last-of-type'); 2482}); 2483 2484// whenever we hover over a menu item that has a submenu 2485setTimeout( 2486 function() { 2487 jQuery( document ).on( 'mouseover', '#site-navigation #navbar-collapse #navbar-extend .menu-item-has-children, #site-navigation #primary-menu .ab-submenu .menu-item-has-children', function () { 2488 var $menuItem = jQuery( this ), 2489 $submenuWrapper = jQuery(this).children( '.ab-submenu' ); 2490 2491 // grab the menu item's position relative to its positioned parent
2492 var menuItemPos = $menuItem.position(); 2493 2494 // place the submenu in the correct position relevant to the menu item 2495 $submenuWrapper.css( 2496 { 2497 top: menuItemPos.top 2498 } 2499 ); 2500 } 2501 ); 2502}, 500);
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.