Package com.google.gwt.dom.client

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


    } else {
      src = "http://www.google-analytics.com/ga.js";
    }

    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc(src);
    script.setType("text/javascript");
    script.setAttribute("async", "true");

    doc.getBody().appendChild(script);

    return false;
  }
View Full Code Here


    } else {
      src = "http://www.google-analytics.com/ga.js";
    }

    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc(src);
    script.setType("text/javascript");
    script.setAttribute("async", "true");

    doc.getBody().appendChild(script);

    return false;
  }
View Full Code Here

   * @param javascript
   *            the JavaScript code
   */
  public static void inject(String javascript) {
    HeadElement head = getHead();
    ScriptElement element = createScriptElement();
    element.setText(javascript);
    head.appendChild(element);
  }
View Full Code Here

    }
    return JavascriptInjector.head;
  }

  private static ScriptElement createScriptElement() {
    ScriptElement script = Document.get().createScriptElement();
    script.setAttribute("type", "text/javascript");
    script.setAttribute("charset", "UTF-8");
    return script;
  }
View Full Code Here

   * @param cmd the command to execute the init function
   */
  private void initHandler(String initFunc, Command cmd) {
    if (GWT.isClient()) {
      // Embed the init script on the page
      ScriptElement scriptElem = Document.get().createScriptElement(initFunc);
      Document.get().getBody().appendChild(scriptElem);
 
      // Initialize the handler
      cmd.execute();
 
View Full Code Here

    if (failureCallbackParam != null) {
      uri.append("&");
      uri.append(failureCallbackParam).append("=").append(prefix).append(
          ".onFailure");
    }
    ScriptElement script = Document.get().createScriptElement();
    script.setType("text/javascript");
    script.setId(callbackId);
    script.setSrc(uri.toString());
    timer = new Timer() {
      @Override
      public void run() {
        onFailure(new TimeoutException("Timeout while calling " + baseUri));
      }
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

  /**
   * 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

public class CustomAnalyticsImpl implements GoogleAnalytics {
  @Override
  public void init(String userAccount) {
    Element firstScript = Document.get().getElementsByTagName("script").getItem(0);

    ScriptElement config = Document.get().createScriptElement(
        "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + userAccount
            + "']);_gaq.push (['_gat._anonymizeIp']);_gaq.push(['_trackPageview']);");

    firstScript.getParentNode().insertBefore(config, firstScript);

    ScriptElement script = Document.get().createScriptElement();

    // Add the google analytics script.
    script.setSrc(("https:".equals(Window.Location.getProtocol())
        ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js");
    script.setType("text/javascript");
    script.setAttribute("async", "true");

    firstScript.getParentNode().insertBefore(script, firstScript);
  }
View Full Code Here

        Element fbRoot = Document.get().createDivElement();
        fbRoot.setId(FB_ROOT);

        firstElement.getParentNode().insertBefore(fbRoot, firstElement);

        ScriptElement fbScript = Document.get().createScriptElement();
        fbScript.setSrc(FB_SCRIPT_SRC);
        fbScript.setType(FB_SCRIPT_TYPE);

        fbRoot.getParentNode().insertAfter(fbScript, fbRoot);

        Timer ensureFbIsLoaded = new Timer() {
            @Override
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.