Index: trunk/extensions/WebFonts/js/webfonts.js |
— | — | @@ -50,6 +50,9 @@ |
51 | 51 | } |
52 | 52 | //set the font option in cookie |
53 | 53 | $.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(); |
54 | 57 | }, |
55 | 58 | |
56 | 59 | /** |
— | — | @@ -64,6 +67,11 @@ |
65 | 68 | //we need to reset the fonts of Input and Select explicitly. |
66 | 69 | $("input").css('font-family', $.webfonts.oldconfig["font-family"]); |
67 | 70 | $("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 | + |
68 | 76 | //remove the cookie |
69 | 77 | $.cookie( 'webfonts-font', 'none', { 'path': '/', 'expires': 30 } ); |
70 | 78 | }, |
— | — | @@ -186,7 +194,11 @@ |
187 | 195 | |
188 | 196 | $.webfonts.loadFontsForFontFamilyStyle(); |
189 | 197 | $.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 | + } |
191 | 203 | }, |
192 | 204 | |
193 | 205 | /** |
— | — | @@ -199,7 +211,7 @@ |
200 | 212 | $('body').find('*[lang]').each(function(index) { |
201 | 213 | //check the availability of font. |
202 | 214 | //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" ) ) { |
204 | 216 | fontFamily = languages[this.lang][0]; |
205 | 217 | $.webfonts.addFont( fontFamily ); |
206 | 218 | $(this).css('font-family', fontFamily); |
— | — | @@ -259,6 +271,13 @@ |
260 | 272 | $fontsMenu.append($fontMenuItem); |
261 | 273 | |
262 | 274 | } |
| 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 | + |
263 | 282 | var $resetLink = $( '<input />' ) |
264 | 283 | .attr("type","radio") |
265 | 284 | .attr("name","font") |
— | — | @@ -278,10 +297,6 @@ |
279 | 298 | .append( $resetLabel ); |
280 | 299 | |
281 | 300 | $fontsMenu.append($resetLinkItem); |
282 | | - if ( !haveSchemes ) { |
283 | | - // No schemes available, don't show the tool |
284 | | - return; |
285 | | - } |
286 | 301 | |
287 | 302 | var $menuDiv = $( '<div />' ).attr('id','webfonts-fonts') |
288 | 303 | .addClass( 'menu' ) |