From 3c27771b28ffc693e784c8646100764108ed82fa Mon Sep 17 00:00:00 2001 From: Jesse Hallett Date: Tue, 10 Dec 2013 13:56:28 -0800 Subject: Adds exceptions to color rule for standard link styles --- guidelines/wikipedia/color.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/guidelines/wikipedia/color.js b/guidelines/wikipedia/color.js index 2ff1f42..cc9fe75 100644 --- a/guidelines/wikipedia/color.js +++ b/guidelines/wikipedia/color.js @@ -12,6 +12,7 @@ exports.rule = function (report) { var $this = $(this); return $this.children().length == 0 && $.trim($this.text()).length > 0; }) + .filter(exceptions) .each(function (i) { var fg = fc.colorToRGB($(this).css('color')); var bg = fc.findBGColor($(this)); @@ -27,5 +28,24 @@ exports.rule = function (report) { } } }); - }; + +function exceptions() { + var $elem = $(this); + return !isStandardLink($elem) && + !isNavboxLink($elem); +} + +function isStandardLink($elem) { + var standard = ['new', 'external', 'extiw']; + var $a = $elem.closest('a'); + return $a.is('a') && standard.some(function(klass) { + return $a.hasClass(klass); + }); +} + +function isNavboxLink($elem) { + var $a = $elem.closest('a'); + var $nav = $a.closest('th.navbox-group'); + return $a.length > 0 && $nav.length > 0; +} -- cgit v1.2.3