Move login JS to Stimulus
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
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"
|
||||
*
|
||||
* Delete this file or adapt it for your use!
|
||||
*/
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
|
||||
}
|
||||
}
|
||||
9
assets/controllers/loading_controller.js
Normal file
9
assets/controllers/loading_controller.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['control'];
|
||||
|
||||
setLoading() {
|
||||
this.controlTarget.classList.add('is-loading');
|
||||
}
|
||||
}
|
||||
9
assets/controllers/notification_controller.js
Normal file
9
assets/controllers/notification_controller.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['notif'];
|
||||
|
||||
close() {
|
||||
this.notifTarget.classList.add('is-hidden');
|
||||
}
|
||||
}
|
||||
28
assets/controllers/show_password_controller.js
Normal file
28
assets/controllers/show_password_controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user