| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CGI::Test::Form::Widget::Menu::Popup; |
|
2
|
14
|
|
|
14
|
|
49
|
use strict; |
|
|
14
|
|
|
|
|
24
|
|
|
|
14
|
|
|
|
|
431
|
|
|
3
|
14
|
|
|
14
|
|
52
|
use warnings; |
|
|
14
|
|
|
|
|
18
|
|
|
|
14
|
|
|
|
|
383
|
|
|
4
|
|
|
|
|
|
|
################################################################## |
|
5
|
|
|
|
|
|
|
# $Id: Popup.pm 411 2011-09-26 11:19:30Z nohuhu@nohuhu.org $ |
|
6
|
|
|
|
|
|
|
# $Name: cgi-test_0-104_t1 $ |
|
7
|
|
|
|
|
|
|
################################################################## |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# Copyright (c) 2001, Raphael Manfredi |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# You may redistribute only under the terms of the Artistic License, |
|
12
|
|
|
|
|
|
|
# as specified in the README file that comes with the distribution. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
|
|
15
|
14
|
|
|
14
|
|
49
|
use Carp; |
|
|
14
|
|
|
|
|
23
|
|
|
|
14
|
|
|
|
|
735
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# This class models a FORM popup menu. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
|
|
21
|
14
|
|
|
14
|
|
51
|
use base qw(CGI::Test::Form::Widget::Menu); |
|
|
14
|
|
|
|
|
19
|
|
|
|
14
|
|
|
|
|
2365
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
# %attr |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# Defines which HTML attributes we should look at within the node, and how |
|
27
|
|
|
|
|
|
|
# to translate that into class attributes. |
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %attr = ('name' => 'name', |
|
31
|
|
|
|
|
|
|
'disabled' => 'is_disabled',); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# |
|
34
|
|
|
|
|
|
|
# ->_init |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# Per-widget initialization routine. |
|
37
|
|
|
|
|
|
|
# Parse HTML node to determine our specific parameters. |
|
38
|
|
|
|
|
|
|
# |
|
39
|
|
|
|
|
|
|
sub _init |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
16
|
|
|
16
|
|
28
|
my $this = shift; |
|
42
|
16
|
|
|
|
|
25
|
my ($node) = shift; |
|
43
|
16
|
|
|
|
|
77
|
$this->_parse_attr($node, \%attr); |
|
44
|
16
|
|
|
|
|
118
|
$this->_parse_options($node); |
|
45
|
16
|
|
|
|
|
27
|
return; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# |
|
49
|
|
|
|
|
|
|
# ->set_selected -- redefined |
|
50
|
|
|
|
|
|
|
# |
|
51
|
|
|
|
|
|
|
# Change "selected" status for a menu value. |
|
52
|
|
|
|
|
|
|
# We can only "select" values from a popup, never unselect one. |
|
53
|
|
|
|
|
|
|
# |
|
54
|
|
|
|
|
|
|
sub set_selected |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
6
|
|
|
6
|
1
|
12
|
my $this = shift; |
|
57
|
6
|
|
|
|
|
10
|
my ($value, $state) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
6
|
50
|
|
|
|
18
|
unless ($state) |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
0
|
|
|
|
|
0
|
carp "cannot unselect value \"%s\" from popup $this", $value; |
|
62
|
0
|
|
|
|
|
0
|
return; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
50
|
return $this->SUPER::set_selected($value, $state); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# |
|
69
|
|
|
|
|
|
|
# Attribute access |
|
70
|
|
|
|
|
|
|
# |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub gui_type |
|
73
|
|
|
|
|
|
|
{ |
|
74
|
0
|
|
|
0
|
1
|
0
|
return "popup menu"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
# Defined predicates |
|
79
|
|
|
|
|
|
|
# |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub is_popup |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
1
|
|
|
1
|
1
|
177
|
return 1; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
CGI::Test::Form::Widget::Menu::Popup - A popup menu |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Inherits from CGI::Test::Form::Widget::Menu |
|
95
|
|
|
|
|
|
|
# $form is a CGI::Test::Form |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $action = $form->menu_by_name("action"); |
|
98
|
|
|
|
|
|
|
$action->select("reboot"); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This class models a popup menu, from which one item at most may be selected, |
|
103
|
|
|
|
|
|
|
and for which there is at least one item selected, i.e. where exactly one |
|
104
|
|
|
|
|
|
|
item is chosen. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If no item was explicitely selected, C arbitrarily chooses the |
|
107
|
|
|
|
|
|
|
first item in the popup (if not empty) and warns you via C. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 INTERFACE |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The interface is the same as the one described in |
|
112
|
|
|
|
|
|
|
L. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHORS |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The original author is Raphael Manfredi. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Steven Hilton was long time maintainer of this module. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Current maintainer is Alexander Tokarev Ftokarev@cpan.orgE>. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
CGI::Test::Form::Widget::Menu(3). |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|