Toolbox/popUpBox/Browser/Netscape.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 45 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
show
2.0
hide
2.0
CRAP 2.0
1 package JavaScript::Toolbox::popUpBox::Browser::Netscape;
2
3 require v5.6;
4
5 use strict;
6 use warnings;
7
8 our $VERSION = '0.01';
9 use base qw(JavaScript::Toolbox::popUpBox::Browser);
10
11
12 sub new {
13 my ($proto, %args) = @_;
14
15 my $class = ref($proto) || $proto;
16 my $self = {};
17
18 bless ($self, $class);
19 return $self;
20 }
21
22 sub show {
23 my $code = q{
24 // -- Netscape 4.x -- The JavaScript::Toolbox.
25 function showBox(event, content) {
26 var currentX, //mouse position on X axis
27 currentY, //mouse position on X axis
28 x, //layer target position on X axis
29 y, //layer target position on Y axis
30 docWidth, //width of current frame
31 docHeight, //height of current frame
32 layerWidth, //width of popup layer
33 layerHeight, //height of popup layer
34 popupElement; //points to the popup element
35
36 var name = 'popUpBox';
37
38 currentX = event.pageX,
39 currentY = event.pageY;
40 docHeight = document.height;
41 docWidth = document.width;
42
43 popupElement = document.layers[name];
44
45 layerWidth = popupElement.clip.width;
46 layerHeight = popupElement.clip.height;
47
48 // -- Calculate popup new position.
49 if ((currentX + layerWidth) > docWidth) {
50 x = (currentX - layerWidth);
51 } else {
52 x = currentX;
53 }
54
55 if ((currentY + layerHeight) >= docHeight) {
56 y = (currentY - layerHeight - 0);
57 } else {
58 y = currentY + 10;
59 }
60
61 // -- Set content.
62 popupElement.document.open();
63 popupElement.document.writeln(content);
64 popupElement.document.close();
65
66 // -- Set position and visibility.
67 popupElement.left = parseInt(x);
68 popupElement.top = parseInt(y);
69
70 popupElement.visibility = "show";
71 }
72 };
73
74 return $code;
75 }
76
77 sub hide {
78 my $code = q{
79 function hideBox() {
80 var name = 'popUpBox';
81
82 document.layers[name].visibility = "hide";
83 }
84 };
85
86 return $code;
87 }
88
89 sub javascript {
90 my ($self, %args) = @_;
91
92 my $show = $self->show();
93 my $hide = $self->hide();
94
95 my $code = qq{
96 <script language="JavaScript">
97 <!--
98 $show
99 $hide
100 //-->
101 </script>
102 };
103
104 return $code;
105 }
106
107 1;
108 __END__