← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/local/src/github.com/foswiki/core/bin/view
  Run on Sun Dec 4 17:17:59 2011
Reported on Sun Dec 4 17:26:34 2011

Filename/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugins/TwistyPlugin.pm
StatementsExecuted 38 statements in 3.92ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111133µs1.04msFoswiki::Plugins::TwistyPlugin::::initPluginFoswiki::Plugins::TwistyPlugin::initPlugin
11139µs454µsFoswiki::Plugins::TwistyPlugin::::_exportAnimationSpeedFoswiki::Plugins::TwistyPlugin::_exportAnimationSpeed
11123µs23µsFoswiki::Plugins::TwistyPlugin::::BEGIN@12Foswiki::Plugins::TwistyPlugin::BEGIN@12
11122µs29µsFoswiki::Plugins::TwistyPlugin::::BEGIN@14Foswiki::Plugins::TwistyPlugin::BEGIN@14
11117µs278µsFoswiki::Plugins::TwistyPlugin::::BEGIN@17Foswiki::Plugins::TwistyPlugin::BEGIN@17
11116µs16µsFoswiki::Plugins::TwistyPlugin::::BEGIN@11Foswiki::Plugins::TwistyPlugin::BEGIN@11
11116µs34µsFoswiki::Plugins::TwistyPlugin::::BEGIN@15Foswiki::Plugins::TwistyPlugin::BEGIN@15
1119µs9µsFoswiki::Plugins::TwistyPlugin::::BEGIN@13Foswiki::Plugins::TwistyPlugin::BEGIN@13
0000s0sFoswiki::Plugins::TwistyPlugin::::_ENDTWISTYTOGGLEFoswiki::Plugins::TwistyPlugin::_ENDTWISTYTOGGLE
0000s0sFoswiki::Plugins::TwistyPlugin::::_TWISTYFoswiki::Plugins::TwistyPlugin::_TWISTY
0000s0sFoswiki::Plugins::TwistyPlugin::::_TWISTYBUTTONFoswiki::Plugins::TwistyPlugin::_TWISTYBUTTON
0000s0sFoswiki::Plugins::TwistyPlugin::::_TWISTYHIDEFoswiki::Plugins::TwistyPlugin::_TWISTYHIDE
0000s0sFoswiki::Plugins::TwistyPlugin::::_TWISTYSHOWFoswiki::Plugins::TwistyPlugin::_TWISTYSHOW
0000s0sFoswiki::Plugins::TwistyPlugin::::_TWISTYTOGGLEFoswiki::Plugins::TwistyPlugin::_TWISTYTOGGLE
0000s0sFoswiki::Plugins::TwistyPlugin::::_addHeaderFoswiki::Plugins::TwistyPlugin::_addHeader
0000s0sFoswiki::Plugins::TwistyPlugin::::_createHtmlPropertiesFoswiki::Plugins::TwistyPlugin::_createHtmlProperties
0000s0sFoswiki::Plugins::TwistyPlugin::::_createIdFoswiki::Plugins::TwistyPlugin::_createId
0000s0sFoswiki::Plugins::TwistyPlugin::::_readCookieFoswiki::Plugins::TwistyPlugin::_readCookie
0000s0sFoswiki::Plugins::TwistyPlugin::::_setDefaultsFoswiki::Plugins::TwistyPlugin::_setDefaults
0000s0sFoswiki::Plugins::TwistyPlugin::::_twistyBtnFoswiki::Plugins::TwistyPlugin::_twistyBtn
0000s0sFoswiki::Plugins::TwistyPlugin::::_wrapInButtonHtmlFoswiki::Plugins::TwistyPlugin::_wrapInButtonHtml
0000s0sFoswiki::Plugins::TwistyPlugin::::_wrapInContainerDivIfNoJavascripCloseFoswiki::Plugins::TwistyPlugin::_wrapInContainerDivIfNoJavascripClose
0000s0sFoswiki::Plugins::TwistyPlugin::::_wrapInContainerHideIfNoJavascripOpenFoswiki::Plugins::TwistyPlugin::_wrapInContainerHideIfNoJavascripOpen
0000s0sFoswiki::Plugins::TwistyPlugin::::_wrapInContentHtmlCloseFoswiki::Plugins::TwistyPlugin::_wrapInContentHtmlClose
0000s0sFoswiki::Plugins::TwistyPlugin::::_wrapInContentHtmlOpenFoswiki::Plugins::TwistyPlugin::_wrapInContentHtmlOpen
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# See bottom of file for license and copyright information
2
3=begin TML
4
5---+ package TwistyPlugin
6
7=cut
8
9package Foswiki::Plugins::TwistyPlugin;
10
11242µs116µs
# spent 16µs within Foswiki::Plugins::TwistyPlugin::BEGIN@11 which was called: # once (16µs+0s) by Foswiki::Plugin::BEGIN@2.19 at line 11
use Foswiki::Func ();
# spent 16µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@11
12254µs123µs
# spent 23µs within Foswiki::Plugins::TwistyPlugin::BEGIN@12 which was called: # once (23µs+0s) by Foswiki::Plugin::BEGIN@2.19 at line 12
use CGI::Cookie ();
# spent 23µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@12
13241µs19µs
# spent 9µs within Foswiki::Plugins::TwistyPlugin::BEGIN@13 which was called: # once (9µs+0s) by Foswiki::Plugin::BEGIN@2.19 at line 13
use CGI ();
# spent 9µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@13
14245µs236µs
# spent 29µs (22+7) within Foswiki::Plugins::TwistyPlugin::BEGIN@14 which was called: # once (22µs+7µs) by Foswiki::Plugin::BEGIN@2.19 at line 14
use strict;
# spent 29µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@14 # spent 7µs making 1 call to strict::import
15254µs253µs
# spent 34µs (16+18) within Foswiki::Plugins::TwistyPlugin::BEGIN@15 which was called: # once (16µs+18µs) by Foswiki::Plugin::BEGIN@2.19 at line 15
use warnings;
# spent 34µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@15 # spent 18µs making 1 call to warnings::import
16
171262µs
# spent 278µs (17+262) within Foswiki::Plugins::TwistyPlugin::BEGIN@17 which was called: # once (17µs+262µs) by Foswiki::Plugin::BEGIN@2.19 at line 18
use vars qw( @twistystack $doneHeader $doneDefaults $twistyCount
# spent 262µs making 1 call to vars::import
1823.51ms1278µs $prefMode $prefShowLink $prefHideLink $prefRemember);
# spent 278µs making 1 call to Foswiki::Plugins::TwistyPlugin::BEGIN@17
19
2012µsour $VERSION = '$Rev$';
21
2212µsour $RELEASE = '1.6.14';
2311µsour $SHORTDESCRIPTION =
24 'Twisty section Javascript library to open/close content dynamically';
2511µsour $NO_PREFS_IN_TOPIC = 1;
26
2712µsmy $TWISTYPLUGIN_COOKIE_PREFIX = "TwistyPlugin_";
2811µsmy $TWISTYPLUGIN_CONTENT_HIDDEN = 0;
2911µsmy $TWISTYPLUGIN_CONTENT_SHOWN = 1;
30
31#there is no need to document this.
32
# spent 1.04ms (133µs+910µs) within Foswiki::Plugins::TwistyPlugin::initPlugin which was called: # once (133µs+910µs) by Foswiki::Plugin::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm:235] at line 228 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Plugin.pm
sub initPlugin {
3315113µs my ( $topic, $web, $user, $installWeb ) = @_;
34
35 # check for Plugins.pm versions
36 if ( $Foswiki::Plugins::VERSION < 1.1 ) {
37 Foswiki::Func::writeWarning(
38 "Version mismatch between TwistyPlugin and Plugins.pm");
39 return 0;
40 }
41
42 $doneDefaults = 0;
43 $doneHeader = 0;
44 $twistyCount = 0;
45
461454µs _exportAnimationSpeed();
47
481107µs Foswiki::Plugins::JQueryPlugin::registerPlugin( 'twisty',
# spent 107µs making 1 call to Foswiki::Plugins::JQueryPlugin::registerPlugin
49 'Foswiki::Plugins::TwistyPlugin::TWISTY' );
50176µs Foswiki::Func::registerTagHandler( 'TWISTYSHOW', \&_TWISTYSHOW );
# spent 76µs making 1 call to Foswiki::Func::registerTagHandler
51147µs Foswiki::Func::registerTagHandler( 'TWISTYHIDE', \&_TWISTYHIDE );
# spent 47µs making 1 call to Foswiki::Func::registerTagHandler
52147µs Foswiki::Func::registerTagHandler( 'TWISTYBUTTON', \&_TWISTYBUTTON );
# spent 47µs making 1 call to Foswiki::Func::registerTagHandler
53145µs Foswiki::Func::registerTagHandler( 'TWISTY', \&_TWISTY );
# spent 45µs making 1 call to Foswiki::Func::registerTagHandler
54146µs Foswiki::Func::registerTagHandler( 'ENDTWISTY', \&_ENDTWISTYTOGGLE );
# spent 46µs making 1 call to Foswiki::Func::registerTagHandler
55144µs Foswiki::Func::registerTagHandler( 'TWISTYTOGGLE', \&_TWISTYTOGGLE );
# spent 44µs making 1 call to Foswiki::Func::registerTagHandler
56144µs Foswiki::Func::registerTagHandler( 'ENDTWISTYTOGGLE', \&_ENDTWISTYTOGGLE );
# spent 44µs making 1 call to Foswiki::Func::registerTagHandler
57
58 return 1;
59}
60
61
# spent 454µs (39+415) within Foswiki::Plugins::TwistyPlugin::_exportAnimationSpeed which was called: # once (39µs+415µs) by Foswiki::Plugins::TwistyPlugin::initPlugin at line 46
sub _exportAnimationSpeed {
62
63342µs2324µs my $pref =
# spent 197µs making 1 call to Foswiki::Func::getPluginPreferencesValue # spent 127µs making 1 call to Foswiki::Func::getPreferencesValue
64 Foswiki::Func::getPreferencesValue('TWISTYANIMATIONSPEED')
65 || Foswiki::Func::getPluginPreferencesValue('TWISTYANIMATIONSPEED')
66 || '0';
67
68 # add TWISTYANIMATIONSPEED to the html head so
69 # that it may be used in the client JS with
70 # foswiki.getPreference('TWISTYANIMATIONSPEED')
71191µs Foswiki::Func::addToZone( "head", "TWISTYPLUGIN::META", <<"HERE");
# spent 91µs making 1 call to Foswiki::Func::addToZone
72<meta name="foswiki.TWISTYANIMATIONSPEED" content="$pref" />
73HERE
74
75 return;
76}
77
78sub _setDefaults {
79 return if $doneDefaults;
80 $doneDefaults = 1;
81
82 $prefMode =
83 Foswiki::Func::getPreferencesValue('TWISTYMODE')
84 || Foswiki::Func::getPluginPreferencesValue('TWISTYMODE')
85 || 'div';
86 $prefShowLink =
87 Foswiki::Func::getPreferencesValue('TWISTYSHOWLINK')
88 || Foswiki::Func::getPluginPreferencesValue('TWISTYSHOWLINK')
89 || '%MAKETEXT{"More..."}%';
90 $prefHideLink =
91 Foswiki::Func::getPreferencesValue('TWISTYHIDELINK')
92 || Foswiki::Func::getPluginPreferencesValue('TWISTYHIDELINK')
93 || '%MAKETEXT{"Close"}%';
94 $prefRemember =
95 Foswiki::Func::getPreferencesValue('TWISTYREMEMBER')
96 || Foswiki::Func::getPluginPreferencesValue('TWISTYREMEMBER')
97 || '';
98
99 return;
100}
101
102sub _addHeader {
103 return if $doneHeader;
104 $doneHeader = 1;
105
106 if ( Foswiki::Func::getContext()->{JQueryPluginEnabled} ) {
107 Foswiki::Plugins::JQueryPlugin::createPlugin('twisty');
108 }
109 else {
110 my $header;
111 Foswiki::Func::loadTemplate('twistyplugin');
112
113 $header =
114 Foswiki::Func::expandTemplate("TwistyPlugin/twisty")
115 . Foswiki::Func::expandTemplate("TwistyPlugin/twisty.css");
116 Foswiki::Func::expandCommonVariables($header);
117 }
118
119 return;
120}
121
122sub _TWISTYSHOW {
123 my ( $session, $params, $theTopic, $theWeb ) = @_;
124 _setDefaults();
125
126 my $mode = $params->{'mode'} || $prefMode;
127 my $btn = _twistyBtn( 'show', $session, $params, $theTopic, $theWeb );
128 return Foswiki::Func::decodeFormatTokens(
129 _wrapInButtonHtml( $btn, $mode ) );
130}
131
132sub _TWISTYHIDE {
133 my ( $session, $params, $theTopic, $theWeb ) = @_;
134 _setDefaults();
135 my $mode = $params->{'mode'} || $prefMode;
136 my $btn = _twistyBtn( 'hide', $session, $params, $theTopic, $theWeb );
137 return Foswiki::Func::decodeFormatTokens(
138 _wrapInButtonHtml( $btn, $mode ) );
139}
140
141sub _TWISTYBUTTON {
142 my ( $session, $params, $theTopic, $theWeb ) = @_;
143 _setDefaults();
144
145 my $mode = $params->{'mode'} || $prefMode;
146 my $btnShow = _twistyBtn( 'show', $session, $params, $theTopic, $theWeb );
147 my $btnHide = _twistyBtn( 'hide', $session, $params, $theTopic, $theWeb );
148 my $prefix = $params->{'prefix'} || '';
149 my $suffix = $params->{'suffix'} || '';
150 my $btn = $prefix . $btnShow . $btnHide . $suffix;
151 return Foswiki::Func::decodeFormatTokens(
152 _wrapInButtonHtml( $btn, $mode ) );
153}
154
155=pod
156
157If no ID is passed, creates a new unique id based on web and topic.
158
159=cut
160
161sub _TWISTY {
162 my ( $session, $params, $theTopic, $theWeb ) = @_;
163
164 _addHeader();
165 $params->{'id'} = _createId( $params, $theWeb, $theTopic );
166 return _TWISTYBUTTON( $session, $params, $theTopic, $theWeb )
167 . _TWISTYTOGGLE( $session, $params, $theTopic, $theWeb );
168}
169
170sub _TWISTYTOGGLE {
171 my ( $session, $params, $theTopic, $theWeb ) = @_;
172 my $id = $params->{'id'};
173 if ( !defined $id || $id eq '' ) {
174 return '';
175 }
176 _setDefaults();
177 my $idTag = $id . 'toggle';
178 my $mode = $params->{'mode'} || $prefMode;
179 push( @twistystack, { mode => $mode, id => $idTag } );
180
181 my $isTrigger = 0;
182 my $cookieState = _readCookie( $session, $idTag );
183 my @propList =
184 _createHtmlProperties( undef, $idTag, $mode, $params, $isTrigger,
185 $cookieState );
186 my $props = @propList ? " " . join( " ", @propList ) : '';
187 my $modeTag = '<' . $mode . $props . '>';
188 return Foswiki::Func::decodeFormatTokens(
189 _wrapInContentHtmlOpen($mode) . $modeTag );
190}
191
192sub _ENDTWISTYTOGGLE {
193 my ( $session, $params, $theTopic, $theWeb ) = @_;
194 my $twisty = pop @twistystack;
195
196 return
197"<div class='foswikiAlert'>woops, ordering error: got an ENDTWISTY before seeing a TWISTY</div>"
198 unless $twisty->{mode};
199
200 my $modeTag = ( $twisty->{mode} ) ? '</' . $twisty->{mode} . '>' : '';
201 return $modeTag . _wrapInContentHtmlClose($twisty);
202}
203
204sub _createId {
205 my ( $params, $inWeb, $inTopic ) = @_;
206
207 my $id = $params->{'id'} || "twistyId$inWeb$inTopic";
208 $id =~ s/\//subweb/go;
209
210 # Ensure uniqueness, or at least try to
211 my $remember = $params->{'remember'} || $prefRemember;
212 if ( Foswiki::Func::isTrue($remember) ) {
213 $id .= ++$twistyCount; # For remember
214 }
215 else { # 100 is the number of remembered cookies to avoid clashes
216 $id .= int( rand(10000) ) + 100; # For AJAX
217 }
218 return $id;
219}
220
221sub _twistyBtn {
222 my ( $twistyControlState, $session, $params, $theTopic, $theWeb ) = @_;
223
224 _addHeader();
225
226 # not used yet:
227 #my $triangle_right = '&#9658;';
228 #my $triangle_down = '&#9660;';
229
230 my $id = $params->{'id'};
231 if ( !defined $id || $id eq '' ) {
232 return '';
233 }
234 my $idTag;
235 if ($twistyControlState) {
236 $idTag = $id . $twistyControlState;
237 }
238 else {
239 $idTag = '';
240 }
241
242 my $defaultLink =
243 ( $twistyControlState eq 'show' ) ? $prefShowLink : $prefHideLink;
244
245 # link="" takes precedence over showlink="" and hidelink=""
246 my $link = $params->{'link'};
247
248 if ( !defined $link ) {
249
250 # if 'link' is not set, try 'showlink' / 'hidelink'
251 $link = $params->{ $twistyControlState . 'link' };
252 }
253 if ( !defined $link ) {
254 $link = $defaultLink || '';
255 }
256 my $img =
257 $params->{ $twistyControlState . 'img' }
258 || $params->{'img'}
259 || '';
260 my $imgright =
261 $params->{ $twistyControlState . 'imgright' }
262 || $params->{'imgright'}
263 || '';
264 my $imgleft =
265 $params->{ $twistyControlState . 'imgleft' }
266 || $params->{'imgleft'}
267 || '';
268 $img =~ s/['\"]//go;
269 $imgright =~ s/['\"]//go;
270 $imgleft =~ s/['\"]//go;
271 my $imgTag =
272 ( $img ne '' ) ? '<img src="' . $img . '" border="0" alt="" />' : '';
273 my $imgRightTag =
274 ( $imgright ne '' )
275 ? '<img src="' . $imgright . '" border="0" alt="" />'
276 : '';
277 my $imgLeftTag =
278 ( $imgleft ne '' )
279 ? '<img src="' . $imgleft . '" border="0" alt="" />'
280 : '';
281
282 my @linkClasses;
283 push( @linkClasses, $params->{'linkclass'} ) if $params->{'linkclass'};
284
285 my $imgLinkTag = CGI::a(
286 {
287 href => '#',
288 class => join( ' ', @linkClasses )
289 },
290 $imgLeftTag
291 . CGI::span( { class => 'foswikiLinkLabel foswikiUnvisited' }, $link )
292 . $imgTag
293 . $imgRightTag
294 );
295
296 my $isTrigger = 1;
297 my $props = '';
298
299 if ( $idTag && $params ) {
300 my $cookieState = _readCookie( $session, $idTag );
301 my @propList =
302 _createHtmlProperties( $twistyControlState, $idTag, undef, $params,
303 $isTrigger, $cookieState );
304 $props = @propList ? " " . join( " ", @propList ) : '';
305 }
306 my $triggerTag = '<span' . $props . '>' . $imgLinkTag . '</span>';
307 return $triggerTag;
308}
309
310sub _createHtmlProperties {
311 my ( $twistyControlState, $idTag, $mode, $params, $isTrigger, $cookie ) =
312 @_;
313 my $class = $params->{'class'} || '';
314 my $firststart = $params->{'firststart'} || '';
315 my $firstStartHidden;
316 $firstStartHidden = 1 if ( $firststart eq 'hide' );
317 my $firstStartShown;
318 $firstStartShown = 1 if ( $firststart eq 'show' );
319 my $cookieShow;
320 $cookieShow = 1 if defined $cookie && $cookie == 1;
321 my $cookieHide;
322 $cookieHide = 1 if defined $cookie && $cookie == 0;
323 my $start = $params->{start} || '';
324 my $startHidden;
325 $startHidden = 1 if ( $start eq 'hide' );
326 my $startShown;
327 $startShown = 1 if ( $start eq 'show' );
328 my @propList = ();
329
330 _setDefaults();
331 my $remember = $params->{'remember'} || $prefRemember;
332 my $noscript = $params->{'noscript'} || '';
333 my $noscriptHide = ( $noscript eq 'hide' ) ? 1 : 0;
334 $mode ||= $prefMode;
335
336 my @classList = ();
337 my @styleList = ();
338 push( @classList, $class ) if $class && !$isTrigger;
339 push( @classList, 'twistyRememberSetting' )
340 if Foswiki::Func::isTrue($remember);
341 push( @classList, 'twistyForgetSetting' ) if $remember eq 'off';
342 push( @classList, 'twistyStartHide' ) if $startHidden;
343 push( @classList, 'twistyStartShow' ) if $startShown;
344 push( @classList, 'twistyFirstStartHide' ) if $firstStartHidden;
345 push( @classList, 'twistyFirstStartShow' ) if $firstStartShown;
346
347 # Mimic the rules in twist.js, function _update()
348 my $state = '';
349 $state = $TWISTYPLUGIN_CONTENT_HIDDEN if $firstStartHidden;
350 $state = $TWISTYPLUGIN_CONTENT_SHOWN if $firstStartShown;
351
352 # cookie setting may override firstStartHidden and firstStartShown
353 $state = $TWISTYPLUGIN_CONTENT_HIDDEN if $cookieHide;
354 $state = $TWISTYPLUGIN_CONTENT_SHOWN if $cookieShow;
355
356 # startHidden and startShown may override cookie
357 $state = $TWISTYPLUGIN_CONTENT_HIDDEN if $startHidden;
358 $state = $TWISTYPLUGIN_CONTENT_SHOWN if $startShown;
359
360 # assume trigger should be hidden
361 # unless explicitly said otherwise
362 my $shouldHideTrigger = 1;
363 if ($isTrigger) {
364 push( @classList, 'twistyTrigger foswikiUnvisited' );
365
366 if ( $state eq $TWISTYPLUGIN_CONTENT_SHOWN
367 && $twistyControlState eq 'hide' )
368 {
369 $shouldHideTrigger = 0;
370 }
371 if ( $state eq $TWISTYPLUGIN_CONTENT_HIDDEN
372 && $twistyControlState eq 'show' )
373 {
374 $shouldHideTrigger = 0;
375 }
376 push( @styleList, 'display:none' ) if $shouldHideTrigger;
377 }
378
379 # assume content should be hidden
380 # unless explicitly said otherwise
381 if ( !$isTrigger ) {
382 push( @classList, 'twistyContent' );
383 }
384
385 # deprecated
386 # should be done by Foswiki template scripts instead
387 if ( !$isTrigger && $noscriptHide ) {
388 push( @classList, 'foswikiMakeVisible' );
389 }
390
391 # let javascript know we have set the state already
392 push( @classList, 'twistyInited' . $state );
393
394 push( @propList, 'id="' . $idTag . '"' );
395
396 my $styleListString = join( ", ", @styleList );
397 push( @propList, 'style="' . $styleListString . '"' );
398
399 my $classListString = join( " ", @classList );
400 push( @propList, 'class="' . $classListString . '"' );
401
402 return @propList;
403}
404
405=begin TML
406
407Reads a setting from the FOSWIKIPREF cookie.
408Returns:
409 * 1 if the cookie has been set (meaning: show content)
410 * 0 if the cookie is '0' (meaning: hide content)
411 * undef if no cookie has been set
412
413=cut
414
415sub _readCookie {
416 my ( $session, $idTag ) = @_;
417
418 return '' if !$idTag;
419
420 # which state do we use?
421 my $cgi = CGI->new();
422 my $cookie = $cgi->cookie('FOSWIKIPREF');
423 my $tag = $idTag;
424 $tag =~ s/^(.*)(hide|show|toggle)$/$1/go;
425 my $key = $TWISTYPLUGIN_COOKIE_PREFIX . $tag;
426
427 return unless ( defined($key) && defined($cookie) );
428
429 my $value = '';
430 if ( $cookie =~ m/\b\Q$key=\E(.+?)\b/gi ) {
431 $value = $1;
432 }
433
434 return if $value eq '';
435 return ( $value eq '1' ) ? 1 : 0;
436}
437
438sub _wrapInButtonHtml {
439 my ( $text, $mode ) = @_;
440 return _wrapInContainerHideIfNoJavascripOpen($mode) . $text
441 . _wrapInContainerDivIfNoJavascripClose($mode);
442}
443
444sub _wrapInContentHtmlOpen {
445 my ($mode) = @_;
446 return "<$mode class=\"twistyPlugin\">";
447}
448
449sub _wrapInContentHtmlClose {
450 my ($twisty) = @_;
451 my $closeTag = "</$twisty->{mode}>";
452
453 return $closeTag;
454}
455
456sub _wrapInContainerHideIfNoJavascripOpen {
457 my ($mode) = @_;
458
459 return '<' . $mode . ' class="twistyPlugin foswikiMakeVisible">';
460}
461
462sub _wrapInContainerDivIfNoJavascripClose {
463 my ($mode) = @_;
464
465 return '</' . $mode . '>';
466}
467
46818µs1;
469__END__