use of org.apache.tapestry5.services.javascript.StackExtension in project tapestry-5 by apache.
the class JavaScriptModule method add.
private static void add(OrderedConfiguration<StackExtension> configuration, StackExtensionType type, String... paths) {
for (String path : paths) {
int slashx = path.lastIndexOf('/');
String id = path.substring(slashx + 1);
configuration.add(id, new StackExtension(type, path));
}
}
use of org.apache.tapestry5.services.javascript.StackExtension in project tapestry-5 by apache.
the class JavaScriptModule method setupCoreJavaScriptStack.
/**
* The core JavaScriptStack has a number of entries:
* <dl>
* <dt>requirejs</dt> <dd>The RequireJS AMD JavaScript library</dd>
* <dt>scriptaculous.js, effects.js</dt> <dd>Optional JavaScript libraries in compatibility mode (see {@link Trait#SCRIPTACULOUS})</dd>
* <dt>t53-compatibility.js</dt> <dd>Optional JavaScript library (see {@link Trait#INITIALIZERS})</dd>
* <dt>underscore-library, underscore-module</dt>
* <dt>The Underscore JavaScript library, and the shim that allows underscore to be injected</dt>
* <dt>t5/core/init</dt> <dd>Optional module related to t53-compatibility.js</dd>
* <dt>jquery-library</dt> <dd>The jQuery library</dd>
* <dt>jquery-noconflict</dt> <dd>Switches jQuery to no-conflict mode (only present when the infrastructure is "prototype").</dd>
* <dt>jquery</dt> <dd>A module shim that allows jQuery to be injected (and also switches jQuery to no-conflict mode)</dd>
* <dt>bootstrap.css, tapestry.css, exception-frame.css, tapestry-console.css, tree.css</dt>
* <dd>CSS files</dd>
* <dt>t5/core/[...]</dt>
* <dd>Additional JavaScript modules</dd>
* <dt>jquery</dt>
* <dd>Added if the infrastructure provider is "jquery".</dd>
* </dl>
*
* User modules may replace or extend this list.
*/
@Contribute(JavaScriptStack.class)
@Core
public static void setupCoreJavaScriptStack(OrderedConfiguration<StackExtension> configuration, Compatibility compatibility, @Symbol(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER) String provider) {
configuration.add("requirejs", StackExtension.library(ROOT + "/require.js"));
configuration.add("underscore-library", StackExtension.library(ROOT + "/underscore-1.8.3.js"));
if (provider.equals("prototype")) {
final String SCRIPTY = "${tapestry.scriptaculous}";
add(configuration, StackExtensionType.LIBRARY, SCRIPTY + "/prototype.js");
if (compatibility.enabled(Trait.SCRIPTACULOUS)) {
add(configuration, StackExtensionType.LIBRARY, SCRIPTY + "/scriptaculous.js", SCRIPTY + "/effects.js");
}
}
if (compatibility.enabled(Trait.INITIALIZERS)) {
add(configuration, StackExtensionType.LIBRARY, ROOT + "/t53-compatibility.js");
configuration.add("t5/core/init", new StackExtension(StackExtensionType.MODULE, "t5/core/init"));
}
configuration.add("jquery-library", StackExtension.library(ROOT + "/jquery.js"));
if (provider.equals("prototype")) {
configuration.add("jquery-noconflict", StackExtension.library(ROOT + "/jquery-noconflict.js"));
}
add(configuration, StackExtensionType.MODULE, "jquery");
add(configuration, StackExtensionType.STYLESHEET, "${" + SymbolConstants.FONT_AWESOME_ROOT + "}/css/font-awesome.css");
if (compatibility.enabled(Trait.BOOTSTRAP_3) && compatibility.enabled(Trait.BOOTSTRAP_4)) {
throw new RuntimeException("You cannot have Trait.BOOTSTRAP_3 and Trait.BOOTSTRAP_4 enabled at the same time. Check your contributions to the Compatibility service.");
}
if (compatibility.enabled(Trait.BOOTSTRAP_3)) {
addCoreStylesheets(configuration, "${" + SymbolConstants.BOOTSTRAP_ROOT + "}/css/bootstrap.css");
}
if (compatibility.enabled(Trait.BOOTSTRAP_4)) {
addCoreStylesheets(configuration, "${" + SymbolConstants.BOOTSTRAP_ROOT + "}/css/bootstrap.css");
add(configuration, StackExtensionType.STYLESHEET, "${" + SymbolConstants.BOOTSTRAP_ROOT + "}/css/bootstrap-grid.css");
}
if (!compatibility.enabled(Trait.BOOTSTRAP_3) && !compatibility.enabled(Trait.BOOTSTRAP_4)) {
configuration.add("defaultcss", StackExtension.stylesheet("${" + SymbolConstants.DEFAULT_STYLESHEET + "}"));
}
for (String name : bundledModules) {
String full = "t5/core/" + name;
configuration.add(full, StackExtension.module(full));
}
configuration.add("underscore-module", StackExtension.module("underscore"));
}
Aggregations