Skip to content

Commit 54bfc46

Browse files
committed
Hide/Unhide functionality
1 parent 642db37 commit 54bfc46

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

web/css/main.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,3 +1276,21 @@ label:active {
12761276
padding: 2px 0 1px 2px;
12771277
}
12781278

1279+
.hide-password {
1280+
color: #2361a1;
1281+
padding-left: 3px;
1282+
margin-left: -36px;
1283+
}
1284+
1285+
.hide-password:hover {
1286+
color: #F79B44;
1287+
}
1288+
1289+
.toggle-psw-visibility-icon {
1290+
cursor: pointer;
1291+
opacity: 0.4;
1292+
}
1293+
1294+
.show-passwords-enabled-action {
1295+
opacity: 1;
1296+
}

web/js/events.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,49 @@ VE.helpers.createConfirmationDialog = function(elm, dialog_title, confirmed_loca
122122
VE.helpers.warn = function(msg) {
123123
alert('WARNING: ' + msg);
124124
}
125+
126+
VE.helpers.extendPasswordFields = function() {
127+
var references = ['.password'];
128+
129+
$(document).ready(function() {
130+
$(references).each(function(i, ref) {
131+
VE.helpers.initAdditionalPasswordFieldElements(ref);
132+
});
133+
});
134+
}
135+
136+
VE.helpers.initAdditionalPasswordFieldElements = function(ref) {
137+
var enabled = $.cookie('hide_passwords') == '1' ? true : false;
138+
if (enabled) {
139+
VE.helpers.hidePasswordFieldText(ref);
140+
}
141+
142+
$(ref).prop('autocomplete', 'off');
143+
144+
var enabled_html = enabled ? '' : 'show-passwords-enabled-action';
145+
var html = '<span class="hide-password"><img class="toggle-psw-visibility-icon ' + enabled_html + '" onClick="VE.helpers.toggleHiddenPasswordText(\'' + ref + '\', this)" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAANlJREFUOI3d0UtKA0EQBuBP0eQCitkJLiXiSSTkUCKIIPg8SJCouDELrxDRCxi3SUQimXFhjRSDZq8/FE3/jyqqm3+JXVziGbOoJ1xgZ1GwiXMUKDFBH1cYB1fgBI16uIG7MJW4x1rS1zFIeh8rucFREicR7mKEV3SwgWnyHVThLXzUuotwxY2Cu0ncDJvLccko4lxKXPkL9509TMQ4du7E5BfsoYW35NvPU1dxncRB7FyhhYek99Qeka+fOMU8TNPY+TZNnuP4p3BGG2d4xHvUMJpvLwr+UXwCQghNMl5Zo0AAAAAASUVORK5CYII=" /></span>';
146+
$(ref).after(html);
147+
}
148+
149+
VE.helpers.hidePasswordFieldText = function(ref) {
150+
$.cookie('hide_passwords', '1', { expires: 365, path: '/' });
151+
$(ref).prop('type', 'password');
152+
}
153+
154+
VE.helpers.revealPasswordFieldText = function(ref) {
155+
$.cookie('hide_passwords', '0', { expires: 365, path: '/' });
156+
$(ref).prop('type', 'text');
157+
}
158+
159+
VE.helpers.toggleHiddenPasswordText = function(ref, triggering_elm) {
160+
$(triggering_elm).toggleClass('show-passwords-enabled-action');
161+
162+
if ($(ref).prop('type') == 'text') {
163+
VE.helpers.hidePasswordFieldText(ref);
164+
}
165+
else {
166+
VE.helpers.revealPasswordFieldText(ref);
167+
}
168+
}
169+
170+
VE.helpers.extendPasswordFields();

0 commit comments

Comments
 (0)