Package org.apache.tapestry5.modules

## Class JavaScriptModule

- java.lang.Object
- - org.apache.tapestry5.modules.JavaScriptModule

-     public class JavaScriptModule
      extends java.lang.Object

  Defines the services related to JavaScript and `JavaScriptStack`s.
  Since:
    5.4

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JavaScriptModule​(Environment environment, EnvironmentalShadowBuilder environmentalBuilder)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `bind​(ServiceBinder binder)` |
    `JavaScriptSupport` | `buildJavaScriptSupport()` | Builds a proxy to the current `JavaScriptSupport` inside this thread's `Environment`.
    `void` | `exposeJavaScriptSupportForFullPageRenders​(OrderedConfiguration<MarkupRendererFilter> configuration, JavaScriptStackSource javascriptStackSource, JavaScriptStackPathConstructor javascriptStackPathConstructor, Request request)` | Adds page render filters, each of which provides an `Environmental` service.
    `void` | `exposeJavaScriptSupportForPartialPageRender​(OrderedConfiguration<PartialMarkupRendererFilter> configuration, JavaScriptStackSource javascriptStackSource, JavaScriptStackPathConstructor javascriptStackPathConstructor, Request request)` | Contributes `PartialMarkupRendererFilter`s used when rendering a partial Ajax response.
    `static void` | `overrideGlyphiconWithFontAwesomeIfNeeded​(MappedConfiguration<java.lang.Class,​java.lang.Class> configuration, Compatibility compatibility)` | Overrides the `Glyphicon` component with `FontAwesomeIcon` if Bootstrap 3 isn't enabled.
    `static void` | `prepareHTMLPageOnRender​(OrderedConfiguration<MarkupRendererFilter> configuration)` | Contributes 'ConfigureHTMLElement', which writes the attributes into the HTML tag to describe locale, etc.
    `static void` | `provideBuiltinJavaScriptStacks​(MappedConfiguration<java.lang.String,​JavaScriptStack> configuration, JavaScriptStack coreStack, JavaScriptStack internalStack)` | Contributes the "core" and "internal" `JavaScriptStack`s
    `static void` | `setupApplicationCatalogModules​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration, LocalizationSetter localizationSetter, ComponentMessagesSource messagesSource, ResourceChangeTracker resourceChangeTracker, boolean compactJSON)` |
    `static void` | `setupBaseModules​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration, Resource underscoreShim, Resource jqueryShim, Resource typeahead, Resource moment, Resource transition, Resource bootstrapUtil, Compatibility compatibility)` |
    `static void` | `setupCompatibilityDefaults​(MappedConfiguration<Trait,​java.lang.Boolean> configuration)` |
    `static void` | `setupCoreJavaScriptStack​(OrderedConfiguration<StackExtension> configuration, Compatibility compatibility, java.lang.String provider)` | The core JavaScriptStack has a number of entries: requirejs The RequireJS AMD JavaScript library scriptaculous.js, effects.js Optional JavaScript libraries in compatibility mode (see `Trait.SCRIPTACULOUS`) t53-compatibility.js Optional JavaScript library (see `Trait.INITIALIZERS`) underscore-library, underscore-module The Underscore JavaScript library, and the shim that allows underscore to be injected t5/core/init Optional module related to t53-compatibility.js jquery-library The jQuery library jquery-noconflict Switches jQuery to no-conflict mode (only present when the infrastructure is "prototype"). jquery A module shim that allows jQuery to be injected (and also switches jQuery to no-conflict mode) bootstrap.css, tapestry.css, exception-frame.css, tapestry-console.css, tree.css CSS files t5/core/[...] Additional JavaScript modules jquery Added if the infrastructure provider is "jquery". User modules may replace or extend this list.
    `static void` | `setupFactoryDefaults​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration)` |
    `static void` | `setupFoundationFramework​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration, java.lang.String provider, Resource domPrototype, Resource domJQuery)` |
    `static void` | `setupInternalJavaScriptStack​(OrderedConfiguration<StackExtension> configuration)` |
    `static void` | `setupModuleDispatchers​(OrderedConfiguration<Dispatcher> configuration, ModuleManager moduleManager, OperationTracker tracker, ResourceStreamer resourceStreamer, PathConstructor pathConstructor, JavaScriptStackSource javaScriptStackSource, JavaScriptStackPathConstructor javaScriptStackPathConstructor, LocalizationSetter localizationSetter, java.lang.String modulePathPrefix, java.lang.String assetPathPrefix)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JavaScriptModule

          public JavaScriptModule​(Environment environment,
                                  EnvironmentalShadowBuilder environmentalBuilder)

  - ### Method Detail

    - #### bind

          public static void bind​(ServiceBinder binder)

    - #### provideBuiltinJavaScriptStacks

          @Contribute(JavaScriptStackSource.class)
          public static void provideBuiltinJavaScriptStacks​(MappedConfiguration<java.lang.String,​JavaScriptStack> configuration,
                                                            @Core
                                                            JavaScriptStack coreStack,
                                                            @Internal
                                                            JavaScriptStack internalStack)

      Contributes the "core" and "internal" `JavaScriptStack`s
      Since:
        5.2.0

    - #### setupCoreJavaScriptStack

          @Contribute(JavaScriptStack.class)
          @Core
          public static void setupCoreJavaScriptStack​(OrderedConfiguration<StackExtension> configuration,
                                                      Compatibility compatibility,
                                                      @Symbol("tapestry.javascript-infrastructure-provider")
                                                      java.lang.String provider)

      The core JavaScriptStack has a number of entries:
      requirejs
        The RequireJS AMD JavaScript library
      scriptaculous.js, effects.js
        Optional JavaScript libraries in compatibility mode (see `Trait.SCRIPTACULOUS`)
      t53-compatibility.js
        Optional JavaScript library (see `Trait.INITIALIZERS`)
      underscore-library, underscore-module
      The Underscore JavaScript library, and the shim that allows underscore to be injected
      t5/core/init
        Optional module related to t53-compatibility.js
      jquery-library
        The jQuery library
      jquery-noconflict
        Switches jQuery to no-conflict mode (only present when the infrastructure is "prototype").
      jquery
        A module shim that allows jQuery to be injected (and also switches jQuery to no-conflict mode)
      bootstrap.css, tapestry.css, exception-frame.css, tapestry-console.css, tree.css
        CSS files
      t5/core/[...]
        Additional JavaScript modules
      jquery
        Added if the infrastructure provider is "jquery".
      User modules may replace or extend this list.

    - #### setupCompatibilityDefaults

          @Contribute(Compatibility.class)
          public static void setupCompatibilityDefaults​(MappedConfiguration<Trait,​java.lang.Boolean> configuration)

    - #### setupInternalJavaScriptStack

          @Contribute(JavaScriptStack.class)
          @Internal
          public static void setupInternalJavaScriptStack​(OrderedConfiguration<StackExtension> configuration)

    - #### buildJavaScriptSupport

          public JavaScriptSupport buildJavaScriptSupport()

      Builds a proxy to the current `JavaScriptSupport` inside this thread's `Environment`.
      Since:
        5.2.0

    - #### setupModuleDispatchers

          @Contribute(Dispatcher.class)
          @Primary
          public static void setupModuleDispatchers​(OrderedConfiguration<Dispatcher> configuration,
                                                    ModuleManager moduleManager,
                                                    OperationTracker tracker,
                                                    ResourceStreamer resourceStreamer,
                                                    PathConstructor pathConstructor,
                                                    JavaScriptStackSource javaScriptStackSource,
                                                    JavaScriptStackPathConstructor javaScriptStackPathConstructor,
                                                    LocalizationSetter localizationSetter,
                                                    @Symbol("tapestry.module-path-prefix")
                                                    java.lang.String modulePathPrefix,
                                                    @Symbol("tapestry.asset-path-prefix")
                                                    java.lang.String assetPathPrefix)

    - #### exposeJavaScriptSupportForFullPageRenders

          @Contribute(MarkupRenderer.class)
          public void exposeJavaScriptSupportForFullPageRenders​(OrderedConfiguration<MarkupRendererFilter> configuration,
                                                                JavaScriptStackSource javascriptStackSource,
                                                                JavaScriptStackPathConstructor javascriptStackPathConstructor,
                                                                Request request)

      Adds page render filters, each of which provides an `Environmental` service. Filters often provide `Environmental` services needed by components as they render.
      JavascriptSupport
        Provides `JavaScriptSupport`

    - #### exposeJavaScriptSupportForPartialPageRender

          @Contribute(PartialMarkupRenderer.class)
          public void exposeJavaScriptSupportForPartialPageRender​(OrderedConfiguration<PartialMarkupRendererFilter> configuration,
                                                                  JavaScriptStackSource javascriptStackSource,
                                                                  JavaScriptStackPathConstructor javascriptStackPathConstructor,
                                                                  Request request)

      Contributes `PartialMarkupRendererFilter`s used when rendering a partial Ajax response.
      JavaScriptSupport
        Provides `JavaScriptSupport`

    - #### setupBaseModules

          @Contribute(ModuleManager.class)
          public static void setupBaseModules​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration,
                                              @Path("${tapestry.asset.root}/underscore-shim.js")
                                              Resource underscoreShim,
                                              @Path("${tapestry.asset.root}/jquery-shim.js")
                                              Resource jqueryShim,
                                              @Path("${tapestry.asset.root}/typeahead.js")
                                              Resource typeahead,
                                              @Path("${tapestry.asset.root}/moment-2.15.1.js")
                                              Resource moment,
                                              @Path("${tapestry.asset.root}/bootstrap/js/transition.js")
                                              Resource transition,
                                              @Path("${tapestry.asset.root}/bootstrap4/js/bootstrap-util.js")
                                              Resource bootstrapUtil,
                                              Compatibility compatibility)

    - #### setupFactoryDefaults

          @Contribute(SymbolProvider.class)
          @FactoryDefaults
          public static void setupFactoryDefaults​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration)

    - #### setupFoundationFramework

          @Contribute(ModuleManager.class)
          public static void setupFoundationFramework​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration,
                                                      @Symbol("tapestry.javascript-infrastructure-provider")
                                                      java.lang.String provider,
                                                      @Path("classpath:org/apache/tapestry5/t5-core-dom-prototype.js")
                                                      Resource domPrototype,
                                                      @Path("classpath:org/apache/tapestry5/t5-core-dom-jquery.js")
                                                      Resource domJQuery)

    - #### setupApplicationCatalogModules

          @Contribute(ModuleManager.class)
          public static void setupApplicationCatalogModules​(MappedConfiguration<java.lang.String,​java.lang.Object> configuration,
                                                            LocalizationSetter localizationSetter,
                                                            ComponentMessagesSource messagesSource,
                                                            ResourceChangeTracker resourceChangeTracker,
                                                            @Symbol("tapestry.compact-json")
                                                            boolean compactJSON)

    - #### prepareHTMLPageOnRender

          @Contribute(MarkupRenderer.class)
          public static void prepareHTMLPageOnRender​(OrderedConfiguration<MarkupRendererFilter> configuration)

      Contributes 'ConfigureHTMLElement', which writes the attributes into the HTML tag to describe locale, etc. Contributes 'AddBrowserCompatibilityStyles', which writes `<style/>` elements into the `<head/>` element that modifies the page loading mask to work on IE 8 and IE 9.

    - #### overrideGlyphiconWithFontAwesomeIfNeeded

          @Contribute(ComponentOverride.class)
          public static void overrideGlyphiconWithFontAwesomeIfNeeded​(MappedConfiguration<java.lang.Class,​java.lang.Class> configuration,
                                                                      Compatibility compatibility)

      Overrides the `Glyphicon` component with `FontAwesomeIcon` if Bootstrap 3 isn't enabled.
      See Also:
        `Trait.BOOTSTRAP_3`, `Compatibility`