Skip to:
Content

BuddyPress.org

Ticket #8214: 8214.patch

File 8214.patch, 14.2 KB (added by passoniate, 3 years ago)

Patch

  • src/bp-templates/bp-nouveau/js/buddypress-nouveau.js

     
    77
    88( function( exports, $ ) {
    99
    10         // Bail if not set
     10        // Bail if not set.
    1111        if ( typeof BP_Nouveau === 'undefined' ) {
    1212                return;
    1313        }
     
    2323                 */
    2424                start: function() {
    2525
    26                         // Setup globals
     26                        // Setup globals.
    2727                        this.setupGlobals();
    2828
    29                         // Adjust Document/Forms properties
     29                        // Adjust Document/Forms properties.
    3030                        this.prepareDocument();
    3131
    32                         // Init the BuddyPress objects
     32                        // Init the BuddyPress objects.
    3333                        this.initObjects();
    3434
    35                         // Set BuddyPress HeartBeat
     35                        // Set BuddyPress HeartBeat.
    3636                        this.setHeartBeat();
    3737
    38                         // Listen to events ("Add hooks!")
     38                        // Listen to events ("Add hooks!").
    3939                        this.addListeners();
    4040                },
    4141
     
    4646                setupGlobals: function() {
    4747                        this.ajax_request           = null;
    4848
    49                         // Object Globals
     49                        // Object Globals.
    5050                        this.objects                = $.map( BP_Nouveau.objects, function( value ) { return value; } );
    5151                        this.objectNavParent        = BP_Nouveau.object_nav_parent;
    5252
    53                         // HeartBeat Global
     53                        // HeartBeat Global.
    5454                        this.heartbeat              = wp.heartbeat || {};
    5555
    56                         // An object containing each query var
     56                        // An object containing each query var.
    5757                        this.querystring            = this.getLinkParams();
    5858                },
    5959
     
    6363                 */
    6464                prepareDocument: function() {
    6565
    66                         // Remove the no-js class and add the js one
     66                        // Remove the no-js class and add the js one.
    6767                        if ( $( 'body' ).hasClass( 'no-js' ) ) {
    6868                                $('body').removeClass( 'no-js' ).addClass( 'js' );
    6969                        }
    7070
    71                         // Log Warnings into the console instead of the screen
     71                        // Log Warnings into the console instead of the screen.
    7272                        if ( BP_Nouveau.warnings && 'undefined' !== typeof console && console.warn ) {
    7373                                $.each( BP_Nouveau.warnings, function( w, warning ) {
    7474                                        console.warn( warning );
     
    7575                                } );
    7676                        }
    7777
    78                         // Remove the directory title if there's a widget containing it
     78                        // Remove the directory title if there's a widget containing it.
    7979                        if ( $( '.buddypress_object_nav .widget-title' ).length ) {
    8080                                var text = $( '.buddypress_object_nav .widget-title' ).html();
    8181
     
    123123                        if ( undefined === value && undefined !== store[ property ] ) {
    124124                                delete store[ property ];
    125125                        } else {
    126                                 // Set property
     126                                // Set property.
    127127                                store[ property ] = value;
    128128                        }
    129129
     
    165165                 * URL Decode a query variable.
    166166                 *
    167167                 * @param  {string} qv    The query variable to decode.
    168                  * @param  {object} chars The specific characters to use. Optionnal.
     168                 * @param  {object} chars The specific characters to use. Optional.
    169169                 * @return {string}       The URL decoded variable.
    170170                 */
    171171                urlDecode: function( qv, chars ) {
     
    193193                                this.ajax_request.abort();
    194194                        }
    195195
    196                         // Extend posted data with stored data and object nonce
     196                        // Extend posted data with stored data and object nonce.
    197197                        var postData = $.extend( {}, bp.Nouveau.getStorage( 'bp-' + object ), { nonce: BP_Nouveau.nonces[object] }, post_data );
    198198
    199199                        if ( undefined !== BP_Nouveau.customizer_settings ) {
     
    254254                                method       : 'reset'
    255255                        }, data );
    256256
    257                         // Do not request if we don't have the object or the target to inject results into
     257                        // Do not request if we don't have the object or the target to inject results into.
    258258                        if ( ! data.object || ! data.target ) {
    259259                                return;
    260260                        }
    261261
    262                         // Prepare the search terms for the request
     262                        // Prepare the search terms for the request.
    263263                        if ( data.search_terms ) {
    264264                                data.search_terms = data.search_terms.replace( /</g, '&lt;' ).replace( />/g, '&gt;' );
    265265                        }
    266266
    267                         // Set session's data
     267                        // Set session's data.
    268268                        if ( null !== data.scope ) {
    269269                                this.setStorage( 'bp-' + data.object, 'scope', data.scope );
    270270                        }
     
    352352                                        scope = objectData.scope;
    353353                                }
    354354
    355                                 // Notifications always need to start with Newest ones
     355                                // Notifications always need to start with Newest ones.
    356356                                if ( undefined !== objectData.extras && 'notifications' !== object ) {
    357357                                        extras = objectData.extras;
    358358                                }
     
    374374                                        $( this.objectNavParent + ' [data-bp-scope="' + object + '"], #object-nav li.current' ).addClass( 'selected' );
    375375                                }
    376376
    377                                 // Check the querystring to eventually include the search terms
     377                                // Check the querystring to eventually include the search terms.
    378378                                if ( null !== self.querystring ) {
    379379                                        if ( undefined !== self.querystring[ object + '_search'] ) {
    380380                                                search_terms = self.querystring[ object + '_search'];
     
    397397                                                extras       : extras
    398398                                        };
    399399
    400                                         // Populate the object list
     400                                        // Populate the object list.
    401401                                        self.objectRequest( queryData );
    402402                                }
    403403                        } );
     
    413413
    414414                        this.heartbeat.interval( Number( BP_Nouveau.pulse ) );
    415415
    416                         // Extend "send" with BuddyPress namespace
     416                        // Extend "send" with BuddyPress namespace.
    417417                        $.fn.extend( {
    418418                                'heartbeat-send': function() {
    419419                                        return this.bind( 'heartbeat-send.buddypress' );
     
    420420                                }
    421421                        } );
    422422
    423                         // Extend "tick" with BuddyPress namespace
     423                        // Extend "tick" with BuddyPress namespace.
    424424                        $.fn.extend( {
    425425                                'heartbeat-tick': function() {
    426426                                        return this.bind( 'heartbeat-tick.buddypress' );
     
    434434                 * [addListeners description]
    435435                 */
    436436                addListeners: function() {
    437                         // Disabled inputs
     437                        // Disabled inputs.
    438438                        $( '[data-bp-disable-input]' ).on( 'change', this.toggleDisabledInput );
    439439
    440                         // HeartBeat Send and Receive
     440                        // HeartBeat Send and Receive.
    441441                        $( document ).on( 'heartbeat-send.buddypress', this.heartbeatSend );
    442442                        $( document ).on( 'heartbeat-tick.buddypress', this.heartbeatTick );
    443443
    444                         // Refreshing
     444                        // Refreshing.
    445445                        $( this.objectNavParent + ' .bp-navs' ).on( 'click', 'a', this, this.scopeQuery );
    446446
    447                         // Filtering
     447                        // Filtering.
    448448                        $( '#buddypress [data-bp-filter]' ).on( 'change', this, this.filterQuery );
    449449
    450                         // Searching
     450                        // Searching.
    451451                        $( '#buddypress [data-bp-search]' ).on( 'submit', 'form', this, this.searchQuery );
    452452                        $( '#buddypress [data-bp-search] form' ).on( 'search', 'input[type=search]', this.resetSearch );
    453453
    454                         // Buttons
     454                        // Buttons.
    455455                        $( '#buddypress [data-bp-list], #buddypress #item-header' ).on( 'click', '[data-bp-btn-action]', this, this.buttonAction );
    456456
    457                         // Close notice
     457                        // Close notice.
    458458                        $( '#buddypress [data-bp-close]' ).on( 'click', this, this.closeNotice );
    459459
    460                         // Pagination
     460                        // Pagination.
    461461                        $( '#buddypress [data-bp-list]' ).on( 'click', '[data-bp-pagination] a', this, this.paginateAction );
    462462                },
    463463
     
    494494                 * @return {[type]}       [description]
    495495                 */
    496496                heartbeatSend: function( event, data ) {
    497                         // Add an heartbeat send event to possibly any BuddyPress pages
     497                        // Add an heartbeat send event to possibly any BuddyPress pages.
    498498                        $( '#buddypress' ).trigger( 'bp_heartbeat_send', data );
    499499                },
    500500
     
    505505                 * @return {[type]}       [description]
    506506                 */
    507507                heartbeatTick: function( event, data ) {
    508                         // Add an heartbeat send event to possibly any BuddyPress pages
     508                        // Add an heartbeat send event to possibly any BuddyPress pages.
    509509                        $( '#buddypress' ).trigger( 'bp_heartbeat_tick', data );
    510510                },
    511511
     
    529529                                return event;
    530530                        }
    531531
    532                         // Stop event propagation
     532                        // Stop event propagation.
    533533                        event.preventDefault();
    534534
    535535                        filter = $( '#buddypress' ).find( '[data-bp-filter="' + object + '"]' ).first().val();
     
    538538                                search_terms = $( '#buddypress [data-bp-search="' + object + '"] input[type=search]' ).val();
    539539                        }
    540540
    541                         // Remove the New count on dynamic tabs
     541                        // Remove the New count on dynamic tabs.
    542542                        if ( target.hasClass( 'dynamic' ) ) {
    543543                                target.find( 'a span' ).html('');
    544544                        }
     
    596596                                return event;
    597597                        }
    598598
    599                         // Stop event propagation
     599                        // Stop event propagation.
    600600                        event.preventDefault();
    601601
    602602                        object       = $( event.delegateTarget ).data( 'bp-search' );
     
    652652                                item = target.closest( '[data-bp-item-id]' ), item_id = item.data( 'bp-item-id' ), item_inner = target.closest('.list-wrap'),
    653653                                object = item.data( 'bp-item-component' ), nonce = '';
    654654
    655                         // Simply let the event fire if we don't have needed values
     655                        // Simply let the event fire if we don't have needed values.
    656656                        if ( ! action || ! item_id || ! object ) {
    657657                                return event;
    658658                        }
    659659
    660                         // Stop event propagation
     660                        // Stop event propagation.
    661661                        event.preventDefault();
    662662
    663663                        if ( ( undefined !== BP_Nouveau[ action + '_confirm'] && false === window.confirm( BP_Nouveau[ action + '_confirm'] ) ) || target.hasClass( 'pending' ) ) {
     
    690690                                object = 'friends';
    691691                        }
    692692
    693                         // Add a pending class to prevent queries while we're processing the action
     693                        // Add a pending class to prevent queries while we're processing the action.
    694694                        target.addClass( 'pending loading' );
    695695
    696696                        self.ajax( {
     
    703703                                        target.removeClass( 'pending loading' );
    704704                                        item.find( '.bp-feedback' ).fadeOut( 6000 );
    705705                                } else {
    706                                         // Specific cases for groups
     706                                        // Specific cases for groups.
    707707                                        if ( 'groups' === object ) {
    708708
    709                                                 // Group's header button
     709                                                // Group's header button.
    710710                                                if ( undefined !== response.data.is_group && response.data.is_group ) {
    711711                                                        return window.location.reload();
    712712                                                }
    713713                                        }
    714714
    715                                         // User's groups invitations screen & User's friend screens
     715                                        // User's groups invitations screen & User's friend screens.
    716716                                        if ( undefined !== response.data.is_user && response.data.is_user ) {
    717717                                                target.parent().html( response.data.feedback );
    718718                                                item.fadeOut( 1500 );
     
    719719                                                return;
    720720                                        }
    721721
    722                                         // Update count
     722                                        // Update count.
    723723                                        if ( $( self.objectNavParent + ' [data-bp-scope="personal"]' ).length ) {
    724724                                                var personal_count = Number( $( self.objectNavParent + ' [data-bp-scope="personal"] span' ).html() ) || 0;
    725725
     
    751751
    752752                        event.preventDefault();
    753753
    754                         // Make sure cookies are removed
     754                        // Make sure cookies are removed.
    755755                        if ( 'clear' === closeBtn.data( 'bp-close' ) ) {
    756756                                if ( undefined !== $.cookie( 'bp-message' ) ) {
    757757                                        $.removeCookie( 'bp-message' );
     
    770770                                }, 'messages' );
    771771                        }
    772772
    773                         // Remove the notice
     773                        // Remove the notice.
    774774                        closeBtn.closest( '.bp-feedback' ).remove();
    775775                },
    776776
     
    788788
    789789                        object = $( event.delegateTarget ).data( 'bp-list' ) || null;
    790790
    791                         // Set the scope & filter
     791                        // Set the scope & filter.
    792792                        if ( null !== object ) {
    793793                                objectData = self.getStorage( 'bp-' + object );
    794794
     
    805805                                }
    806806                        }
    807807
    808                         // Set the search terms
     808                        // Set the search terms.
    809809                        if ( $( '#buddypress [data-bp-search="' + object + '"] input[type=search]' ).length ) {
    810810                                search_terms = $( '#buddypress [data-bp-search="' + object + '"] input[type=search]' ).val();
    811811                        }
     
    819819                                page         : self.getLinkParams( navLink.prop( 'href' ), pagArg ) || 1
    820820                        };
    821821
    822                         // Request the page
     822                        // Request the page.
    823823                        self.objectRequest( queryData );
    824824                }
    825825        };
    826826
    827         // Launch BP Nouveau
     827        // Launch BP Nouveau.
    828828        bp.Nouveau.start();
    829829
    830830} )( bp, jQuery );
  • src/bp-templates/bp-nouveau/js/buddypress-xprofile.js

     
    44
    55( function( exports, $ ) {
    66
    7         // Bail if not set
     7        // Bail if not set.
    88        if ( typeof BP_Nouveau === 'undefined' ) {
    99                return;
    1010        }
     
    1717
    1818        /** Profile Visibility Settings *********************************/
    1919
    20         // Initially hide the 'field-visibility-settings' block
     20        // Initially hide the 'field-visibility-settings' block.
    2121        $( '.field-visibility-settings' ).addClass( 'bp-hide' );
    22         // Add initial aria state to button
     22        // Add initial aria state to button.
    2323        $( '.visibility-toggle-link' ).attr( 'aria-expanded', 'false' );
    2424
    2525        $( '.visibility-toggle-link' ).on( 'click', function( event ) {
  • src/bp-templates/bp-nouveau/js/customizer.js

     
    1212                var groupFrontPage = wp.customize.control( 'group_front_page' ),
    1313                    userFrontPage  = wp.customize.control( 'user_front_page' );
    1414
    15                 // If the Main Group setting is disabled, hide all others
     15                // If the Main Group setting is disabled, hide all others.
    1616                if ( 'undefined' !== typeof groupFrontPage ) {
    1717                        $( groupFrontPage.selector ).on( 'click', 'input[type=checkbox]', function( event ) {
    1818                                var checked = $( event.currentTarget ).prop( 'checked' ), controller = $( event.delegateTarget ).prop( 'id' );
     
    2929                        } );
    3030                }
    3131
    32                 // If the Main User setting is disabled, hide all others
     32                // If the Main User setting is disabled, hide all others.
    3333                if ( 'undefined' !== typeof userFrontPage ) {
    3434                        $( userFrontPage.selector ).on( 'click', 'input[type=checkbox]', function( event ) {
    3535                                var checked = $( event.currentTarget ).prop( 'checked' ), controller = $( event.delegateTarget ).prop( 'id' );
  • src/bp-templates/bp-nouveau/js/password-verify.js

     
    1414                    pass2 = $( '.password-entry-confirm' ).val(),
    1515                    strength;
    1616
    17                 // Reset classes and result text
     17                // Reset classes and result text.
    1818                $( '#pass-strength-result' ).removeClass( 'show mismatch short bad good strong' );
    1919                if ( ! pass1 ) {
    2020                        $( '#pass-strength-result' ).html( pwsL10n.empty );
     
    4242                }
    4343        }
    4444
    45         // Bind check_pass_strength to keyup events in the password fields
     45        // Bind check_pass_strength to keyup events in the password fields.
    4646        $( document ).ready( function() {
    4747                $( '.password-entry' ).val( '' ).keyup( check_pass_strength );
    4848                $( '.password-entry-confirm' ).val( '' ).keyup( check_pass_strength );