Start on some cleanup of how CSS stylesheets are loaded. Initially addressing…


Start on some cleanup of how CSS stylesheets are loaded. Initially addressing only the SkinTemplate-based skins; would like to rip out some near-dupe code in the other skin types, with a little more refactoring...

  • A skin can make calls to $this->addScript to much more cleanly list which style sheets it wants to load, for which media variants and which IE conditional versions. This replaces the 'cssfiles' array hack and giant pile of ugly conditionals in MonoBook's template.
  • 'printable=yes' and 'handheld=yes' URL options are handled transparently -- 'screen' stylesheets are hidden, while those with no media specifier are left.

MediaWiki:Common.css is now listed without media -- so infoboxes are still formatted -- while the skin-specific eg MediaWiki:Monobook.css are listed for screen, as they're specific to the on-screen skin.

Note it should be a matter of one line of code to add a MediaWiki:Print.css and have it correctly handled now.

  • All sheets are now loaded via <link rel="stylesheet"> instead of a mix of those and @import decls.

IIRC we had used @import originally to hide styles from Netscape 4, which tends to utterly break on MonoBook, but these days that's pretty much a non-issue.
@import also breaks some browsers' ability to save stylesheets with a file to disk, which sucks.

Confirmed that Firefox 3 can now save pages with their styles.

  • 'screen, projection' media specifier has been changed to just 'screen' -- projection is something totally different.
  • Added experimental options for specifying handheld stylesheets:


  • Optionally, we can specify a stylesheet to use for media="handheld".
  • This is recognized by some, but not all, handheld/mobile/PDA browsers.
  • If left empty, compliant handheld browsers won't pick up the skin
  • stylesheet, which is specified for 'screen' media. *
  • Can be a complete URL, base-relative path, or $wgStylePath-relative path.
  • Try 'chick/main.css' to apply the Chick styles to the MonoBook HTML. *
  • Will also be switched in when 'handheld=yes' is added to the URL, like
  • the 'printable=yes' mode for print media. */

$wgHandheldStyle = false;


  • If set, 'screen' and 'handheld' media specifiers for stylesheets are
  • transformed such that they apply to the iPhone/iPod Touch Mobile Safari,
  • which doesn't recognize 'handheld' but does support media queries on its
  • screen size. *
  • Consider only using this if you have a *really good* handheld stylesheet,
  • as iPhone users won't have any way to disable it and use the "grown-up"
  • styles instead. */

$wgHandheldForIPhone = false;


brionAuthored on
rSVN38115: Update the Chinese conversion tables