Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.ScriptElement


            }
        });
    }

    protected void include(String source) {
        ScriptElement el = Document.get().createScriptElement();
        el.setType("text/javascript");
        el.setSrc(source);
        Document.get().getBody().appendChild(el);
    }
View Full Code Here


   * Install the Dygraphs JavaScript source into the current document.  This
   * method is idempotent.
   */
  public static synchronized void install() {
    if (!installed) {
      ScriptElement e = Document.get().createScriptElement();
      e.setText(RESOURCES.dygraphs().getText());
      Document.get().getBody().appendChild(e);
      installed = true;
    }
  }
View Full Code Here

        head = document.getElementsByTagName("head").getItem(0);

        // detect already loaded scripts and stylesheets
        NodeList<Element> scripts = document.getElementsByTagName("script");
        for (int i = 0; i < scripts.getLength(); i++) {
            ScriptElement element = ScriptElement.as(scripts.getItem(i));
            String src = element.getSrc();
            if (src != null && src.length() != 0) {
                loadedResources.add(src);
            }
        }
View Full Code Here

            });
            return;
        }

        if (addListener(url, resourceLoadListener, loadListeners)) {
            ScriptElement scriptTag = Document.get().createScriptElement();
            scriptTag.setSrc(url);
            scriptTag.setType("text/javascript");

            scriptTag.setPropertyBoolean("async", async);

            addOnloadHandler(scriptTag, new ResourceLoadListener() {
                @Override
                public void onLoad(ResourceLoadEvent event) {
                    fireLoad(event);
View Full Code Here

            // If ie11+ for some reason gets a preload request
            if (BrowserInfo.get().getBrowserMajorVersion() >= 11) {
                throw new RuntimeException(
                        "Browser doesn't support preloading with text/cache");
            }
            ScriptElement element = Document.get().createScriptElement();
            element.setSrc(url);
            element.setType("text/cache");
            return element;
        } else {
            ObjectElement element = Document.get().createObjectElement();
            element.setData(url);
            if (BrowserInfo.get().isChrome()) {
                element.setType("text/cache");
            } else {
                element.setType("text/plain");
            }
            element.setHeight("0px");
            element.setWidth("0px");
            return element;
        }
    }
View Full Code Here

  private static final String JSAPI_CALLBACK = "__injectedJSAPI";

  public static void load(Chronoscope.URLResolver resolver, final String libName,
      final String version, final Command callback) {
    if (!injectedLoader) {
      final ScriptElement se = Document.get().createScriptElement();
//      se.setSrc(intrinsics.getCachedUrl("http://www.google.com/jsapi?callback=" + JSAPI_CALLBACK));
      se.setSrc("http://www.google.com/jsapi?callback=" + JSAPI_CALLBACK);
     
      final HeadElement he = HeadElement.as(Document.get().getElementsByTagName("head").getItem(0));
      exportHandler(new Command() {

        public void execute() {
View Full Code Here

    Document doc = Document.get();
    String key = (apiKey == null) ? "" : ("key=" + apiKey + "&");
    hostname = (hostname == null) ? "www.google.com" : hostname;
    String src = getProtocol() + "//" + hostname + "/jsapi?" + key
        + "callback=__gwt_AjaxLoader_onLoad";
    ScriptElement script = doc.createScriptElement();
    script.setSrc(src);
    script.setType("text/javascript");
    doc.getBody().appendChild(script);
    return false;
  }
View Full Code Here

  /**
   * Fires a request to a JSONP-supporting URL.
   */
  public void request(String url, final Callback<? super R> request) {
    final String id = JSONP_HANDLER_PREFIX + jsonpCounter++;
    final ScriptElement requestMaker = Document.get().createScriptElement();
    registerCallback(id, new Callback<JavaScriptObject>() {
      @Override
      public void onSuccess(JavaScriptObject cajoled) {
        requestMaker.removeFromParent();
        deregisterCallback(id);
        request.onSuccess(cajoled.<R>cast());
      }

      @Override
      public void onError(String message) {
        // Ignore
      }
    });

    requestMaker.setSrc(url + "&" + JSONP_CALLBACK_PARAM + "=" + id);
    Document.get().getBody().appendChild(requestMaker);
  }
View Full Code Here

  /**
   * Loads Gadget RPC library script.
   */
  private static void loadGadgetRpcScript() {
    ScriptElement script = Document.get().createScriptElement();
    script.setType("text/javascript");
    script.setSrc(GADGET_RPC_PATH);
    Document.get().getBody().appendChild(script);
  }
View Full Code Here

 
  private static void processNextScript(final ScriptLoadCallback callback)
  {
    if (scripts.size() > 0)
    {
      final ScriptElement script = scripts.remove(0).cast();
      final ScriptElement cloneScript = cloneScript(script); // if cloned using node.cloneNode(), browser does not evaluate the
                                   // inner javascript when tag is attached
      Scheduler.get().scheduleDeferred(new ScheduledCommand()
      {
        @Override
        public void execute()
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.ScriptElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.