Search in sources :

Example 1 with ScriptElement

use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.

the class DiffMatchPatch method injectJavascript.

private static void injectJavascript(String source) {
    Document doc = Document.get();
    HeadElement head = (HeadElement) doc.getElementsByTagName("head").getItem(0);
    if (head == null) {
        head = doc.createHeadElement();
        doc.insertBefore(head, doc.getBody());
    }
    ScriptElement script = doc.createScriptElement(source);
    script.setType("text/javascript");
    head.appendChild(script);
}
Also used : HeadElement(com.google.gwt.dom.client.HeadElement) ScriptElement(com.google.gwt.dom.client.ScriptElement) Document(com.google.gwt.dom.client.Document)

Example 2 with ScriptElement

use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.

the class ExternalJavaScriptLoader method startLoading.

private void startLoading() {
    assert state_ == State.Start;
    ScriptElement script = document_.createScriptElement();
    script.setType("text/javascript");
    script.setSrc(url_);
    registerCallback(script);
    Element head = document_.getElementsByTagName("head").getItem(0);
    head.appendChild(script);
}
Also used : ScriptElement(com.google.gwt.dom.client.ScriptElement) Element(com.google.gwt.dom.client.Element) ScriptElement(com.google.gwt.dom.client.ScriptElement)

Example 3 with ScriptElement

use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.

the class MathJaxLoader method createMathJaxScriptElement.

private static ScriptElement createMathJaxScriptElement() {
    ScriptElement el = Document.get().createScriptElement();
    el.setAttribute("type", "text/javascript");
    el.setSrc("mathjax/MathJax.js?config=TeX-MML-AM_CHTML");
    el.setAttribute("async", "true");
    return el;
}
Also used : ScriptElement(com.google.gwt.dom.client.ScriptElement)

Example 4 with ScriptElement

use of com.google.gwt.dom.client.ScriptElement in project rstudio by rstudio.

the class MathJaxLoader method ensureMathJaxLoaded.

public static void ensureMathJaxLoaded() {
    if (MATHJAX_LOADED)
        return;
    initializeMathJaxConfig();
    ScriptElement mathJaxEl = createMathJaxScriptElement();
    HeadElement headEl = Document.get().getHead();
    headEl.appendChild(mathJaxEl);
    Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

        @Override
        public boolean execute() {
            if (isMathJaxReady()) {
                MATHJAX_LOADED = true;
                for (Callback callback : MATHJAX_CALLBACKS) callback.onLoaded(false);
                onMathJaxLoaded();
                return false;
            }
            RETRY_COUNT++;
            return RETRY_COUNT < 50;
        }
    }, 500);
}
Also used : HeadElement(com.google.gwt.dom.client.HeadElement) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) ScriptElement(com.google.gwt.dom.client.ScriptElement)

Aggregations

ScriptElement (com.google.gwt.dom.client.ScriptElement)4 HeadElement (com.google.gwt.dom.client.HeadElement)2 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 Document (com.google.gwt.dom.client.Document)1 Element (com.google.gwt.dom.client.Element)1