PageSourceSearch

https://www.ambassador.wales/wp-content/themes/boss/js/buddyboss.js?ver=2.5.7

js ambassador.wales collected 2026-10-10 01:32:33 UTC 95,201 bytes, 2,336 lines download raw bytes

1/**
2 * BuddyBoss JavaScript functionality
3 *
4 * @since Boss 1.0.0
5 * @package  Boss
6 *
7 * ====================================================================
8 *
9 * 1. jQuery Global
10 * 2. Main BuddyBoss Class
11 * 3. Inline Plugins
12 */
13
14
15
16/**
17 * 1. jQuery Global
18 * ====================================================================
19 */
20var jq = $ = jQuery;
21
22/**
23 * Utility function to generate css selector to use in Selects and initCheckBox
24 * @param input_select
25 * @returns {*}
26 */
27function excluded_inputs_selector( input_select ) {
28
29	if ( BuddyBossOptions.excluded_inputs.length ) {
30		return BuddyBossOptions.excluded_inputs.filter(Boolean).reduce(function(accumulator, currentValue){
31			return accumulator + ':not('+ currentValue +')';
32		}, input_select );
33	}
34
35	return input_select;
36}
37
38/**
39 * 2. Main BuddyBoss Class
40 *
41 * This class takes care of BuddyPress additional functionality and
42 * provides a global name space for BuddyBoss plugins to communicate
43 * through.
44 *
45 * Event name spacing:
46 * $(document).on( "buddyboss:*module*:*event*", myCallBackFunction );
47 * $(document).trigger( "buddyboss:*module*:*event*", [a,b,c]/{k:v} );
48 * ====================================================================
49 * @return {class}
50 */
51var BuddyBossMain = ( function ( $, window, undefined ) {
52
53    /**
54     * Globals/Options
55     */
56    var _l = {
57        $document: $( document ),
58        $window: $( window )
59    };
60
61    // Controller
62    var App = { };
63
64    // Custom Events
65    var Vent = $( { } );
66
67    // Responsive
68    var Responsive = { };
69
70    // BuddyPress Defaults
71    var BuddyPress = { };
72
73    // BuddyPress Legacy
74    var BP_Legacy = { };
75
76
77    /** --------------------------------------------------------------- */
78
79    /**
80     * Application
81     */
82
83    // Initialize, runs when script is processed/loaded
84    App.init = function () {
85
86        _l.$document.ready( App.domReady );
87
88        BP_Legacy.init();
89    }
90
91    // When the DOM is ready (page laoded)
92    App.domReady = function () {
93        _l.body = $( 'body' );
94        _l.$buddypress = $( '#buddypress' );
95
96        Responsive.domReady();
97    }
98
99    /** --------------------------------------------------------------- */
100
101    /**
102     * BuddyPress Responsive Help
103     */
104    Responsive.domReady = function () {
105
106        // GLOBALS *
107        // ---------
108        window.BuddyBoss = window.BuddyBoss || { };
109
110        window.BuddyBoss.is_mobile = null;
111
112        var
113            $document = $( document ),
114            $window = $( window ),
115            $body = $( 'body' ),
116            $mobile_check = $( '#mobile-check' ).css( { position: 'absolute', top: 0, left: 0, width: '100%', height: 1, zIndex: 1 } ),
117            mobile_width = 720,
118            is_mobile = false,
119            has_item_nav = false,
120            mobile_modified = false,
121            swiper = false,
122            $main = $( '#main-wrap' ),
123            $inner = $( '#inner-wrap' ),
124            $buddypress = $( '#buddypress' ),
125            $item_nav = $buddypress.find( '#item-nav' ),
126            Panels = { },
127            inputsEnabled = $( 'body' ).data( 'inputs' ),
128            rtl = Boolean( $( 'body' ).data( 'rtl' ) ),
129            $selects,
130            $mobile_nav_wrap,
131            $mobile_item_wrap,
132            $mobile_item_nav,
133            panel_open_class = 'left-menu-open';
134
135        // Detect android stock browser
136        // http://stackoverflow.com/a/17961266
137        var isAndroid = navigator.userAgent.indexOf( 'Android' ) >= 0;
138        var webkitVer = parseInt( ( /WebKit\/([0-9]+)/.exec( navigator.appVersion ) || 0 )[1], 10 ) || void 0; // also match AppleWebKit
139        var isNativeAndroid = isAndroid && webkitVer <= 534 && navigator.vendor.indexOf( 'Google' ) == 0;
140
141		/* get querystring value */
142		function getQueryVariable( query, variable ) {
143			if ( typeof query !== 'string' || query == '' || typeof variable == 'undefined' || variable == '' )
144				return '';
145
146			var vars = query.split( "&" );
147
148			for ( var i = 0; i < vars.length; i ++ ) {
149				var pair = vars[i].split( "=" );
150
151				if ( pair[0] == variable ) {
152					return pair[1];
153				}
154			}
155			return( false );
156		}
157
158        /**
159         * Observe and unwrap traditional buddyboss-select from the Select2 DropDowns
160         * @type {MutationObserver}
161         */
162        var select2Observer = new MutationObserver(function(mutations) {
163            mutations.forEach(function(mutation) {
164                if (mutation.attributeName === "class") {
165                    var attributeValue = $(mutation.target).prop(mutation.attributeName);
166                    var isBuddyBossSelect = $(mutation.target).parent().hasClass('buddyboss-select-inner');
167                    if ( attributeValue.includes('select2-hidden-accessible') && isBuddyBossSelect ) {
168                        $(mutation.target).parent('.buddyboss-select-inner').children('span').first().remove();
169                        $(mutation.target).unwrap('.buddyboss-select-inner');
170                        $(mutation.target).unwrap('.buddyboss-select');
171                    }
172                }
173            });
174        });
175
176        function boss_select2() {
177			var selectbox = Array.prototype.slice.call( document.querySelectorAll('select') );
178            if ( selectbox.length > 0 ) {
179                selectbox.forEach(function(select){
180                    select2Observer.observe(select, {
181                        attributes: true
182                    });
183                });
184            }
185        }
186
187
188        /*------------------------------------------------------------------------------------------------------
189         1.0 - Core Functions
190         --------------------------------------------------------------------------------------------------------*/
191
192        /**
193         * Checks for supported mobile resolutions via media query and
194         * maximum window width.
195         *
196         * @return {boolean} True when screen size is mobile focused
197         */
198        function check_is_mobile() {
199            // The $mobile_check element refers to an empty div#mobile-check we
200            // hide or show with media queries. We use this to determine if we're
201            // on mobile resolution
202            $mobile_check.remove().appendTo( $body );
203
204//                mobile_css = window.document.getElementById('boss-main-mobile-css'),
205//                $mobile_css = $(mobile_css);
206
207            if ( $.cookie( 'switch_mode' ) != 'mobile' ) {
208//                    if(($mobile_css.attr('media') != 'all')) {
209                if ( ( !translation.only_mobile ) ) {
210                    if ( viewport().width < 480 ) {
211                        $( 'body' ).removeClass( 'is-desktop' ).addClass( 'is-mobile' );
212                    } else {
213                        $( 'body' ).removeClass( 'is-mobile' ).addClass( 'is-desktop' );
214                    }
215                }
216            }
217
218            is_mobile = BuddyBoss.is_mobile = $( 'body' ).hasClass( 'is-mobile' );
219
220            return is_mobile;
221        }
222
223        /**
224         * Checks for a BuddyPress sub-page menu. On smaller screens we turn
225         * this into a left/right swiper
226         *
227         * @return {boolean} True when BuddyPress item navigation exists
228         */
229        function check_has_item_nav() {
230            if ( $item_nav && $item_nav.length ) {
231                has_item_nav = true;
232            }
233
234            return has_item_nav;
235        }
236
237		/**
238		 * Transfer item-nav into mobile device compatible items nav
239		 */
240		function transfer_item_nav_into_mobile() {
241			var $item_nav = $buddypress.find( '#item-nav' );
242
243			// Runs once, first time we experience a mobile resolution
244			$mobile_nav_wrap = $( '<div id="mobile-item-nav-wrap" class="mobile-item-nav-container mobile-item-nav-scroll-container">' );
245			$mobile_item_wrap = $( '<div class="mobile-item-nav-wrapper">' ).appendTo( $mobile_nav_wrap );
246			$mobile_item_nav = $( '<div id="mobile-item-nav" class="mobile-item-nav">' ).appendTo( $mobile_item_wrap );
247			$mobile_item_nav.append( $item_nav.html() );
248
249			$mobile_item_nav.css( 'width', ( $item_nav.find( 'li' ).length * 94 ) );
250			$mobile_nav_wrap.insertBefore( $item_nav ).show();
251			$( '#mobile-item-nav-wrap, .mobile-item-nav-scroll-container, .mobile-item-nav-container' ).addClass( 'fixed' );
252			$item_nav.css( { display: 'none' } );
253		}
254
255        function render_layout() {
256            var
257                window_height = $window.height(), // window height - 60px (Header height) - carousel_nav_height (Carou
257sel Navigation space)
258                carousel_width = ( $item_nav.find( 'li' ).length * 94 );
259
260            // If on small screens make sure the main page elements are
261            // full width vertically
262            if ( is_mobile && ( $inner.height() < $window.height() ) ) {
263                $( '#page' ).css( 'min-height', $window.height() - ( $( '#mobile-header' ).height() + $( '#colophon' ).height() ) );
264            }
265
266            //if ( is_mobile ) {
267            //$( '#messages-layout' ).css( 'margin-top', $( '#leftcolumn' ).height() );
268            //}
269
270            // Swipe/panel shut area
271            if ( is_mobile && $( '#buddyboss-swipe-area' ).length && Panels.state ) {
272                $( '#buddyboss-swipe-area' ).css( {
273                    left: Panels.state === 'left' ? 240 : 'auto',
274                    right: Panels.state === 'right' ? 240 : 'auto',
275                    width: $( window ).width() - 240,
276                    height: $( window ).outerHeight( true ) + 200
277                } );
278            }
279
280            // Log out link in left panel
281            var $left_logout_link = $( '#wp-admin-bar-logout' ),
282                $left_account_panel = $( '#wp-admin-bar-user-actions' ),
283                $left_settings_menu = $( '#wp-admin-bar-my-account-settings .ab-submenu' ).first();
284
285            if ( $left_logout_link.length && $left_account_panel.length && $left_settings_menu.length ) {
286                // On mobile user's accidentally click the link when it's up
287                // top so we move it into the setting menu
288                if ( is_mobile ) {
289                    $left_logout_link.appendTo( $left_settings_menu );
290                }
291                // On desktop we move it back to it's original place
292                else {
293                    $left_logout_link.appendTo( $left_account_panel );
294                }
295            }
296
297            // Runs once, first time we experience a mobile resolution
298            if ( is_mobile && has_item_nav && !mobile_modified ) {
299                mobile_modified = true;
300                transfer_item_nav_into_mobile();
301            }
302            // Resized to non-mobile resolution
303            else if ( !is_mobile && has_item_nav && mobile_modified ) {
304                $mobile_nav_wrap.css( { display: 'none' } );
305                $item_nav.css( { display: 'block' } );
306                $document.trigger( 'menu-close.buddyboss' );
307            }
308            // Resized back to mobile resolution
309            else if ( is_mobile && has_item_nav && mobile_modified ) {
310                $mobile_nav_wrap.css( {
311                    display: 'block',
312                    width: carousel_width
313                } );
314
315                $mobile_item_nav.css( {
316                    width: carousel_width
317                } );
318
319                $item_nav.css( { display: 'none' } );
320            }
321
322            // Update select drop-downs
323            if ( typeof Selects !== 'undefined' ) {
324                if ( $.isFunction( Selects.populate_select_label ) ) {
325                    Selects.populate_select_label( is_mobile );
326                }
327            }
328        }
329
330        /**
331         * Renders the layout, called when the page is loaded and on resize
332         *
333         * @return {void}
334         */
335        function do_render()
336        {
337            check_is_mobile();
338            $( window ).resize( check_is_mobile );
339            check_has_item_nav();
340            render_layout();
341            mobile_carousel();
342        }
343        /*------------------------------------------------------------------------------------------------------
344         1.1 - Startup (Binds Events + Conditionals)
345         --------------------------------------------------------------------------------------------------------*/
346
347        // Render layout
348        do_render();
349
350        // Re-render layout after everything's loaded
351        $window.bind( 'load', function () {
352            do_render();
353        } );
354
355        // Re-render layout on resize
356        var throttle;
357        $window.resize( function () {
358            clearTimeout( throttle );
359            throttle = setTimeout( do_render, 150 );
360        } );
361
362		/**
363		 * Transfer search result main item list into icon menu
364		 */
365		$( document ).ajaxComplete(function( event, xhr, settings ) {
366
367			var action = getQueryVariable( settings.data, 'action' );
368
369			if ( typeof action == 'undefined' || action != 'bboss_global_search_ajax' )
370				return;
371
372			setTimeout( function() {
373				// Transfer search result category list into mobile nav menu
374				if ( is_mobile && has_item_nav ) {
375					mobile_modified = true;
376					transfer_item_nav_into_mobile();
377				}
378				// Init swiper on transferred search result page
379				swiper = false;
380				mobile_carousel();
381			}, 100 );
382		});
383
384        /*------------------------------------------------------------------------------------------------------
385         2.1 - Mobile/Tablet Carousels
386         --------------------------------------------------------------------------------------------------------*/
387
388        function mobile_carousel() {
389            if ( is_mobile && has_item_nav ) {
390                /* Remove submenu if there is any */
391                if ( $( '#mobile-item-nav #nav-bar-filter .hideshow ul' ).length > 0 ) {
392                    $( '#mobile-item-nav #nav-bar-filter' ).append( $( '#mobile-item-nav #nav-bar-filter .hideshow ul' ).html() );
393                    $( '#mobile-item-nav #nav-bar-filter .hideshow' ).remove();
394                }
395
396                if ( !swiper ) {
397                    // console.log( 'Setting up mobile nav swiper' );
398                    swiper = $( '.mobile-item-nav-scroll-container' ).swiper( {
399                        scrollContainer: true,
400                        slideElement: 'div',
401                        slideClass: 'mobile-item-nav',
402                        wrapperClass: 'mobile-item-nav-wrapper',
403                        slidesPerView: 'auto',
404                        freeMode: true
405                    } );
406                }
407            }
408        }
409
410        /*------------------------------------------------------------------------------------------------------
411         2.2 - Responsive Dropdowns
412         --------------------------------------------------------------------------------------------------------*/
413        if ( typeof Selects !== 'undefined' ) {
414            if ( $.isFunction( Selects.init_select ) ) {
415                Selects.init_select( is_mobile, inputsEnabled );
416                boss_select2();
417            }
418        }
419
420        $document.ajaxComplete( function () {
421            setTimeout( function () {
422                if ( $.isFunction( Selects.init_select ) ) {
423                    Selects.init_select( is_mobile, inputsEnabled );
424                    boss_select2();
425                }
426                if ( typeof Selects !== 'undefined' ) {
427                    if ( $.isFunction( Selects.populate_select_label ) ) {
428                        Selects.populate_select_label( is_mobile );
429                    }
430                }
431//                    $('.message-check, #select-all-messages').addClass('styled').after('<strong></strong>');
432
433            }, 500 );
434        } );
435
436        if ( $( 'body' ).find( '#siteRegisterBox-step-2' ).length !== 0 ) {
437            $document.ajaxComplete( function () {
438                setTimeout( function () {
439                    if ( $.isFunction( Selects.init_select ) ) {
440                        Selects.init_select( is_mobile, inputsEnabled );
441                        boss_select2();
442                    }
443                    if ( typeof Selects !== 'undefined' ) {
444                        if ( $.isFunction( Selects.populate_select_label ) ) {
445                            Selects.populate_select_label( is_mobile );
446                        }
447                    }
448
449                }, 500 );
450            } );
451        }
452
453        /* Reset selects on Event booking options changed */
454
455        $( document ).on( 'em_bookings_filtered', function () {
456            if ( $.isFunction( Selects.init_select ) ) {
457                Selects.init_select( is_mobile, inputsEnabled );
458                boss_select2();
459            }
460            if ( typeof Selects !== 'undefined' ) {
461                if ( $.isFunction( Selects.populate_select_label ) ) {
462                    Selects.populate_select_label( is_mobile );
463                }
464            }
465        } );
466        
467        if( $('body').hasClass('bp-docs-create') && $('#item-nav').length === 0 ) {
468            $('#buddypress').addClass('add-space');
469        }
470
471        /*------------------------------------------------------------------------------------------------------
472         3.0 - Content
473         --------------------------------------------------------------------------------------------------------*/
474        /*------------------------------------------------------------------------------------------------------
475         3.1 - Members (Group Admin)
476         --------------------------------------------------------------------------------------------------------*/
477
478        // Hide/Reveal action buttons
479        $( 'a.show-options' ).click( function ( event ) {
480            event.preventDefault;
481
482            parent_li = $( this ).parent( 'li' );
483            if ( $( parent_li ).children( 'ul#members-list span.small' ).hasClass( 'inactive' ) ) {
484                $( this ).removeClass( 'inactive' ).addClass( 'active' );
485                $( parent_li ).children( 'ul#members-list span.small' ).removeClass( 'inactive' ).addClass( 'active' );
486            }
487            else {
488                $( this ).removeClass( 'active' ).addClass( 'inactive' );
489                $( parent_li ).children( 'ul#members-list span.small' ).removeClass( 'active' ).addClass( 'inactive' );
490            }
491
492        } );
493
494
495        /*------------------------------------------------------------------------------------------------------
496         3.2 - Search Input Field
497         --------------------------------------------------------------------------------------------------------*/
498        $( '#buddypress div.dir-search form, #buddypress div.message-search form, div.bbp-search-form form, form#bbp-search-form' ).append( '<a href="#" id="clear-input"> </a>' );
499        $( 'a#clear-input' ).click( function () {
500            jQuery( "#buddypress div.dir-search form input[type=text], #buddypress div.message-search form input[type=text], div.bbp-search-form form input[type=text], form#bbp-search-form input[type=text]" ).val( "" );
501        } );
502
503
504        /*------------------------------------------------------------------------------------------------------
505         3.3 - Hide Profile and Group Buttons Area, when there are no buttons (ex: Add Friend, Join Group etc...)
506         --------------------------------------------------------------------------------------------------------*/
507
508        if ( !$( '#buddypress #item-header #item-buttons .generic-button' ).length ) {
509            $( '#buddypress #item-header #item-buttons' ).hide();
510        }
511
512        /*------------------------------------------------------------------------------------------------------
513         3.4 - Move the Messages Checkbox, below the Avatar
514         --------------------------------------------------------------------------------------------------------*/
515
516        $( '#message-threads.messages-notices .thread-options .checkbox' ).each( function () {
517            move_to_spot = $( this ).parent().siblings( '.thread-avatar' );
518            $( this ).appendTo( move_to_spot );
519        } );
520
521        /*------------------------------------------------------------------------------------------------------
522         3.5 - Select unread and read messages in inbox
523         --------------------------------------------------------------------------------------------------------*/
524
525        // Overwrite/Re-do some of the functionality in buddypress.js,
526        // to accommodate for UL instead of tables in buddyboss theme
527        jq( "#message-type-select" ).change(
528            function () {
529                var selection = jq( "#message-type-select" ).val();
530                var checkboxes = jq( "ul input[type='checkbox']" );
531                checkboxes.each( function ( i ) {
532                    checkboxes[i].checked = "";
533                } );
534
535                switch ( selection ) {
536                    case 'unread':
537                        var checkboxes = jq( "ul.unread input[type='checkbox']" );
538                        break;
539                    case 'read':
540                        var checkboxes = jq( "ul.read input[type='checkbox']" );
541                        break;
542                }
543                if ( selection != '' ) {
544                    checkboxes.each( function ( i ) {
545                        checkboxes[i].checked = "checked";
546                    } );
547                } else {
548                    checkboxes.each( function ( i ) {
549                        checkboxes[i].checked = "";
550                    } );
551                }
552            }
553        );
554
555        /* star ajax according to boss theme as boss not using old tables */
556        if ( typeof starAction !== 'undefined' ) {
557            jq( '#message-threads' ).on( 'click', '.thread-star a', starAction );
558        }
559
560        /* Bulk delete messages */
561        jq( "#delete_inbox_messages, #delete_sentbox_messages" ).on( 'click', function () {
562            checkboxes_tosend = '';
563            checkboxes = jq( "#message-threads ul input[type='checkbox']" );
564
565            jq( '#message' ).remove();
566            jq( this ).addClass( 'loading' );
567
568            jq( checkboxes ).each( function ( i ) {
569                if ( jq( this ).is( ':checked' ) )
570                    checkboxes_tosend += jq( this ).attr( 'value' ) + ',';
571            } );
572
573            if ( '' == checkboxes_tosend ) {
574                jq( this ).removeClass( 'loading' );
575                return false;
576            }
577
578            jq.post( ajaxurl, {
579                action: 'messages_delete',
580                'thread_ids': checkboxes_tosend
581            }, function ( response ) {
582                if ( response[0] + response[1] == "-1" ) {
583                    jq( '#message-threads' ).prepend( response.substr( 2, response.length ) );
584                } else {
585                    jq( '#message-threads' ).before( '<div id="message" class="updated"><p>' + response + '</p></div>' );
586
587                    jq( checkboxes ).each( function ( i ) {
588                        if ( jq( this ).is( ':checked' ) )
589                            jq( this ).parent().parent().fadeOut( 150 );
590                    } );
591                }
592
593                jq( '#message' ).hide().slideDown( 150 );
594                jq( "#delete_inbox_messages, #delete_sentbox_messages" ).removeClass( 'loading' );
595            } );
596            return false;
597        } );
598
599        /*------------------------------------------------------------------------------------------------------
600         3.6 - Make Video Embeds Responsive - Fitvids.js
601         --------------------------------------------------------------------------------------------------------*/
602        if ( typeof $.fn.fitVids !== 'undefined' && $.isFunction( $.fn.fitVids ) ) {
603
604            function videosWidth() {
605
606                $( '#content' ).fitVids();
607
608                if ( $( '.activity-inner' ).length > 0 ) {
609                    $( '.activity-inner' ).find( '.fluid-width-video-wrapper' ).each( function () {
610                        $( this ).parent().css( {
611                            'max-width': '530px'
612                        } );
613                    } );
614                }
615            }
616
617            videosWidth();
618
619            // This ensures that after and Ajax call we check again for
620            // videos to resize.
621            $( document ).ajaxSuccess( function ( event, xhr, settings ) {
622				var action = getQueryVariable( settings.data, 'action' );
623
624				if ( action === 'heartbeat' )
625					return;
626
627				videosWidth();
628			} );
629        }
630
631        /*------------------------------------------------------------------------------------------------------
632         Fix BuddyPanel
633         --------------------------------------------------------------------------------------------------------*/
634
635        var $primary = $( '#primary' );
636
637        function fixBuddyPanel() {
638
639            if ( !is_mobile && $primary.length > 0 ) {
640
641                height = viewport().height;
642
643                $( '#scroll-area' ).css( {
644                    'position': 'relative'
645                } );
646
647                if ( $( '#scroll-area' ).outerHeight() + $( '#masthead' ).outerHeight() + $( '#wpadminbar' ).outerHeight() < height ) {
648                    $( '#scroll-area' ).css( {
649                        'position': 'fixed'
650                    } );
651                }
652
653            } else {
654                $( '#scroll-area' ).css( {
655                    'position': 'relative'
656                } );
657            }
658        }
659
660        /**
661         * Set min height of the Primary content section
662         *
663         * This function will stretch #primary div when BuddyPanel height is
664         * more than the #primary div so there won't be unoccupied area at the
665         * bottom of the page
666         */
667        function setPrimarySectionMinHeight() {
668            var $primary = $( '#primary' );
669            var left_panel_height = $( '#menu-buddypanel' ).height();
670
671            if ( !is_mobile && $primary.length > 0 && left_panel_height > $primary.height() ) {
672                $primary.css({'min-height': left_panel_height+'px' });
673            }
674        }
675
676        setPrimarySectionMinHeight();
677
678        imagesLoaded( 'body', function ( instance ) {
679            fixBuddyPanel();
680        } );
681
682        $window.resize( function () {
683            fixBuddyPanel();
684            setPrimarySectionMinHeight();
685        } );
686
687        // Ajax complete Sidebars Fix
688        $( document ).ajaxComplete( function () {
689            setTimeout( function () {
690                fixBuddyPanel();
691            }, 500 );
692        } );
693
694        setTimeout( function () {
695            $( ".right-col" ).toggleClass( "open" );
696            fixBuddyPanel();
697        }, 500 );
698
699        // Reposition BuddyPanel Sub Menu
700        $( "#menu-buddypanel li.menu-item-has-children:not(.current-menu-item)" ).hover(
701            function() {
702                var $subMenuWrap = $('.sub-menu-wrap', this);
703                var position = $(this).offset().top - $(window).scrollTop();
704                var subMenuHeight = $subMenuWrap.height();
705                var windowHeight = $(window).height();
706                var submenuPosition = position + subMenuHeight;
707
708                if ( submenuPosition >= windowHeight) {
709                    var topOffset = windowHeight - submenuPosition;
710                    $subMenuWrap.css({'top': topOffset+'px'});
711                    $("<style type='text/css' id='buddypanel-dynamic' />").appendTo("head");
712                    var pusdoOffset = Math.abs(topOffset) + 18;
713                    $("#buddypanel-dynamic").text(
714                        "body.left-menu-open .menu-panel .sub-menu-wrap:before," +
715                        "body.left-menu-open .sub-menu-wrap:after," +
716                        "body:not(.left-menu-open) .menu-panel .sub-menu-wrap:before," +
717                        "body:not(.left-menu-open) .sub-menu-wrap:after"+
718                        "{ top:" + pusdoOffset + "px;}"
719                    );
720                }
721            }, function() {
722                var $subMenuWrap = $('.sub-menu-wrap', this);
723                $subMenuWrap.css({'top': 0});
724                $("#buddypanel-dynamic").remove();
725            }
726        );
727
728        /*--------------------------------------------------------------------------------------------------------
729         3.7 - Comment placeholder
730         --------------------------------------------------------------------------------------------------------*/
731        $( '#comment' ).attr( 'placeholder', translation.comment_placeholder );
732
733        /*------------------------------------------------------------------------------------------------------
734         3.8 - Initialise UI scripts
735         --------------------------------------------------------------------------------------------------------*/
736
737        // Accordion
738        if ( $( ".accordion" ).length ) {
739            $( ".accordion" ).each( function () {
740                var open = $( this ).data( 'open' );
741                if ( open == 'false' ) {
742                    open = false;
743                }
744                $( this ).accordion( {
745                    active: open,
746                    heightStyle: "content",
747                    collapsible: true
748                } );
749            } );
750        }
751
752        // Tabs
753        if ( $( ".tabs" ).length ) {
754            $( ".tabs" ).tabs();
755        }
756
757        // Progress Bar
758        if ( $( ".progressbar" ).length ) {
759            $( ".progressbar" ).each( function () {
760                $( this ).progressbar( {
761                    value: $( this ).data( 'progress' )
762                } );
763            } );
764        }
765
766        // Tooltip
767        if ( $( ".tooltip" ).length ) {
768            $( ".tooltip" ).tooltip( {
769                position: {
770                    my: "center bottom-10",
771                    at: "center top",
772                    using: function ( position, feedback ) {
773                        $( this ).css( position );
774                        $( "<div>" )
775                            .addClass( "arrow" )
776                            .addClass( feedback.vertical )
777                            .addClass( feedback.horizontal )
778                            .appendTo( this );
779                    }
780                }
781            } );
782        }
783
784        // Menu
785        if ( $( ".menu-dropdown > ul" ).length ) {
786            $( '.menu-dropdown > ul' ).superfish();
787        }
788
789        $('#signup_form #signup_submit').on('click', function() {
790            $('html, body').animate({scrollTop:$('#profile-details-section').position().top}, 'slow');
791        });
792
793        /*--------------------------------------------------------------------------------------------------------
794         3.9 - Some global functions
795         --------------------------------------------------------------------------------------------------------*/
796
797        //click events
798        var ua = navigator.userAgent,
799            clickevent = ( ua.match( /iPad/i ) || ua.match( /iPhone/i ) || ua.match( /Android/i ) ) ? "touch" : "click";
800
801        // get viewport size
802        function viewport() {
803            var e = window, a = 'inner';
804            if ( !( 'innerWidth' in window ) ) {
805                a = 'client';
806                e = document.documentElement || document.body;
807            }
808            return { width: e[ a + 'Width' ], height: e[ a + 'Height' ] };
809        }
810
811        var disable = 0;
812
813        // Remove inline styling
814        $.fn.removeStyle = function ( style )
815        {
816            var search = new RegExp( style + '[^;]+;?', 'g' );
817
818            return this.each( function ()
819            {
820                $( this ).attr( 'style', function ( i, style )
821                {
822                    if ( style ) {
823                        return style.replace( search, '' );
824                    }
825                } );
826            } );
827        };
828
829        /*--------------------------------------------------------------------------------------------------------
830         3.10 - Fit Site Title
831         --------------------------------------------------------------------------------------------------------*/
832
833        // Fit Text
834        $.fn.fitText = function ( kompressor, options ) {
835
836            // Setup options
837            var compressor = kompressor || 1,
838                settings = $.extend( {
839                    'minFontSize': Number.NEGATIVE_INFINITY,
840                    'maxFontSize': Number.POSITIVE_INFINITY
841                }, options );
842
843            return this.each( function () {
844
845                // Store the object
846                var $this = $( this );
847
848                // Resizer() resizes items based on the object width divided by the compressor * 10
849                var resizer = function () {
850                    $this.css( 'font-size', Math.max( Math.min( $this.width() / ( compressor * 10 ), parseFloat( settings.maxFontSize ) ), parseFloat( settings.minFontSize ) ) );
851                };
852
853                // Call once to set.
854                resizer();
855
856                // Call on resize. Opera debounces their resize by default.
857                $( window ).on( 'resize.fittext orientationchange.fittext', resizer );
858
859            } );
860
861        };
862
863        $( ".mobile-site-title" ).fitText( 1, { minFontSize: '18px', maxFontSize: '25px' } );
864
865        if ( is_mobile ) {
866            $( ".bb-slider-container .title" ).fitText( 1, { minFontSize: '18px', maxFontSize: '70px' } );
867        }
868
869        /**
870         * Core for buddyboss left menu
871         * @return (void)
872         */
873
874        /* add submenu title */
875        if ( !$( "body" ).hasClass( panel_open_class ) ) {
876            $( '#left-panel #nav-menu > ul > li' ).each( function () {
877                var $element = $( this ).children( 'a:not(.fa)' ).clone();
878                if ( $( this ).children( '.sub-menu-wrap' ).length ) {
879                    $( this ).children( '.sub-menu-wrap' ).prepend( $element );
880                } else {
881                    var $submenu = $( '<div/>', {
882                        'class': 'sub-menu-wrap'
883                    } );
884
885                    $element.appendTo( $submenu );
886                    $( this ).append( $submenu );
887                }
888            } );
889        }
890
891        function func_left_menu() {
892            $( "#left-menu-toggle" ).bind( 'click', function ( event ) {
893                event.preventDefault();
894                $( "body" ).toggleClass( panel_open_class );
895
896                if ( $( "body" ).hasClass( panel_open_class ) ) {
897
898                    /* remove submenu title */
899                    $( '#left-panel #nav-menu > ul > li' ).each( function () {
900                        if ( $( this ).children( '.sub-menu-wrap' ).find( 'ul' ).length ) {
901                            $( this ).children( '.sub-menu-wrap' ).children( 'a' ).remove();
902                        } else {
903                            $( this ).children( '.sub-menu-wrap' ).remove();
904                        }
905                    } );
906
907                    $.cookie( 'left-panel-status', 'open', { path: '/' } );
908
909                } else {
910
911                    /* add submenu title */
912                    $( '#left-panel #nav-menu > ul > li' ).each( function () {
913                        var $element = $( this ).children( 'a:not(.fa)' ).clone();
914                        if ( $( this ).children( '.sub-menu-wrap' ).length ) {
915                            $( this ).children( '.sub-menu-wrap' ).prepend( $element );
916                        } else {
917                            var $submenu = $( '<div/>', {
918                                'class': 'sub-menu-wrap'
919                            } );
920
921                            $element.appendTo( $submenu );
922                            $( this ).append( $submenu );
923                        }
924                    } );
925
926                    $.cookie( 'left-panel-status', 'close', { path: '/' } );
927                }
928
929                setTimeout( function () {
930                    if ( rtl ) {
931                        $( ".left-col" ).toggleClass( "open" );
932                    } else {
933                        $( ".right-col" ).toggleClass( "open" );
934                    }
935                    $window.trigger( 'resize' );
936                    setPrimarySectionMinHeight();
937                }, 500 );
938
939                // arrows for tablet
940                menuToggle();
941
942            } );
943        }
944
945
946        func_left_menu();
947
948        // Ajax complete Sidebars Fix
949        $( document ).ajaxComplete( function () {
950            setTimeout( function () {
951                initSpinner();
952            }, 500 );
953
954            setTimeout( function () {
955                initSpinner();
956            }, 1500 );
957        } );
958
959
960        //BuddyBoss Inbox Additional Label Functionality Code
961
962        jQuery( document ).on( 'click', '.bb-add-label-button', function ( e ) {
963            e.preventDefault();
964
965            _this = jQuery( this );
966
967            _this.find( ".fa-spin" ).fadeOut();
968
969            var label_name = jQuery( '.bb-label-name' ).val();
970            var data = {
971                action: 'bbm_label_ajax',
972                task: 'add_new_label',
973                thread_id: 0,
974                label_name: label_name
975            };
976
977            jQuery.post( ajaxurl, data, function ( response ) {
978
979                _this.find( ".fa-spin" ).fadeIn();
980
981                var response = jQuery.parseJSON( response );
982
983                if ( response.label_id != '' ) {
984
985                    jQuery( ".bb-label-container" ).load( window.location.href + " .bb-label-container", function () {
986                        jQuery( ".bb-label-container > .bb-label-container" ).attr( "class", "" );
987                    } );
988
989                }
990
991                if ( typeof response.message == 'undefined' ) {
992                    return false;
993                }
994
995                if ( response.message != '' ) {
996                    alert( response.message );
997                }
998
999            } );
1000        } );
1001
1002        jQuery( document ).on( "keydown", ".bb-label-name", function ( e ) {
1003            if ( e.keyCode == 13 ) {
1004                jQuery( ".bb-add-label-button" ).click();
1005            }
1006        } );
1007
1008        /*--------------------------------------------------------------------------------------------------------
1009         3.12 - Mobile & Tablet menu
1010         --------------------------------------------------------------------------------------------------------*/
1011
1012        function attachArrows() {
1013            if ( $( '.menu-panel .open-submenu' ).length === 0 ) {
1014                $( '.menu-panel .bp_components ul li ul li.menupop' ).prepend( '<a class="open-submenu" href="#"><i class="fa fa-angle-right"></i></a>' );
1015
1016                $( '.menu-panel #nav-menu > ul > li' ).each( function () {
1017                    if ( $( this ).children( '.sub-menu-wrap' ).length && $( this ).children( '.open-submenu' ).length === 0 ) {
1018                        $( this ).prepend( '<a class="open-submenu" href="#"><i class="fa fa-angle-right"></i></a>' );
1019                    }
1020                } );
1021
1022                $( window ).on( 'load', function () {
1023                    $( '.menu-panel #header-menu .sub-menu-wrap' ).hide();
1024                    $( '.menu-panel #header-menu ul li' ).each( function () {
1025                        if ( $( this ).children( '.sub-menu-wrap' ).length && $( this ).children( '.open-submenu' ).length === 0 ) {
1026                            $( this ).prepend( '<a class="open-submenu" href="#"><i class="fa fa-angle-right"></i></a>' );
1027                        }
1028                    } );
1029                } );
1030            }
1031
1032            $( '.menu-panel .open-submenu' ).unbind();
1033//            $( 'body' ).unbind();
1034            $( 'body' ).off( 'click', '.menu-panel .open-submenu' );
1035            $( 'body' ).on( 'click', '.menu-panel .open-submenu', function ( event ) {
1036                event.preventDefault();
1037
1038                $( this ).next().next().slideToggle( "fast", function () {
1039                } );
1040
1041                $( this ).find('.fa, .svg-inline--fa').toggleClass( 'fa-angle-down fa-angle-right' );
1042                $( this ).closest( 'li' ).toggleClass( 'dropdown' );
1043            } );
1044        }
1045
1046        function removeArrows() {
1047            $( '.menu-panel .open-submenu' ).remove();
1048            $( '.menu-panel .ab-sub-wrapper, .sub-menu-wrap' ).removeAttr( "style" );
1049        }
1050
1051        function menuToggle() {
1052            if ( is_mobile || ( $( 'body' ).hasClass( 'tablet' ) && $( 'body' ).hasClass( panel_open_class ) && $( 'body' ).hasClass( 'tablet' ) ) ) {
1053                attachArrows();
1054            } else {
1055                removeArrows();
1056            }
1057        }
1058
1059        menuToggle();
1060        $( window ).resize( menuToggle );
1061
1062        // Account Menu PopUp On Touch For Tablets
1063        $( '.tablet .header-account-login' ).on( "click touch", function ( e ) {
1064            $( this ).find( '.pop' ).toggleClass( 'hover' );
1065        } );
1066
1067        if ( $( '#wp-admin-bar-shortcode-secondary' ).length ) {
1068            $( '.tablet #wp-admin-bar-shortcode-secondary .menupop' ).on( "click touch", function ( e ) {
1069                $( this ).find( '.ab-sub-wrapper' ).toggleClass( 'hover' );
1070            } );
1071        } else {
1072            $( '.tablet .header-notifications' ).on( "click touch", function ( e ) {
1073                $( this ).find( '.pop' ).toggleClass( 'hover' );
1074            } );
1075        }
1076
1077        // Reposition admin bar sub menu
1078        $( ".header-account-login ul#wp-admin-bar-my-account-buddypress > li.menupop, .header-account-login ul#menu-my-profile > li.menu-item-has-children" ).hover(
1079            function() {
1080                var $subMenuWrap = $('div.ab-sub-wrapper, ul.sub-menu', this);
1081                var position = $(this).offset().top - $(window).scrollTop();
1082                var subMenuHeight = $subMenuWrap.height();
1083                var windowHeight = $('div.user-pop-links').height();
1084                var submenuPosition = position + subMenuHeight;
1085
1086                if ( submenuPosition >= windowHeight) {
1087                    var topOffset = windowHeight - submenuPosition;
1088                    $subMenuWrap.css({'top': topOffset+'px'});
1089                    $("<style type='text/css' id='my-account-dynamic' />").appendTo("head");
1090                    var pusdoOffset = Math.abs(topOffset) + 11;
1091                    $("#my-account-dynamic").text(".header-account-login .pop .bp_components .menupop:not(#wp-admin-bar-my-account) > .ab-sub-wrapper:before," +
1092                        ".header-account-login .pop .links li > .sub-menu:before { top:" + pusdoOffset + "px;}");
1093                }
1094            }, function() {
1095                var $subMenuWrap = $('div.ab-sub-wrapper, ul.sub-menu', this);
1096                $subMenuWrap.css({'top': 0});
1097                $("#my-account-dynamic").remove();
1098            }
1099        );
1100
1101        /*--------------------------------------------------------------------------------------------------------
1102         3.13 - Add spinner
1103         --------------------------------------------------------------------------------------------------------*/
1104        function initSpinner() {
1105            $( '#main-button, .generic-button:not(.pending):not(.group-subscription-options)' ).on( 'click', function () {
1106                $link = $( this ).find( 'a' );
1107                if ( !$link.find( 'i' ).length && !$link.hasClass( 'pending' ) ) {
1108                    $link.append( '<i class="fa fa-spinner fa-spin"></i>' );
1109                }
1110            } );
1111        }
1112
1113        initSpinner();
1114
1115        // to activity submit
1116        $( '#whats-new-submit' ).append( '<span class="spinner"></span>' );
1117
1118        /*--------------------------------------------------------------------------------------------------------
1119         3.14 - To Top Button
1120         --------------------------------------------------------------------------------------------------------*/
1121        //Scroll Effect
1122        $( '.scroll' ).bind( 'click', function ( event ) {
1123
1124            event.preventDefault();
1125
1126            var $anchor = $( this );
1127
1128            $( 'html, body' ).stop().animate( {
1129                scrollTop: $( $anchor.attr( 'href' ) ).offset().top + "px"
1130            }, 1000, 'easeInOutExpo' );
1131
1132        } );
1133
1134        /*--------------------------------------------------------------------------------------------------------
1135         3.14 - Custom File Input
1136         --------------------------------------------------------------------------------------------------------*/
1137        $( '#group-create-body input[type=file], #avatar-upload input[type=file], #group-settings-form input[type=file]' ).change( function ( e ) {
1138            var str = $( this ).val(),
1139                parts = str.split( '\\' ),
1140                result = parts[parts.length - 1];
1141
1142            $( "#file-path" ).text( result );
1143        } );
1144
1145        /*--------------------------------------------------------------------------------------------------------
1146         3.15 - 404 Page Go Back Button
1147         --------------------------------------------------------------------------------------------------------*/
1148        $( '.back-btn' ).click( function ( event ) {
1149            event.preventDefault();
1150            window.history.back();
1151        } );
1152
1153        /*--------------------------------------------------------------------------------------------------------
1154         3.16 - Better Radios and Checkboxes Styling
1155         --------------------------------------------------------------------------------------------------------*/
1156        function initCheckboxes() {
1157            if ( !inputsEnabled ) {
1158                //only few buddypress and bbpress related fields
1159                $( '.events input[type="checkbox"], #buddypress table.notifications input, #send_message_form input[type="checkbox"], #profile-edit-form input[type="checkbox"],  #profile-edit-form input[type="radio"], #message-threads input, #settings-form input[type="radio"], #create-group-form input[type="radio"], #create-group-form input[type="checkbox"], #invite-list input[type="checkbox"], #group-settings-form input[type="radio"], #group-settings-form input[type="checkbox"], #new-post input[type="checkbox"], .bbp-form input[type="checkbox"], .bbp-form .input[type="radio"], .register-section .input[type="radio"], .register-section input[type="checkbox"], .message-check, #select-all-messages' ).each( function () {
1160                    var $this = $( this );
1161                    $this.addClass( 'styled' );
1162                    if ( $this.next( "label" ).length == 0 && $this.next( "strong" ).length == 0 ) {
1163                        $this.after( '<strong></strong>' );
1164                    }
1165                } );
1166            } else {
1167
1168				var checkbox = excluded_inputs_selector('input[type="checkbox"]'),
1169					radio    = excluded_inputs_selector('input[type="radio"]');
1170
1171				//all fields
1172				$( checkbox + ',' + radio ).each( function () {
1173                    var $this = $( this );
1174                    if ( $this.val() == 'gf_other_choice' ) {
1175                        $this.addClass( 'styled' );
1176                        $this.next().wrap( '<strong class="other-option"></strong>' );
1177                    } else {
1178                        if ( !$this.parents( '#bp-group-documents-form' ).length ) {
1179                            $this.addClass( 'styled' );
1180                            if ( $this.next( "label" ).length == 0 && $this.next( "strong" ).length == 0 ) {
1181                                $this.after( '<strong></strong>' );
1182                            }
1183                        }
1184                    }
1185                } );
1186            }
1187        }
1188
1189        initCheckboxes();
1190
1191        /*--------------------------------------------------------------------------------------------------------
1192         3.17 - Mobile Panels
1193         --------------------------------------------------------------------------------------------------------*/
1194        $( document ).on( 'click', function ( event ) {
1195
1196            if ( event.originalEvent && $( event.target )[0].id != 'profile-nav' && $( event.target ).closest( '#left-panel' ).length == 0 && is_mobile ) {
1197                closeRightMenu();
1198            }
1199
1200            if ( event.originalEvent && $( event.target )[0].id != 'custom-nav' && $( event.target ).closest( '#mobile-menu' ).length == 0 && is_mobile ) {
1201                closeLeftMenu();
1202            }
1203
1204        } );
1205
1206
1207        //menu button trigger
1208        $( document ).on( 'click', '#profile-nav', function ( event ) {
1209            event.preventDefault();
1210            if ( is_mobile ) {
1211                event.preventDefault();
1212                if ( $( '#right-panel' ).hasClass( 'side-menu-right' ) ) {
1213                    closeRightMenu();
1214                } else {
1215                    openRightMenu();
1216                }
1217            }
1218        } );
1219
1220        $( document ).on( 'click', '#custom-nav', function ( event ) {
1221            event.preventDefault();
1222            if ( is_mobile ) {
1223                event.preventDefault();
1224                if ( $( '#right-panel' ).hasClass( 'side-menu-left' ) ) {
1225                    closeLeftMenu();
1226                } else {
1227                    openLeftMenu();
1228                }
1229            }
1230        } );
1231
1232        // open
1233        function openRightMenu() {
1234            $( '#left-panel' ).css( 'opacity', '1' );
1235            $( '#left-panel' ).css( 'display', 'block' );
1236            $( '#profile-nav' ).addClass( 'close' );
1237            $( '#right-panel' ).addClass( 'side-menu-right' );
1238            $( '#mobile-header' ).addClass( 'side-menu-right' );
1239            $( '#left-panel-inner' ).addClass( 'animated BeanSidebarIn' ).removeClass( 'BeanSidebarOut' );
1240            $( '#masthead' ).css( 'margin-top', '0' );
1241            setTimeout( function () {
1242                $( '#left-panel' ).css( 'z-index', '0' );
1243            }, 300 );
1244        }
1245
1246        function openLeftMenu() {
1247            $( '#mobile-menu' ).css( 'opacity', '1' );
1248            $( '#mobile-menu' ).css( 'display', 'block' );
1249            $( '#custom-nav' ).addClass( 'close' );
1250            $( '#right-panel' ).addClass( 'side-menu-left' );
1251            $( '#mobile-header' ).addClass( 'side-menu-left' );
1252            $( '#mobile-menu-inner' ).addClass( 'animated BeanSidebarIn' ).removeClass( 'BeanSidebarOut' );
1253            $( '#masthead' ).css( 'margin-top', '0' );
1254            setTimeout( function () {
1255                $( '#mobile-menu' ).css( 'z-index', '0' );
1256            }, 300 );
1257        }
1258
1259        // close
1260        function closeRightMenu() {
1261            $( '#left-panel' ).css( 'z-index', '-1' );
1262            $( '#profile-nav' ).removeClass( 'close' );
1263            $( '#right-panel' ).removeClass( 'side-menu-right' );
1264            $( '#mobile-header' ).removeClass( 'side-menu-right' );
1265            $( '#left-panel-inner' ).removeClass( 'BeanSidebarIn' ).addClass( 'BeanSidebarOut' );
1266            $( '#left-panel-inner' ).addClass( 'animated ' );
1267            setTimeout( function () {
1268                $( '#left-panel' ).css( 'z-index', '-1' );
1269                $( '#left-panel' ).css( 'opacity', '0' );
1270            }, 300 );
1271        }
1272
1273        function closeLeftMenu() {
1274            $( '#mobile-menu' ).css( 'z-index', '-1' );
1275            $( '#custom-nav' ).removeClass( 'close' );
1276            $( '#right-panel' ).removeClass( 'side-menu-left' );
1277            $( '#mobile-header' ).removeClass( 'side-menu-left' );
1278            $( '#mobile-menu-inner' ).removeClass( 'BeanSidebarIn' ).addClass( 'BeanSidebarOut' );
1279            $( '#mobile-menu-inner' ).addClass( 'animated ' );
1280            setTimeout( function () {
1281                $( '#mobile-menu' ).css( 'z-index', '-1' );
1282                $( '#mobile-menu' ).css( 'opacity', '0' );
1283            }, 300 );
1284        }
1285
1286        /*--------------------------------------------------------------------------------------------------------
1287         3.19 - Advanced Search Scripts
1288         --------------------------------------------------------------------------------------------------------*/
1289
1290        function searchWidthMobile() {
1291            if ( is_mobile ) {
1292                var $mobile_search = $( ".mobile-header-inner .searchform" );
1293                if ( $mobile_search.length ) {
1294                    $mobile_search.focusin( function () {
1295                        $( this ).css( {
1296                            'z-index': '2'
1297                        } ).stop().animate( {
1298                            'padding-left': '5px',
1299                            'padding-right': '5px'
1300                        }, 400 );
1301                    } );
1302
1303                    $mobile_search.focusout( function () {
1304                        $( this ).stop().animate( {
1305                            'padding-left': '77px',
1306                            'padding-right': '77px'
1307                        }, 400 );
1308                        setTimeout( function () {
1309                            $mobile_search.css( {
1310                                'z-index': '0'
1311                            } );
1312                        }, 400 );
1313                    } );
1314                }
1315            }
1316        }
1317
1318        searchWidthMobile();
1319//        $(window).resize(searchWidthMobile);
1320
1321        if ( $( '.search-wrap input[type="text"]' ).hasClass( 'ui-autocomplete-input' ) ) {
1322
1323            function searchWidth() {
1324                if ( !is_mobile ) {
1325                    $( "#header-search .search-wrap" ).focusin( function () {
1326                        $( this ).closest( '.search-wrap' ).stop().animate( {
1327                            width: '360px'
1328                        }, 400 );
1329                    } );
1330
1331                    $( "#header-search .search-wrap" ).focusout( function () {
1332                        $( this ).closest( '.search-wrap' ).stop().animate( {
1333                            width: '100px'
1334                        }, 400 );
1335                    } );
1336
1337                } else {
1338                    $( "#header-search .search-wrap" ).unbind( 'focus' );
1339                    $( "#header-search .search-wrap" ).unbind( 'focusout' );
1340                }
1341            }
1342
1343            searchWidth();
1344//            $(window).resize(searchWidth);
1345
1346            function dropdownPosition() {
1347                var offset = $( '.ui-autocomplete-input' ).offset().top + 48;
1348                $( '.bb-global-search-ac' ).css( {
1349                    'top': offset
1350                } );
1351            }
1352
1353            $window.scroll( function () {
1354                dropdownPosition();
1355            } );
1356
1357        }
1358
1359
1360        if ( !( '2' == $body.data( 'header' ) ) ) {
1361
1362            $( '.search-toggle a' ).click( function ( e ) {
1363                e.preventDefault();
1364
1365                var $this = $( this ),
1366                    $search_wrap = $( '.searchform' );
1367
1368                if ( $this.hasClass( 'closed' ) ) {
1369                    $this.removeClass( 'closed' );
1370                    $this.addClass( 'open' );
1371                    setTimeout( function () {
1372                        $search_wrap.find( '#s' ).focus();
1373                    }, 301 );
1374                } else {
1375                    $this.removeClass( 'open' );
1376                    $this.addClass
1376( 'closed' );
1377                }
1378
1379                $search_wrap.fadeToggle( 300, 'linear' );
1380
1381            } );
1382
1383            $( document ).click( function ( e )
1384            {
1385                var container = $( '.searchform' ),
1386                    toggle = $( '.search-toggle' );
1387
1388                if ( !container.is( e.target ) && !toggle.is( e.target ) && toggle.has( e.target ).length === 0
1389                    && container.has( e.target ).length === 0 && $( 'body' ).hasClass( 'boxed' ) )
1390                {
1391                    toggle.find( 'a' ).removeClass( 'open' ).addClass( 'closed' );
1392                    container.fadeOut();
1393                }
1394            } );
1395
1396        }
1397
1398        /*--------------------------------------------------------------------------------------------------------
1399         3.20 - Buttons Menu
1400         --------------------------------------------------------------------------------------------------------*/
1401        function attachClick() {
1402            $( '.more-items-btn' ).click( function () {
1403                $( this ).parent( '.single-member-more-actions' ).find( '.pop' ).slideToggle( 100 );
1404            } );
1405        }
1406
1407        if ( is_mobile ) {
1408            attachClick();
1409        }
1410
1411        /*--------------------------------------------------------------------------------------------------------
1412         3.21 - Responsive Menus (...)
1413         --------------------------------------------------------------------------------------------------------*/
1414        if ( !is_mobile ) {
1415            $( "#item-nav > .item-list-tabs > ul" ).jRMenuMore( 60 );
1416
1417
1418            //Initialize jRMenuMore menu when it actually start falling outside of screen width
1419            var members_menu_items_width = 0;
1420            $( '#members-directory-form div.item-list-tabs ul:first-child li' ).each( function () {
1421                members_menu_items_width += $( this ).outerWidth();
1422            } );
1423
1424            var members_ul_menu_width = $( '#members-directory-form div.item-list-tabs ul:first-child' ).width();
1425
1426            if ( members_menu_items_width > members_ul_menu_width ) {
1427                $( '#members-directory-form div.item-list-tabs ul:first-child' ).jRMenuMore( 140 );
1428            }
1429
1430            if ( '2' == $body.data( 'header' ) ) {
1431                $( "#header-menu > ul" ).jRMenuMore( 120 );
1432            } else {
1433                $( "#header-menu > ul" ).jRMenuMore( 70 );
1434            }
1435        }
1436
1437		/**
1438		 * Adjust vertical item nav menu height to fix menu list overflow
1439		 */
1440		var adjustItemNavHeight = (function() {
1441        	function doAdjustItemNavHeight() {
1442				if (!is_mobile) {
1443					var itemNavHeight = $("#item-nav > .item-list-tabs > ul > .hideshow > ul").height();
1444					var itemBodyHeight = $('#item-body').height();
1445
1446					if ( itemNavHeight > itemBodyHeight ) {
1447						$("#item-nav > .item-list-tabs > ul > .hideshow > ul").css({
1448							'height': itemBodyHeight + 'px',
1449							'overflow-y': 'auto'
1450						});
1451					}
1452				}
1453			}
1454			// Return the function
1455			return doAdjustItemNavHeight;
1456		})();
1457
1458        $window.resize(adjustItemNavHeight);
1459
1460        /*--------------------------------------------------------------------------------------------------------
1461         3.22 - BuddyPanel bubbles
1462         --------------------------------------------------------------------------------------------------------*/
1463
1464        function setCounters() {
1465            $( '#wp-admin-bar-my-account-buddypress' ).find( 'li' ).each( function () {
1466                var $this = $( this ),
1467                    $count = $this.children( 'a' ).children( '.count' ),
1468                    id,
1469                    $target;
1470
1471                if ( $count.length != 0 ) {
1472                    id = $this.attr( 'id' );
1473                    $target = $( '.bp-menu.bp-' + id.replace( /wp-admin-bar-my-account-/, '' ) + '-nav' );
1474                    if ( $target.find( '.count' ).length == 0 ) {
1475                        $target.find( 'a' ).append( '<span class="count">' + $count.html() + '</span>' );
1476                    }
1477                }
1478            } );
1479        }
1480
1481        setCounters();
1482
1483        /*--------------------------------------------------------------------------------------------------------
1484         3.23 - Titlebar position on mobile
1485         --------------------------------------------------------------------------------------------------------*/
1486
1487        function attachMobileMenu() {
1488            if ( is_mobile ) {
1489                var $container = $( '#mobile-menu-inner' );
1490                if ( !$container.find( '#header-menu' ).length ) {
1491                    var $element = $( '#header-menu' ).clone(),
1492                        position = $container.data( 'titlebar' ),
1493                        $existing = $container.find( '#nav-menu' );
1494
1495                    $element.find( '.hideshow ul li' ).each( function () {
1496                        $element.children( 'ul' ).append( $( this ) );
1497                    } );
1498                    $element.find( '.hideshow' ).remove();
1499
1500                    if ( $existing.length ) {
1501                        if ( position == 'top' ) {
1502                            $existing.before( $element );
1503                        } else if ( position == 'bottom' ) {
1504                            $existing.after( $element );
1505                        }
1506                    } else {
1507                        $container.append( $element );
1508                    }
1509                }
1510            }
1511        }
1512
1513        attachMobileMenu();
1514
1515        $window.resize( attachMobileMenu );
1516
1517        if ( is_mobile ) {
1518            $( '#switch_mode' ).val( 'desktop' );
1519            $( '#switch_submit' ).val( translation.view_desktop );
1520        } else {
1521            $( '#switch_mode' ).val( 'mobile' );
1522            $( '#switch_submit' ).val( translation.view_mobile );
1523        }
1524
1525        $( '#switch_submit' ).click( function () {
1526            $.cookie( 'switch_mode', $( '#switch_mode' ).val(), { path: '/' } );
1527        } );
1528
1529        /*--------------------------------------------------------------------------------------------------------
1530         3.24 - Infinite Scroll
1531         --------------------------------------------------------------------------------------------------------*/
1532        if ( $( '#masthead' ).data( 'infinite' ) == 'on' ) {
1533            var is_activity_loading = false;//We'll use this variable to make sure we don't send the request again and again.
1534
1535            jq( document ).on( 'scroll', function () {
1536                //Find the visible "load more" button.
1537                //since BP does not remove the "load more" button, we need to find the last one that is visible.
1538                var load_more_btn = jq( ".load-more:visible" );
1539                //If there is no visible "load more" button, we've reached the last page of the activity stream.
1540                if ( !load_more_btn.get( 0 ) )
1541                    return;
1542
1543                //Find the offset of the button.
1544                var pos = load_more_btn.offset();
1545
1546                //If the window height+scrollTop is greater than the top offset of the "load more" button, we have scrolled to the button's position. Let us load more activity.
1547                //            console.log(jq(window).scrollTop() + '  '+ jq(window).height() + ' '+ pos.top);
1548
1549                if ( jq( window ).scrollTop() + jq( window ).height() > pos.top ) {
1550	                load_more_btn.find( 'a' ).trigger('click');
1551                    //bb_load_more_activity();
1552                }
1553
1554            } );
1555
1556            /**
1557             * This routine loads more activity.
1558             * We call it whenever we reach the bottom of the activity listing.
1559             *
1560             */
1561            function bb_load_more_activity() {
1562
1563                //Check if activity is loading, which means another request is already doing this.
1564                //If yes, just return and let the other request handle it.
1565                if ( is_activity_loading )
1566                    return false;
1567
1568                //So, it is a new request, let us set the var to true.
1569                is_activity_loading = true;
1570
1571                //Add loading class to "load more" button.
1572                //Theme authors may need to change the selector if their theme uses a different id for the content container.
1573                //This is designed to work with the structure of bp-default/derivative themes.
1574                //Change #content to whatever you have named the content container in your theme.
1575                jq( "#content li.load-more" ).addClass( 'loading' );
1576
1577
1578                if ( null == jq.cookie( 'bp-activity-oldestpage' ) )
1579                    jq.cookie( 'bp-activity-oldestpage', 1, {
1580                        path: '/'
1581                    } );
1582
1583                var oldest_page = ( jq.cookie( 'bp-activity-oldestpage' ) * 1 ) + 1;
1584
1585                //Send the ajax request.
1586                jq.post( ajaxurl, {
1587                    action: 'activity_get_older_updates',
1588                    'cookie': encodeURIComponent( document.cookie ),
1589                    'page': oldest_page
1590                },
1591                function ( response )
1592                {
1593                    jq( ".load-more" ).hide();//Hide any "load more" button.
1594                    jq( "#content li.load-more" ).removeClass( 'loading' );//Theme authors, you may need to change #content to the id of your container here, too.
1595
1596                    //Update cookie...
1597                    jq.cookie( 'bp-activity-oldestpage', oldest_page, {
1598                        path: '/'
1599                    } );
1600
1601                    //and append the response.
1602                    jq( "#content ul.activity-list" ).append( response.contents );
1603
1604                    //Since the request is complete, let us reset is_activity_loading to false, so we'll be ready to run the routine again.
1605
1606                    is_activity_loading = false;
1607                }, 'json' );
1608
1609                return false;
1610
1611            }
1612        }
1613
1614
1615        /*------------------------------------------------------------------------------------------------------
1616         3.25 BP Profile Search
1617         --------------------------------------------------------------------------------------------------------*/
1618
1619        $( '.page' ).find( '.standard-form' ).each( function () {
1620            var id = $( this ).attr( 'id' );
1621            if ( id && id.indexOf( 'bps_shortcode' ) >= 0 ) {
1622                $( '#' + id ).addClass( 'bps_form' );
1623            }
1624        } );
1625
1626        /*------------------------------------------------------------------------------------------------------
1627         3.26 Add Photo Button
1628         --------------------------------------------------------------------------------------------------------*/
1629
1630        function movePhotoButton() {
1631            if ( is_mobile ) {
1632                if ( $( '#aw-whats-new-submit' ).prev( '#buddyboss-media-add-photo' ).length == 0 ) {
1633                    $( '#buddyboss-media-add-photo' ).insertBefore( '#aw-whats-new-submit' );
1634                }
1635            } else {
1636                if ( $( '#whats-new-additional' ).find( '#buddyboss-media-add-photo' ).length == 0 ) {
1637                    $( '#whats-new-additional' ).append( $( '#buddyboss-media-add-photo' ) );
1638                }
1639            }
1640        }
1641
1642        movePhotoButton();
1643        $window.resize( movePhotoButton );
1644
1645        $( '#buddyboss-media-add-photo-button' ).text( '' );
1646
1647        /*------------------------------------------------------------------------------------------------------
1648         3.27 Activity dropdown
1649         --------------------------------------------------------------------------------------------------------*/
1650        var $span = $( '.item-list-tabs.activity-type-tabs .selected-tab' ),
1651            $ul = $( '.item-list-tabs.activity-type-tabs > ul' ),
1652            $li = $( '.item-list-tabs.activity-type-tabs > ul > li' );
1653
1654        $span.click( function ( e ) {
1655            e.stopPropagation();
1656            $ul.slideToggle();
1657        } );
1658
1659        function cloneText() {
1660            $li.each( function () {
1661                if ( $ul.find( '.selected' ).length == 1 ) {
1662                    if ( $( this ).hasClass( 'selected' ) ) {
1663                        $span.html( $( this ).html() );
1664                    }
1665                } else {
1666                    $span.html( $( '#activity-all' ).html() );
1667                }
1668            } );
1669        }
1670
1671        $( document ).ajaxComplete( function () {
1672            cloneText();
1673        } );
1674
1675        cloneText();
1676
1677        $li.click( function () {
1678            $span.html( $( this ).html() );
1679        } );
1680
1681        /*------------------------------------------------------------------------------------------------------
1682         3.28 - Remove 'Cancel Friendship'
1683         --------------------------------------------------------------------------------------------------------*/
1684        $( '.dir-list div.is_friend' ).remove();
1685
1686        /*------------------------------------------------------------------------------------------------------
1687         3.29 - Mobile header
1688         --------------------------------------------------------------------------------------------------------*/
1689        var mobileHeader = $( '#mobile-header' );
1690
1691        if ( mobileHeader.hasClass( 'with-adminbar' ) ) {
1692            $( window ).scroll( function () {
1693                $fromTop = $( 'body' ).scrollTop();
1694                if ( $fromTop > 46 ) {
1695                    // bc < 600 gives absolute on adminbar
1696                    if ( viewport().width < 600 ) {
1697                        mobileHeader.css( {
1698                            position: 'fixed',
1699                            top: 0
1700                        } );
1701                    } else {
1702                        mobileHeader.css( {
1703                            position: 'fixed',
1704                            top: 46
1705                        } );
1706                    }
1707                } else {
1708                    mobileHeader.css( {
1709                        position: 'static',
1710                        top: 0
1711                    } );
1712                }
1713            } );
1714        }
1715
1716        /*------------------------------------------------------------------------------------------------------
1717         Equal Pricing tables - Membership plugin
1718         --------------------------------------------------------------------------------------------------------*/
1719        /*!
1720         * Simple jQuery Equal Heights
1721         *
1722         * Copyright (c) 2013 Matt Banks
1723         * Dual licensed under the MIT and GPL licenses.
1724         * Uses the same license as jQuery, see:
1725         * http://docs.jquery.com/License
1726         *
1727         * @version 1.5.1
1728         */
1729        !function ( a ) {
1730            a.fn.equalHeights = function () {
1731                var b = 0, c = a( this );
1732                return c.each( function () {
1733                    var c = a( this ).outerHeight();
1734                    c > b && ( b = c )
1735                } ), c.css( "height", b - 34 )
1736            }, a( "[data-equal]" ).each( function () {
1737                var b = a( this ), c = b.data( "equal" );
1738                b.find( c ).equalHeights()
1739            } )
1740        }( jQuery );
1741
1742        if ( $( '#pmpro_levels_pricing_tables' ) ) {
1743            function equalProjects() {
1744                $( '.pricing-content' ).css( 'height', 'auto' );
1745                $( '.pricing-content' ).equalHeights();
1746            }
1747
1748            equalProjects();
1749
1750            /* throttle */
1751            $( window ).resize( function () {
1752                clearTimeout( $.data( this, 'resizeTimer' ) );
1753                $.data( this, 'resizeTimer', setTimeout( function () {
1754                    equalProjects();
1755                }, 50 ) );
1756            } );
1757
1758            $( '#left-menu-toggle' ).click( function () {
1759                setTimeout( function () {
1760                    equalProjects();
1761                }, 550 );
1762            } );
1763
1764            $( window ).trigger( 'resize' );
1765        }
1766
1767        /*------------------------------------------------------------------------------------------------------
1768         Header height
1769         --------------------------------------------------------------------------------------------------------*/
1770        if ( $( 'body' ).hasClass( 'boxed' ) && !is_mobile ) {
1771            function headerHeight() {
1772                var height = $( '#masthead' ).outerHeight();
1773                $( '#right-panel' ).css( {
1774                    'margin-top': height
1775                } );
1776            }
1777
1778            headerHeight();
1779
1780            $window.resize( function () {
1781                headerHeight();
1782            } );
1783        }
1784
1785        /*------------------------------------------------------------------------------------------------------
1786         Double Tap for tablets navigation (boxed layout)
1787         --------------------------------------------------------------------------------------------------------*/
1788        $.fn.doubleTapToGo = function ( params )
1789        {
1790            if ( !( 'ontouchstart' in window ) &&
1791                !navigator.msMaxTouchPoints &&
1792                !navigator.userAgent.toLowerCase().match( /windows phone os 7/i ) )
1793                return false;
1794
1795            this.each( function ()
1796            {
1797                var curItem = false;
1798
1799                $( this ).on( 'click', function ( e )
1800                {
1801                    var item = $( this );
1802                    if ( item[ 0 ] != curItem[ 0 ] )
1803                    {
1804                        e.preventDefault();
1805                        curItem = item;
1806                    }
1807                } );
1808
1809                $( document ).on( 'click touchstart MSPointerDown', function ( e )
1810                {
1811                    var resetItem = true,
1812                        parents = $( e.target ).parents();
1813
1814                    for ( var i = 0; i < parents.length; i++ )
1815                        if ( parents[ i ] == curItem[ 0 ] )
1816                            resetItem = false;
1817
1818                    if ( resetItem )
1819                        curItem = false;
1820                } );
1821            } );
1822            return this;
1823        };
1824
1825        if ( $( 'body' ).hasClass( 'boxed' ) && $( 'body' ).hasClass( 'tablet' ) ) {
1826            $( '#nav-menu > ul > li:has(ul)' ).doubleTapToGo();
1827        }
1828
1829        /*------------------------------------------------------------------------------------------------------
1830         Heartbeat functions
1831         --------------------------------------------------------------------------------------------------------*/
1832
1833        //Notifications related updates
1834        $( document ).on( 'heartbeat-tick.bb_notification_count', function ( event, data ) {
1835            setCounters();
1836
1837            if ( data.hasOwnProperty( 'bb_notification_count' ) ) {
1838                data = data['bb_notification_count'];
1839                /********notification type**********/
1840                if ( data.notification > 0 ) { //has count
1841                    jQuery( "#ab-pending-notifications" ).text( data.notification ).removeClass( "no-alert" );
1842                    jQuery( "#ab-pending-notifications-mobile" ).text( data.notification ).removeClass( "no-alert" );
1843                    jQuery( "#wp-admin-bar-my-account-notifications .ab-item[href*='/notifications/']" ).each( function () {
1844                        jQuery( this ).append( "<span class='count'>" + data.notification + "</span>" );
1845                        if ( jQuery( this ).find( ".count" ).length > 1 ) {
1846                            jQuery( this ).find( ".count" ).first().remove(); //remove the old one.
1847                        }
1848                    } );
1849                } else {
1850                    jQuery( "#ab-pending-notifications" ).text( data.notification ).addClass( "no-alert" );
1851                    jQuery( "#ab-pending-notifications-mobile" ).text( data.notification ).addClass( "no-alert" );
1852                    jQuery( "#wp-admin-bar-my-account-notifications .ab-item[href*='/notifications/']" ).each( function () {
1853                        jQuery( this ).find( ".count" ).remove();
1854                    } );
1855                }
1856                //remove from read ..
1857                jQuery( ".mobile #wp-admin-bar-my-account-notifications-read, #adminbar-links #wp-admin-bar-my-account-notifications-read" ).each( function () {
1858                    $( this ).find( "a" ).find( ".count" ).remove();
1859                } );
1860                /**********messages type************/
1861                if ( data.unread_message > 0 ) { //has count
1862                    jQuery( "#user-messages" ).find( "span" ).html( '<b>' + data.unread_message + '</b>' ).removeClass( "no-alert" );
1863                    jQuery( "#user-messages" ).find( "span" ).text( data.unread_message );
1864                    jQuery( ".ab-item[href*='/messages/']" ).each( function () {
1865                        jQuery( this ).append( "<span class='count'>" + data.unread_message + "</span>" );
1866                        if ( jQuery( this ).find( ".count" ).length > 1 ) {
1867                            jQuery( this ).find( ".count" ).first().remove(); //remove the old one.
1868                        }
1869                    } );
1870                } else {
1871                    jQuery( "#user-messages" ).find( "span" ).html( '<b>' + data.unread_message + '</b>' ).addClass( "no-alert" );
1872                    jQuery( "#user-messages" ).find( "span" ).text( data.unread_message );
1873                    jQuery( ".ab-item[href*='/messages/']" ).each( function () {
1874                        jQuery( this ).find( ".count" ).remove();
1875                    } );
1876                }
1877                //remove from unwanted place ..
1878                jQuery( ".mobile #wp-admin-bar-my-account-messages-default, #adminbar-links #wp-admin-bar-my-account-messages-default" ).find( "li:not('#wp-admin-bar-my-account-messages-inbox')" ).each( function () {
1879                    jQuery( this ).find( "span" ).remove();
1880                } );
1881                /**********messages type************/
1882                if ( data.friend_request > 0 ) { //has count
1883                    jQuery( ".ab-item[href*='/friends/']" ).each( function () {
1884                        jQuery( this ).append( "<span class='count'>" + data.friend_request + "</span>" );
1885                        if ( jQuery( this ).find( ".count" ).length > 1 ) {
1886                            jQuery( this ).find( ".count" ).first().remove(); //remove the old one.
1887                        }
1888                    } );
1889                } else {
1890                    jQuery( ".ab-item[href*='/friends/']" ).each( function () {
1891                        jQuery( this ).find( ".count" ).remove();
1892                    } );
1893                }
1894                //remove from unwanted place ..
1895                jQuery( ".mobile #wp-admin-bar-my-account-friends-default, #adminbar-links #wp-admin-bar-my-account-friends-default" ).find( "li:not('#wp-admin-bar-my-account-friends-requests')" ).each( function () {
1896                    jQuery( this ).find( "span" ).remove();
1897                } );
1898
1899                // notification content
1900				if ( data.notification_content
1901					&& 0 < data.notification_content.length ) {
1902					jQuery( ".header-notifications.all-notifications .pop" ).html( data.notification_content );
1903				}
1904
1905				// messages content
1906				if ( data.message_content
1907					&& 0 < data.message_content.length ) {
1908					jQuery( ".header-notifications.user-messages .pop-links-inner" ).html( data.message_content );
1909				}
1910            }
1911        } );
1912
1913        // Send unread notification and messages count in heartbeat data
1914		$( document ).on( 'heartbeat-send', function( event, data ) {
1915			var unread_notifications = +$('#ab-pending-notifications').text();
1916			var unread_messages = +$('.header-notifications #user-messages > .count').text();
1917			data.unread_notifications = unread_notifications;
1918			data.unread_messages = unread_messages;
1919		} );
1920
1921	}
1922
1923    /**
1924     * BuddyPress Legacy Support
1925     */
1926
1927    // Initialize
1928    BP_Legacy.init = function () {
1929        BP_Legacy.injected = false;
1930        _l.$document.ready( BP_Legacy.domReady );
1931    }
1932
1933    // On dom ready we'll check if we need legacy BP support
1934    BP_Legacy.domReady = function () {
1935        BP_Legacy.check();
1936    }
1937
1938    // Check for legacy support
1939    BP_Legacy.check = function () {
1940        if ( !BP_Legacy.injected && _l.body.hasClass( 'buddypress' ) && _l.$buddypress.length == 0 ) {
1941            BP_Legacy.inject();
1942        }
1943    }
1944
1945    /*================================================================================================
1946     ** Cover Photo Functions **
1947     ==================================================================================================*/
1948
1949    buddyboss_cover_photo = function ( option ) {
1950
1951        $bb_cover_photo = $( "#page .bb-cover-photo:last" );
1952        object = $bb_cover_photo.data( "obj" ); // user or group
1953        object_id = $bb_cover_photo.data( "objid" ); // id of user or group
1954        nonce = $bb_cover_photo.data( "nonce" );
1955        $refresh_button = $( "#refresh-cover-photo-btn" );
1956
1957        rebind_refresh_cover_events = function () {
1958            $refresh_button.click( function () {
1959                $( '.bb-cover-photo #growls' ).remove();
1960                $( "#update-cover-photo-btn" ).prop( "disabled", true ).removeClass( 'uploaded' ).addClass( 'disabled' ).find( "i" ).fadeIn();
1961                $refresh_button.prop( "disabled", true ).removeClass( 'uploaded' ).addClass( 'disabled' ).find( "i" ).fadeIn();
1962
1963                $.ajax( {
1964                    type: "POST",
1965                    url: ajaxurl,
1966                    data: {
1967                        'action': 'buddyboss_cover_photo_refresh',
1968                        'object': object,
1969                        'object_id': object_id,
1970                        'nonce': option.nonce,
1971                        'routine': $refresh_button.data( 'routine' )
1972                    },
1973                    success: function ( response ) {
1974                        var responseJSON = $.parseJSON( response );
1975
1976                        $( "#update-cover-photo-btn" ).prop( "disabled", false ).removeClass( 'disabled' ).addClass( 'uploaded' ).find( "i.fa-spin" ).fadeOut();
1977                        $refresh_button.prop( "disabled", false ).removeClass( 'disabled' ).addClass( 'uploaded' ).find( "i.fa-spin" ).fadeOut();
1978
1979                        if ( !responseJSON ) {
1980                            $.growl.error( { title: "", message: BuddyBossOptions.bb_cover_photo_failed_refresh } );
1981                        }
1982
1983                        if ( responseJSON.error ) {
1984                            $.growl.error( { title: "", message: responseJSON.error } );
1985                        } else {
1986                            $bb_cover_photo.find( ".holder" ).remove();
1987
1988                            image = responseJSON.image;
1989                            $bb_cover_photo.append( '<div class="holder"></div>' );
1990                            $bb_cover_photo.find( ".holder" ).css( "background-image", 'url(' + image + ')' );
1991
1992                            if ( 'refresh' == $refresh_button.data( 'routine' ) ) {
1993                                $refresh_button.parent().toggleClass( 'no-photo' );
1994                                $refresh_button.find( '.fa-refresh' ).removeClass( 'fa-refresh' ).addClass( 'fa-times' );
1995                                $refresh_button.find( '>div' ).html( BuddyBossOptions.bb_cover_photo_remove_title + '<i class="fa fa-spinner fa-spin" style="display: none;"></i>' );
1996                                $refresh_button.attr( 'title', BuddyBossOptions.bb_cover_photo_remove_title );
1997                                $refresh_button.data( 'routine', 'remove' );
1998                            } else {
1999                                $refresh_button.parent().toggleClass( 'no-photo' );
2000                                $refresh_button.find( '.fa-times' ).removeClass( 'fa-times' ).addClass( 'fa-refresh' );
2001                                $refresh_button.find( '>div' ).html( BuddyBossOptions.bb_cover_photo_refresh_title + '<i class="fa fa-spinner fa-spin" style="display: none;"></i>' );
2002                                $refresh_button.attr( 'title', BuddyBossOptions.bb_cover_photo_refresh_title );
2003                                $refresh_button.data( 'routine', 'refresh' );
2004                            }
2005                            $.growl.notice( { title: "", message: responseJSON.success } );
2006                        }
2007                    },
2008                    error: function ( ) {
2009                        $bb_cover_photo.find( ".progress" ).hide().find( "span" ).css( "width", '0%' );
2010
2011                        $.growl.error( { message: 'Error' } );
2012                    }
2013                } );
2014            } );
2015        };
2016
2017        if ( $refresh_button.length > 0 ) {
2018            rebind_refresh_cover_events();
2019        }
2020    }
2021
2022    /** --------------------------------------------------------------- */
2023
2024    /**
2025     * BuddyPress Legacy Support
2026     */
2027
2028    // Initialize
2029    BP_Legacy.init = function () {
2030        BP_Legacy.injected = false;
2031        _l.$document.ready( BP_Legacy.domReady );
2032    }
2033
2034    // On dom ready we'll check if we need legacy BP support
2035    BP_Legacy.domReady = function () {
2036        BP_Legacy.check();
2037    }
2038
2039    // Check for legacy support
2040    BP_Legacy.check = function () {
2041        if ( !BP_Legacy.injected && _l.body.hasClass( 'buddypress' ) && _l.$buddypress.length == 0 ) {
2042            BP_Legacy.inject();
2043        }
2044    }
2045
2046    // Inject the right code depending on what kind of legacy support
2047    // we deduce we need
2048    BP_Legacy.inject = function () {
2049        BP_Legacy.injected = true;
2050
2051        var $secondary = $( '#secondary' ),
2052            do_legacy = false;
2053
2054        var $content = $( '#content' ),
2055            $padder = $content.find( '.padder' ).first(),
2056            do_legacy = false;
2057
2058        var $article = $content.children( 'article' ).first();
2059
2060        var $legacy_page_title,
2061            $legacy_item_header;
2062
2063        // Check if we're using the #secondary widget area and add .bp-legacy inside that
2064        if ( $secondary.length ) {
2065            $secondary.prop( 'id', 'secondary' ).addClass( 'bp-legacy' );
2066
2067            do_legacy = true;
2068        }
2069
2070        // Check if the plugin is using the #content wrapper and add #buddypress inside that
2071        if ( $padder.length ) {
2072            $padder.prop( 'id', 'buddypress' ).addClass( 'bp-legacy entry-content' );
2073
2074            do_legacy = true;
2075
2076            // console.log( 'Buddypress.js #buddypress fix: Adding #buddypress to .padder' );
2077        }
2078        else if ( $content.length ) {
2079            $content.wrapInner( '<div class="bp-legacy entry-content" id="buddypress"/>' );
2080
2081            do_legacy = true;
2082
2083            // console.log( 'Buddypress.js #buddypress fix: Dynamically wrapping with #buddypresss' );
2084        }
2085
2086        // Apply legacy styles if needed
2087        if ( do_legacy ) {
2088
2089            _l.$buddypress = $( '#buddypress' );
2090
2091            $legacy_page_title = $( '.buddyboss-bp-legacy.page-title' );
2092            $legacy_item_header = $( '.buddyboss-bp-legacy.item-header' );
2093
2094            // Article Element
2095            if ( $article.length === 0 ) {
2096                $content.wrapInner( '<article/>' );
2097                $article = $( $content.find( 'article' ).first() );
2098            }
2099
2100            // Page Title
2101            if ( $content.find( '.entry-header' ).length === 0 || $content.find( '.entry-title' ).length === 0 ) {
2102                $legacy_page_title.prependTo( $article ).show();
2103                $legacy_page_title.children().unwrap();
2104            }
2105
2106            // Item Header
2107            if ( $content.find( '#item-header-avatar' ).length === 0 && _l.$buddypress.find( '#item-header' ).length ) {
2108                $legacy_item_header.prependTo( _l.$buddypress.find( '#item-header' ) ).show();
2109                $legacy_item_header.children().unwrap();
2110            }
2111        }
2112    }
2113
2114    // Inject the right code depending on what kind of legacy support
2115    // we deduce we need
2116    BP_Legacy.inject = function () {
2117        BP_Legacy.injected = true;
2118
2119        var $secondary = $( '#secondary' ),
2120            do_legacy = false;
2121
2122        var $content = $( '#content' ),
2123            $padder = $content.find( '.padder' ).first(),
2124            do_legacy = false;
2125
2126        var $article = $content.children( 'article' ).first();
2127
2128        var $legacy_page_title,
2129            $legacy_item_header;
2130
2131        // Check if we're using the #secondary widget area and add .bp-legacy inside that
2132        if ( $secondary.length ) {
2133            $secondary.prop( 'id', 'secondary' ).addClass( 'bp-legacy' );
2134
2135            do_legacy = true;
2136        }
2137
2138        // Check if the plugin is using the #content wrapper and add #buddypress inside that
2139        if ( $padder.length ) {
2140            $padder.prop( 'id', 'buddypress' ).addClass( 'bp-legacy entry-content' );
2141
2142            do_legacy = true;
2143
2144            // console.log( 'Buddypress.js #buddypress fix: Adding #buddypress to .padder' );
2145        }
2146        else if ( $content.length ) {
2147            $content.wrapInner( '<div class="bp-legacy entry-content" id="buddypress"/>' );
2148
2149            do_legacy = true;
2150
2151            // console.log( 'Buddypress.js #buddypress fix: Dynamically wrapping with #buddypresss' );
2152        }
2153
2154        // Apply legacy styles if needed
2155        if ( do_legacy ) {
2156
2157            _l.$buddypress = $( '#buddypress' );
2158
2159            $legacy_page_title = $( '.buddyboss-bp-legacy.page-title' );
2160            $legacy_item_header = $( '.buddyboss-bp-legacy.item-header' );
2161
2162            // Article Element
2163            if ( $article.length === 0 ) {
2164                $content.wrapInner( '<article/>' );
2165                $article = $( $content.find( 'article' ).first() );
2166            }
2167
2168            // Page Title
2169            if ( $content.find( '.entry-header' ).length === 0 || $content.find( '.entry-title' ).length === 0 ) {
2170                $legacy_page_title.prependTo( $article ).show();
2171                $legacy_page_title.children().unwrap();
2172            }
2173
2174            // Item Header
2175            if ( $content.find( '#item-header-avatar' ).length === 0 && _l.$buddypress.find( '#item-header' ).length ) {
2176                $legacy_item_header.prependTo( _l.$buddypress.find( '#item-header' ) ).show();
2177                $legacy_item_header.children().unwrap();
2178            }
2179        }
2180    }
2181
2182    // Boot er' up
2183    jQuery( document ).ready( function () {
2184        App.init();
2185    } );
2186
2187}( jQuery, window ) );
2188
2189/**
2190 * 3. Inline Plugins
2191 * ====================================================================
2192 * Inline Plugins
2193 */
2194
2195
2196/**
2197 * jRMenuMore to allow menu to have a More option for responsiveness
2198 * Credit to http://blog.sodhanalibrary.com/2014/02/jrmenumore-jquery-plugin-for-responsive.html
2199 *
2200 * uses resize.js for better resizing
2201 *
2202 **/
2203( function ( $ ) {
2204    $.fn.jRMenuMore = function ( widthfix ) {
2205        $( this ).each( function () {
2206            $( this ).addClass( "horizontal-responsive-menu" );
2207            alignMenu( this );
2208            var robj = this;
2209
2210            $( '#right-panel-inner' ).resize( function () {
2211                $( robj ).append( $( $( $( robj ).children( "li.hideshow" ) ).children( "ul" ) ).html() );
2212                $( robj ).children( "li.hideshow" ).remove();
2213                alignMenu( robj );
2214            } );
2215
2216            function alignMenu( obj ) {
2217                var w = 0;
2218                var mw = $( obj ).width() - widthfix;
2219                var i = -1;
2220                var menuhtml = '';
2221                jQuery.each( $( obj ).children(), function () {
2222                    i++;
2223                    w += $( this ).outerWidth( true );
2224                    if ( mw < w ) {
2225                        menuhtml += $( '<div>' ).append( $( this ).clone() ).html();
2226                        $( this ).remove();
2227                    }
2228                } );
2229
2230                $( obj ).append(
2231                    '<li class="hideshow">' +
2232                    '<a href="#"><i class="fa fa-ellipsis-h"></i></a><ul>' +
2233                    menuhtml + '</ul></li>' );
2234                $( obj ).children( "li.hideshow ul" ).css( "top",
2235                    $( obj ).children( "li.hideshow" ).outerHeight( true ) + "px" );
2236
2237                $( obj ).find( "li.hideshow > a" ).click( function ( e ) {
2238                    e.preventDefault();
2239                    var $horizontal_menu_ul = $( this ).parent( 'li.hideshow' ).children( "ul" );
2240                    $horizontal_menu_ul.toggle();
2241                    $( this ).parent( 'li.hideshow' ).parent( "ul" ).toggleClass( 'open' );
2242
2243                    //Members Index > Too many member types
2244                    var $members_type_menu = $( '#members-directory-form div.item-list-tabs ul:first-child' );
2245
2246                    if ( 0 < $members_type_menu.length ) {
2247
2248                        //Change horizontal menu display from flex to block for member types tab
2249                        if ( $horizontal_menu_ul.is( ':visible' ) ) {
2250                            $horizontal_menu_ul.css( 'display', 'block' );
2251                        } else {
2252                            $horizontal_menu_ul.css( 'display', 'none' );
2253                        }
2254
2255                        //Horizontal responsive menu right offset fix
2256                        var $horizontal_menu = $( 'div.item-list-tabs .horizontal-responsive-menu' );
2257                        var right_offset = ( $( window ).width() - ( $horizontal_menu.offset().left + $horizontal_menu.outerWidth() ) );
2258                        $( 'div.item-list-tabs li.hideshow > ul' ).css( { right: right_offset } );
2259                    }
2260
2261                } );
2262
2263                $( document ).mouseup( function ( e ) {
2264                    var container = $( 'li.hideshow' );
2265
2266                    if ( !container.is( e.target ) && container.has( e.target ).length === 0 ) {
2267                        container.children( "ul" ).hide();
2268                        container.parent( "ul" ).removeClass( 'open' );
2269                    }
2270                } );
2271
2272                if ( $( obj ).find( "li.hideshow" ).find( "li" ).length > 0 ) {
2273                    $( obj ).find( "li.hideshow" ).show();
2274                } else {
2275                    $( obj ).find( "li.hideshow" ).hide();
2276                }
2277            }
2278
2279        } );
2280
2281    }
2282
2283}( jQuery ) );
2284
2285/* Support some plugins */
2286
2287( function ( $ ) {
2288
2289    "use strict";
2290
2291    window.Plugins = {
2292        init: function () {
2293            this.groupHierarchy();
2294            this.hideActionWrap();
2295            this.onAjaxComplete();
2296            this.fixQuizScroll();
2297        },
2298        groupHierarchy: function () {
2299            $( 'body' ).on( 'click', '.item-subitem-indicator a', function () {
2300                $( this ).parent().toggleClass( 'bb-subitem-open' );
2301            } );
2302        },
2303        onAjaxComplete: function () {
2304            $( document ).ajaxComplete( function () {
2305                $( '.directory.groups #primary #buddypress .item-list li .action .action-wrap' ).each( function () {
2306                    var elem = $( this );
2307                    if ( $.trim( elem.html() ) === '' ) {
2308                        if ( !elem.parent().hasClass( "bb-hide-elem" ) ) {
2309                            elem.parent().addClass( 'bb-hide-elem' );
2310                        }
2311                    }
2312                } );
2313            } );
2314        },
2315        hideActionWrap: function () {
2316            $( '.directory.groups #primary #buddypress .item-list li .action .action-wrap' ).each( function () {
2317                var elem = $( this );
2318                if ( $.trim( elem.html() ) === '' ) {
2319                    if ( !elem.parent().hasClass( "bb-hide-elem" ) ) {
2320                        elem.parent().addClass( 'bb-hide-elem' );
2321                    }
2322                }
2323            } );
2324        },
2325        fixQuizScroll: function() {
2326            if ($('.wpProQuiz_matrixSortString').length > 0) {
2327                $('html').addClass('quiz-sort');
2328            }
2329        }
2330    };
2331
2332    $( document ).on( 'ready', function () {
2333        Plugins.init();
2334    } );
2335
2336} )( jQuery );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.