Skip to content

Commit

Permalink
Item9597: added backwards compatibility of JQuerPlugin for foswiki en…
Browse files Browse the repository at this point in the history
…gines < 1.1

git-svn-id: http://svn.foswiki.org/branches/Release01x01@9304 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Sep 22, 2010
1 parent 86cf936 commit a5e5019
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
36 changes: 23 additions & 13 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
Expand Up @@ -3,6 +3,7 @@ package Foswiki::Plugins::JQueryPlugin::FOSWIKI;
use strict;
use warnings;
use Foswiki::Func;
use Foswiki::Plugins;
use Foswiki::Plugins::JQueryPlugin::Plugin;
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

Expand Down Expand Up @@ -33,7 +34,8 @@ sub new {
version => '2.01',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
dependencies => ['livequery'],
javascript => ['jquery.foswiki.js'],
dependencies => ['JQUERYPLUGIN', 'livequery'],
tags => 'JQTHEME, JQREQUIRE, JQICON, JQICONPATH, JQPLUGINS',
),
$class
Expand All @@ -55,21 +57,29 @@ sub init {

return unless $this->SUPER::init();

my $js = 'jquery.foswiki';
$js .= '.uncompressed' if $this->{debug};
$js .= '.js?version=' . $this->{version};
# get exported prefs
my $prefs = Foswiki::Func::getPreferencesValue('EXPORTEDPREFERENCES') || '';

# Not used
#my $header = '';
#Foswiki::Func::addToZone('head', 'JQUERYPLUGIN::FOSWIKI',
# $header, 'JQUERYPLUGIN');
# try a little harder for foswiki engines < 1.1
if ($Foswiki::Plugins::VERSION < 2.1) {

my $footer = <<FOOTER;
<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/foswiki/$js'></script>
FOOTER
# defaults since foswiki >= 1.1.0
$prefs = 'PUBURL, PUBURLPATH, SCRIPTSUFFIX, SCRIPTURL, SCRIPTURLPATH, SERVERTIME, SKIN, SYSTEMWEB, TOPIC, USERNAME, USERSWEB, WEB, WIKINAME, WIKIUSERNAME, NAMEFILTER';
$prefs .= ', TWISTYANIMATIONSPEED' if $Foswiki::cfg{Plugins}{TwistyPlugin}{Enabled}; # can't use context during init
}

Foswiki::Func::addToZone( 'script', 'JQUERYPLUGIN::FOSWIKI', $footer,
'JQUERYPLUGIN' );
# init NAMEFILTER
unless(Foswiki::Func::getPreferencesValue('NAMEFILTER')) {
Foswiki::Func::setPreferencesValue('NAMEFILTER', $Foswiki::cfg{NameFilter});
}

# add exported preferences to head
my $text = '';
foreach my $pref (split(/\s*,\s*/, $prefs)) {
$text .= '<meta name="foswiki.'.$pref.'" content="%ENCODE{"%'.$pref.'%"}%" />'." <!-- $pref -->\n";
}

Foswiki::Func::addToZone("head", "JQUERYPLUGIN::FOSWIKI::META", $text);
}

1;
Expand Down
5 changes: 2 additions & 3 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm
Expand Up @@ -96,10 +96,9 @@ sub init {
}

# gather dependencies
my @dependencies =
('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default
my @dependencies = ('JQUERYPLUGIN::FOSWIKI'); # jquery.foswiki is in there by default
foreach my $dep ( @{ $this->{dependencies} } ) {
if ( $dep =~ /^JQUERYPLUGIN/ ) {
if ( $dep =~ /^(JQUERYPLUGIN|JavascriptFiles)/ ) { # SMELL: there are some jquery modules that depend on non-jquery code
push @dependencies, $dep;
}
else {
Expand Down

0 comments on commit a5e5019

Please sign in to comment.