private void handleBackwardTab(Event evt) { if (DominoDom.document.activeElement.equals(firstFocusElement)) { evt.preventDefault(); lastFocusElement.focus(); } }
private void handleForwardTab(Event evt) { if (DominoDom.document.activeElement.equals(lastFocusElement)) { evt.preventDefault(); firstFocusElement.focus(); } }
private void handleBackwardTab(Event evt) { if (DominoDom.document.activeElement.equals(firstFocusElement)) { evt.preventDefault(); lastFocusElement.focus(); } }
private void handleForwardTab(Event evt) { if (DominoDom.document.activeElement.equals(lastFocusElement)) { evt.preventDefault(); firstFocusElement.focus(); } }
@Override public void showErrorHighlight(final String errorElementSelector) { querySelector(errorElementSelector).ifPresent(element -> { enableErrorHighlight(element); setupDisableErrorHighlightCallbacks(element); element.focus(); }); }
@Override public T close() { opened_dialogs = opened_dialogs - 1; asElement().classList.remove(ModalStyles.IN); asElement().style.display = "none"; if (nonNull(activeElementBeforeOpen)) activeElementBeforeOpen.focus(); for (int i = 0; i < closeHandlers.size(); i++) { closeHandlers.get(i).onClose(); } if (autoAppendAndRemove) { asElement().remove(); } this.open = false; removeBackDrop(); if (ModalBackDrop.openedModals.contains(this)) { ModalBackDrop.openedModals.pop(); } return (T) this; }
@Override public T close() { opened_dialogs = opened_dialogs - 1; asElement().classList.remove(ModalStyles.IN); asElement().style.display = "none"; if (nonNull(activeElementBeforeOpen)) activeElementBeforeOpen.focus(); for (int i = 0; i < closeHandlers.size(); i++) { closeHandlers.get(i).onClose(); } if (autoAppendAndRemove) { asElement().remove(); } this.open = false; removeBackDrop(); if (ModalBackDrop.openedModals.contains(this)) { ModalBackDrop.openedModals.pop(); } return (T) this; }
@Override public T open() { if (isEnabled()) { if (autoAppendAndRemove) { asElement().remove(); document.body.appendChild(asElement()); } initFocusElements(); activeElementBeforeOpen = DominoDom.document.activeElement; addBackdrop(); style().add(ModalStyles.IN); style().setDisplay("block"); if (nonNull(firstFocusElement)) { firstFocusElement.focus(); if (!Objects.equals(DominoDom.document.activeElement, firstFocusElement)) { if (nonNull(lastFocusElement)) { lastFocusElement.focus(); } } } for (int i = 0; i < openHandlers.size(); i++) openHandlers.get(i).onOpen(); this.open = true; opened_dialogs = opened_dialogs + 1; ModalBackDrop.openedModals.push(this); } return (T) this; }
@Override public T open() { if (isEnabled()) { if (autoAppendAndRemove) { asElement().remove(); document.body.appendChild(asElement()); } initFocusElements(); activeElementBeforeOpen = DominoDom.document.activeElement; addBackdrop(); style().add(ModalStyles.IN); style().setDisplay("block"); if (nonNull(firstFocusElement)) { firstFocusElement.focus(); if (!Objects.equals(DominoDom.document.activeElement, firstFocusElement)) { if (nonNull(lastFocusElement)) { lastFocusElement.focus(); } } } for (int i = 0; i < openHandlers.size(); i++) openHandlers.get(i).onOpen(); this.open = true; opened_dialogs = opened_dialogs + 1; ModalBackDrop.openedModals.push(this); } return (T) this; }
void addTabIndexHandler() { asElement().addEventListener(EventType.keydown.getName(), evt -> { initFocusElements(); KeyboardEvent keyboardEvent = Js.cast(evt); switch (keyboardEvent.code) { case "Tab": if (focusElements.size() <= 1) { evt.preventDefault(); break; } if (keyboardEvent.shiftKey) { handleBackwardTab(evt); } else { handleForwardTab(evt); } break; case "Escape": if (isAutoClose()) { close(); } break; default: break; } if (!focusElements.contains(DominoDom.document.activeElement)) { firstFocusElement.focus(); } }); }
void addTabIndexHandler() { asElement().addEventListener(EventType.keydown.getName(), evt -> { initFocusElements(); KeyboardEvent keyboardEvent = Js.cast(evt); switch (keyboardEvent.code) { case "Tab": if (focusElements.size() <= 1) { evt.preventDefault(); break; } if (keyboardEvent.shiftKey) { handleBackwardTab(evt); } else { handleForwardTab(evt); } break; case "Escape": if (isAutoClose()) { close(); } break; default: break; } if (!focusElements.contains(DominoDom.document.activeElement)) { firstFocusElement.focus(); } }); }