Java 类com.google.gwt.dom.client.ScriptElement 实例源码

项目:Charba    文件:Injector.java   
/**
 * Injects ChartJS if not injected yet.
 */
static void ensureInjected() {
    if (!injected) {
        // gets resource
        Resources res = GWT.create(Resources.class);
        // gets source of ChartJS
        String source = res.chartJsSource().getText();
        // creates a script element
        ScriptElement scriptElement = Document.get().createScriptElement();
        // sets ID
        scriptElement.setId(CHART_JS_SCRIPT_ELEMENT_ID);
        // sets the script content with ChartJS source
        scriptElement.setInnerText(source);
        // appends to the body
        Document.get().getBody().appendChild(scriptElement);
        injected = true;
    }
}
项目:gwt-chronoscope    文件:GoogleLoader.java   
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() {
          injectedLoader=true;
          he.removeChild(se);
          nativeLoad(libName, version, callback);
        }
      });

      he.appendChild(se);
    } else {
      nativeLoad(libName, version, callback);
    }
  }
项目:firefly    文件:JSLoad.java   
public JSLoad(Loaded loaded, String... url) {
    _callbackList.add(loaded);
    Document document= Document.get();

    for(String u : url) {
        ScriptElement script= document.createScriptElement();
        script.setSrc(u);
        script.setType("text/javascript");
        _map.put(script,false);
        if (BrowserUtil.isIE() && BrowserUtil.getMajorVersion()<9) {
            addIEListener(this,script,loaded);
        }
        else {
            addListener(this,script,loaded);
        }
        document.getBody().appendChild(script);
    }

}
项目:gerrit    文件:Loader.java   
public static void injectScript(SafeUri js, AsyncCallback<Void> callback) {
  final ScriptElement[] script = new ScriptElement[1];
  script[0] =
      ScriptInjector.fromUrl(js.asString())
          .setWindow(ScriptInjector.TOP_WINDOW)
          .setCallback(
              new Callback<Void, Exception>() {
                @Override
                public void onSuccess(Void result) {
                  script[0].removeFromParent();
                  callback.onSuccess(result);
                }

                @Override
                public void onFailure(Exception reason) {
                  callback.onFailure(reason);
                }
              })
          .inject()
          .cast();
}
项目:yaph    文件:SQLite.java   
public final static SQLite create(JsArrayInteger data) {
    // Loads the SQLite.js script if not done already
    if (bundle == null) {
        bundle = (SQLiteBundle) GWT.create(SQLiteBundle.class);

        Document doc = Document.get();
        ScriptElement sqljs = doc.createScriptElement();
        sqljs.setAttribute("type", "text/javascript");
        sqljs.setInnerText(bundle.SqlJs().getText());
        doc.getDocumentElement().getFirstChildElement().appendChild(sqljs);
    }

    if (data != null)
        return createWithDataJsni(data);

    return createJsni();
}
项目:hexa.tools    文件:SQLite.java   
public final static SQLite create( JsArrayInteger data )
{
    if( bundle == null )
    {
        bundle = (SQLiteBundle) GWT.create( SQLiteBundle.class );

        Document doc = Document.get();
        ScriptElement sqljs = doc.createScriptElement();
        sqljs.setAttribute( "type", "text/javascript" );
        sqljs.setInnerText( bundle.SqlJs().getText() );
        doc.getDocumentElement().getFirstChildElement().appendChild( sqljs );
    }

    if( data != null )
        return createWithDataJsni( data );

    return createJsni();
}
项目:hexa.tools    文件:JQuery.java   
public static void ensureScriptsLoaded()
{
    if( bundle != null )
        return;

    bundle = GWT.create( JQueryBundle.class );

    Document doc = Document.get();
    ScriptElement sqljs = doc.createScriptElement();
    sqljs.setAttribute( "type", "text/javascript" );
    sqljs.setInnerText( bundle.JQueryJS().getText() );
    doc.getDocumentElement().getFirstChildElement().appendChild( sqljs );

    sqljs = doc.createScriptElement();
    sqljs.setAttribute( "type", "text/javascript" );
    sqljs.setInnerText( bundle.JQueryUIJS().getText() );
    doc.getDocumentElement().getFirstChildElement().appendChild( sqljs );
}
项目:gwt-ga    文件:GoogleAnalyticsImpl.java   
@Override
public void init( final String userAccount )
{
  final Element firstScript = Document.get().getElementsByTagName( "script" ).getItem( 0 );
  final String source =
    "var _gaq = _gaq || [];_gaq.push(['_setAccount', '" + userAccount + "']);_gaq.push(['_trackPageview']);";
  final ScriptElement config = Document.get().createScriptElement( source );

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

  final 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 );
}
项目:Wiab.pro    文件:GadgetWidget.java   
/**
 * Loads Gadget RPC library script.
 */
