List of usage examples for com.google.gwt.dom.client LinkElement setType
public void setType(String type)
From source file:cc.kune.common.client.utils.CSSUtils.java
License:GNU Affero Public License
/** * Sets the css.// ww w . ja v a 2s . c o m * * @param cssUrl the css url * @return the link element */ public static LinkElement setCss(final String cssUrl) { final Element head = Document.get().getElementsByTagName("head").getItem(0); final LinkElement link = Document.get().createLinkElement(); link.setType("text/css"); link.setRel("stylesheet"); link.setHref(cssUrl); link.setMedia("screen"); link.setTitle("dynamicLoadedSheet"); head.insertAfter(head.getLastChild(), link); // you can use removeFromParent return link; }
From source file:cc.kune.core.client.i18n.I18nStyles.java
License:GNU Affero Public License
/** * Load a style sheet onto the page./*from ww w .j a va2s . c o m*/ * * @param href * the url of the style sheet */ private static void loadStyleSheet(final String href) { final LinkElement linkElem = Document.get().createLinkElement(); linkElem.setRel("stylesheet"); linkElem.setType("text/css"); linkElem.setHref(href); getHeadElement().appendChild(linkElem); }
From source file:cing.client.StyleSheetLoader.java
License:Apache License
/** * Load a style sheet onto the page./*from w w w. ja v a2 s .c o m*/ * * @param href * the url of the style sheet */ public static void loadStyleSheet(String href) { LinkElement linkElem = Document.get().createLinkElement(); linkElem.setRel("stylesheet"); linkElem.setType("text/css"); linkElem.setHref(href); getHeadElement().appendChild(linkElem); }
From source file:com.ait.ext4j.client.util.CSS.java
License:Apache License
private static LinkElement createLinkElement() { LinkElement link = Document.get().createLinkElement(); link.setRel("stylesheet"); link.setType("text/css"); return link;//from www. jav a2 s . com }
From source file:com.ait.toolkit.core.client.CSSUtil.java
License:Open Source License
private static LinkElement createLinkElement() { LinkElement link = Document.get().createLinkElement(); link.setRel("stylesheet"); link.setType("text/css"); return link;// w ww .j ava2 s. co m }
From source file:com.dingziran.effective.client.Showcase.java
License:Apache License
/** * Inject the GWT theme style sheet based on the RTL direction of the current * locale.//from ww w . ja va 2s .c om */ private void injectThemeStyleSheet() { // Choose the name style sheet based on the locale. String styleSheet = "gwt/" + THEME + "/" + THEME; styleSheet += LocaleInfo.getCurrentLocale().isRTL() ? "_rtl.css" : ".css"; // Load the GWT theme style sheet String modulePath = GWT.getModuleBaseURL(); LinkElement linkElem = Document.get().createLinkElement(); linkElem.setRel("stylesheet"); linkElem.setType("text/css"); linkElem.setHref(modulePath + styleSheet); getHeadElement().appendChild(linkElem); }
From source file:com.github.gwtbootstrap.client.ui.resources.ResourceInjector.java
License:Apache License
/** * Inject public resource css file as a file. * @param filename inject file name//w w w . ja v a 2 s . c o m */ public static void injectResourceCssAsFile(String filename) { LinkElement link = Document.get().createLinkElement(); link.setType("text/css"); link.setRel("stylesheet"); link.setHref(GWT.getModuleName() + "/css/" + filename); getHead().appendChild(link); }
From source file:com.taxigang.client.css.CSSFactory.java
License:Apache License
public static void loadCSS(String css_src) { cssSrc = css_src;/*from w w w . java 2 s . co m*/ if (css_src != null) { Log.info("css loading:" + css_src); if (!scriptLoaded) { LinkElement style = Document.get().createLinkElement(); style.setHref(css_src); style.setType("text/css"); style.setRel("stylesheet"); Document.get().getElementsByTagName("head").getItem(0).appendChild(style); addOnLoadHandler(style); //cssReady(); } } else { cssReady(); } //return createChannelImpl(channelId); }
From source file:com.taxigang.client.css.StyleSheetLoader.java
License:Apache License
/** * Load a style sheet onto the page.//from w w w . j a v a2 s.c om * * @param href the url of the style sheet */ public static void loadStyleSheet(String href) { Log.info("loadStyleSheet"); LinkElement linkElem = Document.get().createLinkElement(); linkElem.setRel("stylesheet"); linkElem.setType("text/css"); linkElem.setHref(href); getHeadElement().appendChild(linkElem); }
From source file:com.vaadin.client.ResourceLoader.java
License:Apache License
/** * Load a stylesheet and notify a listener when the stylesheet is loaded. * Calling this method when the stylesheet is currently loading or already * loaded doesn't cause the stylesheet to be loaded again, but the listener * will still be notified when appropriate. * /* w w w . ja v a 2 s .c o m*/ * @param stylesheetUrl * the url of the stylesheet to load * @param resourceLoadListener * the listener that will get notified when the stylesheet is * loaded */ public void loadStylesheet(final String stylesheetUrl, final ResourceLoadListener resourceLoadListener) { final String url = WidgetUtil.getAbsoluteUrl(stylesheetUrl); final ResourceLoadEvent event = new ResourceLoadEvent(this, url, false); if (loadedResources.contains(url)) { if (resourceLoadListener != null) { resourceLoadListener.onLoad(event); } return; } if (preloadListeners.containsKey(url)) { // Preload going on, continue when preloaded preloadResource(url, new ResourceLoadListener() { @Override public void onLoad(ResourceLoadEvent event) { loadStylesheet(url, resourceLoadListener); } @Override public void onError(ResourceLoadEvent event) { // Preload failed -> signal error to own listener if (resourceLoadListener != null) { resourceLoadListener.onError(event); } } }); return; } if (addListener(url, resourceLoadListener, loadListeners)) { LinkElement linkElement = Document.get().createLinkElement(); linkElement.setRel("stylesheet"); linkElement.setType("text/css"); linkElement.setHref(url); if (BrowserInfo.get().isSafari()) { // Safari doesn't fire any events for link elements // See http://www.phpied.com/when-is-a-stylesheet-really-loaded/ Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() { private final Duration duration = new Duration(); @Override public boolean execute() { int styleSheetLength = getStyleSheetLength(url); if (getStyleSheetLength(url) > 0) { fireLoad(event); return false; // Stop repeating } else if (styleSheetLength == 0) { // "Loaded" empty sheet -> most likely 404 error fireError(event); return true; } else if (duration.elapsedMillis() > 60 * 1000) { fireError(event); return false; } else { return true; // Continue repeating } } }, 10); } else { addOnloadHandler(linkElement, new ResourceLoadListener() { @Override public void onLoad(ResourceLoadEvent event) { // Chrome, IE, Edge all fire load for errors, must check // stylesheet data if (BrowserInfo.get().isChrome() || BrowserInfo.get().isIE() || BrowserInfo.get().isEdge()) { int styleSheetLength = getStyleSheetLength(url); // Error if there's an empty stylesheet if (styleSheetLength == 0) { fireError(event); return; } } fireLoad(event); } @Override public void onError(ResourceLoadEvent event) { fireError(event); } }, event); if (BrowserInfo.get().isOpera()) { // Opera onerror never fired, assume error if no onload in x // seconds new Timer() { @Override public void run() { if (!loadedResources.contains(url)) { fireError(event); } } }.schedule(5 * 1000); } } head.appendChild(linkElement); } }