line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::JQuery::Data; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$HTML::JQuery::Data::JQuery = []; |
4
|
|
|
|
|
|
|
$HTML::JQuery::Data::Inline = []; |
5
|
|
|
|
|
|
|
$HTML::JQuery::Data::Keystrokes = 0; |
6
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub jquery_add { |
9
|
8
|
|
|
8
|
0
|
17
|
my ($class, $add) = @_; |
10
|
8
|
50
|
|
|
|
19
|
if ($HTML::JQuery::Inline == 1) { push @{$HTML::JQuery::Data::Inline}, "$add\n"; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
11
|
8
|
|
|
|
|
11
|
else { push @{$HTML::JQuery::Data::JQuery}, "$add\n"; } |
|
8
|
|
|
|
|
39
|
|
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub jquery_onclick { |
15
|
0
|
|
|
0
|
0
|
0
|
my ($self, $name) = @_; |
16
|
0
|
|
|
|
|
0
|
return "\$('$name').click(function() {"; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub jquery_end { |
20
|
0
|
|
|
0
|
0
|
0
|
return "});"; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub jquery_fade { |
24
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
25
|
0
|
|
|
|
|
0
|
my $type = shift; |
26
|
0
|
|
|
|
|
0
|
my ($sel, $duration, $after) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
$sel = "\$('$sel')"; |
29
|
0
|
0
|
|
|
|
0
|
$sel = '$(this)' |
30
|
|
|
|
|
|
|
if $sel eq "\$('this')"; |
31
|
0
|
0
|
|
|
|
0
|
$duration = $duration ? $duration : 'undefined'; |
32
|
0
|
0
|
|
|
|
0
|
$after = $after ? $after : 'undefined'; |
33
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add( "$sel.fade$type($duration, function() { $after });"); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub jquery_slidetoggle { |
37
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
38
|
0
|
|
|
|
|
0
|
my ($sel, $duration, $after) = @_; |
39
|
0
|
|
|
|
|
0
|
$sel = "\$('$sel')"; |
40
|
0
|
0
|
|
|
|
0
|
$sel = '$(this)' |
41
|
|
|
|
|
|
|
if $sel eq "\$('this')"; |
42
|
0
|
0
|
|
|
|
0
|
$duration = $duration ? "\"$duration\"" : 'undefined'; |
43
|
0
|
0
|
|
|
|
0
|
$after = $after ? $after : 'undefined'; |
44
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add( "$sel.slideToggle($duration, function() { $after });"); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub jquery_keystrokes { |
48
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
49
|
0
|
|
|
|
|
0
|
my ($sel, $args) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
|
|
|
0
|
if (! exists $args->{keys}) { |
52
|
0
|
|
|
|
|
0
|
$CLASS->js_alert("Please don't forget to include 'keys' in keystrokes."); |
53
|
0
|
|
|
|
|
0
|
return ; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
0
|
$HTML::JQuery::Data::Keystrokes++; |
56
|
|
|
|
|
|
|
#my $keys = join q{, }, $args->{keys}; |
57
|
0
|
|
|
|
|
0
|
my $keys; |
58
|
0
|
|
|
|
|
0
|
map { $keys .= qq{'$_',} } @{$args->{keys}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
59
|
0
|
|
|
|
|
0
|
my $bind = "\$('$sel').bind('keystrokes.$HTML::JQuery::Data::Keystrokes', {\n"; |
60
|
0
|
|
|
|
|
0
|
$bind .= "keys : [ $keys ] },\n"; |
61
|
0
|
|
|
|
|
0
|
$bind .= "function(event) { $args->{event} } );"; |
62
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add($bind); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub jquery_datepicker { |
66
|
0
|
|
|
0
|
0
|
0
|
my ($self, $sel, $args) = @_; |
67
|
0
|
|
|
|
|
0
|
my $p = ""; |
68
|
0
|
|
|
|
|
0
|
foreach my $key (keys %$args) { |
69
|
0
|
0
|
|
|
|
0
|
next if $key eq 'auto'; |
70
|
0
|
0
|
|
|
|
0
|
$args->{$key} = 'false' |
71
|
|
|
|
|
|
|
if $args->{$key} == 0; |
72
|
0
|
0
|
|
|
|
0
|
$args->{$key} = 'true' |
73
|
|
|
|
|
|
|
if $args->{$key} == 1; |
74
|
0
|
|
|
|
|
0
|
$p .= "$key : $args->{$key},\n"; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
0
|
|
|
|
0
|
if ($args->{auto}) { $CLASS->jquery_add( "\$('$sel').datepicker({dateFormat: 'dd/mm/yy', changeMonth: true, changeYear: true, $p});\n" ); } |
|
0
|
|
|
|
|
0
|
|
77
|
0
|
|
|
|
|
0
|
else { $CLASS->jquery_add( "\$('$sel').datepicker({ $p });\n" ); } |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub jquery_dialog { |
81
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
82
|
0
|
|
|
|
|
0
|
my $sel = shift; |
83
|
0
|
|
|
|
|
0
|
my $args = shift; |
84
|
0
|
|
|
|
|
0
|
my $p = ""; |
85
|
0
|
|
|
|
|
0
|
my $selector = $sel; |
86
|
0
|
|
|
|
|
0
|
foreach my $key (keys %$args) { |
87
|
0
|
0
|
0
|
|
|
0
|
unless ($key eq 'id' or $key eq 'body' or $key eq 'buttons' or $key eq 'modal' or $key eq 'autoOpen' or $key eq 'open' or $key eq 'close') { |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
88
|
0
|
0
|
0
|
|
|
0
|
if ($args->{$key} eq 'true' or $args->{$key} eq 'false') { |
89
|
0
|
|
|
|
|
0
|
$p .= "$key : $args->{$key},\n"; |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
0
|
else { $p .= "$key : '$args->{$key}',\n"; } |
92
|
|
|
|
|
|
|
} |
93
|
0
|
0
|
|
|
|
0
|
if ($key eq 'open') { |
94
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add( "\$('$sel').dialog('open');"); |
95
|
0
|
|
|
|
|
0
|
return; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
0
|
|
|
|
0
|
if ($key eq 'close') { |
98
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add( "\$('$sel').dialog('close');"); |
99
|
0
|
|
|
|
|
0
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
0
|
|
|
|
0
|
if ($key eq 'buttons') { |
102
|
0
|
|
|
|
|
0
|
$p .= "buttons : {\n"; |
103
|
0
|
|
|
|
|
0
|
foreach my $button (keys %{$args->{buttons}}) { |
|
0
|
|
|
|
|
0
|
|
104
|
0
|
|
|
|
|
0
|
$p .= "$button : function() { $args->{buttons}->{$button} },\n" |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
0
|
$p .= "},\n"; |
107
|
|
|
|
|
|
|
} |
108
|
0
|
0
|
|
|
|
0
|
if ($key eq 'modal') { |
109
|
0
|
0
|
|
|
|
0
|
if ($args->{$key} == 0) { $p .= "modal : false,\n"; } |
|
0
|
|
|
|
|
0
|
|
110
|
0
|
|
|
|
|
0
|
else { $p .= "modal : true,\n"; } |
111
|
|
|
|
|
|
|
} |
112
|
0
|
0
|
|
|
|
0
|
if ($key eq 'autoOpen') { |
113
|
0
|
0
|
|
|
|
0
|
if ($args->{$key} == 0) { $p .= "autoOpen : false,\n"; } |
|
0
|
|
|
|
|
0
|
|
114
|
0
|
|
|
|
|
0
|
else { $p .= "autoOpen : true,\n"; } |
115
|
|
|
|
|
|
|
} |
116
|
0
|
0
|
|
|
|
0
|
if ($key eq 'body') { |
117
|
0
|
|
|
|
|
0
|
my $title = $args->{title}; |
118
|
0
|
|
|
|
|
0
|
my $body = $args->{body}; |
119
|
0
|
|
|
|
|
0
|
$body =~ s/"/\\"/g; |
120
|
0
|
|
|
|
|
0
|
$body =~ s/\n//g; |
121
|
0
|
0
|
|
|
|
0
|
if (substr($sel, 0, 1) eq '.') { $sel = 'class="' . substr($sel, 1) . '"'; } |
|
0
|
0
|
|
|
|
0
|
|
122
|
0
|
|
|
|
|
0
|
elsif (substr($sel, 0, 1) eq '#') { $sel = 'id="' . substr($sel, 1) . '"'; } |
123
|
0
|
|
|
|
|
0
|
my $build_dialog = qq{ |
124
|
|
|
|
|
|
|
var div = ' $body '; |
125
|
|
|
|
|
|
|
\$(div).appendTo("body"); |
126
|
|
|
|
|
|
|
}; |
127
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add($build_dialog); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
0
|
$CLASS->jquery_add("\$('$selector').dialog({$p});"); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub js_alert { |
134
|
1
|
|
|
1
|
0
|
3
|
my ($self, $message) = @_; |
135
|
1
|
|
|
|
|
10
|
$CLASS->jquery_add( "alert(\"$message\");"); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub js_callfunc { |
139
|
0
|
|
|
0
|
0
|
|
my ($self, $func) = @_; |
140
|
|
|
|
|
|
|
#$CLASS->jquery_add( "if (typeof $func == 'function') { $func(); }" ); |
141
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "$func();" ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub jquery_rel { |
145
|
0
|
|
|
0
|
0
|
|
my ($self, $rel) = @_; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$rel = "\$('$rel')"; |
148
|
0
|
0
|
|
|
|
|
$rel = '$(this)' |
149
|
|
|
|
|
|
|
if $rel eq "\$('this')"; |
150
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "$rel.attr('rel');\n" ); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub jquery_hide { |
154
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
155
|
0
|
|
|
|
|
|
my ($sel, $duration, $after) = @_; |
156
|
0
|
|
|
|
|
|
$sel = "\$('$sel')"; |
157
|
0
|
0
|
|
|
|
|
$sel = '$(this)' |
158
|
|
|
|
|
|
|
if $sel eq "\$('this')"; |
159
|
0
|
0
|
|
|
|
|
$duration = $duration ? "\"$duration\"" : 'undefined'; |
160
|
0
|
0
|
|
|
|
|
$after = $after ? $after : 'undefined'; |
161
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "$sel.hide($duration, function() { $after });"); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub jquery_show { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
my ($sel, $duration, $after) = @_; |
167
|
0
|
|
|
|
|
|
$sel = "\$('$sel')"; |
168
|
0
|
0
|
|
|
|
|
$sel = '$(this)' |
169
|
|
|
|
|
|
|
if $sel eq "\$('this')"; |
170
|
0
|
0
|
|
|
|
|
$duration = $duration ? "\"$duration\"" : 'undefined'; |
171
|
0
|
0
|
|
|
|
|
$after = $after ? $after : 'undefined'; |
172
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "$sel.show($duration, function() { $after });"); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub jquery_remove { |
176
|
0
|
|
|
0
|
0
|
|
my ($self, $sel) = @_; |
177
|
0
|
|
|
|
|
|
$sel = "\$('$sel')"; |
178
|
0
|
0
|
|
|
|
|
$sel = '$(this)' |
179
|
|
|
|
|
|
|
if $sel eq "\$('this')"; |
180
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "$sel.remove();" ); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub jquery_innerhtml { |
184
|
0
|
|
|
0
|
0
|
|
my ($self, $sel, $text) = @_; |
185
|
|
|
|
|
|
|
#my $append; |
186
|
|
|
|
|
|
|
#$append = 1 if substr($text, 0, 1) eq '+'; |
187
|
|
|
|
|
|
|
# |
188
|
|
|
|
|
|
|
#if ($append) { |
189
|
|
|
|
|
|
|
# $CLASS->jquery_add( "$sel.innerHtml |
190
|
0
|
|
|
|
|
|
$text =~ s/"/\\"/g; |
191
|
0
|
|
|
|
|
|
$text =~ s/\n//g; |
192
|
0
|
|
|
|
|
|
$CLASS->jquery_add( "\$('$sel').append(\"$text\");" ); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |