aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jesse Hallett <jesse@galois.com>2013-12-10 13:56:28 -0800
committerGravatar Jesse Hallett <jesse@galois.com>2013-12-10 13:56:28 -0800
commit3c27771b28ffc693e784c8646100764108ed82fa (patch)
tree24103f793544382943c014f2951ce0b528f0a3ac
parent3432b9c8cfd59d15dbc1d013f0f850b0c242e2b0 (diff)
Adds exceptions to color rule for standard link styles
-rw-r--r--guidelines/wikipedia/color.js22
1 files changed, 21 insertions, 1 deletions
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;
+}