webfontloader 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/lib/webfontloader.rb +1 -1
- data/spec/core/domhelper_spec.js +246 -1
- data/spec/core/external_script.js +1 -0
- data/spec/core/fontwatcher_spec.js +11 -11
- data/spec/deps.js +9 -9
- data/spec/index.html +15 -15
- data/spec/{ascender/ascenderscript_spec.js → modules/ascender_spec.js} +17 -17
- data/spec/{custom/customcss_spec.js → modules/custom_spec.js} +3 -3
- data/spec/{fontdeck/fontdeckscript_spec.js → modules/fontdeck_spec.js} +6 -6
- data/spec/{google → modules/google}/fontapiparser_spec.js +2 -2
- data/spec/{google → modules/google}/fontapiurlbuilder_spec.js +2 -2
- data/spec/{google → modules/google}/googlefontapi_spec.js +2 -2
- data/spec/{google → modules/google}/lastresortwebkitfontwatchrunner_spec.js +2 -2
- data/spec/{monotype/monotypescript_spec.js → modules/monotype_spec.js} +5 -4
- data/spec/{typekit/typekitscript_spec.js → modules/typekit_spec.js} +6 -6
- data/src/core/domhelper.js +62 -1
- data/src/core/fontwatcher.js +1 -1
- data/src/core/webfont.js +2 -2
- data/src/modules.yml +9 -9
- data/src/{ascender/ascender_script.js → modules/ascender.js} +13 -13
- data/src/{custom/customcss.js → modules/custom.js} +8 -8
- data/src/{fontdeck/fontdeck_script.js → modules/fontdeck.js} +16 -17
- data/src/{google → modules/google}/fontapiparser.js +7 -7
- data/src/{google → modules/google}/fontapiurlbuilder.js +5 -5
- data/src/{google → modules/google}/googlefontapi.js +12 -12
- data/src/{google → modules/google}/lastresortwebkitfontwatchrunner.js +5 -5
- data/src/{monotype/monotype_script.js → modules/monotype.js} +16 -16
- data/src/{typekit/typekit_script.js → modules/typekit.js} +13 -13
- data/webfontloader.gemspec +21 -20
- metadata +23 -22
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
var
|
1
|
+
describe('modules.Custom', function () {
|
2
|
+
var Custom = webfont.modules.Custom,
|
3
3
|
FontFamily = webfont.FontFamily;
|
4
4
|
|
5
5
|
describe('insert links correctly', function () {
|
@@ -14,7 +14,7 @@ describe('CustomCss', function () {
|
|
14
14
|
|
15
15
|
load = jasmine.createSpy('load');
|
16
16
|
|
17
|
-
var defaultModule = new
|
17
|
+
var defaultModule = new Custom(fakeDomHelper, {
|
18
18
|
families: ['Font1', 'Font2', 'Font3'],
|
19
19
|
urls: ['http://moo', 'http://meuh']
|
20
20
|
});
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
var
|
1
|
+
describe('modules.Fontdeck', function () {
|
2
|
+
var Fontdeck = webfont.modules.Fontdeck,
|
3
3
|
Font = webfont.Font;
|
4
4
|
|
5
5
|
var configuration = {
|
@@ -55,8 +55,8 @@ describe('FontdeckScript', function () {
|
|
55
55
|
insertInto: jasmine.createSpy('insertInto'),
|
56
56
|
createScriptSrc: jasmine.createSpy('createScriptSrc'),
|
57
57
|
getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global),
|
58
|
-
|
59
|
-
|
58
|
+
getProtocol: jasmine.createSpy('getProtocol').andReturn('https:'),
|
59
|
+
getHostName: function () { return 'test-host-name'; }
|
60
60
|
};
|
61
61
|
});
|
62
62
|
|
@@ -65,7 +65,7 @@ describe('FontdeckScript', function () {
|
|
65
65
|
support = null;
|
66
66
|
|
67
67
|
beforeEach(function () {
|
68
|
-
fontdeck = new
|
68
|
+
fontdeck = new Fontdeck(fakeDomHelper, configuration);
|
69
69
|
support = jasmine.createSpy('support');
|
70
70
|
|
71
71
|
fontdeck.supportUserAgent('user agent', support);
|
@@ -95,7 +95,7 @@ describe('FontdeckScript', function () {
|
|
95
95
|
support = null;
|
96
96
|
|
97
97
|
beforeEach(function () {
|
98
|
-
fontdeck = new
|
98
|
+
fontdeck = new Fontdeck(fakeDomHelper, { id: null });
|
99
99
|
support = jasmine.createSpy('support');
|
100
100
|
|
101
101
|
fontdeck.supportUserAgent('user agent', support);
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('FontApiParser', function () {
|
2
|
-
var FontApiParser = webfont.FontApiParser,
|
1
|
+
describe('modules.google.FontApiParser', function () {
|
2
|
+
var FontApiParser = webfont.modules.google.FontApiParser,
|
3
3
|
Font = webfont.Font;
|
4
4
|
|
5
5
|
describe('parsed values are coherent', function () {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('FontApiUrlBuilder', function () {
|
2
|
-
var FontApiUrlBuilder = webfont.FontApiUrlBuilder;
|
1
|
+
describe('modules.google.FontApiUrlBuilder', function () {
|
2
|
+
var FontApiUrlBuilder = webfont.modules.google.FontApiUrlBuilder;
|
3
3
|
|
4
4
|
it('should throw an exception if there are no font families', function () {
|
5
5
|
var builder = new FontApiUrlBuilder('http://moo', 'http:');
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('GoogleFontApi', function () {
|
2
|
-
var GoogleFontApi = webfont.GoogleFontApi,
|
1
|
+
describe('modules.google.GoogleFontApi', function () {
|
2
|
+
var GoogleFontApi = webfont.modules.google.GoogleFontApi,
|
3
3
|
Font = webfont.Font,
|
4
4
|
UserAgent = webfont.UserAgent,
|
5
5
|
userAgent = null,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('LastResortWebKitFontWatchRunner', function () {
|
2
|
-
var LastResortWebKitFontWatchRunner = webfont.LastResortWebKitFontWatchRunner,
|
1
|
+
describe('modules.google.LastResortWebKitFontWatchRunner', function () {
|
2
|
+
var LastResortWebKitFontWatchRunner = webfont.modules.google.LastResortWebKitFontWatchRunner,
|
3
3
|
BrowserInfo = webfont.BrowserInfo,
|
4
4
|
DomHelper = webfont.DomHelper,
|
5
5
|
FontRuler = webfont.FontRuler,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
var
|
1
|
+
describe('modules.Monotype', function () {
|
2
|
+
var Monotype = webfont.modules.Monotype,
|
3
3
|
Font = webfont.Font,
|
4
4
|
BrowserInfo = webfont.BrowserInfo,
|
5
5
|
UserAgent = webfont.UserAgent,
|
@@ -43,17 +43,18 @@ describe('MonotypeScript', function () {
|
|
43
43
|
new BrowserInfo(true, false, false)
|
44
44
|
);
|
45
45
|
|
46
|
-
monotype = new
|
46
|
+
monotype = new Monotype(useragent, fakeDomHelper, configuration);
|
47
47
|
monotype.supportUserAgent(useragent, support);
|
48
48
|
monotype.load(load);
|
49
49
|
|
50
|
-
global[
|
50
|
+
global[Monotype.HOOK + configuration.projectId] = function () {
|
51
51
|
return [{fontfamily: 'aachen bold'}, {fontfamily: 'kid print regular'}];
|
52
52
|
};
|
53
53
|
|
54
54
|
script.onload();
|
55
55
|
});
|
56
56
|
|
57
|
+
|
57
58
|
it('should create a script element', function () {
|
58
59
|
expect(support).toHaveBeenCalled();
|
59
60
|
expect(fakeDomHelper.createElement).toHaveBeenCalledWith('script');
|
@@ -1,5 +1,5 @@
|
|
1
|
-
describe('
|
2
|
-
var
|
1
|
+
describe('modules.Typekit', function () {
|
2
|
+
var Typekit = webfont.modules.Typekit,
|
3
3
|
Font = webfont.Font;
|
4
4
|
|
5
5
|
var configuration = {
|
@@ -27,7 +27,7 @@ describe('TypekitScript', function () {
|
|
27
27
|
});
|
28
28
|
|
29
29
|
it('support load and life cycle', function () {
|
30
|
-
var typekit = new
|
30
|
+
var typekit = new Typekit(fakeDomHelper, configuration);
|
31
31
|
|
32
32
|
typekit.supportUserAgent('useragent', support);
|
33
33
|
|
@@ -53,7 +53,7 @@ describe('TypekitScript', function () {
|
|
53
53
|
});
|
54
54
|
|
55
55
|
it('should load with variations', function () {
|
56
|
-
var typekit = new
|
56
|
+
var typekit = new Typekit(fakeDomHelper, configuration);
|
57
57
|
|
58
58
|
typekit.supportUserAgent('useragent', support);
|
59
59
|
|
@@ -75,7 +75,7 @@ describe('TypekitScript', function () {
|
|
75
75
|
});
|
76
76
|
|
77
77
|
it('should load through the alternative API', function () {
|
78
|
-
var typekit = new
|
78
|
+
var typekit = new Typekit(fakeDomHelper, { id: 'abc', api: '/test' });
|
79
79
|
|
80
80
|
typekit.supportUserAgent('useragent', support);
|
81
81
|
expect(fakeDomHelper.insertInto.calls[0].args[0]).toEqual('head');
|
@@ -83,7 +83,7 @@ describe('TypekitScript', function () {
|
|
83
83
|
});
|
84
84
|
|
85
85
|
it('should not load without a kit id', function () {
|
86
|
-
var typekit = new
|
86
|
+
var typekit = new Typekit(fakeDomHelper, { id: null });
|
87
87
|
|
88
88
|
typekit.supportUserAgent('useragent', support);
|
89
89
|
|
data/src/core/domhelper.js
CHANGED
@@ -82,8 +82,9 @@ goog.scope(function () {
|
|
82
82
|
* @param {function()} callback The function to call.
|
83
83
|
*/
|
84
84
|
DomHelper.prototype.whenBodyExists = function(callback) {
|
85
|
+
var that = this;
|
85
86
|
var check = function() {
|
86
|
-
if (
|
87
|
+
if (that.document_.body) {
|
87
88
|
callback();
|
88
89
|
} else {
|
89
90
|
setTimeout(check, 0);
|
@@ -234,4 +235,64 @@ goog.scope(function () {
|
|
234
235
|
}
|
235
236
|
return protocol == 'https:' ? 'https:' : 'http:';
|
236
237
|
};
|
238
|
+
|
239
|
+
/**
|
240
|
+
* Returns the secure status of the current document.
|
241
|
+
* @return {boolean} true if the current document is served securely.
|
242
|
+
*/
|
243
|
+
DomHelper.prototype.isHttps = function() {
|
244
|
+
return this.getProtocol() === 'https:';
|
245
|
+
};
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Returns the hostname of the current document.
|
249
|
+
* @return {string} hostname.
|
250
|
+
*/
|
251
|
+
DomHelper.prototype.getHostName = function() {
|
252
|
+
return this.getLoadWindow().location.hostname || this.getMainWindow().location.hostname;
|
253
|
+
};
|
254
|
+
|
255
|
+
/**
|
256
|
+
* Creates a style element.
|
257
|
+
* @param {string} css Contents of the style element.
|
258
|
+
* @return {Element} a DOM element.
|
259
|
+
*/
|
260
|
+
DomHelper.prototype.createStyle = function(css) {
|
261
|
+
var e = this.document_.createElement('style');
|
262
|
+
|
263
|
+
e.setAttribute('type', 'text/css');
|
264
|
+
if (e.styleSheet) { // IE
|
265
|
+
e.styleSheet.cssText = css;
|
266
|
+
} else {
|
267
|
+
e.appendChild(document.createTextNode(css));
|
268
|
+
}
|
269
|
+
return e;
|
270
|
+
};
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Loads an external script file.
|
274
|
+
* @param {string} src URL of the script.
|
275
|
+
* @param {function()=} opt_callback callback when the script has loaded.
|
276
|
+
*/
|
277
|
+
DomHelper.prototype.loadScript = function(src, opt_callback) {
|
278
|
+
var head = this.document_.getElementsByTagName('head')[0];
|
279
|
+
|
280
|
+
if (head) {
|
281
|
+
var script = this.document_.createElement('script');
|
282
|
+
script.src = src;
|
283
|
+
var done = false;
|
284
|
+
script.onload = script.onreadystatechange = function() {
|
285
|
+
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
|
286
|
+
done = true;
|
287
|
+
if (opt_callback) {
|
288
|
+
opt_callback();
|
289
|
+
}
|
290
|
+
script.onload = script.onreadystatechange = null;
|
291
|
+
// Avoid a bizarre issue with unclosed <base> tag in IE6 - http://blog.dotsmart.net/2008/04/
|
292
|
+
if (script.parentNode.tagName == 'HEAD') head.removeChild(script);
|
293
|
+
}
|
294
|
+
};
|
295
|
+
head.appendChild(script);
|
296
|
+
}
|
297
|
+
};
|
237
298
|
});
|
data/src/core/fontwatcher.js
CHANGED
@@ -39,7 +39,7 @@ goog.scope(function () {
|
|
39
39
|
* string=)} fontWatchRunnerCtor The font watch runner constructor.
|
40
40
|
* @param {boolean} last True if this is the last set of fonts to watch.
|
41
41
|
*/
|
42
|
-
FontWatcher.prototype.
|
42
|
+
FontWatcher.prototype.watchFonts = function(fonts,
|
43
43
|
fontTestStrings, fontWatchRunnerCtor, last) {
|
44
44
|
var length = fonts.length;
|
45
45
|
|
data/src/core/webfont.js
CHANGED
@@ -73,7 +73,7 @@ goog.scope(function () {
|
|
73
73
|
eventDispatcher.dispatchLoading();
|
74
74
|
}
|
75
75
|
}
|
76
|
-
fontWatcher.
|
76
|
+
fontWatcher.watchFonts([], {}, fontWatchRunnerCtor, allModulesLoaded);
|
77
77
|
return;
|
78
78
|
}
|
79
79
|
|
@@ -106,7 +106,7 @@ goog.scope(function () {
|
|
106
106
|
}
|
107
107
|
|
108
108
|
setTimeout(function () {
|
109
|
-
fontWatcher.
|
109
|
+
fontWatcher.watchFonts(fonts, opt_fontTestStrings || {}, fontWatchRunnerCtor, allModulesLoaded);
|
110
110
|
}, 0);
|
111
111
|
};
|
112
112
|
|
data/src/modules.yml
CHANGED
@@ -16,22 +16,22 @@ core:
|
|
16
16
|
- core/initialize.js
|
17
17
|
|
18
18
|
ascender:
|
19
|
-
- ascender
|
19
|
+
- modules/ascender.js
|
20
20
|
|
21
21
|
google:
|
22
|
-
- google/lastresortwebkitfontwatchrunner.js
|
23
|
-
- google/fontapiurlbuilder.js
|
24
|
-
- google/fontapiparser.js
|
25
|
-
- google/googlefontapi.js
|
22
|
+
- modules/google/lastresortwebkitfontwatchrunner.js
|
23
|
+
- modules/google/fontapiurlbuilder.js
|
24
|
+
- modules/google/fontapiparser.js
|
25
|
+
- modules/google/googlefontapi.js
|
26
26
|
|
27
27
|
fontdeck:
|
28
|
-
- fontdeck
|
28
|
+
- modules/fontdeck.js
|
29
29
|
|
30
30
|
typekit:
|
31
|
-
- typekit
|
31
|
+
- modules/typekit.js
|
32
32
|
|
33
33
|
monotype:
|
34
|
-
- monotype
|
34
|
+
- modules/monotype.js
|
35
35
|
|
36
36
|
custom:
|
37
|
-
- custom
|
37
|
+
- modules/custom.js
|
@@ -1,4 +1,4 @@
|
|
1
|
-
goog.provide('webfont.
|
1
|
+
goog.provide('webfont.modules.Ascender');
|
2
2
|
|
3
3
|
goog.require('webfont.Font');
|
4
4
|
|
@@ -14,14 +14,14 @@ goog.require('webfont.Font');
|
|
14
14
|
* @constructor
|
15
15
|
* @implements {webfont.FontModule}
|
16
16
|
*/
|
17
|
-
webfont.
|
17
|
+
webfont.modules.Ascender = function(domHelper, configuration) {
|
18
18
|
this.domHelper_ = domHelper;
|
19
19
|
this.configuration_ = configuration;
|
20
20
|
};
|
21
21
|
|
22
|
-
webfont.
|
22
|
+
webfont.modules.Ascender.NAME = 'ascender';
|
23
23
|
|
24
|
-
webfont.
|
24
|
+
webfont.modules.Ascender.VARIATIONS = {
|
25
25
|
'regular': 'n4',
|
26
26
|
'bold': 'n7',
|
27
27
|
'italic': 'i4',
|
@@ -33,14 +33,14 @@ webfont.AscenderScript.VARIATIONS = {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
goog.scope(function () {
|
36
|
-
var
|
36
|
+
var Ascender = webfont.modules.Ascender,
|
37
37
|
Font = webfont.Font;
|
38
38
|
|
39
|
-
|
39
|
+
Ascender.prototype.supportUserAgent = function(userAgent, support) {
|
40
40
|
return support(userAgent.getBrowserInfo().hasWebFontSupport());
|
41
41
|
};
|
42
42
|
|
43
|
-
|
43
|
+
Ascender.prototype.load = function(onReady) {
|
44
44
|
var key = this.configuration_['key'];
|
45
45
|
var protocol = this.domHelper_.getProtocol();
|
46
46
|
var url = protocol + '//webfonts.fontslive.com/css/' + key + '.css';
|
@@ -53,7 +53,7 @@ goog.scope(function () {
|
|
53
53
|
* @param {Array.<string>} providedFamilies
|
54
54
|
* @return {Array.<webfont.Font>}
|
55
55
|
*/
|
56
|
-
|
56
|
+
Ascender.prototype.parseFamiliesAndVariations = function (providedFamilies) {
|
57
57
|
var fonts = [];
|
58
58
|
|
59
59
|
for (var i = 0, len = providedFamilies.length; i < len; i++) {
|
@@ -66,7 +66,7 @@ goog.scope(function () {
|
|
66
66
|
* @param {string} providedFamily
|
67
67
|
* @return {Array.<webfont.Font>}
|
68
68
|
*/
|
69
|
-
|
69
|
+
Ascender.prototype.parseFamilyAndVariations = function (providedFamily){
|
70
70
|
var parts = providedFamily.split(':'),
|
71
71
|
familyName = parts[0];
|
72
72
|
|
@@ -86,7 +86,7 @@ goog.scope(function () {
|
|
86
86
|
* @param {string} source
|
87
87
|
* @return {Array.<string>}
|
88
88
|
*/
|
89
|
-
|
89
|
+
Ascender.prototype.parseVariations = function (source) {
|
90
90
|
var providedVariations = source.split(','),
|
91
91
|
variations = [];
|
92
92
|
|
@@ -94,7 +94,7 @@ goog.scope(function () {
|
|
94
94
|
var pv = providedVariations[i];
|
95
95
|
|
96
96
|
if (pv) {
|
97
|
-
var v =
|
97
|
+
var v = Ascender.VARIATIONS[pv];
|
98
98
|
variations.push(v ? v : pv);
|
99
99
|
}
|
100
100
|
}
|
@@ -102,6 +102,6 @@ goog.scope(function () {
|
|
102
102
|
};
|
103
103
|
});
|
104
104
|
|
105
|
-
globalNamespaceObject.addModule(webfont.
|
106
|
-
return new webfont.
|
105
|
+
globalNamespaceObject.addModule(webfont.modules.Ascender.NAME, function(configuration, domHelper) {
|
106
|
+
return new webfont.modules.Ascender(domHelper, configuration);
|
107
107
|
});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
goog.provide('webfont.
|
1
|
+
goog.provide('webfont.modules.Custom');
|
2
2
|
|
3
3
|
goog.require('webfont.Font');
|
4
4
|
|
@@ -13,18 +13,18 @@ goog.require('webfont.Font');
|
|
13
13
|
* @constructor
|
14
14
|
* @implements {webfont.FontModule}
|
15
15
|
*/
|
16
|
-
webfont.
|
16
|
+
webfont.modules.Custom = function(domHelper, configuration) {
|
17
17
|
this.domHelper_ = domHelper;
|
18
18
|
this.configuration_ = configuration;
|
19
19
|
};
|
20
20
|
|
21
|
-
webfont.
|
21
|
+
webfont.modules.Custom.NAME = 'custom';
|
22
22
|
|
23
23
|
goog.scope(function () {
|
24
|
-
var
|
24
|
+
var Custom = webfont.modules.Custom,
|
25
25
|
Font = webfont.Font;
|
26
26
|
|
27
|
-
|
27
|
+
Custom.prototype.load = function(onReady) {
|
28
28
|
var i, len;
|
29
29
|
var urls = this.configuration_['urls'] || [];
|
30
30
|
var familiesConfiguration = this.configuration_['families'] || [];
|
@@ -54,11 +54,11 @@ goog.scope(function () {
|
|
54
54
|
onReady(fonts);
|
55
55
|
};
|
56
56
|
|
57
|
-
|
57
|
+
Custom.prototype.supportUserAgent = function(userAgent, support) {
|
58
58
|
return support(userAgent.getBrowserInfo().hasWebFontSupport());
|
59
59
|
};
|
60
60
|
});
|
61
61
|
|
62
|
-
globalNamespaceObject.addModule(webfont.
|
63
|
-
return new webfont.
|
62
|
+
globalNamespaceObject.addModule(webfont.modules.Custom.NAME, function(configuration, domHelper) {
|
63
|
+
return new webfont.modules.Custom(domHelper, configuration);
|
64
64
|
});
|
@@ -1,4 +1,4 @@
|
|
1
|
-
goog.provide('webfont.
|
1
|
+
goog.provide('webfont.modules.Fontdeck');
|
2
2
|
|
3
3
|
goog.require('webfont.Font');
|
4
4
|
|
@@ -6,44 +6,43 @@ goog.require('webfont.Font');
|
|
6
6
|
* @constructor
|
7
7
|
* @implements {webfont.FontModule}
|
8
8
|
*/
|
9
|
-
webfont.
|
9
|
+
webfont.modules.Fontdeck = function(domHelper, configuration) {
|
10
10
|
this.domHelper_ = domHelper;
|
11
11
|
this.configuration_ = configuration;
|
12
12
|
this.fonts_ = [];
|
13
13
|
};
|
14
14
|
|
15
|
-
webfont.
|
16
|
-
webfont.
|
17
|
-
webfont.
|
15
|
+
webfont.modules.Fontdeck.NAME = 'fontdeck';
|
16
|
+
webfont.modules.Fontdeck.HOOK = '__webfontfontdeckmodule__';
|
17
|
+
webfont.modules.Fontdeck.API = '//f.fontdeck.com/s/css/js/';
|
18
18
|
|
19
19
|
goog.scope(function () {
|
20
|
-
var
|
20
|
+
var Fontdeck = webfont.modules.Fontdeck,
|
21
21
|
Font = webfont.Font,
|
22
22
|
FontVariationDescription = webfont.FontVariationDescription;
|
23
23
|
|
24
|
-
|
24
|
+
Fontdeck.prototype.getScriptSrc = function(projectId) {
|
25
25
|
var protocol = this.domHelper_.getProtocol();
|
26
26
|
// For empty iframes, fall back to main window's hostname.
|
27
|
-
var hostname = this.domHelper_.
|
28
|
-
|
29
|
-
var api = this.configuration_['api'] || webfont.FontdeckScript.API;
|
27
|
+
var hostname = this.domHelper_.getHostName();
|
28
|
+
var api = this.configuration_['api'] || webfont.modules.Fontdeck.API;
|
30
29
|
return protocol + api + hostname + '/' + projectId + '.js';
|
31
30
|
};
|
32
31
|
|
33
|
-
|
32
|
+
Fontdeck.prototype.supportUserAgent = function(userAgent, support) {
|
34
33
|
var projectId = this.configuration_['id'];
|
35
34
|
var loadWindow = this.domHelper_.getLoadWindow();
|
36
35
|
var self = this;
|
37
36
|
|
38
37
|
if (projectId) {
|
39
38
|
// Provide data to Fontdeck for processing.
|
40
|
-
if (!loadWindow[webfont.
|
41
|
-
loadWindow[webfont.
|
39
|
+
if (!loadWindow[webfont.modules.Fontdeck.HOOK]) {
|
40
|
+
loadWindow[webfont.modules.Fontdeck.HOOK] = {};
|
42
41
|
}
|
43
42
|
|
44
43
|
// Fontdeck will call this function to indicate support status
|
45
44
|
// and what fonts are provided.
|
46
|
-
loadWindow[webfont.
|
45
|
+
loadWindow[webfont.modules.Fontdeck.HOOK][projectId] = function(fontdeckSupports, data) {
|
47
46
|
for (var i = 0, j = data['fonts'].length; i<j; ++i) {
|
48
47
|
var font = data['fonts'][i];
|
49
48
|
self.fonts_.push(new Font(font['name'], Font.parseCssVariation('font-weight:' + font['weight'] + ';font-style:' + font['style'])));
|
@@ -60,11 +59,11 @@ goog.scope(function () {
|
|
60
59
|
}
|
61
60
|
};
|
62
61
|
|
63
|
-
|
62
|
+
Fontdeck.prototype.load = function(onReady) {
|
64
63
|
onReady(this.fonts_);
|
65
64
|
};
|
66
65
|
});
|
67
66
|
|
68
|
-
globalNamespaceObject.addModule(webfont.
|
69
|
-
return new webfont.
|
67
|
+
globalNamespaceObject.addModule(webfont.modules.Fontdeck.NAME, function(configuration, domHelper) {
|
68
|
+
return new webfont.modules.Fontdeck(domHelper, configuration);
|
70
69
|
});
|