Search in sources :

Example 1 with EventImpl

use of org.loboevolution.html.js.events.EventImpl in project LoboEvolution by LoboEvolution.

the class WindowImpl method initWindowScope.

private void initWindowScope(final Document doc) {
    final Scriptable ws = this.getWindowScope();
    final JavaScript js = JavaScript.getInstance();
    JavaInstantiator jiXhttp = () -> {
        HTMLDocumentImpl hd = (HTMLDocumentImpl) doc;
        return new XMLHttpRequest(getUaContext(), hd.getDocumentURL(), ws);
    };
    JavaInstantiator jidomp = () -> new DOMParserImpl(document);
    js.defineJsObject(ws, "XMLHttpRequest", XMLHttpRequest.class, jiXhttp);
    js.defineJsObject(ws, "DOMParser", DOMParserImpl.class, jidomp);
    js.defineJsObject(ws, "XMLSerializer", XMLSerializerImpl.class, XMLSerializerImpl::new);
    js.defineJsObject(ws, "XPathResult", XPathResultImpl.class, XPathResultImpl::new);
    js.defineJsObject(ws, "MouseEvent", MouseEventImpl.class, MouseEventImpl::new);
    js.defineJsObject(ws, "UIEvent", UIEventImpl.class, MouseEventImpl::new);
    js.defineJsObject(ws, "Element", Element.class, MouseEventImpl::new);
    js.defineJsObject(ws, "Event", EventImpl.class, EventImpl::new);
    js.defineJsObject(ws, "Text", TextImpl.class, TextImpl::new);
    js.defineJsObject(ws, "Storage", LocalStorage.class, LocalStorage::new);
    js.defineElementClass(ws, doc, "Comment", "comment", CommentImpl.class);
    js.defineElementClass(ws, doc, "Image", "img", HTMLImageElementImpl.class);
    js.defineElementClass(ws, doc, "Script", "script", HTMLScriptElementImpl.class);
    js.defineElementClass(ws, doc, "IFrame", "iframe", HTMLIFrameElementImpl.class);
    js.defineElementClass(ws, doc, "Option", "option", HTMLOptionElementImpl.class);
    js.defineElementClass(ws, doc, "Select", "select", HTMLSelectElementImpl.class);
    js.defineElementClass(ws, doc, "Console", "console", ConsoleImpl.class);
    js.defineElementClass(ws, doc, "HTMLDivElement", "div", HTMLDivElementImpl.class);
    js.defineElementClass(ws, doc, "HTMLElement", "html", HTMLElementImpl.class);
    js.defineElementClass(ws, doc, "HTMLDocument", "document", HTMLDocumentImpl.class);
}
Also used : JavaInstantiator(org.loboevolution.js.JavaInstantiator) LocalStorage(org.loboevolution.html.js.storage.LocalStorage) XPathResultImpl(org.loboevolution.html.dom.xpath.XPathResultImpl) EventImpl(org.loboevolution.html.js.events.EventImpl) MouseEventImpl(org.loboevolution.html.js.events.MouseEventImpl) UIEventImpl(org.loboevolution.html.js.events.UIEventImpl) JavaScript(org.loboevolution.js.JavaScript) XMLHttpRequest(org.loboevolution.html.js.xml.XMLHttpRequest) XMLSerializerImpl(org.loboevolution.html.js.xml.XMLSerializerImpl) Scriptable(org.mozilla.javascript.Scriptable) MouseEventImpl(org.loboevolution.html.js.events.MouseEventImpl) TextImpl(org.loboevolution.html.dom.nodeimpl.TextImpl)

Example 2 with EventImpl

use of org.loboevolution.html.js.events.EventImpl in project LoboEvolution by LoboEvolution.

the class HtmlController method onChange.

/**
 * <p>onChange.</p>
 *
 * @param node a {@link org.loboevolution.html.dom.nodeimpl.ModelNode} object.
 * @return a boolean.
 */
public boolean onChange(ModelNode node) {
    if (node instanceof HTMLSelectElementImpl) {
        final HTMLSelectElementImpl uiElement = (HTMLSelectElementImpl) node;
        final Function f = uiElement.getOnchange();
        if (f != null) {
            final EventImpl evt = new EventImpl();
            evt.initEvent("change", false, false);
            if (!Executor.executeFunction(uiElement, f, evt, new Object[0])) {
                return false;
            }
        }
    }
    return false;
}
Also used : Function(org.mozilla.javascript.Function) EventImpl(org.loboevolution.html.js.events.EventImpl) MouseEventImpl(org.loboevolution.html.js.events.MouseEventImpl)

Aggregations

EventImpl (org.loboevolution.html.js.events.EventImpl)2 MouseEventImpl (org.loboevolution.html.js.events.MouseEventImpl)2 TextImpl (org.loboevolution.html.dom.nodeimpl.TextImpl)1 XPathResultImpl (org.loboevolution.html.dom.xpath.XPathResultImpl)1 UIEventImpl (org.loboevolution.html.js.events.UIEventImpl)1 LocalStorage (org.loboevolution.html.js.storage.LocalStorage)1 XMLHttpRequest (org.loboevolution.html.js.xml.XMLHttpRequest)1 XMLSerializerImpl (org.loboevolution.html.js.xml.XMLSerializerImpl)1 JavaInstantiator (org.loboevolution.js.JavaInstantiator)1 JavaScript (org.loboevolution.js.JavaScript)1 Function (org.mozilla.javascript.Function)1 Scriptable (org.mozilla.javascript.Scriptable)1