From c4a2cb9231d146d22fd4b81f2e6213a1ff241c28 Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Thu, 17 Feb 2011 08:07:59 +0000 Subject: [PATCH] Item10357: only emit inline css when there's a foswikiTable on the current page git-svn-id: http://svn.foswiki.org/branches/Release01x01@10711 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- TablePlugin/data/System/TablePlugin.txt | 3 ++- TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm | 4 ++-- TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm | 12 +++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/TablePlugin/data/System/TablePlugin.txt b/TablePlugin/data/System/TablePlugin.txt index 0870a24f5f..38c9144b49 100644 --- a/TablePlugin/data/System/TablePlugin.txt +++ b/TablePlugin/data/System/TablePlugin.txt @@ -173,11 +173,12 @@ Sort icons in the header are read from System.DocumentGraphics. ---++ Plugin Info %TABLE{columnwidths="10%,90%"}% -| Copyright: | Copyright (C) 2001-2008 TWiki:Main/JohnTalintyre, Peter Thoeny, peter@thoeny.org and TWiki Contributors; © 2008-2010 Foswiki Contributors | +| Copyright: | Copyright (C) 2001-2008 TWiki:Main/JohnTalintyre, Peter Thoeny, peter@thoeny.org and TWiki Contributors; © 2008-2011 Foswiki Contributors | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Version: | %$VERSION% | | Release: | %$RELEASE% | | Change History: |   | +| 16 Feb 2011 | 1.127: Michael Daum: Foswikitask:Item10357: only emit inline css when there's a foswikiTable on the current page | | 18 Aug 2010 | 1.126: Paul harvey: Foswikitask:Item9415: minor documentation changes | | 09 Aug 2010 | 1.125: Crawford Currie: Foswikitask:Item8303: fixed sorting with multiple headers | | 31 Jul 2010 | 1.124: Arthur Clemens: Added attribute =inlinemarkup= to optionally add HTML markup for better copy/pasting. | diff --git a/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm b/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm index 78f1e3cec8..c3fbf14bb7 100644 --- a/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm +++ b/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm @@ -9,7 +9,7 @@ use strict; use warnings; our $VERSION = '$Rev$'; -our $RELEASE = '1.126'; +our $RELEASE = '1.127'; our $SHORTDESCRIPTION = 'Control attributes of tables and sorting of table columns'; our $NO_PREFS_IN_TOPIC = 1; @@ -208,7 +208,7 @@ sub debugData { __END__ Foswiki - The Free and Open Source Wiki, http://foswiki.org/ -Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors +Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors are listed in the AUTHORS file in the root of this distribution. NOTE: Please extend that file, not this notice. diff --git a/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm b/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm index adbc5c5664..29b29e93fb 100644 --- a/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm +++ b/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm @@ -18,6 +18,7 @@ my $defaultAttrs; # to write generic table CSS my $tableSpecificAttrs; # to write table specific table CSS my $combinedTableAttrs; # default and specific table attributes my $styles = {}; # hash of default and specific styles +my $doneDefaults = 0; # not yet refactored: my $tableCount; @@ -119,6 +120,7 @@ $TABLE_FRAME->{border} = 'border-style:solid'; BEGIN { $translationToken = "\0"; + $doneDefaults = 0; # the maximum number of columns we will handle $MAX_SORT_COLS = 10000; @@ -142,6 +144,12 @@ sub _initDefaults { %{Foswiki::Plugins::TablePlugin::pluginAttributes} ); $combinedTableAttrs = _mergeHashes( {}, $defaultAttrs ); +} + +sub _addDefaultStyles { + + return if $doneDefaults; + $doneDefaults = 1; # create CSS styles tables in general my ( $id, @styles ) = _createCssStyles( 1, $defaultAttrs ); @@ -1310,6 +1318,8 @@ sub addDefaultSizeUnit { sub emitTable { + _addDefaultStyles(); + _debug('emitTable'); #Validate headerrows/footerrows and modify if out of range @@ -1875,7 +1885,7 @@ sub _debugData { __END__ Foswiki - The Free and Open Source Wiki, http://foswiki.org/ -Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors +Copyright (C) 2008-2011 Foswiki Contributors. Foswiki Contributors are listed in the AUTHORS file in the root of this distribution. NOTE: Please extend that file, not this notice.