webfontloader 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG +5 -0
  2. data/Rakefile +2 -1
  3. data/lib/webfontloader.rb +1 -1
  4. data/spec/core/font_spec.js +9 -4
  5. data/spec/core/fontruler_spec.js +3 -10
  6. data/spec/core/fontwatcher_spec.js +22 -23
  7. data/spec/core/fontwatchrunner_spec.js +206 -231
  8. data/spec/deps.js +27 -0
  9. data/spec/google/lastresortwebkitfontwatchrunner_spec.js +47 -58
  10. data/spec/index.html +14 -25
  11. data/src/ascender/ascender_script.js +52 -45
  12. data/src/core/browserinfo.js +54 -47
  13. data/src/core/cssclassname.js +27 -22
  14. data/src/core/cssfontfamilyname.js +23 -17
  15. data/src/core/domhelper.js +209 -203
  16. data/src/core/eventdispatcher.js +111 -103
  17. data/src/core/font.js +110 -68
  18. data/src/core/fontmoduleloader.js +56 -13
  19. data/src/core/fontruler.js +52 -43
  20. data/src/core/fontvariationdescription.js +82 -76
  21. data/src/core/fontwatcher.js +93 -88
  22. data/src/core/fontwatchrunner.js +161 -161
  23. data/src/core/initialize.js +22 -15
  24. data/src/core/namespace.js +0 -29
  25. data/src/core/size.js +31 -25
  26. data/src/core/useragent.js +63 -48
  27. data/src/core/useragentparser.js +317 -306
  28. data/src/custom/customcss.js +31 -24
  29. data/src/fontdeck/fontdeck_script.js +46 -37
  30. data/src/google/fontapiparser.js +105 -97
  31. data/src/google/fontapiurlbuilder.js +46 -41
  32. data/src/google/googlefontapi.js +48 -32
  33. data/src/google/lastresortwebkitfontwatchrunner.js +80 -67
  34. data/src/modules.yml +6 -6
  35. data/src/monotype/monotype_script.js +47 -40
  36. data/src/typekit/typekit_script.js +41 -35
  37. data/tools/compiler/base.js +1548 -0
  38. data/tools/compiler/compiler.jar +0 -0
  39. data/webfontloader.gemspec +4 -2
  40. metadata +18 -16
@@ -1,3 +1,7 @@
1
+ goog.provide('webfont.EventDispatcher');
2
+
3
+ goog.require('webfont.CssClassName');
4
+
1
5
  /**
2
6
  * A class to dispatch events and manage the event class names on an html
3
7
  * element that represent the current state of fonts on the page. Active class
@@ -49,115 +53,119 @@ webfont.EventDispatcher.INACTIVE = 'inactive';
49
53
  */
50
54
  webfont.EventDispatcher.FONT = 'font';
51
55
 