private static void loadGadgetRpcScript() {
  ScriptElement script = Document.get().createScriptElement();
  script.setType("text/javascript");
  script.setSrc(Flags.get().gadgetRpcPath());
  Document.get().getBody().appendChild(script);
}
项目:firefly    文件:JSLoad.java   
public native void addIEListener(JSLoad jsload, ScriptElement script, Loaded loaded) /*-{
    var listener= @edu.caltech.ipac.firefly.ui.JSLoad::doneListenerStatic(Ledu/caltech/ipac/firefly/ui/JSLoad;Lcom/google/gwt/user/client/Event;);
    script.attachEvent(
            "onload",
            $entry(
                    function(event) {
                        listener(jsload, event);
                    })
            );
}-*/;
项目:firefly    文件:JSLoad.java   
public native void addListener(JSLoad jsload, ScriptElement script, Loaded loaded) /*-{
    var listener= @edu.caltech.ipac.firefly.ui.JSLoad::doneListenerStatic(Ledu/caltech/ipac/firefly/ui/JSLoad;Lcom/google/gwt/user/client/Event;);
    script.addEventListener(
            "load",
            $entry(
            function(event) { listener(jsload, event); }),
             false);
}-*/;
项目:firefly    文件:JSLoad.java   
public void doneListener(Event ev) {
    JavaScriptObject source= ev.getEventTarget();
    if (_map.containsKey(source) && ScriptElement.is(source)) {
        _map.put(source,true);
    }
    else {
        // some error here
    }
    if (isAllLoaded()) allCompleteNotify();
}
项目:appformer    文件:TwitterGadgetScreen.java   
@PostConstruct
public void init() {
    final ScriptElement se = Document.get().createScriptElement();
    se.setId("twitter-wjs");
    se.setSrc("http://platform.twitter.com/widgets.js");
    this.getElement().appendChild(se);
}
项目:appformer    文件:ChartJs.java   
/**
 * Method injecting native chart.js code into the browser<br/>
 * In case code already been injected do nothing
 */
public static void ensureInjected(){ //TODO: do real injection (lazy loading)
    if(injected)
        return;
    Resources res = GWT.create(Resources.class);
    String source = res.chartJsSource().getText();
       ScriptElement scriptElement = Document.get().createScriptElement();
       scriptElement.setId("_chartjs");
       scriptElement.setInnerText(source);
       Document.get().getBody().appendChild(scriptElement);
    injected = true;
}
项目:dashbuilder    文件:ChartJs.java   
/**
 * Method injecting native chart.js code into the browser<br/>
 * In case code already been injected do nothing
 */
