How to use the cx/util.closest function in cx

To help you get started, we’ve selected a few cx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codaxy / tdo / app / routes / board / Controller.js View on Github external
switch (e.keyCode) {
                case code("K"):
                    if (e.currentTarget.previousSibling && e.currentTarget.previousSibling.previousSibling)
                        FocusManager.focusFirst(e.currentTarget.previousSibling.previousSibling);
                    break;

                case code("J"):
                    if (e.currentTarget.nextSibling && e.currentTarget.nextSibling.nextSibling)
                        FocusManager.focusFirst(e.currentTarget.nextSibling.nextSibling);
                    break;

                case KeyCode.left:
                case code("H"):
                case code("B"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.previousSibling && list.previousSibling.previousSibling)
                        FocusManager.focusFirst(list.previousSibling.previousSibling);
                    break;

                case KeyCode.right:
                case code("W"):
                case code("L"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.nextSibling && list.nextSibling.nextSibling)
                        FocusManager.focusFirst(list.nextSibling.nextSibling);
                    break;
            }
        },
github codaxy / tdo / app / routes / board / Controller.js View on Github external
list;

            switch (e.keyCode) {
                case code("K"):
                    if (e.currentTarget.previousSibling)
                        FocusManager.focusFirst(e.currentTarget.previousSibling);
                    break;

                case code("J"):
                    if (e.currentTarget.nextSibling)
                        FocusManager.focusFirst(e.currentTarget.nextSibling);
                    break;

                case KeyCode.left:
                case code("H"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.previousSibling) FocusManager.focusFirst(list.previousSibling);
                    break;

                case KeyCode.right:
                case code("L"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.nextSibling) FocusManager.focusFirst(list.nextSibling);
                    break;
            }
        },
github codaxy / tdo / app / routes / board / Controller.js View on Github external
break;

                case code("J"):
                    if (e.currentTarget.nextSibling)
                        FocusManager.focusFirst(e.currentTarget.nextSibling);
                    break;

                case KeyCode.left:
                case code("H"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.previousSibling) FocusManager.focusFirst(list.previousSibling);
                    break;

                case KeyCode.right:
                case code("L"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.nextSibling) FocusManager.focusFirst(list.nextSibling);
                    break;
            }
        },
github codaxy / tdo / app / routes / board / Controller.js View on Github external
onTaskKeyDown(e, instance) {
            let {store, data} = instance;
            let t = data.task;
            let {$task} = store.getData();
            let code = c => c.charCodeAt(0);

            switch (e.keyCode) {
                case KeyCode.delete:
                case code("D"):
                    if (e.keyCode === code("D") && !e.shiftKey) return;

                    let item = closest(e.target, el =>
                        el.classList.contains("cxe-menu-item")
                    );
                    let elementReceivingFocus = item.nextElementSibling || item.previousElementSibling;

                    batchUpdatesAndNotify(() => {
                        updateTask({
                            id: $task.id,
                            deleted: true,
                            deletedDate: new Date().toISOString()
                        });
                    }, () => {
                        if (elementReceivingFocus)
                            FocusManager.focusFirst(elementReceivingFocus);
                    });

                    break;
github codaxy / tdo / app / routes / board / Controller.js View on Github external
if (e.currentTarget.nextSibling && e.currentTarget.nextSibling.nextSibling)
                        FocusManager.focusFirst(e.currentTarget.nextSibling.nextSibling);
                    break;

                case KeyCode.left:
                case code("H"):
                case code("B"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.previousSibling && list.previousSibling.previousSibling)
                        FocusManager.focusFirst(list.previousSibling.previousSibling);
                    break;

                case KeyCode.right:
                case code("W"):
                case code("L"):
                    list = closest(e.target, el => el.classList.contains("cxb-tasklist"));
                    if (list.nextSibling && list.nextSibling.nextSibling)
                        FocusManager.focusFirst(list.nextSibling.nextSibling);
                    break;
            }
        },