52
- /**
53
- * Dispatch the loading event and append the loading class name.
54
- */
55
- webfont.EventDispatcher.prototype.dispatchLoading = function() {
56
- this.domHelper_.appendClassName(this.htmlElement_,
57
- this.cssClassName_.build(
58
- this.namespace_, webfont.EventDispatcher.LOADING));
59
- this.dispatch_(webfont.EventDispatcher.LOADING);
60
- };
61
-
62
- /**
63
- * Dispatch the font loading event and append the font loading class name.
64
- * @param {string} fontFamily
65
- * @param {string} fontDescription
66
- */
67
- webfont.EventDispatcher.prototype.dispatchFontLoading = function(fontFamily, fontDescription) {
68
- this.domHelper_.appendClassName(this.htmlElement_,
69
- this.cssClassName_.build(
70
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
71
- this.dispatch_(
72
- webfont.EventDispatcher.FONT + webfont.EventDispatcher.LOADING, fontFamily, fontDescription);
73
- };
56
+ goog.scope(function () {
57
+ var EventDispatcher = webfont.EventDispatcher;
74
58
 
75
- /**
76
- * Dispatch the font active event, remove the font loading class name, remove
77
- * the font inactive class name, and append the font active class name.
78
- * @param {string} fontFamily
79
- * @param {string} fontDescription
80
- */
81
- webfont.EventDispatcher.prototype.dispatchFontActive = function(fontFamily, fontDescription) {
82
- this.domHelper_.removeClassName(this.htmlElement_,
83
- this.cssClassName_.build(
84
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
85
- this.domHelper_.removeClassName(this.htmlElement_,
86
- this.cssClassName_.build(
87
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.INACTIVE));
88
- this.domHelper_.appendClassName(this.htmlElement_,
89
- this.cssClassName_.build(
90
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.ACTIVE));
91
- this.dispatch_(
92
- webfont.EventDispatcher.FONT + webfont.EventDispatcher.ACTIVE, fontFamily, fontDescription);
93
- };
59
+ /**
60
+ * Dispatch the loading event and append the loading class name.
61
+ */
62
+ EventDispatcher.prototype.dispatchLoading = function() {
63
+ this.domHelper_.appendClassName(this.htmlElement_,
64
+ this.cssClassName_.build(
65
+ this.namespace_, webfont.EventDispatcher.LOADING));
66
+ this.dispatch_(webfont.EventDispatcher.LOADING);
67
+ };
94
68
 
95
- /**
96
- * Dispatch the font inactive event, remove the font loading class name, and
97
- * append the font inactive class name (unless the font active class name is
98
- * already present).
99
- * @param {string} fontFamily
100
- * @param {string} fontDescription
101
- */
102
- webfont.EventDispatcher.prototype.dispatchFontInactive = function(fontFamily, fontDescription) {
103
- this.domHelper_.removeClassName(this.htmlElement_,
104
- this.cssClassName_.build(
105
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
106
- var hasFontActive = this.domHelper_.hasClassName(this.htmlElement_,
107
- this.cssClassName_.build(
108
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.ACTIVE));
109
- if (!hasFontActive) {
69
+ /**
70
+ * Dispatch the font loading event and append the font loading class name.
71
+ * @param {string} fontFamily
72
+ * @param {string} fontDescription
73
+ */
74
+ EventDispatcher.prototype.dispatchFontLoading = function(fontFamily, fontDescription) {
110
75
  this.domHelper_.appendClassName(this.htmlElement_,
111
76
  this.cssClassName_.build(
112
- this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.INACTIVE));
113
- }
114
- this.dispatch_(
115
- webfont.EventDispatcher.FONT + webfont.EventDispatcher.INACTIVE, fontFamily, fontDescription);
116
- };
77
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
78
+ this.dispatch_(
79
+ webfont.EventDispatcher.FONT + webfont.EventDispatcher.LOADING, fontFamily, fontDescription);
80
+ };
117
81
 
118
- /**
119
- * Dispatch the inactive event, remove the loading class name, and append the
120
- * inactive class name (unless the active class name is already present).
121
- */
122
- webfont.EventDispatcher.prototype.dispatchInactive = function() {
123
- this.domHelper_.removeClassName(this.htmlElement_,
124
- this.cssClassName_.build(
125
- this.namespace_, webfont.EventDispatcher.LOADING));
126
- var hasActive = this.domHelper_.hasClassName(this.htmlElement_,
127
- this.cssClassName_.build(
128
- this.namespace_, webfont.EventDispatcher.ACTIVE));
129
- if (!hasActive) {
82
+ /**
83
+ * Dispatch the font active event, remove the font loading class name, remove
84
+ * the font inactive class name, and append the font active class name.
85
+ * @param {string} fontFamily
86
+ * @param {string} fontDescription
87
+ */
88
+ EventDispatcher.prototype.dispatchFontActive = function(fontFamily, fontDescription) {
89
+ this.domHelper_.removeClassName(this.htmlElement_,
90
+ this.cssClassName_.build(
91
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
92
+ this.domHelper_.removeClassName(this.htmlElement_,
93
+ this.cssClassName_.build(
94
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.INACTIVE));
130
95
  this.domHelper_.appendClassName(this.htmlElement_,
131
96
  this.cssClassName_.build(
132
- this.namespace_, webfont.EventDispatcher.INACTIVE));
133
- }
134
- this.dispatch_(webfont.EventDispatcher.INACTIVE);
135
- };
97
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.ACTIVE));
98
+ this.dispatch_(
99
+ webfont.EventDispatcher.FONT + webfont.EventDispatcher.ACTIVE, fontFamily, fontDescription);
100
+ };
136
101
 
137
- /**
138
- * Dispatch the active event, remove the loading class name, remove the inactive
139
- * class name, and append the active class name.
140
- */
141
- webfont.EventDispatcher.prototype.dispatchActive = function() {
142
- this.domHelper_.removeClassName(this.htmlElement_,
143
- this.cssClassName_.build(
144
- this.namespace_, webfont.EventDispatcher.LOADING));
145
- this.domHelper_.removeClassName(this.htmlElement_,
146
- this.cssClassName_.build(
147
- this.namespace_, webfont.EventDispatcher.INACTIVE));
148
- this.domHelper_.appendClassName(this.htmlElement_,
149
- this.cssClassName_.build(
150
- this.namespace_, webfont.EventDispatcher.ACTIVE));
151
- this.dispatch_(webfont.EventDispatcher.ACTIVE);
152
- };
102
+ /**
103
+ * Dispatch the font inactive event, remove the font loading class name, and
104
+ * append the font inactive class name (unless the font active class name is
105
+ * already present).
106
+ * @param {string} fontFamily
107
+ * @param {string} fontDescription
108
+ */
109
+ EventDispatcher.prototype.dispatchFontInactive = function(fontFamily, fontDescription) {
110
+ this.domHelper_.removeClassName(this.htmlElement_,
111
+ this.cssClassName_.build(
112
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.LOADING));
113
+ var hasFontActive = this.domHelper_.hasClassName(this.htmlElement_,
114
+ this.cssClassName_.build(
115
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.ACTIVE));
116
+ if (!hasFontActive) {
117
+ this.domHelper_.appendClassName(this.htmlElement_,
118
+ this.cssClassName_.build(
119
+ this.namespace_, fontFamily, fontDescription, webfont.EventDispatcher.INACTIVE));
120
+ }
121
+ this.dispatch_(
122
+ webfont.EventDispatcher.FONT + webfont.EventDispatcher.INACTIVE, fontFamily, fontDescription);
123
+ };
153
124
 
154
- /**
155
- * @param {string} event
156
- * @param {string=} opt_arg1
157
- * @param {string=} opt_arg2
158
- */
159
- webfont.EventDispatcher.prototype.dispatch_ = function(event, opt_arg1, opt_arg2) {
160
- if (this.callbacks_[event]) {
161
- this.callbacks_[event](opt_arg1, opt_arg2);
162
- }
163
- };
125
+ /**
126
+ * Dispatch the inactive event, remove the loading class name, and append the
127
+ * inactive class name (unless the active class name is already present).
128
+ */
129
+ EventDispatcher.prototype.dispatchInactive = function() {
130
+ this.domHelper_.removeClassName(this.htmlElement_,
131
+ this.cssClassName_.build(
132
+ this.namespace_, webfont.EventDispatcher.LOADING));
133
+ var hasActive = this.domHelper_.hasClassName(this.htmlElement_,
134
+ this.cssClassName_.build(
135
+ this.namespace_, webfont.EventDispatcher.ACTIVE));
136
+ if (!hasActive) {
137
+ this.domHelper_.appendClassName(this.htmlElement_,
138
+ this.cssClassName_.build(
139
+ this.namespace_, webfont.EventDispatcher.INACTIVE));
140
+ }
141
+ this.dispatch_(webfont.EventDispatcher.INACTIVE);
142
+ };
143
+
144
+ /**
145
+ * Dispatch the active event, remove the loading class name, remove the inactive
146
+ * class name, and append the active class name.
147
+ */
148
+ EventDispatcher.prototype.dispatchActive = function() {
149
+ this.domHelper_.removeClassName(this.htmlElement_,
150
+ this.cssClassName_.build(
151
+ this.namespace_, webfont.EventDispatcher.LOADING));
152
+ this.domHelper_.removeClassName(this.htmlElement_,
153
+ this.cssClassName_.build(
154
+ this.namespace_, webfont.EventDispatcher.INACTIVE));
155
+ this.domHelper_.appendClassName(this.htmlElement_,
156
+ this.cssClassName_.build(
157
+ this.namespace_, webfont.EventDispatcher.ACTIVE));
158
+ this.dispatch_(webfont.EventDispatcher.ACTIVE);
159
+ };
160
+
161
+ /**
162
+ * @param {string} event
163
+ * @param {string=} opt_arg1
164
+ * @param {string=} opt_arg2
165
+ */
166
+ EventDispatcher.prototype.dispatch_ = function(event, opt_arg1, opt_arg2) {
167
+ if (this.callbacks_[event]) {
168
+ this.callbacks_[event](opt_arg1, opt_arg2);
169
+ }
170
+ };
171
+ });
data/src/core/font.js CHANGED
@@ -1,96 +1,138 @@
1
+ goog.provide('webfont.WebFont');
2
+
3
+ goog.require('webfont.DomHelper');
4
+ goog.require('webfont.EventDispatcher');
5
+ goog.require('webfont.FontWatcher');
6
+ goog.require('webfont.Size');
7
+
1
8
  /**
2
9
  * @param {Window} mainWindow The main application window containing
3
10
  * webfontloader.js.
4
11
  * @param {webfont.FontModuleLoader} fontModuleLoader A loader instance to use.
5
- * @param {function(function(), number=)} asyncCall An async function to use.
6
12
  * @param {webfont.UserAgent} userAgent The detected user agent to load for.
7
13
  * @constructor
8
14
  */
9
- webfont.WebFont = function(mainWindow, fontModuleLoader, asyncCall, userAgent) {
15
+ webfont.WebFont = function(mainWindow, fontModuleLoader, userAgent) {
10
16
  this.mainWindow_ = mainWindow;
11
17
  this.fontModuleLoader_ = fontModuleLoader;
12
- this.asyncCall_ = asyncCall;
13
18
  this.userAgent_ = userAgent;
14
19
  this.moduleLoading_ = 0;
15
20
  this.moduleFailedLoading_ = 0;
16
21
  };
17
22
 
18
- webfont.WebFont.prototype.addModule = function(name, factory) {
19
- this.fontModuleLoader_.addModuleFactory(name, factory);
20
- };
23
+ goog.scope(function () {
24
+ var WebFont = webfont.WebFont,
25
+ DomHelper = webfont.DomHelper,
26
+ EventDispatcher = webfont.EventDispatcher,
27
+ FontWatcher = webfont.FontWatcher,
28
+ Size = webfont.Size;
21
29
 
22
- webfont.WebFont.prototype.load = function(configuration) {
23
- var context = configuration['context'] || this.mainWindow_;
24
- this.domHelper_ = new webfont.DomHelper(this.mainWindow_, context);
30
+ /**
31
+ * @param {string} name
32
+ * @param {webfont.FontModuleFactory} factory
33
+ */
34
+ WebFont.prototype.addModule = function(name, factory) {
35
+ this.fontModuleLoader_.addModuleFactory(name, factory);
36
+ };
25
37
 
26
- var eventDispatcher = new webfont.EventDispatcher(
27
- this.domHelper_, context.document.documentElement, configuration);
38
+ /**
39
+ * @param {Object} configuration
40
+ */
41
+ WebFont.prototype.load = function(configuration) {
42
+ var context = configuration['context'] || this.mainWindow_;
43
+ this.domHelper_ = new DomHelper(this.mainWindow_, context);
28
44
 
29
- if (this.userAgent_.getBrowserInfo().hasWebFontSupport()) {
30
- this.load_(eventDispatcher, configuration);
31
- } else {
32
- eventDispatcher.dispatchInactive();
33
- }
34
- };
45
+ var eventDispatcher = new EventDispatcher(
46
+ this.domHelper_, context.document.documentElement, configuration);
35
47
 
36
- webfont.WebFont.prototype.isModuleSupportingUserAgent_ = function(module, eventDispatcher,
37
- fontWatcher, support) {
38
- var fontWatchRunnerCtor = module.getFontWatchRunnerCtor ?
39
- module.getFontWatchRunnerCtor() : webfont.FontWatchRunner;
40
- if (!support) {
48
+ if (this.userAgent_.getBrowserInfo().hasWebFontSupport()) {
49
+ this.load_(eventDispatcher, configuration);
50
+ } else {
51
+ eventDispatcher.dispatchInactive();
52
+ }
53
+ };
54
+
55
+ /**
56
+ * @param {webfont.FontModule} module
57
+ * @param {webfont.EventDispatcher} eventDispatcher
58
+ * @param {webfont.FontWatcher} fontWatcher
59
+ * @param {boolean} support
60
+ */
61
+ WebFont.prototype.isModuleSupportingUserAgent_ = function(module, eventDispatcher,
62
+ fontWatcher, support) {
63
+ var fontWatchRunnerCtor = module.getFontWatchRunnerCtor ?
64
+ module.getFontWatchRunnerCtor() : webfont.FontWatchRunner,
65
+ that = this;
66
+
67
+ if (!support) {
68
+ var allModulesLoaded = --this.moduleLoading_ == 0;
69
+
70
+ this.moduleFailedLoading_--;
71
+ if (allModulesLoaded) {
72
+ if (this.moduleFailedLoading_ == 0) {
73
+ eventDispatcher.dispatchInactive();
74
+ } else {
75
+ eventDispatcher.dispatchLoading();
76
+ }
77
+ }
78
+ fontWatcher.watch([], {}, {}, fontWatchRunnerCtor, allModulesLoaded);
79
+ return;
80
+ }
81
+
82
+ module.load(function (fontFamilies, fontVariations) {
83
+ that.onModuleReady_(eventDispatcher, fontWatcher, fontWatchRunnerCtor, fontFamilies, fontVariations);
84
+ });
85
+ };
86
+
87
+ /**
88
+ * @param {webfont.EventDispatcher} eventDispatcher
89
+ * @param {webfont.FontWatcher} fontWatcher
90
+ * @param {function(new:webfont.FontWatchRunner,
91
+ * function(string, string),
92
+ * function(string, string),
93
+ * webfont.DomHelper,
94
+ * string,
95
+ * string,
96
+ * webfont.BrowserInfo,
97
+ * number=,
98
+ * Object.<string, boolean>=,
99
+ * string=)} fontWatchRunnerCtor
100
+ * @param {webfont.FontFamilies} fontFamilies
101
+ * @param {webfont.FontVariations=} opt_fontVariations
102
+ * @param {webfont.FontTestStrings=} opt_fontTestStrings
103
+ */
104
+ WebFont.prototype.onModuleReady_ = function(eventDispatcher, fontWatcher,
105
+ fontWatchRunnerCtor, fontFamilies, opt_fontVariations, opt_fontTestStrings) {
41
106
  var allModulesLoaded = --this.moduleLoading_ == 0;
42
107
 
43
- this.moduleFailedLoading_--;
44
108
  if (allModulesLoaded) {
45
- if (this.moduleFailedLoading_ == 0) {
46
- eventDispatcher.dispatchInactive();
47
- } else {
48
- eventDispatcher.dispatchLoading();
49
- }
109
+ eventDispatcher.dispatchLoading();
50
110
  }
51
- fontWatcher.watch([], {}, {}, fontWatchRunnerCtor, allModulesLoaded);
52
- return;
53
- }
54
- module.load(webfont.bind(this, this.onModuleReady_, eventDispatcher,
55
- fontWatcher, fontWatchRunnerCtor));
56
- };
57
111
 
58
- webfont.WebFont.prototype.onModuleReady_ = function(eventDispatcher, fontWatcher,
59
- fontWatchRunnerCtor, fontFamilies, opt_fontDescriptions, opt_fontTestStrings) {
60
- var allModulesLoaded = --this.moduleLoading_ == 0;
61
-
62
- if (allModulesLoaded) {
63
- eventDispatcher.dispatchLoading();
64
- }
65
- this.asyncCall_(webfont.bind(this, function(_fontWatcher, _fontFamilies,
66
- _fontDescriptions, _fontTestStrings, _fontWatchRunnerCtor,
67
- _allModulesLoaded) {
68
- _fontWatcher.watch(_fontFamilies, _fontDescriptions || {},
69
- _fontTestStrings || {}, _fontWatchRunnerCtor, _allModulesLoaded);
70
- }, fontWatcher, fontFamilies, opt_fontDescriptions, opt_fontTestStrings,
71
- fontWatchRunnerCtor, allModulesLoaded));
72
- };
112
+ setTimeout(function () {
113
+ fontWatcher.watch(fontFamilies, opt_fontVariations || {}, opt_fontTestStrings || {}, fontWatchRunnerCtor, allModulesLoaded);
114
+ }, 0);
115
+ };
73
116
 
74
- webfont.WebFont.prototype.load_ = function(eventDispatcher, configuration) {
75
- var modules = this.fontModuleLoader_.getModules(configuration, this.domHelper_),
76
- timeout = configuration['timeout'],
77
- self = this;
117
+ /**
118
+ * @param {webfont.EventDispatcher} eventDispatcher
119
+ * @param {Object} configuration
120
+ */
121
+ WebFont.prototype.load_ = function(eventDispatcher, configuration) {
122
+ var modules = this.fontModuleLoader_.getModules(configuration, this.domHelper_),
123
+ timeout = configuration['timeout'],
124
+ self = this;
78
125
 
79
- this.moduleFailedLoading_ = this.moduleLoading_ = modules.length;
126
+ this.moduleFailedLoading_ = this.moduleLoading_ = modules.length;
80
127
 
81
- var fontWatcher = new webfont.FontWatcher(this.userAgent_, this.domHelper_,
82
- eventDispatcher, {
83
- getSize: function(elem) {
84
- return new webfont.Size(elem.offsetWidth, elem.offsetHeight);
85
- }}, self.asyncCall_, function() {
86
- return new Date().getTime();
87
- }, timeout);
128
+ var fontWatcher = new webfont.FontWatcher(this.userAgent_, this.domHelper_, eventDispatcher, timeout);
88
129
 
89
- for (var i = 0, len = modules.length; i < len; i++) {
90
- var module = modules[i];
130
+ for (var i = 0, len = modules.length; i < len; i++) {
131
+ var module = modules[i];
91
132
 
92
- module.supportUserAgent(this.userAgent_,
93
- webfont.bind(this, this.isModuleSupportingUserAgent_, module,
94
- eventDispatcher, fontWatcher));
95
- }
96
- };
133
+ module.supportUserAgent(this.userAgent_,
134
+ goog.bind(this.isModuleSupportingUserAgent_, this, module,
135
+ eventDispatcher, fontWatcher));
136
+ }
137
+ };
138
+ });
@@ -1,25 +1,68 @@
1
+ goog.provide('webfont.FontModuleLoader');
2
+ goog.provide('webfont.FontModule');
3
+ goog.provide('webfont.FontModuleFactory');
4
+
5
+ /**
6
+ * @interface
7
+ */
8
+ webfont.FontModule = function () {};
9
+
10
+ goog.scope(function () {
11
+ var FontModule = webfont.FontModule;
12
+
13
+ /**
14
+ * @param {webfont.UserAgent} userAgent
15
+ * @param {function(boolean)} support
16
+ */
17
+ FontModule.prototype.supportUserAgent = function (userAgent, support) {};
18
+
19
+ /**
20
+ * @param {function(webfont.FontFamilies, webfont.FontVariations=, webfont.FontTestStrings=)} onReady
21
+ */
22
+ FontModule.prototype.load = function (onReady) {};
23
+ });
24
+
25
+ /** @typedef {function(Object, webfont.DomHelper): webfont.FontModule} */
26
+ webfont.FontModuleFactory;
27
+
1
28
  /**
2
29
  * @constructor
3
30
  */
4
31
  webfont.FontModuleLoader = function() {
32
+ /**
33
+ * @type {Object.<string, webfont.FontModuleFactory>}
34
+ */
5
35
  this.modules_ = {};
6
36
  };
7
37
 
8
- webfont.FontModuleLoader.prototype.addModuleFactory = function(name, factory) {
9
- this.modules_[name] = factory;
10
- };
38
+ goog.scope(function () {
39
+ var FontModuleLoader = webfont.FontModuleLoader;
11
40
 
12
- webfont.FontModuleLoader.prototype.getModules = function(configuration, domHelper) {
13
- var modules = [];
41
+ /**
42
+ * @param {string} name
43
+ * @param {webfont.FontModuleFactory} factory
44
+ */
45
+ FontModuleLoader.prototype.addModuleFactory = function(name, factory) {
46
+ this.modules_[name] = factory;
47
+ };
14
48
 
15
- for (var key in configuration) {
16
- if (configuration.hasOwnProperty(key)) {
17
- var moduleFactory = this.modules_[key];
49
+ /**
50
+ * @param {Object} configuration
51
+ * @param {webfont.DomHelper} domHelper
52
+ * @return {Array.<webfont.FontModule>}
53
+ */
54
+ FontModuleLoader.prototype.getModules = function(configuration, domHelper) {
55
+ var modules = [];
18
56
 
19
- if (moduleFactory) {
20
- modules.push(moduleFactory(configuration[key], domHelper));
57
+ for (var key in configuration) {
58
+ if (configuration.hasOwnProperty(key)) {
59
+ var moduleFactory = this.modules_[key];
60
+
61
+ if (moduleFactory) {
62
+ modules.push(moduleFactory(configuration[key], domHelper));
63
+ }
21
64
  }
22
65
  }
23
- }
24
- return modules;
25
- };
66
+ return modules;
67
+ };
68
+ });