Sha256: 338ff697ecd736f8edfd20957e06d951c26d6dd345c4122c357b703538105c19
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
/** * @constructor */ webfont.FontApiUrlBuilder = function(apiUrl) { if (apiUrl) { this.apiUrl_ = apiUrl; } else { var protocol = 'https:' == window.location.protocol ? 'https:' : 'http:'; this.apiUrl_ = protocol + webfont.FontApiUrlBuilder.DEFAULT_API_URL; } this.fontFamilies_ = null; }; webfont.FontApiUrlBuilder.DEFAULT_API_URL = '//fonts.googleapis.com/css'; webfont.FontApiUrlBuilder.prototype.setFontFamilies = function(fontFamilies) { // maybe clone? this.fontFamilies_ = fontFamilies; }; webfont.FontApiUrlBuilder.prototype.webSafe = function(string) { return string.replace(/ /g, '+'); }; webfont.FontApiUrlBuilder.prototype.build = function() { if (!this.fontFamilies_) { throw new Error('No fonts to load !'); } if (this.apiUrl_.indexOf("kit=") != -1) { return this.apiUrl_; } var length = this.fontFamilies_.length; var sb = []; for (var i = 0; i < length; i++) { sb.push(this.webSafe(this.fontFamilies_[i])); } var url = this.apiUrl_ + '?family=' + sb.join('%7C'); // '|' escaped. return url; };
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
webfontloader-1.0.16 | src/google/fontapiurlbuilder.js |
webfontloader-1.0.15 | src/google/fontapiurlbuilder.js |
webfontloader-1.0.13 | src/google/fontapiurlbuilder.js |