Package com.google.gwt.dom.client

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


                                 + "js = d.createElement(s); js.id = id;"
                                 + "js.src = \"//connect.facebook.net/"+locale.getLocaleName()+"/all.js#xfbml=1&appId="+Constants.FACEBOOK_APP_ID+"\";"
                                 + "fjs.parentNode.insertBefore(js, fjs);"
                                 + "}(document, 'script', 'facebook-jssdk'));";

        final ScriptElement scriptElement = Document.get().createScriptElement(scriptStr);

        // facebook recommends to place the script just after the body tag
        bodyElement.insertFirst(fbRootElement);
        bodyElement.insertAfter(scriptElement, fbRootElement);
  }
View Full Code Here


    }
    Document doc = Document.get();
    String key = (apiKey == null) ? "" : ("key=" + apiKey + "&");
    String src = getProtocol() + "//www.google.com/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

    @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(['_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

        // Every requests gets a new callback, so that we can make many
        // requests in parallel.
        String callbackName = "cb" + callbackCounter++;
        url += "&callback=" + callbackName;
        registerCallback(callbackName, callback);
        ScriptElement element = Document.get().createScriptElement();
        element.setSrc(url);
        Document.get().getBody().appendChild(element);
    }
View Full Code Here

    }
    Document doc = Document.get();
    String key = (apiKey == null) ? "" : ("key=" + apiKey + "&");
    String src = getProtocol() + "//www.google.com/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

    if (fbLocale == null) {
      // todo: get default locale from user, accounting for list of Facebook-allowed locales, available from http://www.facebook.com/translations/FacebookLocales.xml
      fbLocale = DefaultLocale;
    }

    ScriptElement script = doc.createScriptElement();
    script.setType("text/javascript");
    script.setId(FacebookScriptElementID);
    script.setSrc(Window.Location.getProtocol() + "//" + FacebookScriptServer + "/" + fbLocale + "/" + FacebookScriptName);
    // facebook seems to think this async is necessary
    script.setPropertyBoolean("async", true);

    if (initializationTimeout > 0) {
      if (initializationTimer == null) {
        initializationTimer = new Timer() {
          @Override
View Full Code Here

    }

    public static void intject(String javaScript) {
        HeadElement head = getHead();
        ScriptElement element = createScriptElement();
        element.setText(javaScript);
        head.appendChild(element);
    }
View Full Code Here

        element.setText(javaScript);
        head.appendChild(element);
    }

    private static ScriptElement createScriptElement() {
        ScriptElement script = Document.get().createScriptElement();
        script.setAttribute("type", "text/javascript");
        return script;
    }
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

   */
  private void initHandler(String initFunc, String funcName, Command cmd) {
    if (GWT.isClient()) {
      // Embed the init script on the page
      initFunc = initFunc.replaceFirst("function", "function " + funcName);
      ScriptElement scriptElem = Document.get().createScriptElement(initFunc);
      Document.get().getBody().appendChild(scriptElem);
 
      // Initialize the handler
      cmd.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.