From dfc40c8f59ca428c9c672a8c8ee9d6f36076a6c0 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Wed, 6 Nov 2013 20:51:26 +0530 Subject: [PATCH] Refactor the css for interlanguage links and autonym class Move it to a seperate css file ext.uls.webfonts.css so that the RL modules are more granular and clear. Also get the @font-face css for Autonym font get ready on page load so that the font applied automatically to any future elements on page. Change-Id: Icb76df5baedaba8ab613d665a1be923779a6b9e7 --- Resources.php | 1 + resources/css/ext.uls.css | 6 ------ resources/css/ext.uls.webfonts.css | 4 ++++ resources/js/ext.uls.webfonts.js | 7 +++++++ 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 resources/css/ext.uls.webfonts.css diff --git a/Resources.php b/Resources.php index f5d4d99c..3b82f814 100644 --- a/Resources.php +++ b/Resources.php @@ -139,6 +139,7 @@ $wgResourceModules['ext.uls.preferences'] = array( $wgResourceModules['ext.uls.webfonts'] = array( 'scripts' => 'resources/js/ext.uls.webfonts.js', + 'styles' => 'resources/css/ext.uls.webfonts.css', 'dependencies' => array( 'jquery.webfonts', 'ext.uls.init', diff --git a/resources/css/ext.uls.css b/resources/css/ext.uls.css index 812865cb..7eaac41a 100644 --- a/resources/css/ext.uls.css +++ b/resources/css/ext.uls.css @@ -136,9 +136,3 @@ div.display-settings-block:hover .settings-text { .ime-checked .ime-perime-help:hover { opacity: 1; } - -/* Interlanguage links */ -#p-lang ul, -.autonym { - font-family: 'Autonym', sans-serif; -} diff --git a/resources/css/ext.uls.webfonts.css b/resources/css/ext.uls.webfonts.css new file mode 100644 index 00000000..07c78082 --- /dev/null +++ b/resources/css/ext.uls.webfonts.css @@ -0,0 +1,4 @@ +#p-lang ul,/* Interlanguage links */ +.autonym { /* provide autonym class for simplifying the Autonym font usage */ + font-family: 'Autonym', sans-serif; +} diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js index 91b240b9..0ea538ed 100644 --- a/resources/js/ext.uls.webfonts.js +++ b/resources/js/ext.uls.webfonts.js @@ -83,6 +83,13 @@ }() ) } ); $( 'body' ).webfonts(); + // Load the css required for Autonym font. Note that this wont download the font. + // Browsers are smart enough to delay it till some element with this font-family + // become visible. For eg: If there is a popup div with an element with class + // 'autonym', without explicitly calling .webfonts() on it, Autonym font will not + // be applied in general. But we ensure that css is ready so that automatically + // the font get applied to such future elements. + $( 'body' ).data( 'webfonts' ).load( 'Autonym' ); }; $( document ).ready( function () {