[Jifty-commit] r3177 - jifty/trunk/lib/Jifty/Web/Form

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Apr 30 11:58:08 EDT 2007


Any reason not to lift this so that 'beforeclick' is at the same  
level as 'onclick'?

On Apr 30, 2007, at 11:55 AM, jifty-commit at lists.jifty.org wrote:

> Author: yves
> Date: Mon Apr 30 11:55:39 2007
> New Revision: 3177
>
> Modified:
>    jifty/trunk/lib/Jifty/Web/Form/Element.pm
>
> Log:
> add the ability to have some code before a javascript click :
>    onclick => [ { beforeclick => "<somecode>;" }, { args => ...
>
>
> 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 30 11:55:39 2007
> @@ -111,6 +111,10 @@
>  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 beforeclick => STRING
> +
> +String contains some Javascript code to be used before a click.
> +
>  =item confirm => STRING
>
>  Prompt the user with a Javascript confirm dialog with the given text
> @@ -234,6 +238,7 @@
>          my @fragments;
>          my %actions;    # Maps actions => disable?
>          my $confirm;
> +        my $beforeclick;
>
>          for my $hook (grep {ref $_ eq "HASH"} (@{$value})) {
>
> @@ -254,6 +259,11 @@
>                  $confirm = $hook->{confirm};
>              }
>
> +            # Some code usable before onclick
> +            if ($hook->{beforeclick}) {
> +                $beforeclick = $hook->{beforeclick};
> +            }
> +
>              # Placement
>              if (exists $hook->{append}) {
>                  @args{qw/mode path/} = ('Bottom', $hook->{append});
> @@ -315,6 +325,9 @@
>          if ($confirm) {
>              $string = Jifty->web->escape("if(!confirm(" .  
> Jifty::JSON::objToJson($confirm, {singlequote => 1}) . "))  
> { Event.stop(event); return false }") . $string;
>          }
> +        if ($beforeclick) {
> +           $string = Jifty->web->escape($beforeclick) . $string;
> +        }
>          $response .= qq| $trigger="$string"|;
>      }
>      return $response;
> _______________________________________________
> Jifty-commit mailing list
> Jifty-commit at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-commit
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.bestpractical.com/pipermail/jifty-commit/attachments/20070430/b4e054f2/PGP.pgp


More information about the Jifty-commit mailing list