Skip to:
Content

BuddyPress.org

Ticket #5061: leave-group-confirmation.patch

File leave-group-confirmation.patch, 3.5 KB (added by dcavins, 13 years ago)

Adds confirmation dialog to leave-group action

  • bp-templates/bp-legacy/buddypress-functions.php

    diff --git bp-templates/bp-legacy/buddypress-functions.php bp-templates/bp-legacy/buddypress-functions.php
    index 13b407b..e368c01 100644
    class BP_Legacy extends BP_Theme_Compat { 
    238238                        'mark_as_fav'       => __( 'Favorite', 'buddypress' ),
    239239                        'remove_fav'        => __( 'Remove Favorite', 'buddypress' ),
    240240                        'unsaved_changes'   => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ),
     241                        'leave_group_confirm'   => __( 'Are you sure you want to leave this group?', 'buddypress' ),
    241242                );
    242243                wp_localize_script( $asset['handle'], 'BP_DTheme', $params );
    243244
  • bp-templates/bp-legacy/js/buddypress.js

    diff --git bp-templates/bp-legacy/js/buddypress.js bp-templates/bp-legacy/js/buddypress.js
    index 1109940..dc2359d 100644
    jq(document).ready( function() { 
    10211021
    10221022                var thelink = jq(this);
    10231023
     1024                //If leaving a group, ask user to confirm before processing the request
     1025                if ( jq(this).hasClass('leave-group') && ( false == confirm( BP_DTheme.leave_group_confirm ) ) )
     1026                        return false;
     1027                       
    10241028                jq.post( ajaxurl, {
    10251029                        action: 'joinleave_group',
    10261030                        'cookie': bp_get_cookies(),
    jq(document).ready( function() { 
    10441048                return false;
    10451049        } );
    10461050
     1051        //Previous case only handles directory listings. This case handles the button on the group page.
     1052        jq('#item-buttons').on('click', '.group-button a.leave-group', function() {
     1053
     1054                //Ask user to confirm before processing the request
     1055                if ( false == confirm( BP_DTheme.leave_group_confirm ) )
     1056                        return false;   
     1057        });
     1058
    10471059        /** Button disabling ************************************************/
    10481060
    10491061        jq('#buddypress').on( 'click', '.pending', function() {
  • bp-themes/bp-default/_inc/global.js

    diff --git bp-themes/bp-default/_inc/global.js bp-themes/bp-default/_inc/global.js
    index ae05558..2c6264d 100644
    jq(document).ready( function() { 
    992992
    993993                var thelink = jq(this);
    994994
     995                //If leaving a group, ask user to confirm before processing the request
     996                if ( jq(this).hasClass('leave-group') && ( false == confirm( BP_DTheme.leave_group_confirm ) ) )
     997                        return false;
     998
    995999                jq.post( ajaxurl, {
    9961000                        action: 'joinleave_group',
    9971001                        'cookie': bp_get_cookies(),
    jq(document).ready( function() { 
    10151019                return false;
    10161020        } );
    10171021
     1022        //Previous case only handles directory listings. This case handles the button on the group page.
     1023        jq('#item-buttons').on('click', '.group-button a.leave-group', function() {
     1024
     1025                //Ask user to confirm before processing the request
     1026                if ( false == confirm( BP_DTheme.leave_group_confirm ) )
     1027                        return false;   
     1028        });
     1029
    10181030        /** Button disabling ************************************************/
    10191031
    10201032        jq('.pending').click(function() {
  • bp-themes/bp-default/functions.php

    diff --git bp-themes/bp-default/functions.php bp-themes/bp-default/functions.php
    index 78f5107..3de6fc0 100644
    function bp_dtheme_enqueue_scripts() { 
    165165                'close'             => __( 'Close', 'buddypress' ),
    166166                'view'              => __( 'View', 'buddypress' ),
    167167                'mark_as_fav'       => __( 'Favorite', 'buddypress' ),
    168                 'remove_fav'        => __( 'Remove Favorite', 'buddypress' )
     168                'remove_fav'        => __( 'Remove Favorite', 'buddypress' ),
     169                'leave_group_confirm'   => __( 'Are you sure you want to leave this group?', 'buddypress' ),
    169170        );
    170171        wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
    171172