line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Weasel::Widgets::Dojo::Option; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1298
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
8
|
1
|
|
|
1
|
|
7226
|
use Weasel::Widgets::HTML::Selectable; |
|
1
|
|
|
|
|
32340
|
|
|
1
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
extends 'Weasel::Widgets::HTML::Selectable'; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
28
|
use Weasel::WidgetHandlers qw/ register_widget_handler /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
487
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
register_widget_handler(__PACKAGE__, 'Dojo', |
14
|
|
|
|
|
|
|
tag_name => 'tr', |
15
|
|
|
|
|
|
|
attributes => { |
16
|
|
|
|
|
|
|
role => 'option', |
17
|
|
|
|
|
|
|
}); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _option_popup { |
21
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Note, this assumes there are no pop-ups nested in the DOM, |
24
|
|
|
|
|
|
|
# which from experimentation I believe to be true at this point |
25
|
0
|
|
|
|
|
|
my $popup = $self->find('ancestor::*[@dijitpopupparent]'); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $popup; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub click { |
31
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
32
|
0
|
|
|
|
|
|
my $popup = $self->_option_popup; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $id = $popup->get_attribute('dijitpopupparent'); |
35
|
0
|
|
|
|
|
|
my $selector = $self->find("//*[\@id='$id']"); |
36
|
0
|
0
|
|
|
|
|
if (! $popup->is_displayed) { |
37
|
0
|
|
|
|
|
|
$selector->click; # pop up the selector |
38
|
|
|
|
|
|
|
$self->session->wait_for( |
39
|
|
|
|
|
|
|
# Wait till popup opens |
40
|
|
|
|
|
|
|
sub { |
41
|
0
|
|
|
0
|
|
|
my $class = $selector->get_attribute('class'); |
42
|
0
|
|
|
|
|
|
return scalar( grep { $_ eq 'dijitHasDropDownOpen' } |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
split /\s+/, $class); |
44
|
0
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
# Click the text, which masks $self under Firefox |
47
|
0
|
|
|
|
|
|
$self->find("//*[\@id='" . $self->get_attribute('id') . "_text']")->SUPER::click; |
48
|
|
|
|
|
|
|
$self->session->wait_for( |
49
|
|
|
|
|
|
|
# Wait till popup closes |
50
|
|
|
|
|
|
|
sub { |
51
|
0
|
|
|
0
|
|
|
my $class = $selector->get_attribute('class'); |
52
|
0
|
|
|
|
|
|
return !scalar( grep { $_ eq 'dijitHasDropDownOpen' } |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
split /\s+/, $class) ; |
54
|
0
|
|
|
|
|
|
}); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub selected { |
60
|
0
|
|
|
0
|
1
|
|
my ($self, $new_value) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if (defined $new_value) { |
63
|
0
|
|
|
|
|
|
my $selected = $self->get_attribute('aria-selected') eq 'true'; |
64
|
0
|
0
|
0
|
|
|
|
if ($new_value && ! $selected) { |
|
|
0
|
0
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->click; # select |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif (! $new_value && $selected) { |
68
|
0
|
|
|
|
|
|
$self->click; # unselect |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
return $self->get_attribute('aria-selected') eq 'true'; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |