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 2011/10/18 02:06:19 UTC

svn commit: r1185435 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/resources/org/apache/tapestry5/ test/resources/org/apache/tapestry5/integration/app1/pages/

Author: hlship
Date: Tue Oct 18 00:06:18 2011
New Revision: 1185435

URL: http://svn.apache.org/viewvc?rev=1185435&view=rev
Log:
TAP5-1692: Underscore.js should be used in no-conflict mode

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-ajax.js Tue Oct 18 00:06:18 2011
@@ -21,6 +21,7 @@
  */
 T5.define("ajax", function() {
 
+    var _ = T5._;
     var $ = T5.$;
     var spi = T5.spi;
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-core.js Tue Oct 18 00:06:18 2011
@@ -21,41 +21,49 @@
  * @since 5.3
  */
 var T5 = {
-    /**
-     * Extends an object using a source. In the simple case, the source object's
-     * properties are overlaid on top of the destination object. In the typical
-     * case, the source parameter is a function that returns the source object
-     * ... this is to facilitate modularity and encapsulation.
-     *
-     * @param destination
-     *            object to receive new or updated properties
-     * @param source
-     *            source object for properties, or function returning source
-     *            object
-     * @returns the destination object
-     */
-    extend : function(destination, source) {
-        if (_.isFunction(source)) {
-            source = source();
-        }
-
-        return _.extend(destination, source);
-    },
-
-    /**
-     * Defines a new namespace under the T5 object.
-     *
-     * @param name
-     *            string name of the namespace
-     * @param source
-     *            source object for properties (or function returning source
-     *            object)
-     * @return the namespace object
+
+    /** _ is _.noConflict(), in other words, all Underscore functions are not inside
+     * T5._, rather than simply _.
      */
-    define : function(name, source) {
-        var namespace = {};
-        T5[name] = namespace;
+    _ : _.noConflict()
+};
+
+/**
+ * Extends an object using a source. In the simple case, the source object's
+ * properties are overlaid on top of the destination object. In the typical
+ * case, the source parameter is a function that returns the source object
+ * ... this is to facilitate modularity and encapsulation.
+ *
+ * @param destination
+ *            object to receive new or updated properties
+ * @param source
+ *            source object for properties, or function returning source
+ *            object
+ * @returns the destination object
+ */
+T5.extend = function(destination, source) {
+    var _ = T5._;
 
-        return this.extend(namespace, source);
+    if (_.isFunction(source)) {
+        source = source();
     }
-}
\ No newline at end of file
+
+    return _.extend(destination, source);
+};
+
+/**
+ * Defines a new namespace under the T5 object.
+ *
+ * @param name
+ *            string name of the namespace
+ * @param source
+ *            source object for properties (or function returning source
+ *            object)
+ * @return the namespace object
+ */
+T5.define = function(name, source) {
+    var namespace = {};
+    T5[name] = namespace;
+
+    return this.extend(namespace, source);
+};

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-dom.js Tue Oct 18 00:06:18 2011
@@ -15,6 +15,8 @@
 
 T5.define("dom", function() {
 
+    var _ = T5._;
+
     var removeEventHandlers;
 
     // Necessary to lazy-instantiate femoveEventHandlers publisher function,
@@ -84,7 +86,9 @@ T5.define("dom", function() {
         purgeChildren(element);
 
         if (element.t5pubsub) {
-            _.defer(function() { T5.pubsub.cleanupRemovedElement(element) });
+            _.defer(function() {
+                T5.pubsub.cleanupRemovedElement(element)
+            });
         }
 
         doRemoveEventHandlers(element);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js Tue Oct 18 00:06:18 2011
@@ -1,5 +1,7 @@
 T5.define("pubsub", function() {
 
+    var _ = T5._;
+
     // Element keys: topic, element, listenerfn
     // May be multiple elements with some topic/element pair
     // element property may be undefined

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js Tue Oct 18 00:06:18 2011
@@ -1418,6 +1418,8 @@ Tapestry.ErrorPopup = Class.create({
             return;
 
         if (Prototype.Browser.IE) {
+            var _ = T5._;
+
             this.outerDiv.show();
 
             var bound = _.bind(this.hideIfNotFocused, this);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/ClientConsoleDemo.js Tue Oct 18 00:06:18 2011
@@ -1,12 +1,16 @@
 Tapestry.onDOMLoaded(function() {
 
+    var _ = T5._;
+
     function execute(level) {
         T5.console[level]($(level).value);
         $(level).select();
     }
 
     function wire(level) {
-        $(level).observe("change", function() { execute(level); });
+        $(level).observe("change", function() {
+            execute(level);
+        });
 
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js?rev=1185435&r1=1185434&r2=1185435&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/js-testing.js Tue Oct 18 00:06:18 2011
@@ -1,5 +1,7 @@
 var JST = (function() {
 
+    var _ = T5._;
+
     var resultElement;
 
     var $fail = {};