From 33293c9b486bc8bfeefa7cae8042876987342f25 Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Sun, 4 Sep 2011 21:50:02 +0000 Subject: [PATCH] * Mark underline css as !important. It should override other css (such as the css added in r91432) if the user specifically selected that option. * Fix css flipping: for Simple, it still depended on the content language (however, no css actually needs flipping there). For Standard/CologneBlue, I re-added flipping even though it's not needed there either. Just in case css is added that does need flipping, so it is future-proof :). Consequently, I added noflip to the existing css. * For this flipping I added a parameter to addInlineStyle(), which I assume to be useful in other cases as well --- includes/OutputPage.php | 7 ++++- .../ResourceLoaderUserOptionsModule.php | 2 +- skins/CologneBlue.php | 26 +++++++++---------- skins/Simple.php | 9 +++---- skins/Standard.php | 18 ++++++------- 5 files changed, 32 insertions(+), 30 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b4f56b510b..5b0070c925 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2949,8 +2949,13 @@ $distantTemplates /** * Adds inline CSS styles * @param $style_css Mixed: inline CSS + * @param $flip Boolean: Whether to flip the CSS if needed */ - public function addInlineStyle( $style_css ){ + public function addInlineStyle( $style_css, $flip = false ) { + if( $flip && $this->getLang()->isRTL() ) { + # If wanted, and the interface is right-to-left, flip the CSS + $style_css = CSSJanus::transform( $style_css, true, false ); + } $this->mInlineStyles .= Html::inlineStyle( $style_css ); } diff --git a/includes/resourceloader/ResourceLoaderUserOptionsModule.php b/includes/resourceloader/ResourceLoaderUserOptionsModule.php index 1989353b79..2f639066e2 100644 --- a/includes/resourceloader/ResourceLoaderUserOptionsModule.php +++ b/includes/resourceloader/ResourceLoaderUserOptionsModule.php @@ -97,7 +97,7 @@ class ResourceLoaderUserOptionsModule extends ResourceLoaderModule { // Underline: 2 = browser default, 1 = always, 0 = never if ( $options['underline'] < 2 ) { $rules[] = "a { text-decoration: " . - ( $options['underline'] ? 'underline' : 'none' ) . "; }"; + ( $options['underline'] ? 'underline' : 'none' ) . " !important; }"; } if ( $options['highlightbroken'] ) { $rules[] = "a.new, #quickbar a.new { color: #ba0000; }\n"; diff --git a/skins/CologneBlue.php b/skins/CologneBlue.php index 808ed37465..66255ad3c4 100644 --- a/skins/CologneBlue.php +++ b/skins/CologneBlue.php @@ -30,24 +30,24 @@ class SkinCologneBlue extends SkinLegacy { $rules = array(); if ( 2 == $qb ) { # Right - $rules[] = "#quickbar { position: absolute; right: 4px; }"; - $rules[] = "#article { margin-left: 4px; margin-right: 148px; }"; + $rules[] = "/* @noflip */#quickbar { position: absolute; right: 4px; }"; + $rules[] = "/* @noflip */#article { margin-left: 4px; margin-right: 148px; }"; } elseif ( 1 == $qb ) { - $rules[] = "#quickbar { position: absolute; left: 4px; }"; - $rules[] = "#article { margin-left: 148px; margin-right: 4px; }"; + $rules[] = "/* @noflip */#quickbar { position: absolute; left: 4px; }"; + $rules[] = "/* @noflip */#article { margin-left: 148px; margin-right: 4px; }"; } elseif ( 3 == $qb ) { # Floating left - $rules[] = "#quickbar { position:absolute; left:4px }"; - $rules[] = "#topbar { margin-left: 148px }"; - $rules[] = "#article { margin-left:148px; margin-right: 4px; }"; - $rules[] = "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;}"; # Hides from IE + $rules[] = "/* @noflip */#quickbar { position:absolute; left:4px }"; + $rules[] = "/* @noflip */#topbar { margin-left: 148px }"; + $rules[] = "/* @noflip */#article { margin-left:148px; margin-right: 4px; }"; + $rules[] = "/* @noflip */body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto; bottom:4px;}"; # Hides from IE } elseif ( 4 == $qb ) { # Floating right - $rules[] = "#quickbar { position: fixed; right: 4px; }"; - $rules[] = "#topbar { margin-right: 148px }"; - $rules[] = "#article { margin-right: 148px; margin-left: 4px; }"; - $rules[] = "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;}"; # Hides from IE + $rules[] = "/* @noflip */#quickbar { position: fixed; right: 4px; }"; + $rules[] = "/* @noflip */#topbar { margin-right: 148px }"; + $rules[] = "/* @noflip */#article { margin-right: 148px; margin-left: 4px; }"; + $rules[] = "/* @noflip */body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto; bottom:4px;}"; # Hides from IE } $style = implode( "\n", $rules ); - $out->addInlineStyle( $style ); + $out->addInlineStyle( $style, /* flip css if RTL */true ); } } diff --git a/skins/Simple.php b/skins/Simple.php index 06443772ae..ad0dbb03c1 100644 --- a/skins/Simple.php +++ b/skins/Simple.php @@ -30,12 +30,12 @@ class SkinSimple extends SkinTemplate { $out->addModuleStyles( 'skins.simple' ); /* Add some userprefs specific CSS styling */ - global $wgUser, $wgContLang; + global $wgUser; $rules = array(); $underline = ""; if ( $wgUser->getOption( 'underline' ) < 2 ) { - $underline = "text-decoration: " . $wgUser->getOption( 'underline' ) ? 'underline' : 'none' . ";"; + $underline = "text-decoration: " . $wgUser->getOption( 'underline' ) ? 'underline' : 'none' . " !important;"; } /* Also inherits from resourceloader */ @@ -45,10 +45,7 @@ class SkinSimple extends SkinTemplate { $rules[] = "a.stub:after { $underline; }"; } $style = implode( "\n", $rules ); - if ( $wgContLang->getDir() === 'rtl' ) { - $style = CSSJanus::transform( $style, true, false ); - } - $out->addInlineStyle( $style ); + $out->addInlineStyle( $style, /* flip css if RTL */true ); } } diff --git a/skins/Standard.php b/skins/Standard.php index 322f7b2b1d..53b1d63a98 100644 --- a/skins/Standard.php +++ b/skins/Standard.php @@ -29,21 +29,21 @@ class SkinStandard extends SkinLegacy { $rules = array(); if ( 2 == $qb ) { # Right - $rules[] = "#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }"; - $rules[] = "#article, #mw-data-after-content { margin-left: 4px; margin-right: 152px; }"; + $rules[] = "/* @noflip */#quickbar { position: absolute; top: 4px; right: 4px; border-left: 2px solid #000000; }"; + $rules[] = "/* @noflip */#article, /* @noflip */#mw-data-after-content { margin-left: 4px; margin-right: 152px; }"; } elseif ( 1 == $qb || 3 == $qb ) { - $rules[] = "#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }"; - $rules[] = "#article, #mw-data-after-content { margin-left: 152px; margin-right: 4px; }"; + $rules[] = "/* @noflip */#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }"; + $rules[] = "/* @noflip */#article, /* @noflip */#mw-data-after-content { margin-left: 152px; margin-right: 4px; }"; if( 3 == $qb ) { - $rules[] = "#quickbar { position: fixed; padding: 4px; }"; + $rules[] = "/* @noflip */#quickbar { position: fixed; padding: 4px; }"; } } elseif ( 4 == $qb ) { - $rules[] = "#quickbar { position: fixed; right: 0px; top: 0px; padding: 4px;}"; - $rules[] = "#quickbar { border-right: 1px solid gray; }"; - $rules[] = "#article, #mw-data-after-content { margin-right: 152px; margin-left: 4px; }"; + $rules[] = "/* @noflip */#quickbar { position: fixed; right: 0px; top: 0px; padding: 4px;}"; + $rules[] = "/* @noflip */#quickbar { border-right: 1px solid gray; }"; + $rules[] = "/* @noflip */#article, /* @noflip */#mw-data-after-content { margin-right: 152px; margin-left: 4px; }"; } $style = implode( "\n", $rules ); - $out->addInlineStyle( $style ); + $out->addInlineStyle( $style, /* flip css if RTL */true ); } } -- 2.20.1