Skip to content

Commit

Permalink
javascript fixes after liveview update
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Dec 17, 2024
1 parent fbac408 commit 9494444
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions assets/js/hooks/events/listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function click(event: MouseEvent) {
const target = event.target as HTMLDivElement;
const select = target!.querySelector("input.selected") as HTMLInputElement;

select.checked = !select.checked;
select && (select.checked = !select.checked);
}

export function input(event: KeyboardEvent) {
Expand All @@ -21,7 +21,7 @@ export function input(event: KeyboardEvent) {

// clearTimeout(watchdog);
// watchdog = setTimeout(() => {
this.pushEventTo(this.el.phxHookId, "save", { uuid, content });
this.pushEventTo(this.el, "save", { uuid, content });
// }, watchdogInterval);
}

Expand Down
16 changes: 8 additions & 8 deletions assets/js/hooks/events/listener/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ export function processEvent(action, event) {
switch (action) {
case "new_empty_node":
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "new", { uuid, start, stop });
this.pushEventTo(this.el, "new", { uuid, start, stop });
break;

case "indent":
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "indent", { uuid });
this.pushEventTo(this.el, "indent", { uuid });
break;

case "outdent":
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "outdent", { uuid });
this.pushEventTo(this.el, "outdent", { uuid });
break;

case "move_up":
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "move_up", { uuid });
this.pushEventTo(this.el, "move_up", { uuid });
break;

case "move_down":
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "move_down", { uuid });
this.pushEventTo(this.el, "move_down", { uuid });
break;

case "merge_prev":
const prevNode = getPrevNode(node);
if (cursorAtStart && prevNode) {
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "merge_prev", { uuid, content });
this.pushEventTo(this.el, "merge_prev", { uuid, content });
focusNode(prevNode);
}
break;
Expand All @@ -51,7 +51,7 @@ export function processEvent(action, event) {
const nextNode = getNextNode(node);
if (cursorAtEnd && nextNode) {
event.preventDefault();
this.pushEventTo(this.el.phxHookId, "merge_next", { uuid, content });
this.pushEventTo(this.el, "merge_next", { uuid, content });
focusNode(nextNode);
}
break;
Expand All @@ -76,7 +76,7 @@ export function processEvent(action, event) {
const nodes = this.el.querySelectorAll(".node:has(> .selected:checked)");
nodes.forEach((node: HTMLDivElement) => {
const { uuid } = getNodeData(node);
this.pushEventTo(this.el.phxHookId, "delete", { uuid });
this.pushEventTo(this.el, "delete", { uuid });
});
break;

Expand Down

0 comments on commit 9494444

Please sign in to comment.