[Jifty-commit] r5677 - in jifty/trunk: . lib/Jifty lib/Jifty/Subs share/web/static/js share/web/templates/=

Jifty commits jifty-commit at lists.jifty.org
Fri Aug 8 16:20:30 EDT 2008


Author: alexmv
Date: Fri Aug  8 16:20:13 2008
New Revision: 5677

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Subs.pm
   jifty/trunk/lib/Jifty/Subs/Render.pm
   jifty/trunk/lib/Jifty/Web/Form/Element.pm
   jifty/trunk/share/web/static/js/jifty.js
   jifty/trunk/share/web/static/js/jifty_subs.js
   jifty/trunk/share/web/templates/=/subs

Log:
 r35564 at kohr-ah:  chmrr | 2008-08-08 16:19:49 -0400
  * Removal effects
  * Untabify jifty_subs.js


Modified: jifty/trunk/lib/Jifty/Subs.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Subs.pm	(original)
+++ jifty/trunk/lib/Jifty/Subs.pm	Fri Aug  8 16:20:13 2008
@@ -61,6 +61,18 @@
 
 The effect to use when showing the region, if any.
 
+=item effect_args
+
+Arguments to the effect
+
+=item remove_effect
+
+The effect to use when removing the old value of the region, if any.
+
+=item remove_effect_args
+
+Arguments to the remove effect
+
 =item coalesce
 
 If multiple events would cause the update of the given region with the
@@ -87,6 +99,8 @@
     my $queries = $args->{queries} || [];
     my $region  = $args->{region};
     my $channel = $event_class->encode_queries(@$queries);
+    $args->{attrs}{$_} = delete $args->{$_}
+        for grep {exists $args->{$_}} qw/effect effect_args remove_effect remove_effect_args/;
 
     # The ->modify here is calling into the callback sub{...} with
     # the previous value of $_, that is a hashref of channels to
@@ -107,7 +121,7 @@
         "$id-render" => sub {
             $_->{$channel}{$region} = {
                 map { $_ => $args->{$_} }
-                    qw/render_with region arguments mode effect coalesce/
+                    qw/render_with region arguments mode coalesce attrs/
             };
         }
     );

Modified: jifty/trunk/lib/Jifty/Subs/Render.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Subs/Render.pm	(original)
+++ jifty/trunk/lib/Jifty/Subs/Render.pm	Fri Aug  8 16:20:13 2008
@@ -82,11 +82,15 @@
 
 sub render_single {
     my ($class, $msg, $render_info, $callback) = @_;
+
     my $region = Jifty::Web::PageRegion->new(
         name => $render_info->{region},
         path => $render_info->{render_with},
     );
 
+    # So we don't warn about "duplicate region"s
+    delete Jifty->web->{'regions'}{ $region->qualified_name };
+
     # Finally render the region.  In addition to the user-supplied arguments
     # in $render_info, we always pass the target $region and the event object
     # into its %ARGS.
@@ -99,7 +103,7 @@
             $event_object->render_arguments,
         }
     );
-    $callback->( $render_info->{mode}, $region->qualified_name, $region_content, $render_info->{effect});
+    $callback->( $render_info->{mode}, $region->qualified_name, $region_content, $render_info->{attrs} );
     $region->exit;
 }
 

Modified: jifty/trunk/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Element.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Element.pm	Fri Aug  8 16:20:13 2008
@@ -110,14 +110,23 @@
 
 =item effect => STRING
 
-The Scriptaculous visual effect to use when updating or creating the
-fragment.
+The Scriptaculous or jQuery visual effect to use when updating or
+creating the fragment.
 
 =item effect_args => HASHREF
 
 A hashref of arguments to pass to the effect when it is created.  These
 can be used to change the duration of the effect, for instance.
 
+=item remove_effect => STRING
+
+As C<effect>, but for when the previous version of the region is
+removed.
+
+=item remove_effect_args => HASHREF
+
+As C<effect_args>, but for C<remove_effect>.
+
 =item beforeclick => STRING
 
 String contains some Javascript code to be used before a click.
@@ -478,7 +487,7 @@
             $args{toggle} = 1 if $hook->{toggle};
 
             # Effects
-            $args{$_} = $hook->{$_} for grep {exists $hook->{$_}} qw/effect effect_args/;
+            $args{$_} = $hook->{$_} for grep {exists $hook->{$_}} qw/effect effect_args remove_effect remove_effect_args/;
 
             push @fragments, \%args;
         }

Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js	(original)
+++ jifty/trunk/share/web/static/js/jifty.js	Fri Aug  8 16:20:13 2008
@@ -900,10 +900,25 @@
             return;
 
         // If we're removing the element, do it now
-        // XXX TODO: Effects on this?
         if (f['mode'] == "Delete") {
             fragments[name] = null;
-            jQuery(element).remove();
+            if (f['effect']) {
+                Jifty.Effect(
+                    Jifty.$('region-'+f['region']),
+                    f['effect'],
+                    f['effect_args']
+                );
+                jQuery(element).queue(function() { jQuery(element).remove(); });
+            } else if (f['remove_effect']) {
+                Jifty.Effect(
+                    Jifty.$('region-'+f['region']),
+                    f['remove_effect'],
+                    f['remove_effect_args']
+                );
+                jQuery(element).queue(function() { jQuery(element).remove(); });
+            } else {
+                jQuery(element).remove();
+            }
             return;
         }
 
