You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/07/06 02:38:00 UTC
[2/16] git commit: Keep a handle to the exports so that the code can
invoke functions it exports
Keep a handle to the exports so that the code can invoke functions it exports
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/fe438b0a
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/fe438b0a
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/fe438b0a
Branch: refs/heads/5.4-js-rewrite
Commit: fe438b0a70ac265c3a60bea509af5de6c96fafb0
Parents: 1ddc3a6
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu Jul 5 17:35:54 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu Jul 5 17:35:54 2012 -0700
----------------------------------------------------------------------
.../tapestry5/corelib/modulejs/pageinit.coffee | 56 +++++++-------
1 files changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/fe438b0a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/corelib/modulejs/pageinit.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/corelib/modulejs/pageinit.coffee b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/corelib/modulejs/pageinit.coffee
index 7c7a3b8..bdaed47 100644
--- a/tapestry-core/src/main/coffeescript/org/apache/tapestry5/corelib/modulejs/pageinit.coffee
+++ b/tapestry-core/src/main/coffeescript/org/apache/tapestry5/corelib/modulejs/pageinit.coffee
@@ -27,34 +27,34 @@ define ["_", "core/console"], (_, console) ->
fn = if functionName? then moduleLib[functionName] else moduleLib
fn.apply null, initArguments
-
- # Passed a list of initializers, executes each initializer in order. Due to asynchronous loading
- # of modules, the exact order in which initializer functions are invoked is not predictable.
- initialize: (inits) ->
- # apply will split the first value from the rest for us, implicitly.
- invokeInitializer.apply null, init for init in inits
-
- # Pre-loads a number of scripts in order. When the last script is loaded,
- # invokes the callback (with no parameters).
- loadScripts: (scripts, callback) ->
- reducer = (callback, script) -> ->
- console.debug "Loading script #{script}"
- require [script], callback
-
- finalCallback = _.reduceRight scripts, reducer, callback
-
- finalCallback.call(null)
-
- # Loads all the scripts, in order. It then executes the immediate initializations.
- # After that, it waits for the DOM to be ready and executes the other initializations.
- loadScriptsAndInitialize: (scripts, immediateInits, otherInits) ->
- this.loadScripts scripts, ->
- this.initialize immediateInits
- require ["core/domReady!"], -> this.initialize otherInits
-
- evalJavaScript: (js) ->
- console.debug "Evaluating: #{js}"
- eval js
+ exports =
+ # Passed a list of initializers, executes each initializer in order. Due to asynchronous loading
+ # of modules, the exact order in which initializer functions are invoked is not predictable.
+ initialize: (inits) ->
+ # apply will split the first value from the rest for us, implicitly.
+ invokeInitializer.apply null, init for init in inits
+
+ # Pre-loads a number of scripts in order. When the last script is loaded,
+ # invokes the callback (with no parameters).
+ loadScripts: (scripts, callback) ->
+ reducer = (callback, script) -> ->
+ console.debug "Loading script #{script}"
+ require [script], callback
+
+ finalCallback = _.reduceRight scripts, reducer, callback
+
+ finalCallback.call(null)
+
+ # Loads all the scripts, in order. It then executes the immediate initializations.
+ # After that, it waits for the DOM to be ready and executes the other initializations.
+ loadScriptsAndInitialize: (scripts, immediateInits, otherInits) ->
+ exports.loadScripts scripts, ->
+ exports.initialize immediateInits
+ require ["core/domReady!"], -> exports.initialize otherInits
+
+ evalJavaScript: (js) ->
+ console.debug "Evaluating: #{js}"
+ eval js