Skip to:
Content

BuddyPress.org

Changeset 7151


Ignore:
Timestamp:
06/04/2013 01:45:27 PM (13 years ago)
Author:
boonebgorges
Message:

Prompt user before leaving profile edit mode if changes have not been saved

See #4958

Props dcavins

Location:
trunk/bp-templates/bp-legacy
Files:
2 edited

Legend:

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

    r7116 r7151  
    259259                        'view'              => __( 'View', 'buddypress' ),
    260260                        'mark_as_fav'       => __( 'Favorite', 'buddypress' ),
    261                         'remove_fav'        => __( 'Remove Favorite', 'buddypress' )
     261                        'remove_fav'        => __( 'Remove Favorite', 'buddypress' ),
     262                        'unsaved_changes'   => __( 'Your profile has unsaved changes. If you leave the page, the changes will be lost.', 'buddypress' ),
    262263                );
    263264                wp_localize_script( $handle, 'BP_DTheme', $params );
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r7116 r7151  
    880880        } );
    881881
     882        jq("#profile-edit-form input:not(:submit), #profile-edit-form textarea, #profile-edit-form select, #signup_form input:not(:submit), #signup_form textarea, #signup_form select").change( function() {
     883                var shouldconfirm = true;
     884
     885                jq('#profile-edit-form input:submit, #signup_form input:submit').on( 'click', function() {
     886                        shouldconfirm = false;
     887                });
     888               
     889                window.onbeforeunload = function(e) {
     890                        if ( shouldconfirm ) {
     891                                return BP_DTheme.unsaved_changes;
     892                        }
     893                };
     894        });
    882895
    883896        /** Friendship Requests **************************************/
Note: See TracChangeset for help on using the changeset viewer.