Skip to:
Content

BuddyPress.org

Changeset 7159


Ignore:
Timestamp:
06/05/2013 01:16:53 AM (7 years ago)
Author:
boonebgorges
Message:

Add "Are you sure you want to leave this page?" js for unsaved changes on Group Admin

Fixes #4977

Location:
trunk/bp-groups
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/admin/js/admin.js

    r7146 r7159  
    1414    var id = 'undefined' !== typeof group_id ? '&group_id=' + group_id : '';
    1515    $(document).ready( function() {
     16        window.warn_on_leave = false;
     17
    1618        /* Initialize autocomplete */
    1719        $( '.bp-suggest-user' ).autocomplete({
     
    2830        $( '#bp-groups-new-members' ).attr( 'placeholder', BP_Group_Admin.add_member_placeholder );
    2931
     32        /* Warn before leaving unsaved changes */
     33        $(document).on( 'change', 'input#bp-groups-name, input#bp-groups-description, select.bp-groups-role, #bp-groups-settings-section-status input[type="radio"]', function() {
     34            window.warn_on_leave = true;
     35        });
     36
     37        $( 'input#save' ).on( 'click', function() {
     38            window.warn_on_leave = false;
     39        });
     40
     41        window.onbeforeunload = function(e) {
     42            if ( window.warn_on_leave ) {
     43                return BP_Group_Admin.warn_on_leave;
     44            }
     45        };
    3046    });
    3147})(jQuery);
  • trunk/bp-groups/bp-groups-admin.php

    r7158 r7159  
    167167
    168168    wp_localize_script( 'bp_groups_admin_js', 'BP_Group_Admin', array(
    169         'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddypress' )
     169        'add_member_placeholder' => __( 'Start typing a username to add a new member.', 'buddypress' ),
     170        'warn_on_leave'          => __( 'If you leave this page, you will lose any unsaved changes you have made to the group.', 'buddypress' ),
    170171    ) );
    171172
Note: See TracChangeset for help on using the changeset viewer.