Author: hlship
Date: Thu Sep  4 12:17:06 2008
New Revision: 692197

URL: http://svn.apache.org/viewvc?rev=692197&view=rev
Log:
TAPESTRY-2639: tapestry.js does not use Protoype's Class.create() properly

Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/palette.js
    
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js?rev=692197&r1=692196&r2=692197&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/datefield.js
 Thu Sep  4 12:17:06 2008
@@ -12,9 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-Tapestry.DateField = Class.create();
-
-Tapestry.DateField.prototype = {
+Tapestry.DateField = Class.create({
 
     // Initializes a DateField from a JSON specification.
 
@@ -184,7 +182,7 @@
 
         Tapestry.DateField.activeDateField = this;
     }
-};
+});
 
 Tapestry.Initializer.dateField = function(spec)
 {

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/palette.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/palette.js?rev=692197&r1=692196&r2=692197&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/palette.js
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/corelib/components/palette.js
 Thu Sep  4 12:17:06 2008
@@ -1,6 +1,18 @@
-Tapestry.Palette = Class.create();
+// Copyright 2007, 2008 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.Palette.prototype = {
+Tapestry.Palette = Class.create({
 
     // id: of main select element
     // reorder: true to enable extra controls for changing selection order
@@ -8,14 +20,14 @@
     initialize : function(id, reorder, naturalOrder)
     {
         this.reorder = reorder;
-    // The SELECT elements
+        // The SELECT elements
 
         this.avail = $(id + ":avail");
         this.selected = $(id);
 
         this.hidden = $(id + ":values");
 
-         // The BUTTON elements
+        // The BUTTON elements
         this.select = $(id + ":select");
         this.deselect = $(id + ":deselect");
 
@@ -98,7 +110,7 @@
     {
         var options = $A(this.selected.options);
 
-    // Make sure that all elements from the (first) selectedIndex to the end 
are also selected.
+        // Make sure that all elements from the (first) selectedIndex to the 
end are also selected.
         return options.slice(this.selected.selectedIndex).all(function(o)
         {
             return o.selected;
@@ -232,7 +244,7 @@
         var lastPos = lastSelected.index;
         var before = this.selected.options[lastPos + 2];
 
-    // TODO: needs to be "reorder options"
+        // TODO: needs to be "reorder options"
         this.reorderSelected(this.removeSelectedOptions(this.selected), 
before);
 
         Event.stop(event);
@@ -248,7 +260,7 @@
         this.updateHidden();
         this.updateButtons();
     }
-};
+});
 
 
 

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=692197&r1=692196&r2=692197&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
 Thu Sep  4 12:17:06 2008
@@ -54,20 +54,6 @@
     /** Time, in seconds, that console messages are visible. */
     CONSOLE_DURATION : 60,
 
-    FormEventManager : Class.create(),
-
-    FieldEventManager : Class.create(),
-
-    Zone : Class.create(),
-
-    FormFragment : Class.create(),
-
-    FormInjector : Class.create(),
-
-    ErrorPopup : Class.create(),
-
-    DependentExecutor : Class.create(),
-
     // Adds a callback function that will be invoked when the DOM is loaded 
(which
     // occurs *before* window.onload, which has to wait for images and such to 
load
     // first.  This simply observes the dom:loaded event on the document 
object (support for
@@ -733,7 +719,7 @@
     }
 };
 
-Tapestry.ErrorPopup.prototype = {
+Tapestry.ErrorPopup = Class.create({
 
     // If the images associated with the error popup are overridden (by 
overriding Tapestry's default.css stylesheet),
     // then some of these values may also need to be adjusted.
@@ -869,9 +855,9 @@
 
         this.outerDiv.hide();
     }
-};
+});
 
-Tapestry.FormEventManager.prototype = {
+Tapestry.FormEventManager = Class.create({
 
     initialize : function(form)
     {
@@ -941,9 +927,9 @@
             return false;
         }
     }
-};
+});
 
-Tapestry.FieldEventManager.prototype = {
+Tapestry.FieldEventManager = Class.create({
 
     initialize : function(field)
     {
@@ -1040,7 +1026,7 @@
 
         return this.field.validationError;
     }
-};
+});
 
 // Wrappers around Prototype and Scriptaculous effects.
 // All the functions of this object should have all-lowercase names.
@@ -1075,7 +1061,7 @@
 };
 
 
-Tapestry.Zone.prototype = {
+Tapestry.Zone = Class.create({
     // spec are the parameters for the Zone:
     // trigger: required -- name or instance of link.
     // element: required -- name or instance of div element to be shown, 
hidden and updated
@@ -1116,12 +1102,12 @@
 
         func.call(this, this.element);
     }
-};
+});
 
 // A class that managed an element (usually a <div>) that is conditionally 
visible and
 // part of the form when visible.
 
-Tapestry.FormFragment.prototype = {
+Tapestry.FormFragment = Class.create({
 
     initialize: function(spec)
     {
@@ -1184,9 +1170,9 @@
 
         this.hide();
     }
-};
+});
 
-Tapestry.FormInjector.prototype = {
+Tapestry.FormInjector = Class.create({
 
     initialize: function(spec)
     {
@@ -1239,13 +1225,13 @@
             return false;
         }.bind(this);
     }
-};
+});
 
 /**
  * Coordinates the execution of JavaScript code blocks (via eval) with the 
loading
  * of an array of <script> elements.
  */
-Tapestry.DependentExecutor.prototype = {
+Tapestry.DependentExecutor = Class.create({
 
     initialize : function(prereqs, dependent)
     {
@@ -1292,7 +1278,7 @@
         if (this.loaded == this.toload)
             eval(this.dependent);
     }
-};
+});
 
 Tapestry.ScriptManager = {
 

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=692197&r1=692196&r2=692197&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
 Thu Sep  4 12:17:06 2008
@@ -1736,12 +1736,17 @@
 
         click("subscribeToEmail");
         click("on");
+
+        
waitForCondition("selenium.browserbot.getCurrentWindow().$('code').isDeepVisible()
 == true", PAGE_LOAD_TIMEOUT);
+
         type("name", "Barney");
         type("email", "[EMAIL PROTECTED]");
         type("code", "ABC123");
 
         click("off");
-        sleep(1000);
+
+        
waitForCondition("selenium.browserbot.getCurrentWindow().$('code').isDeepVisible()
 == false",
+                         PAGE_LOAD_TIMEOUT);
 
         clickAndWait(SUBMIT);
 
@@ -2195,9 +2200,19 @@
 
         click(SUBMIT);
 
-        
waitForCondition("selenium.browserbot.getCurrentWindow().document.getElementById('amount:errorpopup')",
 "5000");
+        waitForElementToAppear("ammount:errorpopup");
+        waitForElementToAppear("quantity:errorpopup");
 
         assertText("//[EMAIL PROTECTED]'amount:errorpopup']/span", "You must 
provide a numeric value for Amount.");
         assertText("//[EMAIL PROTECTED]'quantity:errorpopup']/span", "Provide 
quantity as a number.");
     }
+
+    private void waitForElementToAppear(String elementId)
+    {
+
+        String condition = 
String.format("selenium.browserbot.getCurrentWindow().document.getElementById('%s')",
+                                         elementId);
+
+        waitForCondition(condition, PAGE_LOAD_TIMEOUT);
+    }
 }


Reply via email to