mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Merge pull request #4451 from mabashian/3827-password-toggle
Fixed password toggles
This commit is contained in:
commit
17407f9e5c
@ -1133,4 +1133,22 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'JobsHelper'])
|
||||
});
|
||||
}
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('awPasswordToggle', [function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, element) {
|
||||
$(element).click(function() {
|
||||
var buttonInnerHTML = $(element).html();
|
||||
if (buttonInnerHTML.indexOf("Show") > -1) {
|
||||
$(element).html("Hide");
|
||||
$(element).closest('.input-group').find('input').first().attr("type", "text");
|
||||
} else {
|
||||
$(element).html("Show");
|
||||
$(element).closest('.input-group').find('input').first().attr("type", "password");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
@ -846,28 +846,15 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
|
||||
html += "\t" + label();
|
||||
if (field.hasShowInputButton) {
|
||||
var tooltip = i18n._("Toggle the display of plaintext.");
|
||||
field.toggleInput = function(id) {
|
||||
var buttonId = id + "_show_input_button",
|
||||
inputId = id + "_input",
|
||||
buttonInnerHTML = $(buttonId).html();
|
||||
if (buttonInnerHTML.indexOf("Show") > -1) {
|
||||
$(buttonId).html("Hide");
|
||||
$(inputId).attr("type", "text");
|
||||
} else {
|
||||
$(buttonId).html("Show");
|
||||
$(inputId).attr("type", "password");
|
||||
}
|
||||
};
|
||||
html += "\<div class='input-group";
|
||||
html += (horizontal) ? " " + getFieldWidth() : "";
|
||||
html += "'>\n";
|
||||
// TODO: make it so that the button won't show up if the mode is edit, hasShowInputButton !== true, and there are no contents in the field.
|
||||
html += "<span class='input-group-btn'>\n";
|
||||
html += "<button type='button' class='btn btn-default show_input_button Form-passwordButton' ";
|
||||
html += "<button aw-password-toggle type='button' class='btn btn-default show_input_button Form-passwordButton' ";
|
||||
html += buildId(field, fld + "_show_input_button", this.form);
|
||||
html += `aw-tool-tip='${tooltip}'} aw-tip-placement='top'`;
|
||||
html += "tabindex='-1' ";
|
||||
html += "ng-click='" + fld + "_field.toggleInput(\"#" + this.form.name + "_" + fld + "\")'";
|
||||
html += (field.ngDisabled) ? "ng-disabled='" + field.ngDisabled + "'" : "";
|
||||
html += ">\n" + field.showInputInnerHTML;
|
||||
html += "\n</button>\n";
|
||||
|
Loading…
Reference in New Issue
Block a user