[Jifty-commit] r4627 - jifty/trunk/lib/Jifty/Web/Form
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Dec 6 00:36:09 EST 2007
Author: clkao
Date: Thu Dec 6 00:36:04 2007
New Revision: 4627
Modified:
jifty/trunk/lib/Jifty/Web/Form/Element.pm
Log:
refactor handlers Jifty::Web::Form::Element to use our
mk_normalising_accessor.
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 Dec 6 00:36:04 2007
@@ -201,184 +201,94 @@
return $self;
}
+__PACKAGE__->mk_normalising_accessor($_) for __PACKAGE__->handlers;
+
+sub mk_normalising_accessor {
+ my ($class, $accessor) = @_;
+ my $internal_method = "_$accessor";
+ no strict 'refs';
+ *{$accessor} = sub {
+ my $self = shift;
+ $self->$internal_method($self->_handler_setup($internal_method, @_));
+ };
+}
-
=head2 onclick
The onclick event occurs when the pointing device button is clicked
over an element. This attribute may be used with most elements.
-=cut
-
-sub onclick {
- my $self = shift;
- $self->_onclick($self->_handler_setup('_onclick', @_));
-}
-
=head2 onchange
The onchange event occurs when a control loses the input focus
and its value has been modified since gaining focus. This handler
can be used with all form elements.
-=cut
-
-sub onchange {
- my $self = shift;
- $self->_onchange($self->_handler_setup('_onchange', @_));
-}
-
-
-
=head2 ondblclick
The ondblclick event occurs when the pointing device button is
double clicked over an element. This handler
can be used with all form elements.
-=cut
-
-sub ondblclick {
- my $self = shift;
- $self->_ondblclick($self->_handler_setup('_ondblclick', @_));
-}
-
=head2 onmousedown
The onmousedown event occurs when the pointing device button is
pressed over an element. This handler
can be used with all form elements.
-=cut
-
-sub onmousedown {
- my $self = shift;
- $self->_onmousedown($self->_handler_setup('_onmousedown', @_));
-}
-
=head2 onmouseup
The onmouseup event occurs when the pointing device button is released
over an element. This handler can be used with all form elements.
-=cut
-
-sub onmouseup {
- my $self = shift;
- $self->_onmouseup($self->_handler_setup('_onmouseup', @_));
-}
-
=head2 onmouseover
The onmouseover event occurs when the pointing device is moved onto an
element. This handler can be used with all form elements.
-=cut
-
-sub onmouseover {
- my $self = shift;
- $self->_onmouseover($self->_handler_setup('_onmouseover', @_));
-}
-
=head2 onmousemove
The onmousemove event occurs when the pointing device is moved while it
is over an element. This handler can be used with all form elements.
-=cut
-
-sub onmousemove {
- my $self = shift;
- $self->_onmousemove($self->_handler_setup('_onmousemove', @_));
-}
-
=head2 onmouseout
The onmouseout event occurs when the pointing device is moved away from
an element. This handler can be used with all form elements.
-=cut
-
-sub onmouseout {
- my $self = shift;
- $self->_onmouseout($self->_handler_setup('_onmouseout', @_));
-}
-
=head2 onfocus
The onfocus event occurs when an element receives focus either by the
pointing device or by tabbing navigation. This handler
can be used with all form elements.
-=cut
-
-sub onfocus {
- my $self = shift;
- $self->_onfocus($self->_handler_setup('_onfocus', @_));
-}
-
=head2 onblur
The onblur event occurs when an element loses focus either by the pointing
device or by tabbing navigation. This handler can be used with all
form elements.
-=cut
-
-sub onblur {
- my $self = shift;
- $self->_onblur($self->_handler_setup('_onblur', @_));
-}
-
=head2 onkeypress
The onkeypress event occurs when a key is pressed and released over an
element. This handler can be used with all form elements.
-=cut
-
-sub onkeypress {
- my $self = shift;
- $self->_onkeypress($self->_handler_setup('_onkeypress', @_));
-}
-
=head2 onkeydown
The onkeydown event occurs when a key is pressed down over an element.
This handler can be used with all form elements.
-=cut
-
-sub onkeydown {
- my $self = shift;
- $self->_onkeydown($self->_handler_setup('_onkeydown', @_));
-}
-
=head2 onkeyup
The onkeyup event occurs when a key is released over an element.
This handler can be used with all form elements.
=cut
-sub onkeyup {
- my $self = shift;
- $self->_onkeyup($self->_handler_setup('_onkeyup', @_));
-}
-
=head2 onselect
The onselect event occurs when a user selects some text in a text field.
This attribute may be used with the text and textarea fields.
-=cut
-
-sub onselect {
- my $self = shift;
- $self->_onselect($self->_handler_setup('_onselect', @_));
-}
-
-
-
=head2 _handler_setup
This method is used by all handlers to normalize all arguments.
More information about the Jifty-commit
mailing list