From 341fbe8b28d2b9cb98934aed0336a99923cfefc0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 13 Mar 2013 15:29:50 +0100 Subject: [PATCH] =?utf8?q?L.button=5Ftag:=20Support=20f=C3=BCr=20'confirm'?= =?utf8?q?=20&=20Doku?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Template/Plugin/L.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index 0bdef40f9..b6021f5c2 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -180,6 +180,8 @@ sub button_tag { $attributes{id} ||= $self->name_to_id($attributes{name}) if $attributes{name}; $attributes{type} ||= 'button'; + $onclick = 'if (!confirm("'. _J(delete($attributes{confirm})) .'")) return false; ' . $onclick if $attributes{confirm}; + return $self->html_tag('input', undef, %attributes, value => $value, onclick => $onclick); } @@ -572,9 +574,20 @@ tag's C defaults to C. If C<$attributes{confirm}> is set then a JavaScript popup dialog will be added via the C handler asking the question given with -C<$attributes{confirm}>. If request is only submitted if the user +C<$attributes{confirm}>. The request is only submitted if the user clicks the dialog's ok/yes button. +=item C + +Creates a HTML 'input type="button"' tag with an onclick handler +C<$onclick> and a value of C<$text>. The button does not have a name +nor an ID by default. + +If C<$attributes{confirm}> is set then a JavaScript popup dialog will +be prepended to the C<$onclick> handler asking the question given with +C<$attributes{confirm}>. The request is only submitted if the user +clicks the dialog's "ok/yes" button. + =item C Creates a HTML 'textarea' tag named C<$name> with the content -- 2.20.1