Search in sources :

Example 6 with Attr

use of org.structr.api.util.html.Attr in project structr by structr.

the class ConfigServlet method setupDocument.

// ----- private methods -----
private Tag setupDocument(final HttpServletRequest request, final Document doc) {
    final Tag head = doc.block("head");
    head.block("title").text(TITLE);
    head.empty("meta").attr(new Attr("http-equiv", "Content-Type"), new Attr("content", "text/html;charset=utf-8"));
    head.empty("meta").attr(new Name("viewport"), new Attr("content", "width=1024, user-scalable=yes"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/lib/jquery-ui-1.10.3.custom.min.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/main.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/config.css"));
    head.empty("link").attr(new Rel("icon"), new Href("favicon.ico"), new Type("image/x-icon"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-1.11.1.min.js"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-ui-1.11.0.custom.min.js"));
    head.block("script").attr(new Src("/structr/js/icons.js"));
    head.block("script").attr(new Src("/structr/js/config.js"));
    final Tag body = doc.block("body");
    final Tag header = body.block("div").id("header");
    header.block("i").css("logo sprite sprite-structr-logo");
    final Tag links = header.block("div").id("menu").css("menu").block("ul");
    if (isAuthenticated(request)) {
        final Tag form = links.block("li").block("form").attr(new Attr("action", ConfigUrl), new Attr("method", "post"), new Style("display: none")).id("logout-form");
        form.empty("input").attr(new Type("hidden"), new Name("action"), new Value("logout"));
        links.block("a").text("Logout").attr(new Style("cursor: pointer"), new OnClick("$('#logout-form').submit();"));
    }
    return body;
}
Also used : Rel(org.structr.api.util.html.attr.Rel) Href(org.structr.api.util.html.attr.Href) Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 7 with Attr

use of org.structr.api.util.html.Attr in project structr by structr.

the class StringSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    final Tag label = group.block("label").text(getKey());
    if (getComment() != null) {
        label.attr(new Attr("class", "has-comment"));
        label.attr(new Attr("data-comment", getComment()));
    }
    final Tag input = group.empty("input").attr(new Attr("type", "text"), new Attr("name", getKey()));
    final String value = getValue();
    // display value if non-empty
    if (value != null) {
        input.attr(new Attr("value", value));
    }
    renderResetButton(group);
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 8 with Attr

use of org.structr.api.util.html.Attr in project structr by structr.

the class BooleanSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    final Tag label = group.block("label").text(getKey());
    if (getComment() != null) {
        label.attr(new Attr("class", "has-comment"));
        label.attr(new Attr("data-comment", getComment()));
    }
    final Tag trueInput = group.empty("input").attr(new Attr("type", "radio"), new Attr("name", getKey()), new Attr("value", "true"));
    group.block("span").text("Enabled");
    final Tag falseInput = group.empty("input").attr(new Attr("type", "radio"), new Attr("name", getKey()), new Attr("value", "false"));
    group.block("span").text("Disabled");
    if (getValue()) {
        trueInput.attr(new Attr("checked", "checked"));
    } else {
        falseInput.attr(new Attr("checked", "checked"));
    }
    renderResetButton(group);
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 9 with Attr

use of org.structr.api.util.html.Attr in project structr by structr.

the class ChoiceSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    group.block("label").text(getKey());
    final Tag select = group.block("select").attr(new Attr("name", getKey()));
    for (final String choice : choices) {
        final Tag option = select.block("option").text(choice);
        // selected?
        if (choice.equals(getValue())) {
            option.attr(new Attr("selected", "selected"));
        }
    }
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 10 with Attr

use of org.structr.api.util.html.Attr in project structr by structr.

the class IntegerSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    group.block("label").text(getKey());
    final Tag input = group.empty("input").attr(new Attr("type", "text"), new Attr("name", getKey()));
    final Integer value = getValue();
    // display value if non-empty
    if (value != null) {
        input.attr(new Attr("value", value));
    }
    renderResetButton(group);
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Aggregations

Attr (org.structr.api.util.html.Attr)11 Tag (org.structr.api.util.html.Tag)11 Href (org.structr.api.util.html.attr.Href)3 Document (org.structr.api.util.html.Document)2 Css (org.structr.api.util.html.attr.Css)2 If (org.structr.api.util.html.attr.If)2 Onload (org.structr.api.util.html.attr.Onload)2 Type (org.structr.api.util.html.attr.Type)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 SchemaNode (org.structr.core.entity.SchemaNode)2 Tx (org.structr.core.graph.Tx)2 SettingsGroup (org.structr.api.config.SettingsGroup)1 Service (org.structr.api.service.Service)1 Rel (org.structr.api.util.html.attr.Rel)1 Services (org.structr.core.Services)1