Sha256: 89496cd16e8aeead6a54bc4a02f2f69ec9b5543deba1e06ef74e91b151149a87

Contents?: true

Size: 1.51 KB

Versions: 22

Compression:

Stored size: 1.51 KB

Contents

goog.provide('webfont.modules.Custom');

goog.require('webfont.Font');

/**
 *
 * WebFont.load({
 *   custom: {
 *     families: ['Font1', 'Font2'],
 *    urls: [ 'http://moo', 'http://meuh' ] }
 * });
 *
 * @constructor
 * @implements {webfont.FontModule}
 */
webfont.modules.Custom = function(domHelper, configuration) {
  this.domHelper_ = domHelper;
  this.configuration_ = configuration;
};

/**
 * @const
 * @type {string}
 */
webfont.modules.Custom.NAME = 'custom';

goog.scope(function () {
  var Custom = webfont.modules.Custom,
      Font = webfont.Font;

  Custom.prototype.load = function(onReady) {
    var i, len;
    var urls = this.configuration_['urls'] || [];
    var familiesConfiguration = this.configuration_['families'] || [];
    var fontTestStrings = this.configuration_['testStrings'] || {};

    for (i = 0, len = urls.length; i < len; i++) {
      this.domHelper_.loadStylesheet(urls[i]);
    }

    var fonts = [];

    for (i = 0, len = familiesConfiguration.length; i < len; i++) {
      var components = familiesConfiguration[i].split(":");

      if (components[1]) {
        var variations = components[1].split(",");

        for (var j = 0; j < variations.length; j += 1) {
          fonts.push(new Font(components[0], variations[j]));
        }
      } else {
        fonts.push(new Font(components[0]));
      }
    }

    onReady(fonts, fontTestStrings);
  };

  Custom.prototype.supportUserAgent = function(userAgent, support) {
    return support(userAgent.getBrowserInfo().hasWebFontSupport());
  };
});

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
webfontloader-1.5.21 src/modules/custom.js
webfontloader-1.5.20 src/modules/custom.js
webfontloader-1.5.19 src/modules/custom.js
webfontloader-1.5.18 src/modules/custom.js
webfontloader-1.5.17 src/modules/custom.js
webfontloader-1.5.16 src/modules/custom.js
webfontloader-1.5.15 src/modules/custom.js
webfontloader-1.5.14 src/modules/custom.js
webfontloader-1.5.13 src/modules/custom.js
webfontloader-1.5.12 src/modules/custom.js
webfontloader-1.5.11 src/modules/custom.js
webfontloader-1.5.10 src/modules/custom.js
webfontloader-1.5.9 src/modules/custom.js
webfontloader-1.5.8 src/modules/custom.js
webfontloader-1.5.7 src/modules/custom.js
webfontloader-1.5.6 src/modules/custom.js
webfontloader-1.5.5 src/modules/custom.js
webfontloader-1.5.4 src/modules/custom.js
webfontloader-1.5.3 src/modules/custom.js
webfontloader-1.5.2 src/modules/custom.js