Permalink
Browse files

Item9422: Convert to a JQueryPlugin::Plugin implementation

- Renamed js files to be consistent with other jquery plugins
- Removed (now redundant) template DEFs
- Removed dependency on foswikiPref, prematurely, next commit addresses this
- Depend on JQueryPlugin instead of Behaviour (which is now optional)

git-svn-id: http://svn.foswiki.org/trunk@8501 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
PaulHarvey PaulHarvey
PaulHarvey authored and PaulHarvey committed Aug 15, 2010
1 parent 98591ca commit 4f227d05438999b61ead5cf950426138e726eb35
@@ -485,6 +485,7 @@ You can override some default settings in the plugin by setting the following [[
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; |
| 15 Aug 2010 | 1.6.0 Foswiki:Tasks.Item9422: Implement as JQueryPlugin::Plugin; emit =display: none= style on hidden twisties to avoid relying on CSS/JS |
| 27 Jul 2010 | 1.5.6 Foswiki:Tasks.Item9387: Fixed jQuery JS |
| 13 Mar 2010 | 1.5.5 Fixed id generated in subwebs. |
| 12 Feb 2010 | 1.5.4 Fixed jquery twisties, improved templates structure |
@@ -18,7 +18,7 @@ use vars qw( @modes $doneHeader $doneDefaults $twistyCount
our $VERSION = '$Rev$';
our $RELEASE = '1.5.8';
our $RELEASE = '1.6.0';
our $SHORTDESCRIPTION =
'Twisty section Javascript library to open/close content dynamically';
our $NO_PREFS_IN_TOPIC = 1;
@@ -42,6 +42,8 @@ sub initPlugin {
$doneHeader = 0;
$twistyCount = 0;
Foswiki::Plugins::JQueryPlugin::registerPlugin('twisty',
'Foswiki::Plugins::TwistyPlugin::TWISTY');
Foswiki::Func::registerTagHandler( 'TWISTYSHOW', \&_TWISTYSHOW );
Foswiki::Func::registerTagHandler( 'TWISTYHIDE', \&_TWISTYHIDE );
Foswiki::Func::registerTagHandler( 'TWISTYBUTTON', \&_TWISTYBUTTON );
@@ -80,16 +82,18 @@ sub _addHeader {
return if $doneHeader;
$doneHeader = 1;
Foswiki::Func::loadTemplate( 'twistyplugin' );
my $lib = '';
if (Foswiki::Func::getContext()->{JQueryPluginEnabled}) {
$lib = '.jquery';
Foswiki::Plugins::JQueryPlugin::createPlugin('twisty');
} else {
my $header;
Foswiki::Func::loadTemplate( 'twistyplugin' );
$header = Foswiki::Func::expandTemplate("TwistyPlugin/twisty")
. Foswiki::Func::expandTemplate("TwistyPlugin/twisty.css");
Foswiki::Func::expandCommonVariables($header);
}
my $header = Foswiki::Func::expandTemplate("TwistyPlugin/twisty$lib")
. Foswiki::Func::expandTemplate("TwistyPlugin/twisty$lib.css");
return Foswiki::Func::expandCommonVariables($header);
return;
}
sub _TWISTYSHOW {
@@ -283,6 +287,7 @@ sub _createHtmlProperties {
$startHidden = 1 if ( $start eq 'hide' );
my $startShown;
$startShown = 1 if ( $start eq 'show' );
my @propList = ();
_setDefaults();
my $remember = $params->{'remember'} || $prefRemember;
@@ -334,14 +339,13 @@ sub _createHtmlProperties {
# assume content should be hidden
# unless explicitly said otherwise
my $shouldHideContent = 1;
if ( !$isTrigger ) {
push( @classList, 'twistyContent' );
if ( $state eq $TWISTYPLUGIN_CONTENT_SHOWN ) {
$shouldHideContent = 0;
if ( not ($state eq $TWISTYPLUGIN_CONTENT_SHOWN) ) {
push( @propList, 'style="display: none;"' );
push( @classList, 'foswikiMakeHidden' );
}
push( @classList, 'foswikiMakeHidden' ) if $shouldHideContent;
}
# deprecated
@@ -358,7 +362,6 @@ sub _createHtmlProperties {
# let javascript know we have set the state already
push( @classList, 'twistyInited' . $state );
my @propList = ();
push( @propList, 'id="' . $idTag . '"' );
my $classListString = join( " ", @classList );
push( @propList, 'class="' . $classListString . '"' );
@@ -1,16 +1,17 @@
data/System/TwistyPlugin.txt 0644
data/System/VarTWISTY.txt 0644
lib/Foswiki/Plugins/TwistyPlugin.pm 0444
lib/Foswiki/Plugins/TwistyPlugin/TWISTY.pm 0444
pub/System/TwistyPlugin/twisty.js 0644
pub/System/TwistyPlugin/twisty.js.gz 0644
pub/System/TwistyPlugin/twisty.uncompressed.js 0644
pub/System/TwistyPlugin/twisty.css 0644
pub/System/TwistyPlugin/twisty.css.gz 0644
pub/System/TwistyPlugin/twisty.uncompressed.css 0644
pub/System/TwistyPlugin/twisty.jquery.css 0644
pub/System/TwistyPlugin/twisty.jquery.css.gz 0644
pub/System/TwistyPlugin/twisty.jquery.uncompressed.css 0644
pub/System/TwistyPlugin/twisty.jquery.js 0644
pub/System/TwistyPlugin/twisty.jquery.js.gz 0644
pub/System/TwistyPlugin/twisty.jquery.uncompressed.js 0644
pub/System/TwistyPlugin/jquery.twisty.css 0644
pub/System/TwistyPlugin/jquery.twisty.css.gz 0644
pub/System/TwistyPlugin/jquery.twisty.uncompressed.css 0644
pub/System/TwistyPlugin/jquery.twisty.js 0644
pub/System/TwistyPlugin/jquery.twisty.js.gz 0644
pub/System/TwistyPlugin/jquery.twisty.uncompressed.js 0644
templates/twistyplugin.tmpl 0444
@@ -0,0 +1,66 @@
# See bottom of file for license and copyright information
package Foswiki::Plugins::TwistyPlugin::TWISTY;
use strict;
use warnings;
use Foswiki::Plugins::JQueryPlugin::Plugin;
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );
=begin TML
---+ package Foswiki::Plugins::JQueryPlugin::TWISTY
This is the perl stub for the jquery.twisty plugin.
=cut
=begin TML
---++ ClassMethod new( $class, $session, ... )
Constructor
=cut
sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;
my $this = bless(
$class->SUPER::new(
$session,
name => 'Twisty',
version => '1.6.0',
author => 'Rafael Alvarez, Michael Daum, Arthur Clemens',
homepage => 'http://foswiki.org/Extensions/TwistyPlugin',
puburl => '%PUBURLPATH%/%SYSTEMWEB%/TwistyPlugin',
javascript => ['jquery.twisty.js'],
css => ['jquery.twisty.css']
),
$class
);
return $this;
}
1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Additional copyrights apply to some or all of the code in this
file as follows:
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
@@ -15,20 +15,3 @@
}%%TMPL:P{"LIBJS" id="TwistyPlugin/twisty" requires="JavascriptFiles/foswikilib,JavascriptFiles/foswikiPref,JavascriptFiles/foswikiCSS"}%
%TMPL:END%
%TMPL:DEF{"TwistyPlugin/twisty.jquery"}%
%TMPL:P{"JavascriptFiles/foswikiPref"}%%{
}%%ADDTOZONE{
"body"
tag="TwistyPlugin/twisty"
text="<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/TwistyPlugin/twisty.jquery%FWUNCOMPRESSED%.js'></script>"
requires="JavascriptFiles/foswikiPref,JQUERYPLUGIN::FOSWIKI"}%
%TMPL:END%
%TMPL:DEF{"TwistyPlugin/twisty.jquery.css"}%
%ADDTOZONE{
"head"
tag="TwistyPlugin/twisty.css"
text="<link rel='stylesheet' type='text/css' media='all' href='%PUBURL%/%SYSTEMWEB%/TwistyPlugin/twisty%FWUNCOMPRESSED%.css' />"
}%
%TMPL:END%
Oops, something went wrong.

0 comments on commit 4f227d0

Please sign in to comment.