| 1 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | package HTML::Widget::Plugin::Textarea; | ||||||||||
| 4 | # ABSTRACT: a widget for a large text entry box | ||||||||||
| 5 | 15 | $HTML::Widget::Plugin::Textarea::VERSION = '0.204'; | |||||||||
| 6 | 15 | ▶ | use parent 'HTML::Widget::Plugin'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | #pod =head1 SYNOPSIS | ||||||||||
| 9 | #pod | ||||||||||
| 10 | #pod $widget_factory->textarea({ | ||||||||||
| 11 | #pod id => 'elem-id', # also used as control name, if no name given | ||||||||||
| 12 | #pod value => $big_hunk_of_text, | ||||||||||
| 13 | #pod }); | ||||||||||
| 14 | #pod | ||||||||||
| 15 | #pod =head1 DESCRIPTION | ||||||||||
| 16 | #pod | ||||||||||
| 17 | #pod This plugin provides a text-entry area widget. | ||||||||||
| 18 | #pod | ||||||||||
| 19 | #pod The C<default_classes> attribute may be used to add a default class to every | ||||||||||
| 20 | #pod produced input. This class cannot be overridden. | ||||||||||
| 21 | #pod | ||||||||||
| 22 | #pod my $plugin = HTML::Widget::Factory::Input->new({ | ||||||||||
| 23 | #pod default_classes => [ qw(foo bar) ], | ||||||||||
| 24 | #pod }); | ||||||||||
| 25 | #pod | ||||||||||
| 26 | #pod =head1 METHODS | ||||||||||
| 27 | #pod | ||||||||||
| 28 | #pod =head2 C< provided_widgets > | ||||||||||
| 29 | #pod | ||||||||||
| 30 | #pod This plugin provides the following widgets: textarea | ||||||||||
| 31 | #pod | ||||||||||
| 32 | #pod =cut | ||||||||||
| 33 | |||||||||||
| 34 | 17 | ▶ | sub provided_widgets { qw(textarea) } | ||||||||
|
Subroutine
provided_widgets: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 35 | |||||||||||
| 36 | #pod =head2 C< textarea > | ||||||||||
| 37 | #pod | ||||||||||
| 38 | #pod This method returns a text-entry area widget. | ||||||||||
| 39 | #pod | ||||||||||
| 40 | #pod In addition to the generic L<HTML::Widget::Plugin> attributes, the following | ||||||||||
| 41 | #pod are valid arguments: | ||||||||||
| 42 | #pod | ||||||||||
| 43 | #pod =over | ||||||||||
| 44 | #pod | ||||||||||
| 45 | #pod =item disabled | ||||||||||
| 46 | #pod | ||||||||||
| 47 | #pod If true, this option indicates that the widget can't be changed by the user. | ||||||||||
| 48 | #pod | ||||||||||
| 49 | #pod =item value | ||||||||||
| 50 | #pod | ||||||||||
| 51 | #pod If this argument is given and defined, the widget will be initially populated | ||||||||||
| 52 | #pod by its value. | ||||||||||
| 53 | #pod | ||||||||||
| 54 | #pod =back | ||||||||||
| 55 | #pod | ||||||||||
| 56 | #pod =cut | ||||||||||
| 57 | |||||||||||
| 58 | 15 | ▶ | use HTML::Element; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 59 | |||||||||||
| 60 | 17 | ▶ | sub _attribute_args { qw(disabled id) } | ||||||||
|
Subroutine
_attribute_args: called CC=1 SCAR=0.0
| |||||||||||
| 61 | 34 | ▶ | sub _boolean_args { qw(disabled) } | ||||||||
|
Subroutine
_boolean_args: called CC=1 SCAR=0.0
| |||||||||||
| 62 | |||||||||||
| 63 | 5 | ▶ | sub textarea { | ||||||||
|
Subroutine
textarea: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 64 | 5 | my ($self, $factory, $arg) = @_; | |||||||||
| 65 | |||||||||||
| 66 | 5 | ▶ | $arg->{attr}{name} = $arg->{attr}{id} if not defined $arg->{attr}{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | 5 | my $widget = HTML::Element->new('textarea'); | |||||||||
| 69 | |||||||||||
| 70 | $widget->attr($_ => $arg->{attr}{$_}) | ||||||||||
| 71 | 5 | for grep {; defined $arg->{attr}{$_} } keys %{ $arg->{attr} }; | |||||||||
| 72 | |||||||||||
| 73 | 5 | ▶ | $widget->push_content($arg->{value}) if defined $arg->{value}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | |||||||||||
| 75 | 5 | return $widget->as_XML; | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 5 | ▶ | sub rewrite_arg { | ||||||||
|
Subroutine
rewrite_arg: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 79 | 5 | my ($self, $arg, @rest) = @_; | |||||||||
| 80 | |||||||||||
| 81 | 5 | $arg = $self->SUPER::rewrite_arg($arg, @rest); | |||||||||
| 82 | |||||||||||
| 83 | 5 | ▶ | if ($self->{default_classes}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 2 | my $class = join q{ }, @{ $self->{default_classes} }; | |||||||||
| 85 | $arg->{attr}{class} = defined $arg->{attr}{class} | ||||||||||
| 86 | 2 | ▶ | ? "$class $arg->{attr}{class}" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | : $class; | ||||||||||
| 88 | } | ||||||||||
| 89 | |||||||||||
| 90 | 5 | return $arg; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 15 | 1; | |||||||||
| 94 | |||||||||||
| 95 | __END__ | ||||||||||