Skip to:
Content

BuddyPress.org

Changeset 7385


Ignore:
Timestamp:
09/17/2013 05:24:20 PM (11 years ago)
Author:
r-a-y
Message:

Tweak JS when joining or leaving a group from the groups directory.

This commit does the following:

  • When leaving a hidden group, it removes the hidden group from the group loop.
  • Increases or decreases the "My Groups" count if you join or leave a group.

Props imath for the initial patch.

See #5077.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r7195 r7385  
    10321032            var parentdiv = thelink.parent();
    10331033
    1034             if ( !jq('body.directory').length )
     1034            // user groups page
     1035            if ( ! jq('body.directory').length ) {
    10351036                location.href = location.href;
    1036             else {
     1037
     1038            // groups directory
     1039            } else {
    10371040                jq(parentdiv).fadeOut(200,
    10381041                    function() {
    10391042                        parentdiv.fadeIn(200).html(response);
     1043
     1044                        var mygroups = jq('#groups-personal span');
     1045                        var add      = 1;
     1046
     1047                        if( thelink.hasClass( 'leave-group' ) ) {
     1048                            // hidden groups slide up
     1049                            if ( parentdiv.hasClass( 'hidden' ) ) {
     1050                                parentdiv.closest('li').slideUp( 200 );
     1051                            }
     1052
     1053                            add = 0;
     1054                        } else if ( thelink.hasClass( 'request-membership' ) ) {
     1055                            add = false;
     1056                        }
     1057
     1058                        // change the "My Groups" value
     1059                        if ( mygroups.length && add !== false ) {
     1060                            if ( add ) {
     1061                                mygroups.text( ( mygroups.text() >> 0 ) + 1 );
     1062                            } else {
     1063                                mygroups.text( ( mygroups.text() >> 0 ) - 1 );
     1064                            }
     1065                        }
     1066
    10401067                    }
    1041                     );
     1068                );
    10421069            }
    10431070        });
  • trunk/bp-themes/bp-default/_inc/global.js

    r7252 r7385  
    10161016            var parentdiv = thelink.parent();
    10171017
    1018             if ( !jq('body.directory').length )
     1018            // user groups page
     1019            if ( ! jq('body.directory').length ) {
    10191020                location.href = location.href;
    1020             else {
     1021
     1022            // groups directory
     1023            } else {
    10211024                jq(parentdiv).fadeOut(200,
    10221025                    function() {
    10231026                        parentdiv.fadeIn(200).html(response);
     1027
     1028                        var mygroups = jq('#groups-personal span');
     1029                        var add      = 1;
     1030
     1031                        if( thelink.hasClass( 'leave-group' ) ) {
     1032                            // hidden groups slide up
     1033                            if ( parentdiv.hasClass( 'hidden' ) ) {
     1034                                parentdiv.closest('li').slideUp( 200 );
     1035                            }
     1036
     1037                            add = 0;
     1038                        } else if ( thelink.hasClass( 'request-membership' ) ) {
     1039                            add = false;
     1040                        }
     1041
     1042                        // change the "My Groups" value
     1043                        if ( add !== false && mygroups.length ) {
     1044                            if ( add ) {
     1045                                mygroups.text( ( mygroups.text() >> 0 ) + 1 );
     1046                            } else {
     1047                                mygroups.text( ( mygroups.text() >> 0 ) - 1 );
     1048                            }
     1049                        }
     1050
    10241051                    }
    1025                     );
     1052                );
    10261053            }
    10271054        });
Note: See TracChangeset for help on using the changeset viewer.