<commit_before>/**
 * Users widget.  Sets up dropdowns, modals, etc for a table of users.
 */

/**
 * Set up the form in a modal after being successfully attached to the body.
 */
function attachUserForm() {
    $("body").on('renderSuccess.ufModal', function (data) {
        var modal = $(this).ufModal('getModal');
        var form = modal.find('.js-form');

        // Set up any widgets inside the modal
        form.find(".js-select2").select2({
            width: '100%'
        });

        // Set up the form for submission
        form.ufForm({
            validators: page.validators
        }).on("submitSuccess.ufForm", function() {
            // Reload page on success
            //window.location.reload();
        });
		
		toggleSetPasswordMode(modal, 'link');

        // On submission, submit either the PUT request, or POST for a password reset, depending on the toggle state
        modal.find("input[name='change_password_mode']").click(function() {
            var changePasswordMode = $(this).val();
            toggleSetPasswordMode(modal, changePasswordMode);
        });
    });
}

/**
 * Enable/disable password fields when switch is toggled
 * Applies to 'creating' a user
 */
function toggleSetPasswordMode(el, changePasswordMode) {
    var form = el.find("form");
    if (changePasswordMode == 'link') {
        $(".controls-password").find("input[type='password']").prop('disabled', true);
        // Form submits password reset request

        var validator = form.validate();
        if (validator) {
            //Iterate through named elements inside of the form, and mark them as error free<commit_msg>Fix commenting out 'window.location.reload();'<commit_after>/**
 * Users widget.  Sets up dropdowns, modals, etc for a table of users.
 */

/**
 * Set up the form in a modal after being successfully attached to the body.
 */
function attachUserForm() {
    $("body").on('renderSuccess.ufModal', function (data) {
        var modal = $(this).ufModal('getModal');
        var form = modal.find('.js-form');

        // Set up any widgets inside the modal
        form.find(".js-select2").select2({
            width: '100%'
        });

        // Set up the form for submission
        form.ufForm({
            validators: page.validators
        }).on("submitSuccess.ufForm", function() {
            // Reload page on success
            window.location.reload();
        });
		
		toggleSetPasswordMode(modal, 'link');

        // On submission, submit either the PUT request, or POST for a password reset, depending on the toggle state
        modal.find("input[name='change_password_mode']").click(function() {
            var changePasswordMode = $(this).val();
            toggleSetPasswordMode(modal, changePasswordMode);
        });
    });
}

/**
 * Enable/disable password fields when switch is toggled
 * Applies to 'creating' a user
 */
function toggleSetPasswordMode(el, changePasswordMode) {
    var form = el.find("form");
    if (changePasswordMode == 'link') {
        $(".controls-password").find("input[type='password']").prop('disabled', true);
        // Form submits password reset request

        var validator = form.validate();
        if (validator) {
            //Iterate through named elements inside of the form, and mark them as error free
{'fraction_non_alphanumeric': 0.13138024765931744, 'fraction_numerical': 0.0030202355783751134, 'mean_word_length': 2.5536480686695278, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4330669', 'n_tokens_mistral': 889, 'n_tokens_neox': 867, 'n_words': 276}