line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SparkX::Form::Field::Image; |
2
|
|
|
|
|
|
|
our $VERSION = '0.2102'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: An image field for SparkX::Form |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
543
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
4745
|
use HTML::Tiny; |
|
1
|
|
|
|
|
1857
|
|
|
1
|
|
|
|
|
157
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Spark::Form::Field'; |
11
|
|
|
|
|
|
|
with 'Spark::Form::Field::Role::Printable::HTML', |
12
|
|
|
|
|
|
|
'Spark::Form::Field::Role::Printable::XHTML'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has '+value' => ( |
15
|
|
|
|
|
|
|
isa => 'Str', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## no critic (ProhibitMagicNumbers) |
19
|
|
|
|
|
|
|
has 'names' => ( |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
(Moose->VERSION >= 0.84) ? (is => 'bare') : (), |
22
|
|
|
|
|
|
|
default => sub { |
23
|
|
|
|
|
|
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return [$self->name . '.x', $self->name . '.y']; |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
## use critic |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub to_html { |
31
|
0
|
|
|
0
|
1
|
0
|
return shift->_render(HTML::Tiny->new(mode => 'html')); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub to_xhtml { |
35
|
1
|
|
|
1
|
1
|
12
|
return shift->_render(HTML::Tiny->new(mode => 'xml')); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _render { |
39
|
1
|
|
|
1
|
|
47
|
my ($self, $html) = @_; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
31
|
return $html->input({type => 'image', name => $self->name}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
SparkX::Form::Field::Image - An image field for SparkX::Form |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 VERSION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
version 0.2102 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Note that this does not support server-side image map functionality but will be treated as a submit. Patches welcome that don't break this (99% of the time desired) behaviour. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 METHODS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 to_html() => Str |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Renders the field to HTML |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 to_xhtml() => Str |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Renders the field to XHTML |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 validate() => Bool |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Validates the field. Before composition with validators, always returns 1. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 SEE ALSO |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over 4 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item L<SparkX::Form> - The forms module this is to be used with |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item L<SparkX::Form::BasicFields> - A collection of fields for use with C<Spark::Form> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=back |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
James Laver L<http://jameslaver.com> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This software is copyright (c) 2009 by James Laver C<< <sprintf qw(%s@%s.%s cpan jameslaver com)> >>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
98
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |
105
|
|
|
|
|
|
|
|