Script to hide / show encrypted values in web ui
added a function to show/hide encrypted values with a simple trick because ClipboardJS can't copy display:none element's value
This commit is contained in:
parent
9359809b4f
commit
8abd359b5b
1 changed files with 18 additions and 2 deletions
|
@ -964,8 +964,7 @@
|
||||||
var clickedElement = $(e.trigger);
|
var clickedElement = $(e.trigger);
|
||||||
// Get the target element selector from data attribute
|
// Get the target element selector from data attribute
|
||||||
var targetSelector = clickedElement.data('data-clipboard-target');
|
var targetSelector = clickedElement.data('data-clipboard-target');
|
||||||
// Find the target element
|
// Show the alert that the content was copied
|
||||||
var targetEl = $(targetSelector);
|
|
||||||
clickedElement.tooltip('hide').attr('data-original-title', '{{ trans('general.copied') }}').tooltip('show');
|
clickedElement.tooltip('hide').attr('data-original-title', '{{ trans('general.copied') }}').tooltip('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -979,6 +978,23 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function showHideEncValue(e) {
|
||||||
|
// Use element id to find the text element to hide / show
|
||||||
|
var targetElement = e.id+"-to-show";
|
||||||
|
var hiddenElement = e.id+"-to-hide";
|
||||||
|
if($(e).hasClass('fa-lock')) {
|
||||||
|
$(e).removeClass('fa-lock').addClass('fa-unlock');
|
||||||
|
// Show the encrypted custom value and hide the element with asterisks
|
||||||
|
document.getElementById(targetElement).style.fontSize = "100%";
|
||||||
|
document.getElementById(hiddenElement).style.display = "none";
|
||||||
|
} else {
|
||||||
|
$(e).removeClass('fa-unlock').addClass('fa-lock');
|
||||||
|
// ClipboardJS can't copy display:none elements so use a trick to hide the value
|
||||||
|
document.getElementById(targetElement).style.fontSize = "0px";
|
||||||
|
document.getElementById(hiddenElement).style.display = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
// Invoke Bootstrap 3's tooltip
|
// Invoke Bootstrap 3's tooltip
|
||||||
|
|
Loading…
Add table
Reference in a new issue