Search in sources :

Example 1 with StylesheetLink

use of org.apache.tapestry5.services.javascript.StylesheetLink in project tapestry-5 by apache.

the class AssetDemo method afterRender.

@Import(stylesheet = "context:css/via-import.css")
void afterRender() {
    javascriptSupport.importStylesheet(new StylesheetLink(ieOnly, new StylesheetOptions(null, "IE")));
    javascriptSupport.importJavaScriptLibrary(getAssetWithWrongChecksumUrl());
}
Also used : StylesheetLink(org.apache.tapestry5.services.javascript.StylesheetLink) StylesheetOptions(org.apache.tapestry5.services.javascript.StylesheetOptions) Import(org.apache.tapestry5.annotations.Import)

Example 2 with StylesheetLink

use of org.apache.tapestry5.services.javascript.StylesheetLink in project tapestry-5 by apache.

the class DocumentLinkerImpl method addStylesheetsToHead.

/**
 * Locates the head element under the root ("html") element, creating it if necessary, and adds the stylesheets to
 * it.
 *
 * @param root
 *         element of document
 * @param stylesheets
 *         to add to the document
 */
protected void addStylesheetsToHead(Element root, List<StylesheetLink> stylesheets) {
    int count = stylesheets.size();
    if (count == 0) {
        return;
    }
    // This only applies when the document is an HTML document. This may need to change in the
    // future, perhaps configurable, to allow for html and xhtml and perhaps others. Does SVG
    // use stylesheets?
    String rootElementName = root.getName();
    // Not an html document, don't add anything.
    if (!rootElementName.equals("html")) {
        return;
    }
    Element head = findOrCreateElement(root, "head", true);
    // Create a temporary container element.
    Element container = createTemporaryContainer(head, "style", "stylesheet-container");
    for (int i = 0; i < count; i++) {
        stylesheets.get(i).add(container);
    }
    container.pop();
}
Also used : Element(org.apache.tapestry5.dom.Element)

Example 3 with StylesheetLink

use of org.apache.tapestry5.services.javascript.StylesheetLink in project tapestry-5 by apache.

the class PartialMarkupDocumentLinker method addStylesheetLink.

public void addStylesheetLink(StylesheetLink stylesheet) {
    JSONObject object = new JSONObject("href", stylesheet.getURL(), "media", stylesheet.getOptions().media);
    stylesheets.put(object);
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject)

Aggregations

Import (org.apache.tapestry5.annotations.Import)1 Element (org.apache.tapestry5.dom.Element)1 JSONObject (org.apache.tapestry5.json.JSONObject)1 StylesheetLink (org.apache.tapestry5.services.javascript.StylesheetLink)1 StylesheetOptions (org.apache.tapestry5.services.javascript.StylesheetOptions)1