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

2011-07-18 Thread hlship
Author: hlship
Date: Tue Jul 19 01:32:26 2011
New Revision: 1148123

URL: http://svn.apache.org/viewvc?rev=1148123view=rev
Log:
TAP5-999: Pass the actual element on which a topic is published to listener 
functions

Modified:

tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js

tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml

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-pubsub.js
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.js?rev=1148123r1=1148122r2=1148123view=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 Jul 19 01:32:26 2011
@@ -1,226 +1,252 @@
-T5.define(pubsub, function() {
+T5.define(pubsub, function()
+{
 
-   var arrays = T5.arrays;
-   var first = arrays.first;
-   var without = arrays.without;
-   var filter = arrays.filter;
-   var remove = arrays.remove;
-   var map = arrays.map;
-   var each = arrays.each;
-
-   // Element keys: topic, element, listenerfn
-   // May be multiple elements with some topic/element pair
-   // element property may be undefined
-   var subscribers = [];
-
-   // Element keys: topic, element, publisherfn
-   var publishers = [];
-
-   // Necessary since T5.dom depends on T5.pubsub
-   function $(element) {
-   return T5.$(element);
-   }
-
-   function purgePublisherCache(topic) {
-   each(function(publisher) {
-   if (publisher.topic === topic) {
-   publisher.listeners = undefined;
-   }
-   }, publishers);
-   }
-
-   function findListeners(topic, element) {
-   var gross = filter(function(subscriber) {
-   return subscriber.topic === topic;
-   }, subscribers);
-
-   var primary = filter(function(subscriber) {
-   return subscriber.element === element;
-   }, gross);
-
-   var secondary = filter(function(subscriber) {
-   // Match where the element is null or undefined
-   return !subscriber.element;
-   }, gross);
-
-   // Return the listenerfn property from each match.
-   return map(arrays.extractProperty(listenerfn), primary
-   .concat(secondary));
-   }
-
-   /**
-* Subscribes a listener function to the selector. The listener function
-* will be invoked when a message for the given topic is published. If 
an
-* element is specified, then the listener will only be invoked when the
-* subscribed element matches the published element.
-* 
-* @param topic
-*a topic name, which must not be blank
-* @param element
-*a DOM element, which may be null to subscribe to all 
messages
-*for the topic. If a string, then T5.$() is used to locate 
the
-*DOM element with the matching client id.
-* @param listenerfn
-*function invoked when a message for the topic is 
published.
-*The function is invoked only if the supplied selector 
element
-*is undefined OR exactly matches the source element node. 
The
-*return value of the listenerfn will be accumulated in an 
array
-*and returned to the publisher.
-* @return a function of no arguments used to unsubscribe the listener
-*/
-   function subscribe(topic, element, listenerfn) {
-
-   var subscriber = {
-   topic : topic,
-   element : $(element),
-   listenerfn : listenerfn
-   };
-
-   subscribers.push(subscriber);
-   purgePublisherCache(subscriber.topic);
-
-   // To prevent memory leaks via closure:
-
-   topic = null;
-   element = null;
-   listenerfn = null;
-
-   // Return a function to unsubscribe
-   return function() {
-   subscribers = without(subscriber, subscribers);
-   purgePublisherCache(subscriber.topic);
-   }
-   }
-
-   /**
-* Creates a publish function for the indicated topic name and DOM 
element.
-* 

svn commit: r1148124 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/internal/services/javascript/ main/resources/org/apache/tapestry5/ test/resources/org/apache/tapes

2011-07-18 Thread hlship
Author: hlship
Date: Tue Jul 19 01:32:53 2011
New Revision: 1148124

URL: http://svn.apache.org/viewvc?rev=1148124view=rev
Log:
TAP5-999: Add a message topic to allow the underlying framework to remove event 
handlers on DOM elements

Added:

tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-events.js
  - copied, changed from r1148123, 
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-prototype.js
Modified:

tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java

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-prototype.js

tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-pubsub.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/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java?rev=1148124r1=1148123r2=1148124view=diff
==
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/CoreJavaScriptStack.java
 Tue Jul 19 01:32:53 2011
@@ -61,7 +61,8 @@ public class CoreJavaScriptStack impleme
 
   // Uses functions defined by the prior three.
   // Order is important, there are some dependencies
-  // going on here.
+  // going on here. Switching over to a more managed module 
system
+  // is starting to look like a really nice idea!
 
   ROOT + /t5-core.js,
 
@@ -77,6 +78,8 @@ public class CoreJavaScriptStack impleme
 
   ROOT + /t5-pubsub.js,
 
+  ROOT + /t5-events.js,
+
   ROOT + /t5-dom.js,
 
   ROOT + /t5-console.js,

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=1148124r1=1148123r2=1148124view=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 Jul 19 01:32:53 2011
@@ -15,98 +15,107 @@
 
 T5.define(dom, function() {
 
-   /**
-* Locates an element. If element is a string, then
-* document.getElementById() is used to resolve a client element id to 
a DOM
-* element. If the id does not exist, then null will be returned.
-* p
-* If element is not a string, it is presumed to already by a DOM 
element,
-* and is returned.
-*/
-   function locate(element) {
-   if (typeof element == string) {
-   return document.getElementById(element);
-   }
-
-   return element; // may be null, otherwise presumed to be a DOM 
node
-   }
-
-   /**
-* Tree-walks the children of the element; for each dhild, ensure that 
all
-* event handlers, listeners and PubSub publishers for the child are
-* removed.
-*/
-   function purgeChildren(element) {
-   var children = element.childNodes;
-
-   if (children) {
-   var l = children.length, i, child;
-
-   for (i = 0; i  l; i++) {
-   var child = children[i];
-
-   /* Just purge element nodes, not text, etc. */
-   if (child.nodeType == 1)
-   purge(children[i]);
-   }
-   }
-   }
-
-   // Adapted from http://javascript.crockford.com/memory/leak.html
-   function purge(element) {
-   var attrs = element.attributes;
-   if (attrs) {
-   var i, name;
-   for (i = attrs.length - 1; i = 0; i--) {
-   if (attrs[i]) {
-   name = attrs[i].name;
-   /* Looking for onclick, etc. */
-   if (typeof element[name] == 'function') 
{
-  

[jira] [Created] (TAP5-1578) When toggling the visibility of a form fragment, the effective visibility doesn't change until after the animation completes

2011-07-18 Thread Howard M. Lewis Ship (JIRA)
When toggling the visibility of a form fragment, the effective visibility 
doesn't change until after the animation completes


 Key: TAP5-1578
 URL: https://issues.apache.org/jira/browse/TAP5-1578
 Project: Tapestry 5
  Issue Type: Bug
  Components: tapestry-core
Affects Versions: 5.3, 5.2
Reporter: Howard M. Lewis Ship


The visibility change should take effect immediately, and the animation should 
lag. Instead, it's the other way around, which means that if the user is quick, 
the data in the now visible fragment will not be submitted with the rest of the 
form.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Assigned] (TAP5-1578) When toggling the visibility of a form fragment, the effective visibility doesn't change until after the animation completes

2011-07-18 Thread Howard M. Lewis Ship (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Howard M. Lewis Ship reassigned TAP5-1578:
--

Assignee: Howard M. Lewis Ship

 When toggling the visibility of a form fragment, the effective visibility 
 doesn't change until after the animation completes
 

 Key: TAP5-1578
 URL: https://issues.apache.org/jira/browse/TAP5-1578
 Project: Tapestry 5
  Issue Type: Bug
  Components: tapestry-core
Affects Versions: 5.3, 5.2
Reporter: Howard M. Lewis Ship
Assignee: Howard M. Lewis Ship
  Labels: forms, javascript

 The visibility change should take effect immediately, and the animation 
 should lag. Instead, it's the other way around, which means that if the user 
 is quick, the data in the now visible fragment will not be submitted with the 
 rest of the form.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Assigned] (TAP5-1558) FormFragment should allow more fine grained control over when to be considered invisible

2011-07-18 Thread Howard M. Lewis Ship (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Howard M. Lewis Ship reassigned TAP5-1558:
--

Assignee: Howard M. Lewis Ship  (was: Robert Zeigler)

 FormFragment should allow more fine grained control over when to be 
 considered invisible
 --

 Key: TAP5-1558
 URL: https://issues.apache.org/jira/browse/TAP5-1558
 Project: Tapestry 5
  Issue Type: Improvement
  Components: tapestry-core
Affects Versions: 5.3
Reporter: Robert Zeigler
Assignee: Howard M. Lewis Ship
Priority: Minor

 The 5.2 line of Tapestry introduced the alwaysSubmit parameter to form 
 fragment.  This is nice because it allows the fragment to be submitted even 
 if hidden.  However, it doesn't cover all use cases.  Consider a situation 
 like:
 form
div id=tab1...t:formfragment ...t:textfield 
 validate=required...//t:formfragment/div
div id=tab2...t:formfragment ...t:textfield 
 validate=required...//t:formfragment/div
t:submit/
 /form
 User reveals tab 1, then reveals the form fragment on tab1 and makes changes. 
 Now user reveals tab2. Note that the fragment on tab1 is still revealed in 
 the context of tab1, but the entire tab1 is hidden.  There is currently no 
 way to make it so that submit will submit the information from the 
 formfragment in both tabs and behave correctly in all situations. I will 
 enumerate.  Some definitions for clarity:
 fragmentX is the fragment on tabX. 
 fragmentX visibility refers to the state of the actual fragment, rather than 
 the state of the containing tab.  So if fragment1 is visible, it means it's 
 visible when tab1 is active... and I am considering it visible when tab2 is 
 active, even though the entire tab1 is invisible.
 1) If alwaysSubmit is false and fragment1 is invisible, you will get the 
 correct behavior regardless of tab1/tab2 visibility
 2) If alwaysSubmit is false and fragment1 is visible, you will get the 
 correct behavior iff tab1 is active.  If tab2 is active, fragment1's fields 
 will not be submitted.
 3) If alwaysSubmit is true and fragment1 is invisible, you will get 
 incorrect behavior (well, technically, it's correct: the information will 
 be submitted, as per alwaysSubmit, but this is a case where you don't 
 actually /want/ the information submitted if the fragment isn't visible)
 4) If alwaysSubmit is true and fragment is visible, you will get correct 
 behavior.
 You can conditionally alwaysSubmit: alwaysSubmit on the same condition for 
 visibility as the visible trigger.  The problem here comes in the following 
 scenario:
 User opens a page with fragment1 initially visible, but no data yet in the 
 required field.  User marks fragment1 as invisible. User submits the form.  
 The submission will fail because alwaysSubmit was true at the time the form 
 rendered.
 The culprit behind this is Tapestry's isDeepVisible method.  It searches 
 for visibility up to the point where it finds a form element.  But in the 
 case above, the form element contains the tab divs, so the fragment is 
 determined to be invisible and the data not submitted for the inactive tab, 
 even if the user clicked on the trigger to make the fragment visible while 
 the tab was active.
 This is something of an edge case, but I think it can be handled cleanly by 
 introducing a new parameter to formfragment, such as visiblebound (but 
 better named!).  The idea is to allow developers to specify an element or 
 selector expression that bounds the search for visibility.  The default would 
 be the containing form element which would preserve the current behavior. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Assigned] (TAP5-1558) FormFragment should allow more fine grained control over when to be considered invisible

2011-07-18 Thread Howard M. Lewis Ship (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Howard M. Lewis Ship reassigned TAP5-1558:
--

Assignee: (was: Howard M. Lewis Ship)

 FormFragment should allow more fine grained control over when to be 
 considered invisible
 --

 Key: TAP5-1558
 URL: https://issues.apache.org/jira/browse/TAP5-1558
 Project: Tapestry 5
  Issue Type: Improvement
  Components: tapestry-core
Affects Versions: 5.3
Reporter: Robert Zeigler
Priority: Minor

 The 5.2 line of Tapestry introduced the alwaysSubmit parameter to form 
 fragment.  This is nice because it allows the fragment to be submitted even 
 if hidden.  However, it doesn't cover all use cases.  Consider a situation 
 like:
 form
div id=tab1...t:formfragment ...t:textfield 
 validate=required...//t:formfragment/div
div id=tab2...t:formfragment ...t:textfield 
 validate=required...//t:formfragment/div
t:submit/
 /form
 User reveals tab 1, then reveals the form fragment on tab1 and makes changes. 
 Now user reveals tab2. Note that the fragment on tab1 is still revealed in 
 the context of tab1, but the entire tab1 is hidden.  There is currently no 
 way to make it so that submit will submit the information from the 
 formfragment in both tabs and behave correctly in all situations. I will 
 enumerate.  Some definitions for clarity:
 fragmentX is the fragment on tabX. 
 fragmentX visibility refers to the state of the actual fragment, rather than 
 the state of the containing tab.  So if fragment1 is visible, it means it's 
 visible when tab1 is active... and I am considering it visible when tab2 is 
 active, even though the entire tab1 is invisible.
 1) If alwaysSubmit is false and fragment1 is invisible, you will get the 
 correct behavior regardless of tab1/tab2 visibility
 2) If alwaysSubmit is false and fragment1 is visible, you will get the 
 correct behavior iff tab1 is active.  If tab2 is active, fragment1's fields 
 will not be submitted.
 3) If alwaysSubmit is true and fragment1 is invisible, you will get 
 incorrect behavior (well, technically, it's correct: the information will 
 be submitted, as per alwaysSubmit, but this is a case where you don't 
 actually /want/ the information submitted if the fragment isn't visible)
 4) If alwaysSubmit is true and fragment is visible, you will get correct 
 behavior.
 You can conditionally alwaysSubmit: alwaysSubmit on the same condition for 
 visibility as the visible trigger.  The problem here comes in the following 
 scenario:
 User opens a page with fragment1 initially visible, but no data yet in the 
 required field.  User marks fragment1 as invisible. User submits the form.  
 The submission will fail because alwaysSubmit was true at the time the form 
 rendered.
 The culprit behind this is Tapestry's isDeepVisible method.  It searches 
 for visibility up to the point where it finds a form element.  But in the 
 case above, the form element contains the tab divs, so the fragment is 
 determined to be invisible and the data not submitted for the inactive tab, 
 even if the user clicked on the trigger to make the fragment visible while 
 the tab was active.
 This is something of an edge case, but I think it can be handled cleanly by 
 introducing a new parameter to formfragment, such as visiblebound (but 
 better named!).  The idea is to allow developers to specify an element or 
 selector expression that bounds the search for visibility.  The default would 
 be the containing form element which would preserve the current behavior. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira




[jira] [Assigned] (TAP5-1574) Provide constants for available data types

2011-07-18 Thread Igor Drobiazko (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1574?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Igor Drobiazko reassigned TAP5-1574:


Assignee: Igor Drobiazko

 Provide constants for available data types
 --

 Key: TAP5-1574
 URL: https://issues.apache.org/jira/browse/TAP5-1574
 Project: Tapestry 5
  Issue Type: Improvement
  Components: tapestry-core
Affects Versions: 5.2.5
Reporter: Igor Drobiazko
Assignee: Igor Drobiazko
Priority: Minor

 Data types contributed to the DefaultDataTypeAnalyzer's configuration should 
 be exposed as constants. It is odd to use string value when useing @DataType 
 annotation.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira