| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Iconify; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
59705
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
|
2
|
|
|
|
|
160802
|
|
|
|
2
|
|
|
|
|
15
|
|
|
4
|
2
|
|
|
2
|
|
1550
|
use Mojo::DOM::HTML; |
|
|
2
|
|
|
|
|
2522
|
|
|
|
2
|
|
|
|
|
87
|
|
|
5
|
2
|
|
|
2
|
|
383
|
use Mojo::ByteStream; |
|
|
2
|
|
|
|
|
3022
|
|
|
|
2
|
|
|
|
|
952
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
1
|
38
|
my ( $self, $app, $config ) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$app->helper( |
|
14
|
|
|
|
|
|
|
icon => sub { |
|
15
|
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
50714
|
my ( $self, $icon, %params ) = @_; |
|
17
|
3
|
50
|
|
|
|
16
|
return unless $icon; |
|
18
|
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
16
|
my %iconify_params = ( |
|
20
|
|
|
|
|
|
|
'class' => 'iconify', |
|
21
|
|
|
|
|
|
|
'data-icon' => $icon, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
12
|
foreach my $param ( keys %params ) { |
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
6
|
my $value = $params{$param}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
2
|
100
|
|
|
|
6
|
if ( $param eq 'size' ) { |
|
29
|
1
|
|
|
|
|
3
|
$iconify_params{'data-width'} = $value; |
|
30
|
1
|
|
|
|
|
3
|
$iconify_params{'data-height'} = $value; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
2
|
50
|
|
|
|
6
|
if ( $param eq 'inline' ) { |
|
34
|
0
|
0
|
|
|
|
0
|
$iconify_params{'data-inline'} = ( $value == 0 ) ? 'false' : 'true'; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
2
|
50
|
|
|
|
7
|
if ( $param eq 'block' ) { |
|
38
|
0
|
0
|
|
|
|
0
|
$iconify_params{'data-inline'} = ( $value == 0 ) ? 'true' : 'false'; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
50
|
33
|
|
|
22
|
if ( $param eq 'width' || $param eq 'height' || $param eq 'flip' || $param eq 'align' ) { |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
$iconify_params{"data-$param"} = $value; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
50
|
|
|
|
7
|
$iconify_params{'data-flip'} .= 'horizontal ' if ( $param eq 'flip_horizontal' ); |
|
46
|
2
|
50
|
|
|
|
5
|
$iconify_params{'data-flip'} .= 'vertical ' if ( $param eq 'flip_vertical' ); |
|
47
|
2
|
50
|
|
|
|
7
|
$iconify_params{'data-rotate'} = $value . 'deg' if ( $param eq 'rotate' ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Core HTML attributes |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
7
|
if ( $param eq 'class' ) { |
|
52
|
0
|
|
|
|
|
0
|
$iconify_params{'class'} .= " $value"; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
2
|
50
|
66
|
|
|
10
|
if ( $param eq 'id' || $param eq 'title' || $param eq 'style' ) { |
|
|
|
|
66
|
|
|
|
|
|
56
|
1
|
|
|
|
|
3
|
$iconify_params{$param} = $value; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
3
|
50
|
|
|
|
10
|
if ( defined $iconify_params{'data-flip'} ) { |
|
62
|
0
|
|
|
|
|
0
|
$iconify_params{'data-flip'} =~ s/\s$//; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
16
|
return _tag( 'span', %iconify_params ); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
|
68
|
1
|
|
|
|
|
9
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$app->helper( |
|
71
|
|
|
|
|
|
|
iconify_js => sub { |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
|
0
|
my ( $self, $url ) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
0
|
my $iconify_version = '1.0.3'; |
|
76
|
0
|
|
0
|
|
|
0
|
my $iconify_js_url = $url || "https://code.iconify.design/1/$iconify_version/iconify.min.js"; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
return _tag( 'script', 'src' => $iconify_js_url ); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
|
81
|
1
|
|
|
|
|
125
|
); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
3
|
|
|
3
|
|
18
|
sub _tag { Mojo::ByteStream->new( Mojo::DOM::HTML::tag_to_html(@_) ) } |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |