| 1 | package JavaScript::Framework::jQuery::Plugin::Superfish; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | with 'JavaScript::Framework::jQuery::Role::Plugin'; | ||||||||||
| 8 | 6 | ▶ | use MooseX::Types::Moose qw( Bool Str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | our $VERSION = '0.05'; | ||||||||||
| 11 | |||||||||||
| 12 | has 'options' => ( | ||||||||||
| 13 | is => 'ro', | ||||||||||
| 14 | isa => Str, | ||||||||||
| 15 | coerce => 1, | ||||||||||
| 16 | ); | ||||||||||
| 17 | |||||||||||
| 18 | has 'use_supersubs' => ( | ||||||||||
| 19 | is => 'ro', | ||||||||||
| 20 | isa => Bool, | ||||||||||
| 21 | default => sub {0}, | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | has 'supersubs_options' => ( | ||||||||||
| 25 | is => 'ro', | ||||||||||
| 26 | isa => Str, | ||||||||||
| 27 | coerce => 1, | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | 6 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | =head1 NAME | ||||||||||
| 33 | |||||||||||
| 34 | JavaScript::Framework::jQuery::Plugin::Superfish - Support for jQuery Superfish plugin | ||||||||||
| 35 | |||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||
| 37 | |||||||||||
| 38 | my $plugin = JavaScript::Framework::jQuery::Plugin::Superfish->new( | ||||||||||
| 39 | target_selector => 'ul.sf-menu', | ||||||||||
| 40 | options => | ||||||||||
| 41 | 'delay : 500, | ||||||||||
| 42 | animation : { opacity : "show" }, | ||||||||||
| 43 | dropShadows : true', | ||||||||||
| 44 | use_supersubs => 1, | ||||||||||
| 45 | supersubs_options => | ||||||||||
| 46 | 'minWidth : 12, | ||||||||||
| 47 | maxWidth : 27, | ||||||||||
| 48 | extraWidth : 1' | ||||||||||
| 49 | ); | ||||||||||
| 50 | |||||||||||
| 51 | print $plugin->cons_statement; | ||||||||||
| 52 | |||||||||||
| 53 | # $("ul.sf-menu").supersubs({ | ||||||||||
| 54 | # minWidth: 12, | ||||||||||
| 55 | # maxWidth: 27, | ||||||||||
| 56 | # extraWidth: 1 | ||||||||||
| 57 | # }).superfish({ | ||||||||||
| 58 | # delay: 500, | ||||||||||
| 59 | # animation: { opacity : "show" }, | ||||||||||
| 60 | # dropShadows: true, | ||||||||||
| 61 | # }); | ||||||||||
| 62 | |||||||||||
| 63 | =head1 DESCRIPTION | ||||||||||
| 64 | |||||||||||
| 65 | This module implements the interface required to generate a jQuery constructor for | ||||||||||
| 66 | the jQuery Superfish plugin. | ||||||||||
| 67 | |||||||||||
| 68 | L<http://users.tpg.com.au/j_birch/plugins/superfish/> | ||||||||||
| 69 | |||||||||||
| 70 | =head1 CONSTRUCTOR PARAMETERS | ||||||||||
| 71 | |||||||||||
| 72 | The C<new> constructor, provided automatically by Moose (in case you're looking for it and | ||||||||||
| 73 | can't find it) is called from &JavaScript::Framework::jQuery::construct_plugin. The | ||||||||||
| 74 | arguments passed to this subroutine are validated by this module. | ||||||||||
| 75 | |||||||||||
| 76 | =cut | ||||||||||
| 77 | |||||||||||
| 78 | =head2 cons_statement( ) | ||||||||||
| 79 | |||||||||||
| 80 | Return the text of the JavaScript statement that invokes the Superfish constructor. | ||||||||||
| 81 | |||||||||||
| 82 | =cut | ||||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | sub cons_statement { | ||||||||
|
Subroutine
cons_statement: not called CC=4 SCAR=30.0
| |||||||||||
| 85 | 0 | my ( $self ) = @_; | |||||||||
| 86 | |||||||||||
| 87 | 0 | my @arg = $self->target_selector; | |||||||||
| 88 | |||||||||||
| 89 | 0 | my $supersubs_options; | |||||||||
| 90 | 0 | ▶ | if ($self->use_supersubs) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | 0 | ▶ | if ($supersubs_options = $self->supersubs_options) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | $supersubs_options = join "\n" => '{', $supersubs_options, '}'; | |||||||||
| 93 | 0 | push @arg, [ 'supersubs', [ $supersubs_options ] ]; | |||||||||
| 94 | } | ||||||||||
| 95 | else { | ||||||||||
| 96 | 0 | push @arg, [ 'supersubs', [ ] ]; | |||||||||
| 97 | } | ||||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 0 | my $options; | |||||||||
| 101 | 0 | ▶ | if ($options = $self->options) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 0 | $options = join "\n" => '{', $options, '}'; | |||||||||
| 103 | 0 | push @arg, [ 'superfish', [ $options ] ]; | |||||||||
| 104 | } | ||||||||||
| 105 | else { | ||||||||||
| 106 | 0 | push @arg, [ 'superfish', [ ] ]; | |||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 0 | return $self->mk_jQuery_method_call(@arg); | |||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 1; | ||||||||||
| 113 | |||||||||||
| 114 | __END__ | ||||||||||