Nulo
3a0c41b736
Squashed commit of the following: commit 482eea28821868f03ace33562e7bd34ab9a4478f Merge: 5f485281c128f2
Author: f <f@sutty.nl> Date: Thu Nov 25 18:31:35 2021 -0300 Merge branch 'master' into limpiar-eventos commit 5f48528c28b0709bd859a4dc52a830f60bfedc6e Author: f <f@sutty.nl> Date: Thu Nov 25 18:23:23 2021 -0300 pretty commit 70d05bc90a6cb64d1c4bfc39f48388af3fbc3c18 Merge: c4f33c0ff1bc21
Author: Nulo <nulo@sutty.nl> Date: Thu Oct 28 16:46:31 2021 -0300 Merge branch 'master' into limpiar-eventos commit c4f33c084058002a10fc0ec2137ffe045826cfd2 Author: f <f@sutty.nl> Date: Thu Oct 28 14:52:41 2021 -0300 limpiar eventos
32 lines
809 B
JavaScript
32 lines
809 B
JavaScript
import { CartBaseController } from "./cart_base_controller";
|
|
|
|
export default class extends CartBaseController {
|
|
static targets = ["form", "username"];
|
|
|
|
connect() {
|
|
this.focusout_event = this._focusout_event.bind(this);
|
|
|
|
if (!this.hasUsernameTarget) return;
|
|
if (!this.hasFormTarget) return;
|
|
|
|
this.formTarget.addEventListener("focusout", this.focusout_event);
|
|
}
|
|
|
|
disconnect() {
|
|
this.formTarget.removeEventListener("focusout", this.focusout_event);
|
|
}
|
|
|
|
_focusout_event(event) {
|
|
if (!this.formTarget.checkValidity()) {
|
|
this.formTarget.classList.add("was-validated");
|
|
return;
|
|
}
|
|
|
|
this.formTarget.classList.remove("was-validated");
|
|
|
|
const username = this.usernameTarget.value.trim();
|
|
if (username.length === 0) return;
|
|
|
|
this.email = username;
|
|
}
|
|
}
|