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/08/03 23:33:10 UTC
[4/10] Rework more of the existing JavaScript libraries to be
compatible with the RequireJS modules
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-debug.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-debug.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-debug.js
new file mode 100644
index 0000000..0cf84c7
--- /dev/null
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-debug.js
@@ -0,0 +1,18 @@
+/* Copyright 2012 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+require(["core/compat/tapestry"], function () {
+ Tapestry.DEBUG_ENABLED = true;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages.js
index 120ccb2..d3507ff 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages.js
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010, 2011 The Apache Software Foundation
+// Copyright 2009-2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,29 +12,32 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-Tapestry.Messages = {
+define("core/compat/tapestry-messages", ["core/compat/tapestry"], function () {
- pageIsLoading : "Please wait for the page to finish loading ...",
+ Tapestry.Messages = {
- missingInitializer : "Function Tapestry.Initializer.#{name}() does not exist.",
+ pageIsLoading: "Please wait for the page to finish loading ...",
- missingValidator : "Function Tapestry.Validator.#{name}() does not exist for field '#{fieldName}'.",
+ missingInitializer: "Function Tapestry.Initializer.#{name}() does not exist.",
- ajaxFailure : "Ajax failure: Status #{status} for #{request.url}: ",
+ missingValidator: "Function Tapestry.Validator.#{name}() does not exist for field '#{fieldName}'.",
- ajaxRequestUnsuccessful : "Server request was unsuccessful. There may be a problem accessing the server.",
+ ajaxFailure: "Ajax failure: Status #{status} for #{request.url}: ",
- clientException : "Client exception processing response: ",
+ ajaxRequestUnsuccessful: "Server request was unsuccessful. There may be a problem accessing the server.",
- missingZone : "Unable to locate Ajax Zone '#{id}' for dynamic update.",
+ clientException: "Client exception processing response: ",
- noZoneManager : "Element '#{id}' does not have an associated Tapestry.ZoneManager object." ,
+ missingZone: "Unable to locate Ajax Zone '#{id}' for dynamic update.",
- pathDoesNotStartWithSlash : "External path #{path} does not start with a leading slash.",
+ noZoneManager: "Element '#{id}' does not have an associated Tapestry.ZoneManager object.",
- notAnInteger : "Not an integer",
+ pathDoesNotStartWithSlash: "External path #{path} does not start with a leading slash.",
- invalidCharacter : "Invalid character",
+ notAnInteger: "Not an integer",
- communicationFailed : "Communication with the server failed: "
-};
\ No newline at end of file
+ invalidCharacter: "Invalid character",
+
+ communicationFailed: "Communication with the server failed: "
+ };
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_de.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_de.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_de.js
index 6523bbe..1566cfd 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_de.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_de.js
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010, 2011 The Apache Software Foundation
+// Copyright 2009-2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -12,29 +12,31 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-Tapestry.Messages = {
+require(["core/compat/tapestry-messages"], function () {
+ Tapestry.Messages = {
- pageIsLoading : "Bitte warten während die Seite zu Ende lädt ...",
+ pageIsLoading: "Bitte warten während die Seite zu Ende lädt ...",
- missingInitializer : "Die Funktion Tapestry.Initializer.#{name}() existiert nicht.",
+ missingInitializer: "Die Funktion Tapestry.Initializer.#{name}() existiert nicht.",
- missingValidator : "Die Funktion Tapestry.Validator.#{name}() existiert nicht für das Feld '#{fieldName}'.",
+ missingValidator: "Die Funktion Tapestry.Validator.#{name}() existiert nicht für das Feld '#{fieldName}'.",
- ajaxFailure : "Ajax Fehler: Status #{status} für #{request.url}: ",
+ ajaxFailure: "Ajax Fehler: Status #{status} für #{request.url}: ",
- ajaxRequestUnsuccessful : "Die Serveranfrage schlug fehl. Es gibt womöglich ein Problem beim Zugriff auf den Server.",
+ ajaxRequestUnsuccessful: "Die Serveranfrage schlug fehl. Es gibt womöglich ein Problem beim Zugriff auf den Server.",
- clientException : "Client exception beim Verarbeiten der Antwort: ",
+ clientException: "Client exception beim Verarbeiten der Antwort: ",
- missingZone : "Ajax Zone '#{id}' konnte für ein dynamisches Update nicht gefunden werden.",
+ missingZone: "Ajax Zone '#{id}' konnte für ein dynamisches Update nicht gefunden werden.",
- noZoneManager : "Element '#{id}' ist nicht mit einem Tapestry.ZoneManager Objekt verknüpft." ,
+ noZoneManager: "Element '#{id}' ist nicht mit einem Tapestry.ZoneManager Objekt verknüpft.",
- pathDoesNotStartWithSlash : "Der externe Pfad #{path} beginnt nicht mit einem führenden '/'.",
+ pathDoesNotStartWithSlash: "Der externe Pfad #{path} beginnt nicht mit einem führenden '/'.",
- notAnInteger : "Kein ganzzahliger Wert",
+ notAnInteger: "Kein ganzzahliger Wert",
- invalidCharacter : "Ungültiges Zeichen",
+ invalidCharacter: "Ungültiges Zeichen",
- communicationFailed : "Kommunikation mit dem Server ist fehlgeschlagen: "
-};
+ communicationFailed: "Kommunikation mit dem Server ist fehlgeschlagen: "
+ };
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_fi_FI.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_fi_FI.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_fi_FI.js
index 045193d..d4efeb4 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_fi_FI.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry-messages_fi_FI.js
@@ -1,38 +1,40 @@
-// Copyright 2009 The Apache Software Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-Tapestry.Messages = {
-
- pageIsLoading : "Ole hyv� ja odota kunnes sivu on latautunut...",
-
- missingInitializer : "Funktiota Tapestry.Initializer.#{name}() ei ole olemassa.",
-
- missingValidator : "Funktiota Tapestry.Validator.#{name}() ei ole olemassa kent�ss� '#{fieldName}'.",
-
- ajaxFailure : "Ajax virhe: Status #{status} pyynn�lle #{request.url}: ",
-
- ajaxRequestUnsuccessful : "Pyynt�� palvelimelle ei voitu suorittaa. Palvelimeen ei saatu yhteytt�.",
-
- clientException : "Palvelin palautti vastauksen mutta sen prosessoinnin aikana tapahtui virhe: ",
-
- missingZone : "Ajax Zone '#{id}' yritettiin p�ivitt�� dynaamisesti, mutta sit� ei l�ytynyt.",
-
- noZoneManager : "Ajax Zone '#{id}':iin ei ole liitetty Tapestry.ZoneManager -objektia." ,
-
- pathDoesNotStartWithSlash : "Ulkoinen polku #{path} ei ala kauttaviivalla ( merkki '/' ).",
-
- notAnInteger : "Ei ole kokonaisluku",
-
- invalidCharacter : "Virheellinen merkki"
-};
\ No newline at end of file
+// Copyright 2009-2012 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+// b
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+require(["core/compat/tapestry-messages"], function () {
+ Tapestry.Messages = {
+
+ pageIsLoading: "Ole hyv� ja odota kunnes sivu on latautunut...",
+
+ missingInitializer: "Funktiota Tapestry.Initializer.#{name}() ei ole olemassa.",
+
+ missingValidator: "Funktiota Tapestry.Validator.#{name}() ei ole olemassa kent�ss� '#{fieldName}'.",
+
+ ajaxFailure: "Ajax virhe: Status #{status} pyynn�lle #{request.url}: ",
+
+ ajaxRequestUnsuccessful: "Pyynt�� palvelimelle ei voitu suorittaa. Palvelimeen ei saatu yhteytt�.",
+
+ clientException: "Palvelin palautti vastauksen mutta sen prosessoinnin aikana tapahtui virhe: ",
+
+ missingZone: "Ajax Zone '#{id}' yritettiin p�ivitt�� dynaamisesti, mutta sit� ei l�ytynyt.",
+
+ noZoneManager: "Ajax Zone '#{id}':iin ei ole liitetty Tapestry.ZoneManager -objektia.",
+
+ pathDoesNotStartWithSlash: "Ulkoinen polku #{path} ei ala kauttaviivalla ( merkki '/' ).",
+
+ notAnInteger: "Ei ole kokonaisluku",
+
+ invalidCharacter: "Virheellinen merkki"
+ };
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/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 83c669d..a10137d 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-require(["_"], function (_) {
+define("core/compat/tapestry", ["_", "core/compat/t5-dom", "core/compat/t5-init"], function (_) {
window.Tapestry = {
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a0fc1093/tapestry-core/src/main/resources/org/apache/tapestry5/tree.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tree.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tree.js
index 5a381f3..aeba1d0 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tree.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tree.js
@@ -1,4 +1,4 @@
-/* Copyright 2011 The Apache Software Foundation
+/* Copyright 2011, 2012 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12,183 +12,184 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+define("core/compat/tree", ["core/compat/t5-init"], function () {
+ T5.extend(T5, {
+ tree: {
+
+ /**
+ * Approximate time per pixel for the hide and reveal animations. The
+ * idea is to have small (few children) and large (many childen)
+ * animations operate at the same visible rate, even though they will
+ * take different amounts of time.
+ */
+ ANIMATION_RATE: .005,
+
+ /**
+ * Maximum animation time, in seconds. This is necessary for very large
+ * animations, otherwise its looks visually odd to see the child tree
+ * nodes whip down the screen.
+ */
+ MAX_ANIMATION_DURATION: .5,
+
+ /** Type of Scriptaculous effect to hide/show child nodes. */
+ TOGGLE_TYPE: 'blind',
+
+ /**
+ * Name of Scriptaculous effects queue to ensure that animations do not
+ * overwrite each other.
+ */
+ QUEUE_NAME: 't-tree-updates'
+ }
+ });
-T5.extend(T5, {
- tree : {
-
- /**
- * Approximate time per pixel for the hide and reveal animations. The
- * idea is to have small (few children) and large (many childen)
- * animations operate at the same visible rate, even though they will
- * take different amounts of time.
- */
- ANIMATION_RATE : .005,
-
- /**
- * Maximum animation time, in seconds. This is necessary for very large
- * animations, otherwise its looks visually odd to see the child tree
- * nodes whip down the screen.
- */
- MAX_ANIMATION_DURATION : .5,
+ T5.extendInitializers(function () {
- /** Type of Scriptaculous effect to hide/show child nodes. */
- TOGGLE_TYPE : 'blind',
+ var cfg = T5.tree;
- /**
- * Name of Scriptaculous effects queue to ensure that animations do not
- * overwrite each other.
- */
- QUEUE_NAME : 't-tree-updates'
- }
-});
+ function doAnimate(element) {
+ var sublist = $(element).up('li').down("ul");
-T5.extendInitializers(function() {
+ var dim = sublist.getDimensions();
- var cfg = T5.tree;
+ var duration = Math.min(dim.height * cfg.ANIMATION_RATE,
+ cfg.MAX_ANIMATION_DURATION)
- function doAnimate(element) {
- var sublist = $(element).up('li').down("ul");
+ new Effect.toggle(sublist, cfg.TOGGLE_TYPE, {
+ duration: duration,
+ queue: {
+ position: 'end',
+ scope: cfg.QUEUE_NAME
+ }
+ });
+ }
- var dim = sublist.getDimensions();
+ function animateRevealChildren(element) {
+ $(element).addClassName("t-tree-expanded");
- var duration = Math.min(dim.height * cfg.ANIMATION_RATE,
- cfg.MAX_ANIMATION_DURATION)
+ doAnimate(element);
+ }
- new Effect.toggle(sublist, cfg.TOGGLE_TYPE, {
- duration : duration,
- queue : {
- position : 'end',
- scope : cfg.QUEUE_NAME
- }
- });
- }
+ function animateHideChildren(element) {
+ $(element).removeClassName("t-tree-expanded");
- function animateRevealChildren(element) {
- $(element).addClassName("t-tree-expanded");
+ doAnimate(element);
+ }
- doAnimate(element);
- }
+ function initializer(spec) {
+ var loaded = spec.expanded || spec.leaf;
+ var expanded = spec.expanded;
+ var loading = false;
- function animateHideChildren(element) {
- $(element).removeClassName("t-tree-expanded");
+ if (expanded) {
+ $(spec.clientId).addClassName("t-tree-expanded")
+ }
- doAnimate(element);
- }
- function initializer(spec) {
- var loaded = spec.expanded || spec.leaf;
- var expanded = spec.expanded;
- var loading = false;
+ function successHandler(reply) {
+ // Remove the Ajax load indicator
+ $(spec.clientId).update("");
+ $(spec.clientId).removeClassName("t-empty-node");
- if (expanded) {
- $(spec.clientId).addClassName("t-tree-expanded")
- }
+ var response = reply.responseJSON;
+ Tapestry.loadScriptsInReply(response, function () {
+ var element = $(spec.clientId).up("li");
+ var label = element.down("span.t-tree-label");
- function successHandler(reply) {
- // Remove the Ajax load indicator
- $(spec.clientId).update("");
- $(spec.clientId).removeClassName("t-empty-node");
+ label.insert({
+ after: response.content
+ });
- var response = reply.responseJSON;
+ // Hide the new sublist so that we can animate revealing it.
+ element.down("ul").hide();
- Tapestry.loadScriptsInReply(response, function() {
- var element = $(spec.clientId).up("li");
- var label = element.down("span.t-tree-label");
+ animateRevealChildren(spec.clientId);
- label.insert({
- after : response.content
+ loading = false;
+ loaded = true;
+ expanded = true;
});
- // Hide the new sublist so that we can animate revealing it.
- element.down("ul").hide();
-
- animateRevealChildren(spec.clientId);
-
- loading = false;
- loaded = true;
- expanded = true;
- });
-
- }
+ }
- function doLoad() {
- if (loading)
- return;
+ function doLoad() {
+ if (loading)
+ return;
- loading = true;
+ loading = true;
- $(spec.clientId).addClassName("t-empty-node");
+ $(spec.clientId).addClassName("t-empty-node");
- $(spec.clientId).update("<span class='t-ajax-wait'/>");
+ $(spec.clientId).update("<span class='t-ajax-wait'/>");
- Tapestry.ajaxRequest(spec.expandChildrenURL, successHandler);
- }
+ Tapestry.ajaxRequest(spec.expandChildrenURL, successHandler);
+ }
- $(spec.clientId).observe("click", function(event) {
- event.stop();
+ $(spec.clientId).observe("click", function (event) {
+ event.stop();
- if (!loaded && spec.expandChildrenURL) {
+ if (!loaded && spec.expandChildrenURL) {
- doLoad();
+ doLoad();
- return;
- }
+ return;
+ }
- // Children have been loaded, just a matter of toggling
- // between showing or hiding the children.
+ // Children have been loaded, just a matter of toggling
+ // between showing or hiding the children.
- var f = expanded ? animateHideChildren : animateRevealChildren;
+ var f = expanded ? animateHideChildren : animateRevealChildren;
- f.call(null, spec.clientId);
+ f.call(null, spec.clientId);
- var url = expanded ? spec.markCollapsedURL : spec.markExpandedURL;
+ var url = expanded ? spec.markCollapsedURL : spec.markExpandedURL;
- // Send request, ignore response.
+ // Send request, ignore response.
- Tapestry.ajaxRequest(url, {});
+ Tapestry.ajaxRequest(url, {});
- expanded = !expanded;
- });
+ expanded = !expanded;
+ });
- if (spec.selectURL) {
+ if (spec.selectURL) {
- var selected = spec.selected;
+ var selected = spec.selected;
- var label = $(spec.clientId).next("span.t-tree-label");
+ var label = $(spec.clientId).next("span.t-tree-label");
- label.addClassName("t-selectable");
+ label.addClassName("t-selectable");
- if (selected) {
- label.addClassName("t-selected-leaf-node-label");
- }
+ if (selected) {
+ label.addClassName("t-selected-leaf-node-label");
+ }
- label.observe("click", function(event) {
- event.stop();
+ label.observe("click", function (event) {
+ event.stop();
- selected = ! selected;
+ selected = !selected;
- if (selected) {
- label.addClassName("t-selected-leaf-node-label");
- }
- else {
- label.removeClassName("t-selected-leaf-node-label");
- }
+ if (selected) {
+ label.addClassName("t-selected-leaf-node-label");
+ }
+ else {
+ label.removeClassName("t-selected-leaf-node-label");
+ }
- // TODO: In the future, we may want to select children when a parent is selected,
- // or vice-versa. There's a lot of use cases. These will be directed from new methods
- // on the TreeSelectionModel interface and encoded into the response. For now,
- // the response is empty and ignored.
+ // TODO: In the future, we may want to select children when a parent is selected,
+ // or vice-versa. There's a lot of use cases. These will be directed from new methods
+ // on the TreeSelectionModel interface and encoded into the response. For now,
+ // the response is empty and ignored.
- Tapestry.ajaxRequest(spec.selectURL, { parameters: { "t:selected": selected } });
- });
+ Tapestry.ajaxRequest(spec.selectURL, { parameters: { "t:selected": selected } });
+ });
+ }
}
- }
- return {
- treeNode : initializer
- };
-});
+ return {
+ treeNode: initializer
+ };
+ });
+});
\ No newline at end of file