Add missing file
This commit is contained in:
37
src/js/utils.js
Normal file
37
src/js/utils.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/* This file contains helpers which should not be part of client.js */
|
||||
|
||||
angular.module('Application').directive('passwordReveal', function () {
|
||||
return {
|
||||
link: function (scope, elements) {
|
||||
var element = elements[0];
|
||||
|
||||
if (!element.parentNode) {
|
||||
console.error('Wrong password-reveal directive usage. Element has no parent.');
|
||||
return;
|
||||
}
|
||||
|
||||
var eye = document.createElement('i');
|
||||
eye.classList.add('fa');
|
||||
eye.classList.add('fa-eye-slash');
|
||||
eye.style.position = 'absolute';
|
||||
eye.style.right = '10px';
|
||||
eye.style.bottom = '10px';
|
||||
eye.style.cursor = 'pointer';
|
||||
|
||||
eye.addEventListener('click', function () {
|
||||
if (element.type === 'password') {
|
||||
element.type = 'text';
|
||||
eye.classList.remove('fa-eye-slash');
|
||||
eye.classList.add('fa-eye');
|
||||
} else {
|
||||
element.type = 'password';
|
||||
eye.classList.remove('fa-eye');
|
||||
eye.classList.add('fa-eye-slash');
|
||||
}
|
||||
});
|
||||
|
||||
element.parentNode.style.position = 'relative';
|
||||
element.parentNode.append(eye);
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user