diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLButtonElement.java b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLButtonElement.java index 061a3e68d..6706335fc 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLButtonElement.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLButtonElement.java @@ -16,8 +16,9 @@ package org.teavm.jso.dom.html; import org.teavm.jso.JSProperty; +import org.teavm.jso.popover.PopoverInvokerElement; -public abstract class HTMLButtonElement extends HTMLElement { +public abstract class HTMLButtonElement extends HTMLElement implements PopoverInvokerElement { public static final String TYPE_BUTTON = "button"; public static final String TYPE_RESET = "reset"; diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java index 20786be97..df41315e5 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLElement.java @@ -29,9 +29,10 @@ import org.teavm.jso.dom.types.DOMTokenList; import org.teavm.jso.dom.xml.Element; import org.teavm.jso.dom.xml.Node; import org.teavm.jso.dom.xml.NodeList; +import org.teavm.jso.popover.ToggleEventTarget; public abstract class HTMLElement implements Element, ElementCSSInlineStyle, EventTarget, FocusEventTarget, - MouseEventTarget, WheelEventTarget, KeyboardEventTarget, LoadEventTarget, TouchEventTarget { + MouseEventTarget, WheelEventTarget, KeyboardEventTarget, LoadEventTarget, TouchEventTarget, ToggleEventTarget { @Override public abstract NodeList getElementsByTagName(String name); @@ -158,6 +159,20 @@ public abstract class HTMLElement implements Element, ElementCSSInlineStyle, Eve @JSProperty public abstract DOMTokenList getClassList(); + @JSProperty + public abstract String getPopover(); + + @JSProperty + public abstract void setPopover(String popover); + + public abstract void hidePopover(); + + public abstract void showPopover(); + + public abstract boolean togglePopover(); + + public abstract boolean togglePopover(boolean force); + public final HTMLElement withAttr(String name, String value) { setAttribute(name, value); return this; diff --git a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLInputElement.java b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLInputElement.java index 150270b46..8b7c0948c 100644 --- a/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLInputElement.java +++ b/jso/apis/src/main/java/org/teavm/jso/dom/html/HTMLInputElement.java @@ -17,8 +17,9 @@ package org.teavm.jso.dom.html; import org.teavm.jso.JSProperty; import org.teavm.jso.file.FileList; +import org.teavm.jso.popover.PopoverInvokerElement; -public abstract class HTMLInputElement extends HTMLElement { +public abstract class HTMLInputElement extends HTMLElement implements PopoverInvokerElement { @JSProperty public abstract boolean isChecked(); diff --git a/jso/apis/src/main/java/org/teavm/jso/popover/PopoverInvokerElement.java b/jso/apis/src/main/java/org/teavm/jso/popover/PopoverInvokerElement.java new file mode 100644 index 000000000..80186ef71 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/popover/PopoverInvokerElement.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 lasse-cs. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.popover; + +import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.html.HTMLElement; + +public interface PopoverInvokerElement { + + String HIDE = "hide"; + + String SHOW = "show"; + + String TOGGLE = "toggle"; + + @JSProperty + String getPopoverTargetAction(); + + @JSProperty + void setPopoverTargetAction(String action); + + @JSProperty + HTMLElement getPopoverTargetElement(); + + @JSProperty + void setPopoverTargetElement(HTMLElement popoverTarget); +} diff --git a/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEvent.java b/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEvent.java new file mode 100644 index 000000000..d78cb347e --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEvent.java @@ -0,0 +1,31 @@ +/* + * Copyright 2024 lasse-cs. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.popover; + +import org.teavm.jso.JSProperty; +import org.teavm.jso.dom.events.Event; + +public interface ToggleEvent extends Event { + + String OPEN = "open"; + String CLOSED = "closed"; + + @JSProperty + String getOldState(); + + @JSProperty + String getNewState(); +} diff --git a/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEventTarget.java b/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEventTarget.java new file mode 100644 index 000000000..143f98af1 --- /dev/null +++ b/jso/apis/src/main/java/org/teavm/jso/popover/ToggleEventTarget.java @@ -0,0 +1,31 @@ +/* + * Copyright 2024 lasse-cs. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.jso.popover; + +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.dom.events.EventTarget; +import org.teavm.jso.dom.events.Registration; + +public interface ToggleEventTarget extends EventTarget { + + default Registration onBeforeToggle(EventListener listener) { + return onEvent("beforetoggle", listener); + } + + default Registration onToggle(EventListener listener) { + return onEvent("toggle", listener); + } +}