Skip to content

Commit

Permalink
Item14845: don't apply colors on empty text
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jul 1, 2019
1 parent f8ff08c commit ffa5f34
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,4 +9,6 @@ igp_*
/JQAutoColorContrib.zip
/JQAutoColorContrib_installer
/JQAutoColorContrib_installer.pl
pub/System/JQAutoColorContrib/autocolor.css
pub/System/JQAutoColorContrib/autocolor.js
pub/System/JQAutoColorContrib/*jslint
19 changes: 10 additions & 9 deletions data/System/JQAutoColorContrib.txt
@@ -1,6 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1522237725" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" comment="" date="1561969171" format="1.1" version="1"}%
---+!! %TOPIC%
%$SHORTDESCRIPTION%
%FORMFIELD{"Description"}%

%TOC%

Expand Down Expand Up @@ -153,17 +153,18 @@ Use HTML5 data parameters to specify parameters to the autoColor plugin. All par
---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 01 Jul 2019 | skip auto-color if text is empty |
| 28 Mar 2018 | initial release |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Michael Daum"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Description" title="Description" value=""}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25$ROOTMODULE%25"}%
%META:FIELD{name="Copyright" title="Copyright" value="2018, MichaelDaum, All Rights Reserved"}%
%META:FIELD{name="Description" title="Description" value="%25$SHORTDESCRIPTION%25"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/JQAutoColorContrib"}%
%META:FIELD{name="Copyright" title="Copyright" value="2018-2019, Michael Daum, All Rights Reserved"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%25$ROOTMODULE%25"}%
%META:FILEATTACHMENT{name="example1.png" attachment="examples.png" attr="" comment="" date="1522229792" size="41482" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="example2.png" attachment="example2.png" attr="" comment="" date="1522237538" size="30362" user="ProjectContributor" version="1"}%
%META:FIELD{name="Home" title="Home" value="https://foswiki.org/Extensions/JQAutoColorContrib"}%
%META:FIELD{name="Support" title="Support" value="https://foswiki.org/Support/JQAutoColorContrib"}%
%META:FILEATTACHMENT{name="example1.png" attachment="examples.png" attr="" comment="" date="1561969171" size="41482" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="example2.png" attachment="example2.png" attr="" comment="" date="1561969171" size="30362" user="ProjectContributor" version="1"}%
6 changes: 3 additions & 3 deletions lib/Foswiki/Contrib/JQAutoColorContrib.pm
@@ -1,6 +1,6 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# JQAutoColorContrib is Copyright (C) 2018 Michael Daum http://michaeldaumconsulting.com
# JQAutoColorContrib is Copyright (C) 2018-2019 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,8 +20,8 @@ use warnings;

use Foswiki::Func ();

our $VERSION = '1.00';
our $RELEASE = '28 Mar 2018';
our $VERSION = '1.01';
our $RELEASE = '01 Jul 2019';
our $SHORTDESCRIPTION = 'Assign colors automatically based on text properties';
our $NO_PREFS_IN_TOPIC = 1;

Expand Down
5 changes: 3 additions & 2 deletions lib/Foswiki/Contrib/JQAutoColorContrib/Core.pm
@@ -1,6 +1,6 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# JQAutoColorContrib is Copyright (C) 2018 Michael Daum http://michaeldaumconsulting.com
# JQAutoColorContrib is Copyright (C) 2018-2019 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -35,9 +35,10 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'AutoColor',
version => '1.00',
version => '1.01',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQAutoColorContrib',
css => ['autocolor.css'],
javascript => ['autocolor.js'],
puburl => '%PUBURLPATH%/%SYSTEMWEB%/JQAutoColorContrib',
dependencies => ['livequery'],
Expand Down
4 changes: 0 additions & 4 deletions lib/Foswiki/Contrib/JQAutoColorContrib/DEPENDENCIES
@@ -1,4 +0,0 @@
# Dependencies for JQAutoColorContrib
# Example:
# Time::ParseDate,>=2003.0211,cpan,Required.
# Foswiki::Plugins,>=1.2,perl,Requires version 1.2 of handler API.
3 changes: 3 additions & 0 deletions lib/Foswiki/Contrib/JQAutoColorContrib/MANIFEST
Expand Up @@ -4,8 +4,11 @@ lib/Foswiki/Contrib/JQAutoColorContrib/Config.spec 0644
lib/Foswiki/Contrib/JQAutoColorContrib/Core.pm 0644
lib/Foswiki/Contrib/JQAutoColorContrib/DEPENDENCIES 0644
lib/Foswiki/Contrib/JQAutoColorContrib.pm 0644
pub/System/JQAutoColorContrib/autocolor.css 0644
pub/System/JQAutoColorContrib/autocolor.css.gz 0644
pub/System/JQAutoColorContrib/autocolor.js 0644
pub/System/JQAutoColorContrib/autocolor.js.gz 0644
pub/System/JQAutoColorContrib/autocolor.uncompressed.css 0644
pub/System/JQAutoColorContrib/autocolor.uncompressed.js 0644
pub/System/JQAutoColorContrib/example1.png 0644
pub/System/JQAutoColorContrib/example2.png 0644
Expand Down
2 changes: 1 addition & 1 deletion pub/System/JQAutoColorContrib/Makefile
@@ -1,5 +1,5 @@
FOSWIKI_ROOT?=~/foswiki/core
TARGET=autocolor.js
TARGET=autocolor.js autocolor.css

-include $(FOSWIKI_ROOT)/pub/System/JQueryPlugin/Makefile.include

Expand Down
3 changes: 3 additions & 0 deletions pub/System/JQAutoColorContrib/autocolor.uncompressed.css
@@ -0,0 +1,3 @@
.jqAutoColor > a {
color:inherit;
}
14 changes: 9 additions & 5 deletions pub/System/JQAutoColorContrib/autocolor.uncompressed.js
@@ -1,11 +1,9 @@
/*
* jQuery auto-color plugin 1.00
* jQuery auto-color plugin 1.01
*
* Copyright (c) 2018 Michael Daum http://michaeldaumconsulting.com
* Copyright (c) 2018-2019 Michael Daum http://michaeldaumconsulting.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Licensed under the GPL license http://www.gnu.org/licenses/gpl.html
*
*/

Expand Down Expand Up @@ -68,6 +66,11 @@
}

text = text.replace(/^\s*|\s*$/g, "");

if (!text.length) {
return;
}

hsl = self.formatHSL(self.getHSL(text));

//console.log("text=",text,"hash=",self.getHash(text),"hue=",self.getHue(self.getHash(text)));
Expand All @@ -76,6 +79,7 @@
self.target.css(self.opts.property, hsl);
} else {
self.target
.addClass("jqAutoColor")
.css("background", hsl)
.css("color", self.getMatchingForeground());
}
Expand Down

0 comments on commit ffa5f34

Please sign in to comment.