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 2010/04/28 04:23:43 UTC

svn commit: r938749 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java main/resources/org/apache/tapestry5/tapestry.js test/app1/FormFragmentDemo.tml

Author: hlship
Date: Wed Apr 28 02:23:43 2010
New Revision: 938749

URL: http://svn.apache.org/viewvc?rev=938749&view=rev
Log:
TAP5-179: The TriggerFragment mixin would be more useful if it could invert its logic, i.e., make a a fragment visible when a checkbox was turned off

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FormFragmentDemo.tml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java?rev=938749&r1=938748&r2=938749&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/TriggerFragment.java Wed Apr 28 02:23:43 2010
@@ -43,6 +43,15 @@ public class TriggerFragment
     @Parameter(required = true, defaultPrefix = BindingConstants.COMPONENT, allowNull = false)
     private ClientElement fragment;
 
+    /**
+     * If true then the client-side logic is inverted; the fragment is made visible when the checkbox is NOT checked.
+     * The default is false (the fragment is visible when the checkbox IS checked).
+     * 
+     * @since 5.2.0
+     */
+    @Parameter
+    private boolean invert;
+
     @Environmental
     private JavascriptSupport javascriptSupport;
 
@@ -50,6 +59,7 @@ public class TriggerFragment
     void beginRender()
     {
         JSONObject spec = new JSONObject("triggerId", container.getClientId(), "fragmentId", fragment.getClientId());
+        spec.put("invert", invert);
 
         javascriptSupport.addInitializerCall("linkTriggerToFormFragment", spec);
     }

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=938749&r1=938748&r2=938749&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 Wed Apr 28 02:23:43 2010
@@ -1036,8 +1036,11 @@ Tapestry.Initializer = {
 		var trigger = $(spec.triggerId);
 
 		var update = function() {
+			var checked = trigger.checked;
+			var makeVisible = checked == ! spec.invert;
+
 			$(spec.fragmentId).fire(Tapestry.CHANGE_VISIBILITY_EVENT, {
-				visible : trigger.checked
+				visible : makeVisible
 			}, true);
 		}
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FormFragmentDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FormFragmentDemo.tml?rev=938749&r1=938748&r2=938749&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FormFragmentDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/FormFragmentDemo.tml Wed Apr 28 02:23:43 2010
@@ -27,9 +27,9 @@
             <br/>
 
             <t:radiogroup value="codeVisible">
-                <t:radio t:id="on" label="On" value="true" t:mixins="triggerfragment" fragment="codeFragment"/>
+                <t:radio t:id="on" label="On" value="true"/>
                 <t:label for="on"/>
-                <t:radio t:id="off" label="Off" value="false"/>
+                <t:radio t:id="off" label="Off"  t:mixins="triggerfragment" fragment="codeFragment" invert="true" value="false"/>
                 <t:label for="off"/>
             </t:radiogroup>