List of usage examples for com.google.gwt.dom.client LinkElement getRel
public String getRel()
From source file:com.vaadin.client.ResourceLoader.java
License:Apache License
/** * Creates a new resource loader. You should generally not create you own * resource loader, but instead use {@link ResourceLoader#get()} to get an * instance./*from w w w . j a v a 2 s .co m*/ */ protected ResourceLoader() { Document document = Document.get(); head = document.getElementsByTagName("head").getItem(0); // detect already loaded scripts and stylesheets NodeList<Element> scripts = document.getElementsByTagName("script"); for (int i = 0; i < scripts.getLength(); i++) { ScriptElement element = ScriptElement.as(scripts.getItem(i)); String src = element.getSrc(); if (src != null && src.length() != 0) { loadedResources.add(src); } } NodeList<Element> links = document.getElementsByTagName("link"); for (int i = 0; i < links.getLength(); i++) { LinkElement linkElement = LinkElement.as(links.getItem(i)); String rel = linkElement.getRel(); String href = linkElement.getHref(); if ("stylesheet".equalsIgnoreCase(rel) && href != null && href.length() != 0) { loadedResources.add(href); } } }
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
/** * Internal helper for removing any stylesheet with the given URL * /*from w w w . j a v a2 s . c o m*/ * @since 7.3 * @param url * the url to match with existing stylesheets */ private void removeStylesheet(String url) { NodeList<Element> linkTags = getHead().getElementsByTagName(LinkElement.TAG); for (int i = 0; i < linkTags.getLength(); i++) { LinkElement link = LinkElement.as(linkTags.getItem(i)); if (!"stylesheet".equals(link.getRel())) { continue; } if (!"text/css".equals(link.getType())) { continue; } if (url.equals(link.getHref())) { getHead().removeChild(link); } } }
From source file:com.vaadin.client.ui.ui.UIConnector.java
License:Apache License
/** * Finds a link tag for a style sheet with the given URL * /* w ww . j a v a 2s . com*/ * @since 7.3 * @param url * the URL of the style sheet * @return the link tag or null if no matching link tag was found */ private LinkElement findStylesheetTag(String url) { NodeList<Element> linkTags = getHead().getElementsByTagName(LinkElement.TAG); for (int i = 0; i < linkTags.getLength(); i++) { final LinkElement link = LinkElement.as(linkTags.getItem(i)); if ("stylesheet".equals(link.getRel()) && "text/css".equals(link.getType()) && url.equals(link.getHref())) { return link; } } return null; }
From source file:fr.putnami.pwt.core.theme.client.DefaultThemeController.java
License:Open Source License
/** * Removes all link tags in the head if not initialized. *///from www . jav a 2 s.com private void removeCssLinks() { if (this.isInit) { return; } this.isInit = true; // Remove all existing link element NodeList<Element> links = this.getHead().getElementsByTagName(LinkElement.TAG); int size = links.getLength(); for (int i = 0; i < size; i++) { LinkElement elem = LinkElement.as(links.getItem(0)); if ("stylesheet".equals(elem.getRel())) { elem.removeFromParent(); } } }