line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
15
|
|
|
15
|
|
10989
|
use strict; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
561
|
|
2
|
15
|
|
|
15
|
|
80
|
use warnings; |
|
15
|
|
|
|
|
27
|
|
|
15
|
|
|
|
|
821
|
|
3
|
|
|
|
|
|
|
package HTML::Widget::Plugin::Image; |
4
|
|
|
|
|
|
|
# ABSTRACT: an image object |
5
|
|
|
|
|
|
|
$HTML::Widget::Plugin::Image::VERSION = '0.202'; |
6
|
15
|
|
|
15
|
|
76
|
use parent 'HTML::Widget::Plugin'; |
|
15
|
|
|
|
|
25
|
|
|
15
|
|
|
|
|
82
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod $widget_factory->image({ |
11
|
|
|
|
|
|
|
#pod src => 'http://example.com/example.jpg', |
12
|
|
|
|
|
|
|
#pod alt => 'An Example Image', |
13
|
|
|
|
|
|
|
#pod }); |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod This plugin provides a basic image widget. |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =cut |
20
|
|
|
|
|
|
|
|
21
|
15
|
|
|
15
|
|
827
|
use Carp (); |
|
15
|
|
|
|
|
26
|
|
|
15
|
|
|
|
|
294
|
|
22
|
15
|
|
|
15
|
|
74
|
use HTML::Element; |
|
15
|
|
|
|
|
23
|
|
|
15
|
|
|
|
|
100
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#pod =head1 METHODS |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =head2 C< provided_widgets > |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod This plugin provides the following widgets: image |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod =cut |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
16
|
1
|
55
|
sub provided_widgets { qw(image) } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#pod =head2 C< image > |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod This method returns a basic image element. |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod In addition to the generic L attributes, the following |
39
|
|
|
|
|
|
|
#pod are valid arguments: |
40
|
|
|
|
|
|
|
#pod |
41
|
|
|
|
|
|
|
#pod =over |
42
|
|
|
|
|
|
|
#pod |
43
|
|
|
|
|
|
|
#pod =item src |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod This is the source href for the image. "href" is a synonym for src. If no |
46
|
|
|
|
|
|
|
#pod href is supplied, an exception is thrown. |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod =item alt |
49
|
|
|
|
|
|
|
#pod |
50
|
|
|
|
|
|
|
#pod This is the alt text for the image. |
51
|
|
|
|
|
|
|
#pod |
52
|
|
|
|
|
|
|
#pod =back |
53
|
|
|
|
|
|
|
#pod |
54
|
|
|
|
|
|
|
#pod =cut |
55
|
|
|
|
|
|
|
|
56
|
16
|
|
|
16
|
|
138
|
sub _attribute_args { qw(src alt) } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub image { |
59
|
4
|
|
|
4
|
1
|
5
|
my ($self, $factory, $arg) = @_; |
60
|
|
|
|
|
|
|
|
61
|
4
|
100
|
100
|
|
|
25
|
if ($arg->{attr}{src} and $arg->{href}) { |
62
|
1
|
|
|
|
|
612
|
Carp::croak "don't provide both href and src for image widget"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
3
|
100
|
|
|
|
12
|
$arg->{attr}{src} = $arg->{href} if not defined $arg->{attr}{src}; |
66
|
|
|
|
|
|
|
|
67
|
3
|
100
|
|
|
|
569
|
Carp::croak "can't create an image without a src" |
68
|
|
|
|
|
|
|
unless defined $arg->{attr}{src}; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
15
|
my $widget = HTML::Element->new('img'); |
71
|
2
|
|
|
|
|
176
|
$widget->attr($_ => $arg->{attr}{$_}) for keys %{ $arg->{attr} }; |
|
2
|
|
|
|
|
88
|
|
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
63
|
return $widget->as_XML; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |