Dbrant has submitted this change and it was merged.
Change subject: Remove inline colors from within tables in night mode
......................................................................
Remove inline colors from within tables in night mode
Change-Id: Ie14ea00b01bb8d9ef48f03e897f20e3823ae04fb
---
M wikipedia/assets/bundle.js
M wikipedia/assets/preview.js
M www/js/night.js
3 files changed, 54 insertions(+), 3 deletions(-)
Approvals:
Dbrant: Looks good to me, approved
jenkins-bot: Verified
diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js
index 4a8a7ef..1817830 100644
--- a/wikipedia/assets/bundle.js
+++ b/wikipedia/assets/bundle.js
@@ -217,11 +217,28 @@
el.style[propertyName] = 'rgb(' + (255 - r) + ', ' + (255 - g) + ', ' +
(255 - b ) + ')';
}
+function hasAncestor( el, tagName ) {
+ if ( el.tagName === tagName) {
+ return true;
+ } else {
+ if ( el.parentNode !== null && el.parentNode.tagName !== 'BODY'
) {
+ return hasAncestor( el.parentNode, tagName );
+ } else {
+ return false;
+ }
+ }
+}
+
var invertProperties = [ 'color', 'background-color', 'border-color' ];
function invertOneElement( el ) {
+ var shouldStrip = hasAncestor( el, 'TABLE' );
for ( var i = 0; i < invertProperties.length; i++ ) {
if ( el.style[invertProperties[i]] ) {
- invertColorProperty( el, invertProperties[i] );
+ if ( shouldStrip ) {
+ el.style[invertProperties[i]] = 'inherit';
+ } else {
+ invertColorProperty( el, invertProperties[i] );
+ }
}
}
}
diff --git a/wikipedia/assets/preview.js b/wikipedia/assets/preview.js
index 7bcd926..83fd816 100644
--- a/wikipedia/assets/preview.js
+++ b/wikipedia/assets/preview.js
@@ -141,11 +141,28 @@
el.style[propertyName] = 'rgb(' + (255 - r) + ', ' + (255 - g) + ', ' +
(255 - b ) + ')';
}
+function hasAncestor( el, tagName ) {
+ if ( el.tagName === tagName) {
+ return true;
+ } else {
+ if ( el.parentNode !== null && el.parentNode.tagName !== 'BODY'
) {
+ return hasAncestor( el.parentNode, tagName );
+ } else {
+ return false;
+ }
+ }
+}
+
var invertProperties = [ 'color', 'background-color', 'border-color' ];
function invertOneElement( el ) {
+ var shouldStrip = hasAncestor( el, 'TABLE' );
for ( var i = 0; i < invertProperties.length; i++ ) {
if ( el.style[invertProperties[i]] ) {
- invertColorProperty( el, invertProperties[i] );
+ if ( shouldStrip ) {
+ el.style[invertProperties[i]] = 'inherit';
+ } else {
+ invertColorProperty( el, invertProperties[i] );
+ }
}
}
}
diff --git a/www/js/night.js b/www/js/night.js
index c51c89e..e898007 100644
--- a/www/js/night.js
+++ b/www/js/night.js
@@ -14,11 +14,28 @@
el.style[propertyName] = 'rgb(' + (255 - r) + ', ' + (255 - g) + ', ' +
(255 - b ) + ')';
}
+function hasAncestor( el, tagName ) {
+ if ( el.tagName === tagName) {
+ return true;
+ } else {
+ if ( el.parentNode !== null && el.parentNode.tagName !== 'BODY'
) {
+ return hasAncestor( el.parentNode, tagName );
+ } else {
+ return false;
+ }
+ }
+}
+
var invertProperties = [ 'color', 'background-color', 'border-color' ];
function invertOneElement( el ) {
+ var shouldStrip = hasAncestor( el, 'TABLE' );
for ( var i = 0; i < invertProperties.length; i++ ) {
if ( el.style[invertProperties[i]] ) {
- invertColorProperty( el, invertProperties[i] );
+ if ( shouldStrip ) {
+ el.style[invertProperties[i]] = 'inherit';
+ } else {
+ invertColorProperty( el, invertProperties[i] );
+ }
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/148047
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie14ea00b01bb8d9ef48f03e897f20e3823ae04fb
Gerrit-PatchSet: 4
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits