Sha256: df99af1508d675400d2cbbe31d491101b34ad459e23c6d2708de81139b6dbcc9

Contents?: true

Size: 1.58 KB

Versions: 19

Compression:

Stored size: 1.58 KB

Contents

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

goog.require('webfont.Font');
goog.require('webfont.StyleSheetWaiter');

/**
 *
 * 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,
      StyleSheetWaiter = webfont.StyleSheetWaiter;

  Custom.prototype.load = function(onReady) {
    var i, len;
    var urls = this.configuration_['urls'] || [];
    var familiesConfiguration = this.configuration_['families'] || [];
    var fontTestStrings = this.configuration_['testStrings'] || {};
    var waiter = new StyleSheetWaiter();
    for (i = 0, len = urls.length; i < len; i++) {
      this.domHelper_.loadStylesheet(urls[i], waiter.startWaitingLoad());
    }

    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]));
      }
    }

    waiter.waitWhileNeededThen(function() {
      onReady(fonts, fontTestStrings);
    });
  };
});

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
webfontloader-1.6.27 src/modules/custom.js
webfontloader-1.6.26 src/modules/custom.js
webfontloader-1.6.25 src/modules/custom.js
webfontloader-1.6.24 src/modules/custom.js
webfontloader-1.6.23 src/modules/custom.js
webfontloader-1.6.22 src/modules/custom.js
webfontloader-1.6.21 src/modules/custom.js
webfontloader-1.6.20 src/modules/custom.js
webfontloader-1.6.19 src/modules/custom.js
webfontloader-1.6.18 src/modules/custom.js
webfontloader-1.6.16 src/modules/custom.js
webfontloader-1.6.15 src/modules/custom.js
webfontloader-1.6.14 src/modules/custom.js
webfontloader-1.6.13 src/modules/custom.js
webfontloader-1.6.12 src/modules/custom.js
webfontloader-1.6.11 src/modules/custom.js
webfontloader-1.6.10 src/modules/custom.js
webfontloader-1.6.9 src/modules/custom.js
webfontloader-1.6.8 src/modules/custom.js