tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject [11/16] git commit: Refactor module core/pageinit to export a named function: "initialize"
Date Fri, 06 Jul 2012 00:38:00 GMT
Refactor module core/pageinit to export a named function: "initialize"


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0ee55258
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0ee55258
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0ee55258

Branch: refs/heads/5.4-js-rewrite
Commit: 0ee55258beddde75228e27a0562ef612812e17a6
Parents: c9b2da4
Author: Howard M. Lewis Ship <hlship@apache.org>
Authored: Thu Jul 5 11:14:47 2012 -0700
Committer: Howard M. Lewis Ship <hlship@apache.org>
Committed: Thu Jul 5 11:14:47 2012 -0700

----------------------------------------------------------------------
 .../tapestry5/corelib/modulejs/pageinit.coffee     |   15 +++++++++------
 .../internal/services/DocumentLinkerImpl.java      |    2 +-
 .../services/DocumentLinkerImplTest.groovy         |   12 ++++++------
 3 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ee55258/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 42b611e..abf8cf2 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
@@ -13,10 +13,12 @@
 # limitations under the License.
 
 
-# Single function module used for page initialization. The function is passed an array of
arrays;
-# the first value in the array defines the module to invoke. The module name may also indicate
the
-# function exported by the module, as a suffix following a colon: e.g., "my/module:myfunc".
-# Any additional values in the array are passed to the function. The context of the function
(this) is null.
+# Module that defines functions used for page initialization.
+# The initialize function is passed an array of initializers; each initializer is itself
+# an array. The first value in the initializer defines the name of the module to invoke.
+# The module name may also indicate the function exported by the module, as a suffix following
a colon:
+# e.g., "my/module:myfunc".
+# Any additional values in the initializer are passed to the function. The context of the
function (this) is null.
 define ->
   invokeInitializer = (qualifiedName, initArguments...) ->
 
@@ -26,8 +28,9 @@ define ->
       fn = if functionName? then moduleLib[functionName] else moduleLib
       fn.apply null, initArguments
 
-  # Exports this single function:
-  (inits) ->
+
+  # Exported function passed a list of initializers.
+  initialize : (inits) ->
     # apply will split the first value from the rest for us, implicitly.
     invokeInitializer.apply null, init for init in inits
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ee55258/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
index c012da7..14cae57 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/DocumentLinkerImpl.java
@@ -280,7 +280,7 @@ public class DocumentLinkerImpl implements DocumentLinker
         }
 
         block.append("require([\"core/pageinit\"], function (pageinit) {\n");
-        block.append("  pageinit([");
+        block.append("  pageinit.initialize([");
 
         String sep = "";
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0ee55258/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.groovy
b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.groovy
index ce6b3fe..f241b52 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/DocumentLinkerImplTest.groovy
@@ -298,7 +298,7 @@ doSomethingElse();
         check document, '''
 <html><head><meta/><script></script></head><body><script
src="/js/require.js"></script><script type="text/javascript">require.config();
 </script><script type="text/javascript">require(["core/pageinit"], function (pageinit)
{
-  pageinit([["immediate/module:myfunc",{"fred":"barney"}]]);
+  pageinit.initialize([["immediate/module:myfunc",{"fred":"barney"}]]);
 });
 </script></body></html>
 '''
@@ -328,7 +328,7 @@ doSomethingElse();
 <html><head><meta/></head><body><script src="/js/require.js"></script><script
type="text/javascript">require.config();
 </script><script type="text/javascript">Tapestry.onDOMLoaded(function() {
 require(["core/pageinit"], function (pageinit) {
-  pageinit([[
+  pageinit.initialize([[
   "my/module"
 ],
   [
@@ -338,7 +338,7 @@ require(["core/pageinit"], function (pageinit) {
 ]]);
 });
 require(["core/pageinit"], function (pageinit) {
-  pageinit([[
+  pageinit.initialize([[
   "my/other/module:late",
   333,
   444
@@ -370,7 +370,7 @@ require(["core/pageinit"], function (pageinit) {
 <html><head><meta/><script></script></head><body><script
src="/js/require.js"></script><script type="text/javascript">require.config();
 </script><script type="text/javascript">Tapestry.onDOMLoaded(function() {
 require(["core/pageinit"], function (pageinit) {
-  pageinit([["my/module","barney"]]);
+  pageinit.initialize([["my/module","barney"]]);
 });
 });
 </script></body></html>
@@ -440,11 +440,11 @@ require(["core/pageinit"], function (pageinit) {
 <html><head><meta/></head><body><script src="/js/require.js"></script><script
type="text/javascript">require.config();
 </script><script type="text/javascript">Tapestry.onDOMLoaded(function() {
 require(["core/pageinit"], function (pageinit) {
-  pageinit([["my/module"],
+  pageinit.initialize([["my/module"],
   ["my/other/module:normal",111,222]]);
 });
 require(["core/pageinit"], function (pageinit) {
-  pageinit([["my/other/module:late",333,444]]);
+  pageinit.initialize([["my/other/module:late",333,444]]);
 });
 });
 </script></body></html>


Mime
View raw message