| 1 | 4 | ▶ | use strictures 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Mojito::Template::Role::Javascript; | ||||||||||
| 3 | 4 | $Mojito::Template::Role::Javascript::VERSION = '0.25'; | |||||||||
| 4 | 4 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use Data::Dumper::Concise; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 Name | ||||||||||
| 9 | |||||||||||
| 10 | Mojito::Template::Role::Javascript - a class for Javascript resources | ||||||||||
| 11 | |||||||||||
| 12 | =cut | ||||||||||
| 13 | |||||||||||
| 14 | 4 | with('Mojito::Role::Config'); | |||||||||
| 15 | |||||||||||
| 16 | 4 | has javascripts => ( | |||||||||
| 17 | is => 'ro', | ||||||||||
| 18 | isa => ArrayRef, | ||||||||||
| 19 | lazy => 1, | ||||||||||
| 20 | builder => '_build_javascripts', | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub _build_javascripts { | ||||||||
|
Subroutine
_build_javascripts: not called CC=1 SCAR=6.9
| |||||||||||
| 24 | [ | ||||||||||
| 25 | # { uri => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'}, | ||||||||||
| 26 | # { uri => 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js'}, | ||||||||||
| 27 | 0 | 'jquery/jquery.min.js', | |||||||||
| 28 | 'javascript/render_page.js', | ||||||||||
| 29 | 'javascript/style.js', | ||||||||||
| 30 | 'javascript/publish.js', | ||||||||||
| 31 | 'syntax_highlight/prettify.js', | ||||||||||
| 32 | 'jquery/jquery-ui.custom.min.js', | ||||||||||
| 33 | 'jquery/jquery.cookie.js', | ||||||||||
| 34 | # 'SHJS/sh_main.min.js', | ||||||||||
| 35 | # 'SHJS/sh_perl.min.js', | ||||||||||
| 36 | # 'SHJS/sh_javascript.min.js', | ||||||||||
| 37 | # 'SHJS/sh_html.min.js', | ||||||||||
| 38 | # 'SHJS/sh_css.min.js', | ||||||||||
| 39 | # 'SHJS/sh_sql.min.js', | ||||||||||
| 40 | # 'SHJS/sh_sh.min.js', | ||||||||||
| 41 | # 'SHJS/sh_diff.min.js', | ||||||||||
| 42 | # 'SHJS/sh_haskell.min.js', | ||||||||||
| 43 | #-concatenation fo the SHJS/sh_$language.js files | ||||||||||
| 44 | 'SHJS/sh_langs.min.js', | ||||||||||
| 45 | ]; | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 4 | has javascript_html => ( | |||||||||
| 49 | is => 'ro', | ||||||||||
| 50 | isa => ArrayRef, | ||||||||||
| 51 | lazy => 1, | ||||||||||
| 52 | builder => '_build_javascript_html', | ||||||||||
| 53 | ); | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub _build_javascript_html { | ||||||||
|
Subroutine
_build_javascript_html: not called CC=3 SCAR=24.8
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | 0 | my $static_url = $self->config->{static_url}; | |||||||||
| 58 | 0 | my @javascripts; # = map { "<script src=${static_url}$_></script>" } @{$self->javascripts}; | |||||||||
| 59 | # Local scripts comes as scalars, while remote scripts are a HashRef | ||||||||||
| 60 | 0 | foreach my $script (@{$self->javascripts}) { | |||||||||
| 61 | 0 | ▶ | if (ref($script) eq 'HASH') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | push @javascripts, "<script src=$script->{uri}></script>"; | |||||||||
| 63 | } | ||||||||||
| 64 | else { | ||||||||||
| 65 | 0 | push @javascripts, "<script src=${static_url}$script></script>"; | |||||||||
| 66 | } | ||||||||||
| 67 | } | ||||||||||
| 68 | 0 | return [@javascripts]; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 4 | 1 | |||||||||