29 lines
833 B
JavaScript
29 lines
833 B
JavaScript
import { Controller } from '@hotwired/stimulus';
|
|
|
|
/*
|
|
* This is an example Stimulus controller!
|
|
*
|
|
* Any element with a data-controller="hello" attribute will cause
|
|
* this controller to be executed. The name "hello" comes from the filename:
|
|
* hello_controller.js -> "hello"
|
|
*/
|
|
export default class extends Controller {
|
|
static targets = ['pass'];
|
|
|
|
toggle(event) {
|
|
const span = event.currentTarget;
|
|
const icon = span.firstElementChild;
|
|
|
|
if (this.passTarget.type === 'password') {
|
|
icon.classList.remove('fa-eye');
|
|
icon.classList.add('fa-eye-slash');
|
|
this.passTarget.type = 'text';
|
|
}
|
|
else {
|
|
icon.classList.remove('fa-eye-slash');
|
|
icon.classList.add('fa-eye');
|
|
this.passTarget.type = 'password';
|
|
}
|
|
}
|
|
}
|