Example usage for com.google.gwt.dom.client LinkElement setHref

List of usage examples for com.google.gwt.dom.client LinkElement setHref

Introduction

In this page you can find the example usage for com.google.gwt.dom.client LinkElement setHref.

Prototype

public void setHref(@IsTrustedResourceUri String href) 

Source Link

Document

The URI of the linked resource.

Usage

From source file:cc.kune.common.client.utils.CSSUtils.java

License:GNU Affero Public License

/**
 * Sets the css.//from   w  w w.j  av  a2 s.com
 *
 * @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 w  w w  . ja v  a  2s  .  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:ch.unifr.pai.twice.layout.client.mobile.MobileUtils.java

License:Apache License

/**
 * Add necessary html tags to ensure unified initial zoom levels of the web page, fullscreen establishment and add proprietary tags (e.g.
 * "apple-mobile-web-app-capable" for extended functionalities).
 * /*from   www  .  j av a2 s .  co  m*/
 * The main purpose is to establish a "native" look of the application even within the boundaries of the web browser.
 */
public static void preparePage() {
    RootPanel.getBodyElement().getStyle().setHeight(100, Unit.PCT);
    RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
    RootPanel.getBodyElement().getStyle().setMargin(0, Unit.PX);
    RootPanel.getBodyElement().getStyle().setPadding(0, Unit.PX);
    Document.get().getDocumentElement().getStyle().setProperty("minHeight", "300px");
    Document.get().getDocumentElement().getStyle().setHeight(100, Unit.PCT);
    NodeList<Element> tags = Document.get().getElementsByTagName("head");
    Element head;
    if (tags.getLength() > 0) {
        head = tags.getItem(0);
    } else {
        head = DOM.createElement("head");
        Document.get().insertFirst(head);
    }
    Element meta = DOM.createElement("meta");
    meta.setAttribute("name", "viewport");
    meta.setAttribute("content", "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0");
    head.appendChild(meta);
    LinkElement e = Document.get().createLinkElement();
    e.setRel("stylesheet");
    e.setHref(GWT.getModuleBaseURL() + "master.css");
    head.appendChild(e);

    Element iphoneFullscreen = DOM.createElement("meta");
    iphoneFullscreen.setAttribute("name", "apple-touch-fullscreen");
    iphoneFullscreen.setAttribute("content", "yes");
    head.appendChild(iphoneFullscreen);

    Element iphoneWebAppCapable = DOM.createElement("meta");
    iphoneWebAppCapable.setAttribute("name", "apple-mobile-web-app-capable");
    iphoneWebAppCapable.setAttribute("content", "yes");
    head.appendChild(iphoneWebAppCapable);

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            Window.scrollTo(0, 1);
        }
    });
}

From source file:cing.client.StyleSheetLoader.java

License:Apache License

/**
 * Load a style sheet onto the page./*from   ww  w .  j  a  v  a  2s.co  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

/**
 * /** Injects the css url code into a//www. ja  va2  s  .c o  m
 * {@code <link rel="stylesheet" href="...." />} element in the document
 * header.
 * 
 * @param href
 *            , url of the href to inject
 */
public static void injectStyleSheet(String href) {
    HeadElement head = getHead();
    LinkElement element = createLinkElement();
    element.setHref(href);
    head.appendChild(element);
}

From source file:com.ait.toolkit.core.client.CSSUtil.java

License:Open Source License

public static void injectStyleSheet(String href, String id) {
    HeadElement head = getHead();/* w  w w.  j  a va  2s.co  m*/
    LinkElement element = createLinkElement();
    element.setHref(href);
    element.setId(id);
    head.appendChild(element);
}

From source file:com.ait.toolkit.sencha.ext.client.util.CSS.java

License:Open Source License

/**
 * /** Injects the css url code into a/*  ww  w.  ja va2 s .  c o  m*/
 * {@code <link rel="stylesheet" href="...." />} element in the document
 * header.
 * 
 * @param href
 *            , url of the href to inject
 */
public static LinkElement injectStyleSheet(String href) {
    HeadElement head = getHead();
    LinkElement element = createLinkElement();
    element.setHref(href);
    head.appendChild(element);
    return element;
}

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.//w w w.  ja v a  2 s  . c o  m
 */
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.dotweblabs.friendscube.app.client.local.util.CssHelper.java

License:Apache License

/** Load CSS file from url */
public static void loadCss(String url) {
    LinkElement link = Document.get().createLinkElement();
    link.setRel("stylesheet");
    link.setHref(url);
    nativeAttachToHead(link);// w ww .  j a va 2 s . c o m
    styles.put(url, link);
}

From source file:com.emitrom.pilot.core.formfactor.client.ResourceInjector.java

License:Apache License

/**
 * Loads a css file base on the file url
 * /*from w  w w .  ja v a  2  s  .  c o m*/
 * @param url
 *            , url of the file to load
 */
public void loadCss(String url) {
    LinkElement link = Document.get().createLinkElement();
    link.setRel("stylesheet");
    link.setHref(url);
    attachToHead(link);
}