Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fixes in language fallback for getFont

  • Loading branch information...
commit 3d36163996cf6a6f21257af5de4c29ccc565b638 1 parent 6d896b9
@santhoshtr santhoshtr authored
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/jquery.webfonts.js
View
20 src/jquery.webfonts.js
@@ -25,6 +25,7 @@
this.repository = $.extend(WebFonts.repository, this.options.repository);
this.fonts = [];
this.originalFontFamily = this.$element.css('font-family');
+ this.language = this.$element.attr('lang') || $('html').attr('lang');
this.init();
};
@@ -52,7 +53,7 @@
getFont: function(language){
if (this.options.fontSelector) {
- return this.options.fontSelector(this.repository, language);
+ return this.options.fontSelector(this.repository, language || this.language);
} else {
return this.repository.defaultFont(language);
}
@@ -62,10 +63,9 @@
* Initialize.
*/
init : function() {
- var language, fontFamily;
- language = this.$element.attr('lang') || $('html').attr('lang');
- if (language) {
- fontFamily = this.getFont(language);
+ var fontFamily;
+ if (this.language) {
+ fontFamily = this.getFont(this.language);
this.apply(fontFamily);
}
this.parse();
@@ -83,12 +83,12 @@
apply : function(fontFamily, $element) {
$element = $element || this.$element;
var fontStack = this.options.fontStack.slice(0);
- if (!fontFamily) {
- this.reset();
- return;
+ // Loading an empty string is pointless.
+ // Putting an empty string into a font-family list doesn't work with jQuery.css().
+ if ( fontFamily ) {
+ this.load(fontFamily);
+ fontStack.unshift(fontFamily);
}
- this.load(fontFamily);
- fontStack.unshift(fontFamily);
$element.css('font-family', fontStack.join() );
$element.find('textarea, input').css('font-family', fontStack.join());
},
Please sign in to comment.
Something went wrong with that request. Please try again.