line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DragAndDrop; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5661
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
143
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
12
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
13
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This allows declaration use HTML::DragAndDrop ':all'; |
16
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17
|
|
|
|
|
|
|
# will save memory. |
18
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
) ] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @EXPORT = qw( |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
29
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
87
|
|
30
|
|
|
|
|
|
|
our $module = "DragDrop.pm"; |
31
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
32
|
1
|
|
|
1
|
|
384889
|
use CGI; |
|
1
|
|
|
|
|
19143
|
|
|
1
|
|
|
|
|
8
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Preloaded methods go here. |
36
|
|
|
|
|
|
|
sub new { |
37
|
0
|
|
|
0
|
0
|
|
my ($class, %arg) = @_; |
38
|
0
|
|
|
|
|
|
my $self = {}; |
39
|
0
|
|
0
|
|
|
|
$self->{javascript_dir} = $arg{javascript_dir} || '/'; |
40
|
0
|
0
|
|
|
|
|
$self->{javascript_dir} .= "/" unless ($self->{javascript_dir} =~ m:/$:); |
41
|
0
|
|
|
|
|
|
$self->{tooltip} = $arg{tooltip}; |
42
|
0
|
|
|
|
|
|
$self->{dragables} = {}; |
43
|
0
|
|
|
|
|
|
bless($self, $class); |
44
|
0
|
|
|
|
|
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_dragable($%) { |
48
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
49
|
0
|
|
|
|
|
|
$self->{dragables}->{$args{name}} = \%args; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub output_html($) { |
53
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
# The order in which we parse the objects, is not the order in which |
55
|
|
|
|
|
|
|
# we need to output them |
56
|
0
|
|
|
|
|
|
my $output = ''; |
57
|
0
|
|
|
|
|
|
my $script_include_output; |
58
|
|
|
|
|
|
|
my $dragables_output; |
59
|
0
|
|
|
|
|
|
my $javascript = $self->{javascript_dir} . 'wz_dragdrop.js'; |
60
|
0
|
|
|
|
|
|
$script_include_output .= |
61
|
|
|
|
|
|
|
qq(\n\n); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
foreach my $d (keys %{$self->{dragables}}) { |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $name = $self->{dragables}->{$d}->{name}; |
66
|
0
|
|
|
|
|
|
my $width = $self->{dragables}->{$d}->{width}; |
67
|
0
|
|
|
|
|
|
my $height = $self->{dragables}->{$d}->{height}; |
68
|
0
|
|
0
|
|
|
|
my $class = $self->{dragables}->{$d}->{class} || 'dragable'; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $copy = $self->{dragables}->{$d}->{copy}; |
71
|
0
|
0
|
|
|
|
|
$copy = 0 if (!$copy); |
72
|
0
|
|
|
|
|
|
for (0 .. $copy) { |
73
|
0
|
|
|
|
|
|
my $left = $self->{dragables}->{$d}->{left}; |
74
|
0
|
|
|
|
|
|
my $top = $self->{dragables}->{$d}->{top}; |
75
|
0
|
|
|
|
|
|
my $use_name; |
76
|
0
|
0
|
|
|
|
|
if ($_ == 0) { |
77
|
0
|
0
|
|
|
|
|
$use_name = $name if ($_ == 0); |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
|
$use_name = $name . 'div' . $_; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
my $tooltip; |
82
|
0
|
|
|
|
|
|
my $tooltip_output = ''; |
83
|
0
|
0
|
|
|
|
|
if ($self->{tooltip}) { |
84
|
0
|
|
|
|
|
|
$tooltip = $self->{dragables}->{$d}->{tooltip}; |
85
|
0
|
0
|
|
|
|
|
if ($tooltip) { |
86
|
0
|
|
|
|
|
|
$tooltip =~ s/'/\\'/g; |
87
|
0
|
|
|
|
|
|
$tooltip_output = qq(onmouseover="return escape('$tooltip');"); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
0
|
0
|
|
|
|
|
if ($self->{dragables}->{$d}->{src}) { |
|
|
0
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Image |
92
|
0
|
|
|
|
|
|
my $src = $self->{dragables}->{$d}->{src}; |
93
|
0
|
|
|
|
|
|
$dragables_output .= qq(\n); |
94
|
|
|
|
|
|
|
} elsif ($self->{dragables}->{$d}->{content}) { |
95
|
|
|
|
|
|
|
# A div? |
96
|
0
|
|
|
|
|
|
my $content = $self->{dragables}->{$d}->{content}; |
97
|
0
|
|
|
|
|
|
$dragables_output .= qq( $content \n); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$output .= $script_include_output; |
103
|
0
|
|
|
|
|
|
$output .= $dragables_output; |
104
|
0
|
|
|
|
|
|
return $output; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub output_script($) { |
108
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
109
|
0
|
|
|
|
|
|
my $dragables; |
110
|
0
|
|
|
|
|
|
my $output = ''; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
foreach my $d (keys %{$self->{dragables}}) { |
|
0
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $name = $self->{dragables}->{$d}->{name}; |
114
|
0
|
|
|
|
|
|
my $features = $self->{dragables}->{$d}->{features}; |
115
|
0
|
0
|
0
|
|
|
|
$features = '+' . $features unless($features =~ m/^\+/ || $features =~ m/^\s*$/); |
116
|
0
|
|
|
|
|
|
my $src = $self->{dragables}->{$d}->{src}; |
117
|
0
|
|
|
|
|
|
my $copy = $self->{dragables}->{$d}->{copy}; |
118
|
0
|
|
|
|
|
|
my $to_add = qq("$name"); |
119
|
0
|
0
|
0
|
|
|
|
if ($src && $copy) { |
120
|
0
|
|
|
|
|
|
$to_add .= "+COPY+$copy"; |
121
|
|
|
|
|
|
|
} |
122
|
0
|
0
|
|
|
|
|
$to_add .= $features if ($features); |
123
|
0
|
|
|
|
|
|
$dragables .= $to_add . ','; |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
$dragables =~ s/,$//; |
126
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
if ($dragables) { |
128
|
0
|
|
|
|
|
|
$output .= qq(\n); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
0
|
0
|
|
|
|
|
if ($self->{tooltip}) { |
134
|
0
|
|
|
|
|
|
my $javascript = $self->{javascript_dir} . 'wz_tooltip.js'; |
135
|
0
|
|
|
|
|
|
$output .= qq(\n); |
136
|
|
|
|
|
|
|
} |
137
|
0
|
|
|
|
|
|
return $output; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
1; |
141
|
|
|
|
|
|
|
__END__ |