Package com.google.gwt.dom.client

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


            // Check if we have resources to inject
            if (cssInjectionsUidl.getTag().equals("css-resource")) {
                String url = getWidget().connection
                        .translateVaadinUri(cssInjectionsUidl
                                .getStringAttribute("url"));
                LinkElement link = LinkElement.as(DOM
                        .createElement(LinkElement.TAG));
                link.setRel("stylesheet");
                link.setHref(url);
                link.setType("text/css");
                getHead().appendChild(link);
                // Check if we have CSS string to inject
            } else if (cssInjectionsUidl.getTag().equals("css-string")) {
                for (Iterator<?> it2 = cssInjectionsUidl.getChildIterator(); it2
                        .hasNext();) {
View Full Code Here


     */
    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);
            }
        }
    }
View Full Code Here

     *            The url of the new theme
     */
    private void replaceTheme(final String oldTheme, final String newTheme,
            String oldThemeUrl, final String newThemeUrl) {

        LinkElement tagToReplace = null;

        if (oldTheme != null) {
            tagToReplace = findStylesheetTag(oldThemeUrl);

            if (tagToReplace == null) {
                getLogger()
                        .warning(
                                "Did not find the link tag for the old theme ("
                                        + oldThemeUrl
                                        + "), adding a new stylesheet for the new theme ("
                                        + newThemeUrl + ")");
            }
        }

        if (newTheme != null) {
            loadTheme(newTheme, newThemeUrl, tagToReplace);
        } else {
            if (tagToReplace != null) {
                tagToReplace.getParentElement().removeChild(tagToReplace);
            }

            activateTheme(null);
        }

View Full Code Here

     */
    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;
    }
View Full Code Here

     *            The link element to replace. If null, then the new link
     *            element is added at the end.
     */
    private void loadTheme(final String newTheme, final String newThemeUrl,
            final LinkElement tagToReplace) {
        LinkElement newThemeLinkElement = Document.get().createLinkElement();
        newThemeLinkElement.setRel("stylesheet");
        newThemeLinkElement.setType("text/css");
        newThemeLinkElement.setHref(newThemeUrl);
        ResourceLoader.addOnloadHandler(newThemeLinkElement,
                new ResourceLoadListener() {

                    @Override
                    public void onLoad(ResourceLoadEvent event) {
View Full Code Here

            }
        }

        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);
            }
        }
View Full Code Here

            });
            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() {
View Full Code Here

   *
   * @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);
  }
View Full Code Here

    NodeList<Element> nodeList = Document.get().getElementsByTagName("head");
    if (nodeList.getLength() != 1) {
      throw new RuntimeException("can not find head element, does your html include a head section?");
    }
    final Element head = nodeList.getItem(0);
    final LinkElement linkElement = Document.get().createLinkElement();
    linkElement.setRel("stylesheet");
    linkElement.setType("text/css");
    linkElement.setHref(url);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

      @Override
      public void execute() {
        head.appendChild(linkElement);
View Full Code Here

    // by putting this in your gwt.xml
    // <set-property name="mgwt.mainresource.inject" value="no" />
    MainResourceHolder.inject();

    if (settings.getIconUrl() != null) {
      LinkElement iconUrlLinkElement = Document.get().createLinkElement();
      iconUrlLinkElement.setRel("apple-touch-icon");
      iconUrlLinkElement.setHref(settings.getIconUrl());
      head.appendChild(iconUrlLinkElement);
    }

    if (settings.getStartUrl() != null) {
      LinkElement startUrlLinkElement = Document.get().createLinkElement();
      startUrlLinkElement.setRel("apple-touch-startup-image");
      startUrlLinkElement.setHref(settings.getStartUrl());
      head.appendChild(startUrlLinkElement);
    }

    ViewPort viewPort = settings.getViewPort();
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.LinkElement

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.