r100688 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100687‎ | r100688 | r100689 >
Date:11:18, 25 October 2011
Author:santhosh
Status:ok
Tags:
Comment:
Reset the fonts for the tags with lang attribute for which we loaded fonts.
Show the reset option, even if there is no fonts to show, but page has tags with lang attr based font embedding.

Mingle card #122
Modified paths:
  • /trunk/extensions/WebFonts/js/webfonts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WebFonts/js/webfonts.js
@@ -50,6 +50,9 @@
5151 }
5252 //set the font option in cookie
5353 $.cookie( 'webfonts-font', font, { 'path': '/', 'expires': 30 } );
 54+
 55+ // If we had reset the fonts for tags with lang attribute, apply the fonts again.
 56+ $.webfonts.loadFontsForLangAttr();
5457 },
5558
5659 /**
@@ -64,6 +67,11 @@
6568 //we need to reset the fonts of Input and Select explicitly.
6669 $("input").css('font-family', $.webfonts.oldconfig["font-family"]);
6770 $("select").css('font-family', $.webfonts.oldconfig["font-family"]);
 71+
 72+ // Reset the fonts applied for tags with lang attribute.
 73+ $(".webfonts-lang-attr").css( 'font-family', 'none' );
 74+ $(".webfonts-lang-attr").removeClass( 'webfonts-lang-attr' );
 75+
6876 //remove the cookie
6977 $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } );
7078 },
@@ -186,7 +194,11 @@
187195
188196 $.webfonts.loadFontsForFontFamilyStyle();
189197 $.webfonts.loadFontsForLangAttr();
190 -
 198+ if ( $(".webfonts-lang-attr").length && !$( '#webfonts-fontsmenu' ).length ){
 199+ // We need to show the reset option even if there is no font to show
 200+ // for the language, if there is lang attr based font embedding.
 201+ $.webfonts.buildMenu(config);
 202+ }
191203 },
192204
193205 /**
@@ -199,7 +211,7 @@
200212 $('body').find('*[lang]').each(function(index) {
201213 //check the availability of font.
202214 //add a font-family style if it does not have any
203 - if( languages[this.lang] && !this.style.fontFamily ) {
 215+ if( languages[this.lang] && ( !this.style.fontFamily || this.style.fontFamily == "none" ) ) {
204216 fontFamily = languages[this.lang][0];
205217 $.webfonts.addFont( fontFamily );
206218 $(this).css('font-family', fontFamily);
@@ -259,6 +271,13 @@
260272 $fontsMenu.append($fontMenuItem);
261273
262274 }
 275+
 276+ if ( !haveSchemes && !$('.webfonts-lang-attr').length ) {
 277+ // No schemes available, and no tags with lang attr
 278+ // with fonts loaded. Don't show the menu.
 279+ return;
 280+ }
 281+
263282 var $resetLink = $( '<input />' )
264283 .attr("type","radio")
265284 .attr("name","font")
@@ -278,10 +297,6 @@
279298 .append( $resetLabel );
280299
281300 $fontsMenu.append($resetLinkItem);
282 - if ( !haveSchemes ) {
283 - // No schemes available, don't show the tool
284 - return;
285 - }
286301
287302 var $menuDiv = $( '<div />' ).attr('id','webfonts-fonts')
288303 .addClass( 'menu' )

Status & tagging log