DEV: Remove jquery from create-account modal (#16983)
This commit is contained in:
parent
300f835703
commit
3ebfde5ea2
|
@ -21,6 +21,23 @@ export default Component.extend({
|
|||
}
|
||||
},
|
||||
|
||||
actionOnEnter(event) {
|
||||
if (!this.disabled && event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.action();
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
selectKitFocus(event) {
|
||||
const target = document.getElementById(event.target.getAttribute("for"));
|
||||
if (target?.classList.contains("select-kit")) {
|
||||
event.preventDefault();
|
||||
target.querySelector(".select-kit-header").click();
|
||||
}
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
|
@ -43,31 +60,15 @@ export default Component.extend({
|
|||
}
|
||||
}
|
||||
|
||||
$(this.element).on("keydown.discourse-create-account", (e) => {
|
||||
if (!this.disabled && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.action();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(this.element).on("click.dropdown-user-field-label", "[for]", (event) => {
|
||||
const $element = $(event.target);
|
||||
const $target = $(`#${$element.attr("for")}`);
|
||||
|
||||
if ($target.is(".select-kit")) {
|
||||
event.preventDefault();
|
||||
$target.find(".select-kit-header").trigger("click");
|
||||
}
|
||||
});
|
||||
this.element.addEventListener("keydown", this.actionOnEnter);
|
||||
this.element.addEventListener("click", this.selectKitFocus);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
$(this.element).off("keydown.discourse-create-account");
|
||||
$(this.element).off("click.dropdown-user-field-label");
|
||||
this.element.removeEventListener("keydown", this.actionOnEnter);
|
||||
this.element.removeEventListener("click", this.selectKitFocus);
|
||||
|
||||
let userTextFields = document.getElementsByClassName("user-fields")[0];
|
||||
|
||||
|
|
Loading…
Reference in New Issue