aboutsummaryrefslogtreecommitdiff
path: root/guidelines/wikipedia/color.js
diff options
context:
space:
mode:
authorGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
committerGravatar Rogan Creswick <creswick@gmail.com>2013-12-19 13:31:29 -0800
commitaa2a7b34b64be8daf1a9d50f589563275284d50e (patch)
treeda898aabcbca0191a57140e635e167b88aaa84e0 /guidelines/wikipedia/color.js
parent3b53cef842cf0288ad55fe55ae2f578f75b40ae7 (diff)
parent15a644f91a8b6e80bbd24a824b91c24547b80035 (diff)
merge
Diffstat (limited to 'guidelines/wikipedia/color.js')
-rw-r--r--guidelines/wikipedia/color.js27
1 files changed, 24 insertions, 3 deletions
diff --git a/guidelines/wikipedia/color.js b/guidelines/wikipedia/color.js
index 13c5422..045a8ac 100644
--- a/guidelines/wikipedia/color.js
+++ b/guidelines/wikipedia/color.js
@@ -52,9 +52,10 @@ exports.rule = function (report) {
var $this = $(this);
return $this.children().length == 0 && $.trim($this.text()).length > 0;
})
- .each(function (i,elt) {
- var fg = fc.colorToRGB($(elt).css('color'));
- var bg = fc.findBGColor($(elt));
+ .filter(exceptions)
+ .each(function (i) {
+ var fg = fc.colorToRGB($(this).css('color'));
+ var bg = fc.findBGColor($(this));
if (fg && bg) {
var ratio = fc.contrast(fc.luminance(fg), fc.luminance(bg));
console.log("comparing witch ratio" + ratio);
@@ -68,3 +69,23 @@ 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;
+}