Search in sources :

Example 1 with Inline

use of com.vaadin.flow.component.page.Inline in project flow by vaadin.

the class InlineTargets method addInlineDependency.

/**
 * Inline contents from classpath file to head of initial page.
 *
 * @param inline
 *            inline dependency to add to bootstrap page
 * @param request
 *            the request that is handled
 */
public void addInlineDependency(Inline inline, VaadinRequest request) {
    Inline.Wrapping type;
    // Determine the type as given or try to automatically decide
    if (inline.wrapping().equals(Inline.Wrapping.AUTOMATIC)) {
        type = determineDependencyType(inline);
    } else {
        type = inline.wrapping();
    }
    JsonObject dependency = Json.createObject();
    dependency.put(Dependency.KEY_TYPE, type.toString());
    dependency.put("LoadMode", LoadMode.INLINE.toString());
    dependency.put(Dependency.KEY_CONTENTS, BootstrapUtils.getDependencyContents(request, inline.value()));
    // Add to correct element target
    if (inline.target() == TargetElement.BODY) {
        getInlineBody(inline.position()).add(dependency);
    } else {
        getInlineHead(inline.position()).add(dependency);
    }
}
Also used : JsonObject(elemental.json.JsonObject) Inline(com.vaadin.flow.component.page.Inline)

Example 2 with Inline

use of com.vaadin.flow.component.page.Inline in project flow by vaadin.

the class InlineTargets method addInlineDependency.

/**
 * Inline contents from classpath file to head of initial page.
 *
 * @param inline
 *            inline dependency to add to bootstrap page
 * @param service
 *            the service that can find the dependency
 */
public void addInlineDependency(Inline inline, VaadinService service) {
    Inline.Wrapping type;
    // Determine the type as given or try to automatically decide
    if (inline.wrapping().equals(Inline.Wrapping.AUTOMATIC)) {
        type = determineDependencyType(inline);
    } else {
        type = inline.wrapping();
    }
    JsonObject dependency = Json.createObject();
    dependency.put(Dependency.KEY_TYPE, type.toString());
    dependency.put("LoadMode", LoadMode.INLINE.toString());
    dependency.put(Dependency.KEY_CONTENTS, BootstrapUtils.getDependencyContents(service, inline.value()));
    // Add to correct element target
    if (inline.target() == TargetElement.BODY) {
        getInlineBody(inline.position()).add(dependency);
    } else {
        getInlineHead(inline.position()).add(dependency);
    }
}
Also used : JsonObject(elemental.json.JsonObject) Inline(com.vaadin.flow.component.page.Inline)

Aggregations

Inline (com.vaadin.flow.component.page.Inline)2 JsonObject (elemental.json.JsonObject)2