@@ -1028,6 +1043,13 @@
 
                     jQuery.fn[method].call(jQuery(element), textContent);
                     element = document.getElementById('region-' + f['region']);
+                } else if (f['remove_effect']) {
+                    Jifty.Effect(
+                        Jifty.$('region-'+f['region']),
+                        f['remove_effect'],
+                        f['remove_effect_args']
+                    );
+                    jQuery(element).queue(function() { jQuery(element).html( textContent ); });
                 } else {
                     jQuery(element).html( textContent );
                 }
@@ -1039,18 +1061,15 @@
 
     // Also, set us up the effect
     if (f['effect']) {
+        if(f['is_new']) 
+            jQuery(Jifty.$('region-'+f['region'])).hide();
         Jifty.Effect(
             Jifty.$('region-'+f['region']),
             f['effect'],
-            f['effect_args'],
-            {
-                before: function() {
-                    if(f['is_new']) 
-                        jQuery(this).hide();
-                }
-            }
+            f['effect_args']
         );
     }
+    return Jifty.$('region-'+f['region']);
 }
 
 // Update a region.  Takes a hash of named parameters, including:
@@ -1617,15 +1636,14 @@
         name == 'SlideUp' ? 'slideUp' :
         name;
 
-    if (jQuery.isFunction( jQuery(el)[ effect ] ) ) {
-        if ( jQuery.isFunction(options["before"])  ) 
-            options["before"].call( el );
+    if ( jQuery.isFunction(options["before"]) ) 
+        options["before"].call( el );
 
+    if ( jQuery.isFunction( jQuery(el)[ effect ] ) )
         ( jQuery(el)[ effect ] )(args);
 
-        if ( jQuery.isFunction(options["after"])  ) 
-            options["after"].call( el );
-    }
+    if ( jQuery.isFunction(options["after"]) ) 
+        options["after"].call( el );
 };
 
 /*

Modified: jifty/trunk/share/web/static/js/jifty_subs.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty_subs.js	(original)
+++ jifty/trunk/share/web/static/js/jifty_subs.js	Fri Aug  8 16:20:13 2008
@@ -9,16 +9,18 @@
        Then it calls jifty's "apply_fragment_updates to the item
        inside the <pushfrag> (the actual fragment);
 
-	f is the specification for the new fragment. (region, path,
-	mode and other infomration extracted from the fragment)
+        f is the specification for the new fragment. (region, path,
+        mode and other information extracted from the fragment)
 
        */
 
     var onPushHandler = function(t) {
-    	var mode = t.getAttribute('mode');
-    	var effect =  t.getAttribute('effect');
-    	var rid =  t.firstChild.getAttribute('id');
-    	var f = { region: rid, path: '', mode: mode, effect: effect };
+        var rid =  t.firstChild.getAttribute('id');
+        var f = { region: rid, path: '' };
+        f['effect']             =  t.getAttribute('effect');
+        f['effect_args']        =  t.getAttribute('effect_args');
+        f['remove_effect']      =  t.getAttribute('remove_effect');
+        f['remove_effect_args'] =  t.getAttribute('remove_effect_args');
 
         // If SinglePlugin is enabled, region name will be prefixed
         // "__page-" by the time that region was rendered. Therefore
@@ -27,9 +29,9 @@
             f['region'] = "__page-" + f['region']
         }
 
-    	f = prepare_element_for_update(f);
+        f = prepare_element_for_update(f);
         if (f == null) return;
-    	apply_fragment_updates(t.firstChild, f);
+        apply_fragment_updates(t.firstChild, f);
     };
 
     
@@ -43,13 +45,13 @@
     /* Jifty.Subs.start() will connect to the iframe transport */
 
     Jifty.Subs = function(args) {
-    	var window_id = args.window_id; // XXX: not yet
-    	var uri = args.uri;
-    	if (!uri)
-    	    uri = "/=/subs?forever=0";
-    	
-    	this.start = function() {
-    	    //push.start();
+        var window_id = args.window_id; // XXX: not yet
+        var uri = args.uri;
+        if (!uri)
+            uri = "/=/subs?forever=0";
+        
+        this.start = function() {
+            //push.start();
             var self = this;
 
             jQuery.ajax({

Modified: jifty/trunk/share/web/templates/=/subs
==============================================================================
--- jifty/trunk/share/web/templates/=/subs	(original)
+++ jifty/trunk/share/web/templates/=/subs	Fri Aug  8 16:20:13 2008
@@ -41,8 +41,8 @@
     Jifty::Subs::Render->render(
         Jifty->web->session->id,
         sub {
-            my ( $mode, $name, $content, $effect ) = @_;
-            $writer->startTag( "pushfrag", mode => $mode, ($effect? (effect => $effect) : ()) );
+            my ( $mode, $name, $content, $attrs ) = @_;
+            $writer->startTag( "pushfrag", mode => $mode, %{$attrs || {}} );
             $writer->startTag( "fragment", id   => $name );
             $writer->dataElement( "content", $content );
             $writer->endTag();


More information about the Jifty-commit mailing list