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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Jan 11 14:50:34 EST 2007


Author: trs
Date: Thu Jan 11 14:50:33 2007
New Revision: 2492

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

Log:
 r18814 at zot:  tom | 2007-01-11 14:50:11 -0500
 Add a key_binding_label attribute so that key binding labels can be set independently of the normal label


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	Thu Jan 11 14:50:33 2007
@@ -144,8 +144,8 @@
 
 =cut
 
-sub accessors { shift->handlers, qw(class key_binding id label tooltip) }
-__PACKAGE__->mk_accessors(qw(_onclick class key_binding id label tooltip));
+sub accessors { shift->handlers, qw(class key_binding key_binding_label id label tooltip) }
+__PACKAGE__->mk_accessors(qw(_onclick class key_binding key_binding_label id label tooltip));
 
 =head2 new PARAMHASH OVERRIDE
 
@@ -336,7 +336,12 @@
 
 =head2 key_binding
 
-Sets the key binding associated with this elements
+Sets the key binding associated with this element
+
+=head2 key_binding_label
+
+Sets the key binding label associated with this element (if none is specified,
+the normal label is used instead)
 
 =head2 id
 
@@ -345,7 +350,7 @@
 =head2 label
 
 Sets the label of the element.  This will be used for the key binding
-legend, at very least.
+legend if key_binding_label is not set.
 
 =head2 key_binding_javascript
 
@@ -355,14 +360,17 @@
 =cut
 
 sub key_binding_javascript {
-    my $self = shift;
-    my $key  = $self->key_binding;
+    my $self  = shift;
+    my $key   = $self->key_binding;
+    my $label = defined $self->key_binding_label
+                    ? $self->key_binding_label
+                    : $self->label;
     if ($key) {
         return "Jifty.KeyBindings.add("
                 . Jifty::JSON::objToJson( uc($key), { singlequote => 1 } ).","
                 . "'click', "
                 . Jifty::JSON::objToJson( $self->id, { singlequote => 1 } ).","
-                . Jifty::JSON::objToJson( $self->label, { singlequote => 1 } )
+                . Jifty::JSON::objToJson( $label, { singlequote => 1 } )
                 . ");";
     }
 }

Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm	Thu Jan 11 14:50:33 2007
@@ -129,6 +129,11 @@
 
 Sets this form field's "submit" key binding to VALUE. 
 
+=head2 key_binding_label VALUE
+
+Sets this form field's key binding label to VALUE.  If none is specified
+the normal label is used.
+
 =head2 default_value [VALUE]
 
 Gets or sets the default value for the form.


More information about the Jifty-commit mailing list