Filename | /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin.pm |
Statements | Executed 258 statements in 2.08ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
9 | 1 | 1 | 227µs | 652µs | handleJQueryIcon | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 76µs | 2.88ms | initPlugin | Foswiki::Plugins::JQueryPlugin::
6 | 5 | 4 | 27µs | 3.88ms | createPlugin | Foswiki::Plugins::JQueryPlugin::
6 | 6 | 5 | 22µs | 81µs | registerPlugin | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 13µs | 25µs | BEGIN@3 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 12µs | 169µs | finishPlugin | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 10µs | 14µs | BEGIN@4 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 9µs | 20µs | BEGIN@21 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 8µs | 21µs | BEGIN@23 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 8µs | 19µs | BEGIN@18 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 6µs | 43µs | createTheme | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@14 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@15 | Foswiki::Plugins::JQueryPlugin::
1 | 1 | 1 | 4µs | 4µs | BEGIN@16 | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | _inlineError | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleButton | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleEndTab | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleEndTabPane | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryIconPath | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryPlugins | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryRequire | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleJQueryTheme | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handlePopUpWindow | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleRestTmpl | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleTab | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleTabPane | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | handleToggle | Foswiki::Plugins::JQueryPlugin::
0 | 0 | 0 | 0s | 0s | registerTheme | Foswiki::Plugins::JQueryPlugin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Plugins::JQueryPlugin; | ||||
3 | 2 | 35µs | 2 | 37µs | # spent 25µs (13+12) within Foswiki::Plugins::JQueryPlugin::BEGIN@3 which was called:
# once (13µs+12µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 3 # spent 25µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@3
# spent 12µs making 1 call to strict::import |
4 | 2 | 35µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::Plugins::JQueryPlugin::BEGIN@4 which was called:
# once (10µs+4µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 4 # spent 14µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@4
# spent 4µs making 1 call to warnings::import |
5 | |||||
6 | =begin TML | ||||
7 | |||||
8 | ---+ package Foswiki::Plugins::JQueryPlugin | ||||
9 | |||||
10 | Container for jQuery and plugins | ||||
11 | |||||
12 | =cut | ||||
13 | |||||
14 | 2 | 26µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::JQueryPlugin::BEGIN@14 which was called:
# once (4µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 14 # spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@14 |
15 | 2 | 22µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::JQueryPlugin::BEGIN@15 which was called:
# once (4µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 15 # spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@15 |
16 | 2 | 37µs | 1 | 4µs | # spent 4µs within Foswiki::Plugins::JQueryPlugin::BEGIN@16 which was called:
# once (4µs+0s) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 16 # spent 4µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@16 |
17 | |||||
18 | # spent 19µs (8+11) within Foswiki::Plugins::JQueryPlugin::BEGIN@18 which was called:
# once (8µs+11µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 25 | ||||
19 | # Backwards compatibility for Foswiki 1.1.x | ||||
20 | 1 | 7µs | 1 | 11µs | unless ( Foswiki::Request->can('multi_param') ) { # spent 11µs making 1 call to CGI::can |
21 | 2 | 38µs | 2 | 31µs | # spent 20µs (9+11) within Foswiki::Plugins::JQueryPlugin::BEGIN@21 which was called:
# once (9µs+11µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 21 # spent 20µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@21
# spent 11µs making 1 call to warnings::unimport |
22 | *Foswiki::Request::multi_param = \&Foswiki::Request::param; | ||||
23 | 2 | 25µs | 2 | 35µs | # spent 21µs (8+13) within Foswiki::Plugins::JQueryPlugin::BEGIN@23 which was called:
# once (8µs+13µs) by Foswiki::Contrib::JEditableContrib::JEDITABLE::BEGIN@7 at line 23 # spent 21µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@23
# spent 13µs making 1 call to warnings::import |
24 | } | ||||
25 | 1 | 1.50ms | 1 | 19µs | } # spent 19µs making 1 call to Foswiki::Plugins::JQueryPlugin::BEGIN@18 |
26 | |||||
27 | 1 | 600ns | our $VERSION = '6.13'; | ||
28 | 1 | 100ns | our $RELEASE = '16 Jun 2015'; | ||
29 | 1 | 100ns | our $SHORTDESCRIPTION = 'jQuery <nop>JavaScript library for Foswiki'; | ||
30 | 1 | 200ns | our $NO_PREFS_IN_TOPIC = 1; | ||
31 | |||||
32 | =begin TML | ||||
33 | |||||
34 | ---++ initPlugin($topic, $web, $user) -> $boolean | ||||
35 | |||||
36 | =cut | ||||
37 | |||||
38 | # spent 2.88ms (76µs+2.81) within Foswiki::Plugins::JQueryPlugin::initPlugin which was called:
# once (76µs+2.81ms) by Foswiki::Plugin::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Plugin.pm:257] at line 250 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
39 | 1 | 2µs | my ( $topic, $web, $user ) = @_; | ||
40 | |||||
41 | # check for prerequisites | ||||
42 | 1 | 900ns | unless ( defined(&Foswiki::Func::addToZone) ) { | ||
43 | Foswiki::Func::writeWarning( | ||||
44 | "ZonePlugin required for legacy Foswiki engines ... disabling JQueryPlugin" | ||||
45 | ); | ||||
46 | return 0; | ||||
47 | } | ||||
48 | |||||
49 | 1 | 2µs | 1 | 16µs | Foswiki::Func::registerTagHandler( 'JQTHEME', \&handleJQueryTheme ); # spent 16µs making 1 call to Foswiki::Func::registerTagHandler |
50 | 1 | 2µs | 1 | 12µs | Foswiki::Func::registerTagHandler( 'JQREQUIRE', \&handleJQueryRequire ); # spent 12µs making 1 call to Foswiki::Func::registerTagHandler |
51 | 1 | 2µs | 1 | 12µs | Foswiki::Func::registerTagHandler( 'JQICON', \&handleJQueryIcon ); # spent 12µs making 1 call to Foswiki::Func::registerTagHandler |
52 | 1 | 2µs | 1 | 12µs | Foswiki::Func::registerTagHandler( 'JQICONPATH', \&handleJQueryIconPath ); # spent 12µs making 1 call to Foswiki::Func::registerTagHandler |
53 | 1 | 2µs | 1 | 14µs | Foswiki::Func::registerTagHandler( 'JQPLUGINS', \&handleJQueryPlugins ); # spent 14µs making 1 call to Foswiki::Func::registerTagHandler |
54 | |||||
55 | # jquery.tabpane | ||||
56 | 1 | 2µs | 1 | 23µs | Foswiki::Func::registerTagHandler( 'TABPANE', \&handleTabPane ); # spent 23µs making 1 call to Foswiki::Func::registerTagHandler |
57 | 1 | 2µs | 1 | 11µs | Foswiki::Func::registerTagHandler( 'ENDTABPANE', \&handleEndTabPane ); # spent 11µs making 1 call to Foswiki::Func::registerTagHandler |
58 | 1 | 2µs | 1 | 11µs | Foswiki::Func::registerTagHandler( 'TAB', \&handleTab ); # spent 11µs making 1 call to Foswiki::Func::registerTagHandler |
59 | 1 | 2µs | 1 | 13µs | Foswiki::Func::registerTagHandler( 'ENDTAB', \&handleEndTab ); # spent 13µs making 1 call to Foswiki::Func::registerTagHandler |
60 | |||||
61 | # jquery.button | ||||
62 | 1 | 2µs | 1 | 13µs | Foswiki::Func::registerTagHandler( 'BUTTON', \&handleButton ); # spent 13µs making 1 call to Foswiki::Func::registerTagHandler |
63 | |||||
64 | # jquery.popupwindow | ||||
65 | 1 | 2µs | 1 | 11µs | Foswiki::Func::registerTagHandler( 'POPUPWINDOW', \&handlePopUpWindow ); # spent 11µs making 1 call to Foswiki::Func::registerTagHandler |
66 | |||||
67 | # init plugin handler and preload default plugins | ||||
68 | 1 | 3µs | 1 | 2.63ms | Foswiki::Plugins::JQueryPlugin::Plugins::init(); # spent 2.63ms making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::init |
69 | |||||
70 | # backwards compatibility | ||||
71 | 1 | 14µs | 1 | 8µs | if ( $Foswiki::Plugins::VERSION < 2.1 ) { # spent 8µs making 1 call to version::vxs::VCMP |
72 | Foswiki::Func::setPreferencesValue( "CLEAR", | ||||
73 | "<span class='foswikiClear'></span>" ); | ||||
74 | } | ||||
75 | |||||
76 | # jquery.tmpl | ||||
77 | Foswiki::Func::registerRESTHandler( | ||||
78 | 1 | 4µs | 1 | 24µs | 'tmpl', \&handleRestTmpl, # spent 24µs making 1 call to Foswiki::Func::registerRESTHandler |
79 | authenticate => 0, # Safe. Expands templates. | ||||
80 | validate => 0, # Doesn't update. | ||||
81 | http_allow => 'GET,POST', # Can't update so doesn't matter | ||||
82 | description => | ||||
83 | 'Load and expand a template in current web/topic context.' | ||||
84 | ); | ||||
85 | |||||
86 | 1 | 5µs | return 1; | ||
87 | } | ||||
88 | |||||
89 | =begin TML | ||||
90 | |||||
91 | finish up the plugins container | ||||
92 | |||||
93 | =cut | ||||
94 | |||||
95 | # spent 169µs (12+157) within Foswiki::Plugins::JQueryPlugin::finishPlugin which was called:
# once (12µs+157µs) by Foswiki::Plugin::invoke at line 310 of /var/www/foswikidev/core/lib/Foswiki/Plugin.pm | ||||
96 | 1 | 6µs | 1 | 157µs | Foswiki::Plugins::JQueryPlugin::Plugins::finish(); # spent 157µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::finish |
97 | } | ||||
98 | |||||
99 | =begin TML | ||||
100 | |||||
101 | ---++ createPlugin($pluginName, ...) -> $plugin | ||||
102 | |||||
103 | API to create a jQuery plugin. Instantiating it adds all required javascript | ||||
104 | and css files to the html page header. | ||||
105 | |||||
106 | =cut | ||||
107 | |||||
108 | # spent 3.88ms (27µs+3.85) within Foswiki::Plugins::JQueryPlugin::createPlugin which was called 6 times, avg 647µs/call:
# 2 times (13µs+2.08ms) by Foswiki::Plugins::SubscribePlugin::_SUBSCRIBE at line 104 of /var/www/foswikidev/core/lib/Foswiki/Plugins/SubscribePlugin.pm, avg 1.05ms/call
# once (3µs+664µs) by Foswiki::Plugins::UpdatesPlugin::initPlugin at line 53 of /var/www/foswikidev/core/lib/Foswiki/Plugins/UpdatesPlugin.pm
# once (5µs+466µs) by Foswiki::Plugins::CommentPlugin::initPlugin at line 44 of /var/www/foswikidev/core/lib/Foswiki/Plugins/CommentPlugin.pm
# once (3µs+447µs) by Foswiki::Plugins::UpdatesPlugin::initPlugin at line 52 of /var/www/foswikidev/core/lib/Foswiki/Plugins/UpdatesPlugin.pm
# once (3µs+196µs) by Foswiki::Plugins::JEditableContribPlugin::initPlugin at line 14 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JEditableContribPlugin.pm | ||||
109 | 6 | 30µs | 6 | 3.85ms | return Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin(@_); # spent 3.85ms making 6 calls to Foswiki::Plugins::JQueryPlugin::Plugins::createPlugin, avg 642µs/call |
110 | } | ||||
111 | |||||
112 | =begin TML | ||||
113 | |||||
114 | ---++ createTheme($themeName) -> $boolean | ||||
115 | |||||
116 | API to load a jQuery UI theme. Returns true if the theme has | ||||
117 | been loaded successfully. | ||||
118 | |||||
119 | =cut | ||||
120 | |||||
121 | # spent 43µs (6+37) within Foswiki::Plugins::JQueryPlugin::createTheme which was called:
# once (6µs+37µs) by Foswiki::Plugins::JQueryPlugin::UI::init at line 59 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JQueryPlugin/UI.pm | ||||
122 | 1 | 6µs | 1 | 37µs | return Foswiki::Plugins::JQueryPlugin::Plugins::createTheme(@_); # spent 37µs making 1 call to Foswiki::Plugins::JQueryPlugin::Plugins::createTheme |
123 | } | ||||
124 | |||||
125 | =begin TML | ||||
126 | |||||
127 | ---++ registerPlugin($pluginName, $class) -> $plugin | ||||
128 | |||||
129 | API to register a jQuery plugin. This is of use for other Foswiki plugins | ||||
130 | to register their javascript modules as a jQuery plugin. Registering a plugin 'foobar' | ||||
131 | will make it available via =%<nop>JQREQUIRE{"foobar"}%=. | ||||
132 | |||||
133 | Class will default to 'Foswiki::Plugins::JQueryPlugin::FOOBAR, | ||||
134 | |||||
135 | The FOOBAR.pm stub must be derived from Foswiki::Plugins::JQueryPlugin::Plugin class. | ||||
136 | |||||
137 | =cut | ||||
138 | |||||
139 | # spent 81µs (22+59) within Foswiki::Plugins::JQueryPlugin::registerPlugin which was called 6 times, avg 14µs/call:
# once (6µs+14µs) by Foswiki::Plugins::CommentPlugin::initPlugin at line 42 of /var/www/foswikidev/core/lib/Foswiki/Plugins/CommentPlugin.pm
# once (3µs+10µs) by Foswiki::Plugins::JEditableContribPlugin::initPlugin at line 12 of /var/www/foswikidev/core/lib/Foswiki/Plugins/JEditableContribPlugin.pm
# once (3µs+10µs) by Foswiki::Plugins::TwistyPlugin::initPlugin at line 45 of /var/www/foswikidev/core/lib/Foswiki/Plugins/TwistyPlugin.pm
# once (3µs+9µs) by Foswiki::Plugins::SubscribePlugin::initPlugin at line 60 of /var/www/foswikidev/core/lib/Foswiki/Plugins/SubscribePlugin.pm
# once (3µs+9µs) by Foswiki::Plugins::ConfigurePlugin::initPlugin at line 78 of /var/www/foswikidev/core/lib/Foswiki/Plugins/ConfigurePlugin.pm
# once (3µs+7µs) by Foswiki::Plugins::ConfigurePlugin::initPlugin at line 81 of /var/www/foswikidev/core/lib/Foswiki/Plugins/ConfigurePlugin.pm | ||||
140 | 6 | 25µs | 6 | 60µs | return Foswiki::Plugins::JQueryPlugin::Plugins::registerPlugin(@_); # spent 60µs making 6 calls to Foswiki::Plugins::JQueryPlugin::Plugins::registerPlugin, avg 10µs/call |
141 | } | ||||
142 | |||||
143 | =begin TML | ||||
144 | |||||
145 | ---++ registerTheme($themeName, $url) | ||||
146 | |||||
147 | API to register a jQuery theme. this is of use for other Foswiki plugins | ||||
148 | to register their theme. Registering a theme 'foobar' | ||||
149 | will make it available via =%<nop>JQTHEME{"foobar"}%=. | ||||
150 | |||||
151 | The =$url= parameter will default to '%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/ui/$themeName/jquery-ui.css'. | ||||
152 | |||||
153 | =cut | ||||
154 | |||||
155 | sub registerTheme { | ||||
156 | return Foswiki::Plugins::JQueryPlugin::Plugins::registerTheme(@_); | ||||
157 | } | ||||
158 | |||||
159 | =begin TML | ||||
160 | |||||
161 | ---++ handleButton($session, $params, $topic, $web) -> $result | ||||
162 | |||||
163 | Handles the =%<nop>BUTTON% tag. | ||||
164 | |||||
165 | =cut | ||||
166 | |||||
167 | sub handleButton { | ||||
168 | my $session = shift; | ||||
169 | |||||
170 | my $plugin = createPlugin( 'Button', $session ); | ||||
171 | return $plugin->handleButton(@_) if $plugin; | ||||
172 | return ''; | ||||
173 | } | ||||
174 | |||||
175 | =begin TML | ||||
176 | |||||
177 | ---++ handleRestTmpl($session, $params, $topic, $web) -> $result | ||||
178 | |||||
179 | Handles the tmpl rest handler | ||||
180 | |||||
181 | =cut | ||||
182 | |||||
183 | sub handleRestTmpl { | ||||
184 | my $session = shift; | ||||
185 | |||||
186 | my $plugin = createPlugin( 'render', $session ); | ||||
187 | return $plugin->restTmpl( $session, @_ ) if $plugin; | ||||
188 | return ''; | ||||
189 | } | ||||
190 | |||||
191 | =begin TML | ||||
192 | |||||
193 | ---++ handlePopUpWindow($session, $params, $topic, $web) -> $result | ||||
194 | |||||
195 | Handles the =%<nop>POPUPWINDOW% tag. | ||||
196 | |||||
197 | =cut | ||||
198 | |||||
199 | sub handlePopUpWindow { | ||||
200 | my $session = shift; | ||||
201 | |||||
202 | my $plugin = createPlugin( 'PopUpWindow', $session ); | ||||
203 | return $plugin->handlePopUpWindow(@_) if $plugin; | ||||
204 | return ''; | ||||
205 | } | ||||
206 | |||||
207 | =begin TML | ||||
208 | |||||
209 | ---++ handleToggle($session, $params, $topic, $web) -> $result | ||||
210 | |||||
211 | Handles the =%<nop>TOGGLE% tag. | ||||
212 | |||||
213 | =cut | ||||
214 | |||||
215 | sub handleToggle { | ||||
216 | my $session = shift; | ||||
217 | |||||
218 | my $plugin = createPlugin( 'Toggle', $session ); | ||||
219 | return $plugin->handleToggle(@_) if $plugin; | ||||
220 | return ''; | ||||
221 | } | ||||
222 | |||||
223 | =begin TML | ||||
224 | |||||
225 | ---++ handleTabPane($session, $params, $topic, $web) -> $result | ||||
226 | |||||
227 | Handles the =%<nop>TABPANE% tag. | ||||
228 | |||||
229 | =cut | ||||
230 | |||||
231 | sub handleTabPane { | ||||
232 | my $session = shift; | ||||
233 | |||||
234 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
235 | return $plugin->handleTabPane(@_) if $plugin; | ||||
236 | return ''; | ||||
237 | } | ||||
238 | |||||
239 | =begin TML | ||||
240 | |||||
241 | ---++ handleTab($session, $params, $topic, $web) -> $result | ||||
242 | |||||
243 | Handles the =%<nop>TAB% tag. | ||||
244 | |||||
245 | =cut | ||||
246 | |||||
247 | sub handleTab { | ||||
248 | my $session = shift; | ||||
249 | |||||
250 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
251 | return $plugin->handleTab(@_) if $plugin; | ||||
252 | return ''; | ||||
253 | } | ||||
254 | |||||
255 | =begin TML | ||||
256 | |||||
257 | ---++ handleEndTab($session, $params, $topic, $web) -> $result | ||||
258 | |||||
259 | Handles the =%<nop>ENDTAB% tag. | ||||
260 | |||||
261 | =cut | ||||
262 | |||||
263 | sub handleEndTab { | ||||
264 | my $session = shift; | ||||
265 | |||||
266 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
267 | return $plugin->handleEndTab(@_) if $plugin; | ||||
268 | return ''; | ||||
269 | } | ||||
270 | |||||
271 | =begin TML | ||||
272 | |||||
273 | ---++ handleEndTabPane($session, $params, $topic, $web) -> $result | ||||
274 | |||||
275 | Handles the =%<nop>ENDTABPANE% tag. | ||||
276 | |||||
277 | =cut | ||||
278 | |||||
279 | sub handleEndTabPane { | ||||
280 | my $session = shift; | ||||
281 | |||||
282 | my $plugin = createPlugin( 'Tabpane', $session ); | ||||
283 | return $plugin->handleEndTabPane(@_) if $plugin; | ||||
284 | return ''; | ||||
285 | } | ||||
286 | |||||
287 | =begin TML | ||||
288 | |||||
289 | ---++ handleJQueryRequire($session, $params, $topic, $web) -> $result | ||||
290 | |||||
291 | Handles the =%<nop>JQREQUIRE% tag. | ||||
292 | |||||
293 | =cut | ||||
294 | |||||
295 | sub handleJQueryRequire { | ||||
296 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
297 | |||||
298 | my $plugins = $params->{_DEFAULT} || ''; | ||||
299 | my $warn = Foswiki::Func::isTrue( $params->{warn}, 1 ); | ||||
300 | my $errorMsg = ''; | ||||
301 | foreach my $pluginName ( split( /\s*,\s*/, $plugins ) ) { | ||||
302 | my $plugin = createPlugin( $pluginName, $session ); | ||||
303 | $errorMsg .= _inlineError("No such plugin $pluginName") | ||||
304 | if !$plugin && $warn; | ||||
305 | } | ||||
306 | |||||
307 | return $errorMsg; | ||||
308 | } | ||||
309 | |||||
310 | =begin TML | ||||
311 | |||||
312 | ---++ handleJQueryTheme($session, $params, $topic, $web) -> $result | ||||
313 | |||||
314 | Handles the =%<nop>JQTHEME% tag. | ||||
315 | |||||
316 | =cut | ||||
317 | |||||
318 | sub handleJQueryTheme { | ||||
319 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
320 | |||||
321 | my $themeName = $params->{_DEFAULT} | ||||
322 | || $Foswiki::cfg{JQueryPlugin}{JQueryTheme}; | ||||
323 | |||||
324 | my $warn = Foswiki::Func::isTrue( $params->{warn}, 1 ); | ||||
325 | |||||
326 | return _inlineError("No such theme $themeName") | ||||
327 | if !createTheme($themeName) && $warn; | ||||
328 | |||||
329 | return ''; | ||||
330 | } | ||||
331 | |||||
332 | =begin TML | ||||
333 | |||||
334 | ---++ handleJQueryIconPath($session, $params, $topic, $web) -> $result | ||||
335 | |||||
336 | Handles the =%<nop>JQICONPATH% tag. | ||||
337 | |||||
338 | =cut | ||||
339 | |||||
340 | sub handleJQueryIconPath { | ||||
341 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
342 | |||||
343 | my $iconName = $params->{_DEFAULT} || ''; | ||||
344 | return Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName); | ||||
345 | } | ||||
346 | |||||
347 | =begin TML | ||||
348 | |||||
349 | ---++ handleJQueryIcon($session, $params, $topic, $web) -> $result | ||||
350 | |||||
351 | Handles the =%<nop>JQICON% tag. | ||||
352 | |||||
353 | =cut | ||||
354 | |||||
355 | # spent 652µs (227+425) within Foswiki::Plugins::JQueryPlugin::handleJQueryIcon which was called 9 times, avg 72µs/call:
# 9 times (227µs+425µs) by Foswiki::Func::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Func.pm:662] at line 660 of /var/www/foswikidev/core/lib/Foswiki/Func.pm, avg 72µs/call | ||||
356 | 9 | 6µs | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||
357 | |||||
358 | 9 | 5µs | my $iconName = $params->{_DEFAULT} || ''; | ||
359 | 9 | 3µs | my $iconAlt = $params->{alt} || $iconName; | ||
360 | 9 | 3µs | my $iconTitle = $params->{title} || ''; | ||
361 | 9 | 2µs | my $iconFormat = $params->{format}; | ||
362 | 9 | 2µs | my $iconStyle = $params->{style}; | ||
363 | 9 | 800ns | my $iconPath; | ||
364 | 9 | 800ns | my $iconClass; | ||
365 | |||||
366 | # fontawesome | ||||
367 | 9 | 11µs | if ( $iconName =~ m/^fa\-/ ) { | ||
368 | $iconFormat = '<i class=\'$iconClass\' $iconStyle $iconTitle></i>'; | ||||
369 | $iconPath = ''; | ||||
370 | $iconClass = "foswikiIcon jqIcon fa $iconName"; | ||||
371 | createPlugin("fontawesome"); | ||||
372 | } | ||||
373 | |||||
374 | # default img based | ||||
375 | else { | ||||
376 | 9 | 4µs | $iconFormat = | ||
377 | '<img src=\'$iconPath\' class=\'$iconClass $iconName\' $iconStyle $iconAlt$iconTitle/>' | ||||
378 | unless $iconFormat; | ||||
379 | 9 | 13µs | 9 | 425µs | $iconPath = # spent 425µs making 9 calls to Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath, avg 47µs/call |
380 | Foswiki::Plugins::JQueryPlugin::Plugins::getIconUrlPath($iconName); | ||||
381 | 9 | 900ns | return '' unless $iconPath; | ||
382 | |||||
383 | 9 | 3µs | $iconClass = "foswikiIcon jqIcon"; | ||
384 | } | ||||
385 | |||||
386 | 9 | 3µs | $iconClass .= " $params->{class}" if $params->{class}; | ||
387 | |||||
388 | 9 | 2µs | my $img = $iconFormat; | ||
389 | 9 | 29µs | $img =~ s/\$iconName/$iconName/g; | ||
390 | 9 | 27µs | $img =~ s/\$iconPath/$iconPath/g; | ||
391 | 9 | 21µs | $img =~ s/\$iconClass/$iconClass/g; | ||
392 | 9 | 2µs | $img =~ s/\$iconStyle/style='$iconStyle'/g if $iconStyle; | ||
393 | 9 | 26µs | $img =~ s/\$iconAlt/alt='$iconAlt' /g if $iconAlt; | ||
394 | 9 | 2µs | $img =~ s/\$iconTitle/title='$iconTitle' /g if $iconTitle; | ||
395 | 9 | 33µs | $img =~ s/\$(iconAlt|iconTitle|iconStyle)//g; | ||
396 | |||||
397 | 9 | 29µs | return $img; | ||
398 | } | ||||
399 | |||||
400 | =begin TML | ||||
401 | |||||
402 | ---++ handleJQueryPlugins($session, $params, $topic, $web) -> $result | ||||
403 | |||||
404 | Handles the =%<nop>JQPLUGINS% tag. | ||||
405 | |||||
406 | =cut | ||||
407 | |||||
408 | sub handleJQueryPlugins { | ||||
409 | my ( $session, $params, $theTopic, $theWeb ) = @_; | ||||
410 | |||||
411 | my $thePlugin = $params->{_DEFAULT} || ''; | ||||
412 | my $theFormat = $params->{format}; | ||||
413 | my $theHeader = $params->{header} || ''; | ||||
414 | my $theFooter = $params->{footer} || ''; | ||||
415 | my $theSeparator = $params->{separator}; | ||||
416 | my $theTagFormat = $params->{tagformat}; | ||||
417 | |||||
418 | $theFormat = ' 1 <a href="$homepage">$name</a> $active $version $author' | ||||
419 | unless defined $theFormat; | ||||
420 | $theSeparator = '$n' | ||||
421 | unless defined $theSeparator; | ||||
422 | $theTagFormat = '[[%SYSTEMWEB%.Var$tag][$tag]]' | ||||
423 | unless defined $theTagFormat; | ||||
424 | |||||
425 | my @plugins = | ||||
426 | Foswiki::Plugins::JQueryPlugin::Plugins::getPlugins($thePlugin); | ||||
427 | |||||
428 | my @result; | ||||
429 | my $counter = 0; | ||||
430 | foreach my $plugin (@plugins) { | ||||
431 | my $summary = $plugin->getSummary(); | ||||
432 | $summary =~ s/^\s+//; | ||||
433 | $summary =~ s/\s+$//; | ||||
434 | my $tags = ''; | ||||
435 | if ( $theFormat =~ m/\$tags/ ) { | ||||
436 | my @lines = (); | ||||
437 | my @tags = (); | ||||
438 | if ( ref( $plugin->{tags} ) ) { | ||||
439 | @tags = @{ $plugin->{tags} }; | ||||
440 | } | ||||
441 | else { | ||||
442 | @tags = split( /\s*,\s*/, $plugin->{tags} ); | ||||
443 | } | ||||
444 | foreach my $tag ( sort @tags ) { | ||||
445 | my $line = $theTagFormat; | ||||
446 | $line =~ s/\$tag/$tag/g; | ||||
447 | push @lines, $line if $line; | ||||
448 | } | ||||
449 | $tags = join( ', ', @lines ); | ||||
450 | } | ||||
451 | my $active = | ||||
452 | defined( $plugin->{isInit} ) | ||||
453 | ? '<span class="foswikiAlert">(active)</span>' | ||||
454 | : ''; | ||||
455 | my $line = Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( | ||||
456 | $theFormat, | ||||
457 | 'index' => ( $counter + 1 ), | ||||
458 | name => $plugin->{name}, | ||||
459 | version => $plugin->{version}, | ||||
460 | summary => $summary, | ||||
461 | documentation => $plugin->{documentation}, | ||||
462 | author => $plugin->{author}, | ||||
463 | homepage => $plugin->{homepage}, | ||||
464 | tags => $tags, | ||||
465 | active => $active, | ||||
466 | ); | ||||
467 | next unless $line; | ||||
468 | push @result, $line; | ||||
469 | $counter++; | ||||
470 | } | ||||
471 | |||||
472 | $theHeader = | ||||
473 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theHeader, | ||||
474 | counter => $counter, ); | ||||
475 | $theFooter = | ||||
476 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables( $theFooter, | ||||
477 | counter => $counter, ); | ||||
478 | $theSeparator = | ||||
479 | Foswiki::Plugins::JQueryPlugin::Plugins::expandVariables($theSeparator); | ||||
480 | |||||
481 | return $theHeader . join( $theSeparator, @result ) . $theFooter; | ||||
482 | } | ||||
483 | |||||
484 | sub _inlineError { | ||||
485 | my $msg = shift; | ||||
486 | return "<div class='foswikiAlert'>$msg</div>"; | ||||
487 | } | ||||
488 | |||||
489 | 1 | 4µs | 1; | ||
490 | __END__ |