Skip to:
Content

BuddyPress.org

Ticket #4958: profile-field-vis-3.patch

File profile-field-vis-3.patch, 3.1 KB (added by dcavins, 11 years ago)

Cleanup of jQuery traversal, added confirmation dialog when leaving registration page

  • bp-templates/bp-legacy/js/buddypress.js

    diff --git bp-templates/bp-legacy/js/buddypress.js bp-templates/bp-legacy/js/buddypress.js
    index 889c919..1d90310 100644
    jq(document).ready( function() { 
    834834
    835835        jq('.field-visibility-settings-close').on( 'click', function() {
    836836                var settings_div = jq(this).parent();
     837                var vis_setting_text = settings_div.find('input:checked').parent().text();
    837838
    838                 jq(settings_div).slideUp( 400, function(){
    839                         jq(settings_div).siblings('.field-visibility-settings-toggle').fadeIn(800);
     839
     840                settings_div.slideUp( 400, function(){
     841                        settings_div.siblings('.field-visibility-settings-toggle').fadeIn(800);
     842                        settings_div.siblings('.field-visibility-settings-toggle').children('.current-visibility-level').html(vis_setting_text);
    840843                });
    841844
    842845                return false;
    843846        } );
    844847
     848        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(){
     849               
     850                var shouldconfirm = true;
     851
     852                jq('#profile-edit-form input:submit,#signup_form input:submit').on( 'click', function() {
     853                        shouldconfirm = false;
     854                });
     855               
     856                window.onbeforeunload = function(e) {
     857                        if ( shouldconfirm ) {
     858                            return 'You have unsaved changes on this page. Do you want to leave this page and discard your changes or stay on this page?';
     859                        }
     860                };
     861        });
    845862
    846863        /** Friendship Requests **************************************/
    847864
  • bp-xprofile/bp-xprofile-template.php

    diff --git bp-xprofile/bp-xprofile-template.php bp-xprofile/bp-xprofile-template.php
    index c6ecda3..5a949e3 100644
    function bp_the_profile_field_visibility_level() { 
    730730         */
    731731        function bp_get_the_profile_field_visibility_level() {
    732732                global $field;
    733 
    734                 $retval = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     733                //On the registration page, values stored in POST should take precedence over default visibility
     734                if ( bp_is_register_page() && !empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
     735                        $retval = $_POST['field_' . $field->id . '_visibility'];
     736                } else {
     737                        $retval = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     738                }
    735739
    736740                return apply_filters( 'bp_get_the_profile_field_visibility_level', $retval );
    737741        }
    function bp_the_profile_field_visibility_level_label() { 
    747751         */
    748752        function bp_get_the_profile_field_visibility_level_label() {
    749753                global $field;
     754                //On the registration page, values stored in POST should take precedence over default visibility
     755                if ( bp_is_register_page() && !empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
     756                        $level  = $_POST['field_' . $field->id . '_visibility'];
     757                } else {
     758                        $level  = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
     759                }
    750760
    751                 $level  = !empty( $field->visibility_level ) ? $field->visibility_level : 'public';
    752761                $fields = bp_xprofile_get_visibility_levels();
    753762
    754763                return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[$level]['label'] );