public static void ensureInjected(){ //TODO: do real injection (lazy loading)
    if(injected)
        return;
    Resources res = GWT.create(Resources.class);
    String source = res.chartJsSource().getText();
       ScriptElement scriptElement = Document.get().createScriptElement();
       scriptElement.setId("_chartjs");
       scriptElement.setInnerText(source);
       Document.get().getBody().appendChild(scriptElement);
    injected = true;
}
项目:hexa.tools    文件:RaphaelJS.java   
private static void _ensureScriptLoaded()
{
    if( bundle != null )
        return;

    bundle = (RaphaelBundle) GWT.create( RaphaelBundle.class );

    Document doc = Document.get();
    ScriptElement sqljs = doc.createScriptElement();
    sqljs.setAttribute( "type", "text/javascript" );
    sqljs.setInnerText( bundle.RaphaelJs().getText() );
    doc.getDocumentElement().getFirstChildElement().appendChild( sqljs );
}
项目:hexa.tools    文件:ImagePreLoader.java   
public void preload( String url, Callback callback )
{
    if( !isScriptInstalled() )
    {
        ScriptElement script = Document.get().createScriptElement();
        script.setText( resources.preloadImageScript().getText() );

        Document.get().getBody().appendChild( script );
    }

    preloadImpl( id++, url, callback );
}
项目:putnami-web-toolkit    文件:GoogleAnalyticsImpl.java   
private void loadAnalyticsScript() {
    ScriptElement script = Document.get().createScriptElement();
    script.setSrc(GoogleAnalyticsImpl.SCRIPT_URL);
    script.setType("text/javascript");
    script.setAttribute("async", "true");

    Element firstScript = Document.get().getElementsByTagName("script").getItem(0);
    firstScript.getParentNode().insertBefore(script, firstScript);
}
项目:lumongo    文件:PlaceHandler.java   
private void initGA() {
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("https://ssl.google-analytics.com/ga.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);
}
项目:cloud-dev-studio    文件:ESBJavaScriptInjector.java   
public static void inject(String javascript) {

        HeadElement head = getHead();
        new Timer() {

            public void run() {
                // goJsPlumb();
                goJS();
            }
        }.schedule(1);

        ScriptElement element = createScriptElement();
        element.setText(javascript);
        head.appendChild(element);
    }
项目:QMAClone    文件:PlusOne.java   
public static void render() {
    ScriptElement scriptElement = Document.get().createScriptElement();
    scriptElement.setType("text/javascript");
    scriptElement.setAttribute("async", "true");
    scriptElement.setSrc("https://apis.google.com/js/plusone.js");
    getHead().appendChild(scriptElement);
}
项目:incubator-wave    文件:GadgetWidget.java   
/**
 * 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);
}
项目:swarm    文件:U_Native.java   
public static void insertScript(String scriptSrc)
{
    Document document = Document.get();
    ScriptElement element = document.createScriptElement();
    element.setType("text/javascript");
    element.setLang("javascript");

    document.getElementsByTagName("head").getItem(0).appendChild(element);

    element.setSrc(scriptSrc);
}
项目:gwt-chartjs    文件:ChartJs.java   
/**
 * Method injecting native chart.js code into the browser<br/>
 * In case code already been injected do nothing
 */
public static void ensureInjected(){ //TODO: do real injection (lazy loading)
    if(injected)
        return;
    Resources res = GWT.create(Resources.class);
    String source = res.chartJsSource().getText();
       ScriptElement scriptElement = Document.get().createScriptElement();
       scriptElement.setId("_chartjs");
       scriptElement.setInnerText(source);
       Document.get().getBody().appendChild(scriptElement);
    injected = true;
}
项目:ahome-touch    文件:JsInjector.java   
public static void intject(String javaScript) {
    HeadElement head = getHead();
    ScriptElement element = createScriptElement();
    element.setText(javaScript);
    head.appendChild(element);
}
项目:ahome-touch    文件:JsInjector.java   
private static ScriptElement createScriptElement() {
    ScriptElement script = Document.get().createScriptElement();
    script.setAttribute("type", "text/javascript");
    return script;
}
项目:cloud-dev-studio    文件:ESBJavaScriptInjector.java   
private static ScriptElement createScriptElement() {
    ScriptElement script = Document.get().createScriptElement();
    script.setAttribute("language", "javascript");
    return script;

}
项目:cloud-dev-studio    文件:JSLibInjector.java   
public static void inject(String javascript) {
    HeadElement head = getHead();
    ScriptElement element = createScriptElement();
    element.setText(javascript);
    head.appendChild(element);
}
项目:cloud-dev-studio    文件:JSLibInjector.java   
private static ScriptElement createScriptElement() {
    ScriptElement script = Document.get().createScriptElement();
    script.setAttribute("language", "javascript");
    return script;
}
项目:touch4j    文件:JsInjector.java   
public static void intject(String javaScript) {
    HeadElement head = getHead();
    ScriptElement element = createScriptElement();
    element.setText(javaScript);
    head.appendChild(element);
}
项目:touch4j    文件:JsInjector.java   
private static ScriptElement createScriptElement() {
    ScriptElement script = Document.get().createScriptElement();
    script.setAttribute("type", "text/javascript");
    return script;
}