Search in sources :

Example 1 with HeadElement

use of com.google.gwt.dom.client.HeadElement 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)

Example 2 with HeadElement

use of com.google.gwt.dom.client.HeadElement 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)

Aggregations

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