You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/10/23 02:55:10 UTC
git commit: Replace T5.initializers.activate() with
core/pageinit:focus()
Updated Branches:
refs/heads/5.4-js-rewrite 70bf5816f -> 3c451a767
Replace T5.initializers.activate() with core/pageinit:focus()
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/3c451a76
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/3c451a76
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/3c451a76
Branch: refs/heads/5.4-js-rewrite
Commit: 3c451a7670a59e34d333cf446af51477bb56ff10
Parents: 70bf581
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Oct 22 17:55:02 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Oct 22 17:55:02 2012 -0700
----------------------------------------------------------------------
.../META-INF/modules/core/pageinit.coffee | 5 +++++
.../coffeescript/META-INF/modules/core/spi.coffee | 6 ++++++
.../services/ajax/JavaScriptSupportImpl.java | 4 ++--
.../resources/org/apache/tapestry5/tapestry.js | 12 ------------
4 files changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3c451a76/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
index 73e7e81..6efe766 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/pageinit.coffee
@@ -153,6 +153,11 @@ define ["_", "core/console", "core/spi", "core/events"],
console.debug "Evaluating: #{js}"
eval js
+ focus: (fieldId) ->
+ field = spi fieldId
+
+ field && field.focus()
+
# Passed the response from an Ajax request, when the request is successful.
# This is used for any request that attaches partial-page-render data to the main JSON object
# response. If no such data is attached, the callback is simply invoked immediately.
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3c451a76/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
index 75d80fa..47fac14 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/spi.coffee
@@ -211,6 +211,12 @@ define ["_", "prototype"], (_) ->
return current
+ # Moves the cursor to the field.
+ focus: ->
+ @element.focus()
+
+ return this
+
# Returns true if the element has the indicated class name, false otherwise.
hasClass: (name) ->
@element.hasClassName name
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3c451a76/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
index be9adee..b553eae 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ajax/JavaScriptSupportImpl.java
@@ -152,7 +152,7 @@ public class JavaScriptSupportImpl implements JavaScriptSupport
{
if (focusFieldId != null)
{
- addInitializerCall("activate", focusFieldId);
+ require("core/pageinit").invoke("focus").with(focusFieldId);
}
F.flow(stylesheetLinks).each(new Worker<StylesheetLink>()
@@ -230,7 +230,7 @@ public class JavaScriptSupportImpl implements JavaScriptSupport
if (partialMode)
{
- addInitializerCall(priority, "evalScript", newScript);
+ require("core/pageinit").invoke("intervalId").with(newScript);
} else
{
linker.addScript(priority, newScript);
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/3c451a76/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
index 52f0068..965cfa1 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
@@ -576,18 +576,6 @@ define("core/compat/tapestry", [
/** Container of functions that may be invoked by the Tapestry.init() function. */
T5.extendInitializers({
- /** Make the given field the active field (focus on the field). */
- activate: function (id) {
- $(id).activate();
- },
-
- /**
- * evalScript is a synonym for the JavaScript eval function. It is
- * used in Ajax requests to handle any setup code that does not fit
- * into a standard Tapestry.Initializer call.
- */
- evalScript: eval,
-
ajaxFormLoop: function (spec) {
var rowInjector = $(spec.rowInjector);