[Jifty-commit] r829 - in jifty/trunk: lib/Jifty lib/Jifty/Test/WWW lib/Jifty/Web/Form lib/Jifty/Web/Form/Field

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Apr 10 18:52:09 EDT 2006


Author: alexmv
Date: Mon Apr 10 18:52:08 2006
New Revision: 829

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
   jifty/trunk/lib/Jifty/Web.pm
   jifty/trunk/lib/Jifty/Web/Form/Element.pm
   jifty/trunk/lib/Jifty/Web/Form/Field/Checkbox.pm

Log:
 r12190 at zoq-fot-pik:  chmrr | 2006-04-10 18:51:55 -0400
  * Checkboxes get to check themselves off
  * Jifty->web->url takes a scheme argument now/again
  * $mech->moniker_for can take a unqualified action


Modified: jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	(original)
+++ jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	Mon Apr 10 18:52:08 2006
@@ -39,7 +39,7 @@
 
 sub moniker_for {
   my $self = shift;
-  my $action = shift;
+  my $action = Jifty->api->qualify(shift);
   my %args = @_;
 
   for my $f ($self->forms) {

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Mon Apr 10 18:52:08 2006
@@ -63,14 +63,16 @@
 
 =head3 url
 
-Returns the root url of this Jifty application.  This is pulled from the
-configuration file.  
-
+Returns the root url of this Jifty application.  This is pulled from
+the configuration file.  Takes an optional named parameter C<scheme>
+to specify the scheme.
 
 =cut
 
 sub url {
     my $self = shift;
+    my %args = @_;
+
     my $url  = Jifty->config->framework("Web")->{BaseURL};
     my $port = Jifty->config->framework("Web")->{Port};
     
@@ -78,6 +80,7 @@
     if ($url =~ /^(\w+)/) {
         $scheme = $1;
     }
+    $scheme = $args{scheme} if $args{scheme};
 
     if ($ENV{'HTTP_HOST'}) {
         return $scheme ."://".$ENV{'HTTP_HOST'};

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	Mon Apr 10 18:52:08 2006
@@ -181,11 +181,24 @@
 
             push @fragments, \%args;
         }
-        $response .= qq| $trigger="return update( @{[ Jifty::JSON::objToJson( {actions => \@actions, fragments => \@fragments }, {singlequote => 1}) ]} ) "|;
+
+        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;"|;
     }
     return $response;
 }
 
+=head2 javascript_preempt
+
+Returns true if the the javascript's handlers should prevent the web
+browser's standard effects from happening; that is, for C<onclick>, it
+prevents buttons from submitting and the like.  The default is to
+return true, but this can be overridden.
+
+=cut
+
+sub javascript_preempt { return 1 };
+
 =head2 class
 
 Sets the CSS class that the element will display as

Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Checkbox.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Checkbox.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Checkbox.pm	Mon Apr 10 18:52:08 2006
@@ -41,4 +41,13 @@
     '';
 }
 
+=head2 javascript_preempt
+
+By default, javascript (such as onclick handlers) should not actually
+prevent browsers from placing the checkmark in the checkbox.
+
+=cut
+
+sub javascript_preempt { return 0; }
+
 1;


More information about the Jifty-commit mailing list