[Jifty-commit] r1128 - in jifty/trunk: lib/Jifty/Web/Form

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue May 30 14:04:45 EDT 2006


Author: alexmv
Date: Tue May 30 14:04:25 2006
New Revision: 1128

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
   jifty/trunk/lib/Jifty/Web/Form/Element.pm

Log:
 r13364 at zoq-fot-pik:  chmrr | 2006-05-30 14:04:14 -0400
  * Allow arbitrary JS on elements


Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	Tue May 30 14:04:25 2006
@@ -480,6 +480,7 @@
         next unless $value;
         my @hooks = ref $value eq "ARRAY" ? @{$value} : ($value);
         for my $hook (@hooks) {
+            next unless ref $hook eq "HASH";
             $hook->{region} ||= $hook->{refresh} || Jifty->web->qualified_region;
             $hook->{args}   ||= {};
             my $region = ref $hook->{region} ? $hook->{region} : Jifty->web->get_region( $hook->{region} );

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	Tue May 30 14:04:25 2006
@@ -17,8 +17,10 @@
 set of arguments.
 
 The format of the arguments passed to C<onclick> (or any similar
-method) is a hash reference.  It takes a number of possible keys.  The
-most important is the mode of the fragment replacement, if any; it is
+method) is a hash reference or string Strings are inserted verbatim.
+
+Hash references can take a number of possible keys.  The most
+important is the mode of the fragment replacement, if any; it is
 specified by providing at most one of the following keys:
 
 =over
@@ -142,7 +144,8 @@
         my @fragments;
         my @actions;
 
-        for my $hook (ref $value eq "ARRAY" ? @{$value} : ($value)) {
+        for my $hook (grep {ref $_ eq "HASH"} (ref $value eq "ARRAY" ? @{$value} : ($value))) {
+
             my %args;
 
             # Submit action
@@ -214,8 +217,12 @@
             push @fragments, \%args;
         }
 
-        my $update = "update( ". Jifty::JSON::objToJson( {actions => \@actions, fragments => \@fragments }, {singlequote => 1}) ." )";
-        $response .= $self->javascript_preempt ? qq| $trigger="return $update"| : qq| $trigger="$update; return true;"|;
+        my $string = join ";", (grep {not ref $_} (ref $value eq "ARRAY" ? @{$value} : ($value)));
+        if (@fragments) {
+            my $update = "update( ". Jifty::JSON::objToJson( {actions => \@actions, fragments => \@fragments }, {singlequote => 1}) ." );";
+            $string .= $self->javascript_preempt ? "return $update" : "$update; return true;";
+        }
+        $response .= qq| $trigger="$string"|;
     }
     return $response;
 }


More information about the Jifty-commit mailing list