use of org.structr.web.entity.html.Script in project structr by structr.
the class DeploymentTest method test03ContentTypes.
@Test
public void test03ContentTypes() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test03");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test03");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Script script = createElement(page, div1, "script");
final Content content = createContent(page, script, "$(function () {\n\n" + "$('a[data-toggle=\"tab\"]').on('click', function (e) {\n\n" + "var id = $(e.target).attr(\"href\").substr(1) // activated tab\n" + "window.location.hash = id;\n" + "});\n\n" + "});");
// workaround for strange importer behaviour
script.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
content.setProperty(StructrApp.key(Content.class, "contentType"), "text/javascript");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Script in project structr by structr.
the class ImporterTest method testWidgetWithScriptTags.
@Test
public void testWidgetWithScriptTags() {
try (final Tx tx = app.tx()) {
Settings.JsonIndentation.setValue(true);
Settings.HtmlIndentation.setValue(true);
final String source = testImportWidget("<div>\n" + " <script src=\"/structr/js/lib/jquery-1.11.1.min.js\" type=\"text/javascript\"></script>\n" + " <script type=\"text/javascript\"></script>\n" + "</div>", RenderContext.EditMode.WIDGET, "https://widgets.structr.org/structr/rest/widgets");
// System.out.println(source);
assertEquals("<!DOCTYPE html>\n" + "<html>\n" + " <head></head>\n" + " <body>\n" + " <div>\n" + " <script src=\"/structr/js/lib/jquery-1.11.1.min.js\" type=\"text/javascript\"></script>\n" + " <script type=\"text/javascript\"></script>\n" + " </div>\n" + " </body>\n" + "</html>", source);
Script secondScriptElement = (Script) app.nodeQuery(Script.class).blank(StructrApp.key(Script.class, "_html_src")).getFirst();
assertNull(secondScriptElement.getOutgoingRelationship(StructrApp.getConfiguration().getRelationshipEntityClass("LinkSourceLINKLinkable")));
} catch (FrameworkException ex) {
logger.warn("", ex);
}
}
use of org.structr.web.entity.html.Script in project structr by structr.
the class DeploymentTest method test12EmptyContentElementWithContentType.
@Test
public void test12EmptyContentElementWithContentType() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page = Page.createNewPage(securityContext, "test12");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test12");
final Body body = createElement(page, html, "body");
final Script script1 = createElement(page, body, "script");
final Script script2 = createElement(page, body, "script");
script1.setProperty(StructrApp.key(Script.class, "_html_type"), "text/javascript");
createContent(page, script1, "");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Script in project structr by structr.
the class DeploymentTest method test13EmptyContentElement.
@Test
public void test13EmptyContentElement() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page = Page.createNewPage(securityContext, "test13");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test13");
final Body body = createElement(page, html, "body");
final Script script1 = createElement(page, body, "script", "");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), false);
}
Aggregations