/** * @param js * to inject * @return wheter the js injected already, or not. This check is made during * injection, but can be useful. */ public static boolean injected(TextResource js) { return DOM.getElementById(js.getName()) != null; } }
public static void injectJs(TextResource resource, boolean removeTag, boolean sourceUrl) { if (!resource.getName().equals("jQuery") && !resource.getName().equals("jQueryDebug") && !checkJQuery(sourceUrl)) { // We need to wait for jQuery to load if (futureResources == null) { futureResources = new ArrayList<>(); } futureResources.add(new FutureResource(resource, removeTag, sourceUrl)); } else { directInjectJs(resource, removeTag, sourceUrl); } }
public static void injectJs(TextResource resource, boolean removeTag, boolean sourceUrl) { if (!resource.getName().equals("jQuery") && !resource.getName().equals("jQueryDebug") && !checkJQuery(sourceUrl)) { // We need to wait for jQuery to load if (futureResources == null) { futureResources = new ArrayList<>(); } futureResources.add(new FutureResource(resource, removeTag, sourceUrl)); } else { directInjectJs(resource, removeTag, sourceUrl); } }
/** * @param scriptResource * javascript file */ public static void inject(TextResource scriptResource) { if (DOM.getElementById(scriptResource.getName()) == null) { ScriptElement element = createScriptElement(scriptResource .getName()); element.setText(scriptResource.getText()); getHead().appendChild(element); } }
private boolean checkPreloadNative(String familyName, TextResource resource) { if (resource.getName().equals(familyName)) { ScriptInjector.fromString(resource.getText()) .setWindow(ScriptInjector.TOP_WINDOW).inject(); parseFont(familyName); return true; } return false; }
protected static void directInjectJs(TextResource resource, boolean removeTag, boolean sourceUrl) { String text = resource.getText() + (sourceUrl ? "//# sourceURL=" + resource.getName() + ".js" : ""); // Inject the script resource ScriptInjector.fromString(text) .setWindow(ScriptInjector.TOP_WINDOW) .setRemoveTag(removeTag) .inject(); }
protected static void directInjectJs(TextResource resource, boolean removeTag, boolean sourceUrl) { String text = resource.getText() + (sourceUrl ? "//# sourceURL=" + resource.getName() + ".js" : ""); // Inject the script resource ScriptInjector.fromString(text) .setWindow(ScriptInjector.TOP_WINDOW) .setRemoveTag(removeTag) .inject(); }