[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:55:47 EDT 2007
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;
More information about the Jifty-commit
mailing list