webfontloader 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.md +3 -3
- data/Rakefile +30 -7
- data/lib/webfontloader.rb +1 -1
- data/spec/core/useragentparser_spec.js +44 -0
- data/spec/index.html +4 -1
- data/src/core/useragentparser.js +21 -4
- data/tools/compiler/base.js +1 -1
- data/webfontloader.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
v1.4.8 (June 24, 2013)
|
2
|
+
* Add support for the Chromium based Opera browser
|
3
|
+
* Change the debug task to do a Closure Compiler debug build
|
4
|
+
* Fix a global variable leak in the compiled output
|
5
|
+
* Add support for the PhantomJS user agent string
|
6
|
+
|
1
7
|
v1.4.7 (June 6, 2013)
|
2
8
|
* Fix backwards compatibility with version strings for Chrome
|
3
9
|
* Restore specs that test against version strings for backwards compatibility with the old UserAgent API.
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Web Font Loader gives you added control when using linked fonts via `@font-face`
|
|
24
24
|
|
25
25
|
To use the Web Font Loader library, just include it in your page and tell it which fonts to load. For example, you could load fonts from [Google Fonts](http://www.google.com/fonts/) using the Web Font Loader hosted on [Google Hosted Libraries](https://developers.google.com/speed/libraries/) using the following code.
|
26
26
|
|
27
|
-
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.
|
27
|
+
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
|
28
28
|
<script>
|
29
29
|
WebFont.load({
|
30
30
|
google: {
|
@@ -33,7 +33,7 @@ To use the Web Font Loader library, just include it in your page and tell it whi
|
|
33
33
|
});
|
34
34
|
</script>
|
35
35
|
|
36
|
-
Alternatively, you can link to the latest `1.x` version of the Web Font Loader by using `//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js` as the `script` source. Note that the version in this url is less specific. It will always load the latest `1.x` version, but it also has a shorter cache time to ensure that your page gets updates in a timely manner. For performance reasons, we recommend using an explicit version number (such as `1.4.
|
36
|
+
Alternatively, you can link to the latest `1.x` version of the Web Font Loader by using `//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js` as the `script` source. Note that the version in this url is less specific. It will always load the latest `1.x` version, but it also has a shorter cache time to ensure that your page gets updates in a timely manner. For performance reasons, we recommend using an explicit version number (such as `1.4.7`) in urls when using the Web Font Loader in production. You can manually update the Web Font Loader version number in the url when you want to adopt a new version.
|
37
37
|
|
38
38
|
It is also possible to use the Web Font Loader asynchronously. For example, to load [Typekit](http://www.typekit.com) fonts asynchronously, you could use the following code.
|
39
39
|
|
@@ -45,7 +45,7 @@ It is also possible to use the Web Font Loader asynchronously. For example, to l
|
|
45
45
|
(function() {
|
46
46
|
var wf = document.createElement('script');
|
47
47
|
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
|
48
|
-
'://ajax.googleapis.com/ajax/libs/webfont/1.4.
|
48
|
+
'://ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js';
|
49
49
|
wf.type = 'text/javascript';
|
50
50
|
wf.async = 'true';
|
51
51
|
var s = document.getElementsByTagName('script')[0];
|
data/Rakefile
CHANGED
@@ -95,7 +95,8 @@ file "target/webfont.js" => SourceJs + ["target"] do |t|
|
|
95
95
|
"--generate_exports",
|
96
96
|
["--output_wrapper", %("#{output_wrapper}")],
|
97
97
|
["--warning_level", "VERBOSE"],
|
98
|
-
["--summary_detail_level", "3"]
|
98
|
+
["--summary_detail_level", "3"],
|
99
|
+
"--define goog.DEBUG=false"
|
99
100
|
]
|
100
101
|
|
101
102
|
# Extra args to add warnings.
|
@@ -115,12 +116,34 @@ desc "Creates debug version into target/webfont.js"
|
|
115
116
|
task :debug => "target/webfont_debug.js"
|
116
117
|
|
117
118
|
file "target/webfont_debug.js" => SourceJs + ["target"] do |t|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
119
|
+
|
120
|
+
output_marker = "%output%"
|
121
|
+
output_wrapper = @modules.js_output_wrapper(output_marker)
|
122
|
+
|
123
|
+
args = [
|
124
|
+
["-jar", JsCompilerJar],
|
125
|
+
["--compilation_level", "ADVANCED_OPTIMIZATIONS"],
|
126
|
+
["--js_output_file", t.name],
|
127
|
+
"--generate_exports",
|
128
|
+
["--output_wrapper", %("#{output_wrapper}")],
|
129
|
+
["--warning_level", "VERBOSE"],
|
130
|
+
["--summary_detail_level", "3"],
|
131
|
+
"--debug=true",
|
132
|
+
"--formatting=PRETTY_PRINT",
|
133
|
+
"--formatting=PRINT_INPUT_DELIMITER"
|
134
|
+
]
|
135
|
+
|
136
|
+
# Extra args to add warnings.
|
137
|
+
args.concat([
|
138
|
+
["--warning_level", "VERBOSE"],
|
139
|
+
["--summary_detail_level", "1"]
|
140
|
+
])
|
141
|
+
|
142
|
+
source = @modules.all_source_files
|
143
|
+
args.concat source.map { |f| ["--js", f] }
|
144
|
+
|
145
|
+
output = `java #{args.flatten.join(' ')} 2>&1`
|
146
|
+
$?.success? ? (puts output) : (fail output)
|
124
147
|
end
|
125
148
|
|
126
149
|
#
|
data/lib/webfontloader.rb
CHANGED
@@ -1222,6 +1222,27 @@ describe('UserAgentParser', function () {
|
|
1222
1222
|
}
|
1223
1223
|
});
|
1224
1224
|
});
|
1225
|
+
|
1226
|
+
it('should detect Opera Next (15)', function () {
|
1227
|
+
expect(parse('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.20 Safari/537.36 OPR/15.0.1147.18 (Edition Next)'))
|
1228
|
+
.toMatchUserAgent({
|
1229
|
+
name: 'Opera',
|
1230
|
+
parsedVersion: new Version(15, 0, 1147, 18),
|
1231
|
+
version: '15.0.1147.18',
|
1232
|
+
platform: 'Macintosh',
|
1233
|
+
parsedPlatformVersion: new Version(10, 8, 3),
|
1234
|
+
platformVersion: '10_8_3',
|
1235
|
+
engine: 'AppleWebKit',
|
1236
|
+
parsedEngineVersion: new Version(537, 36),
|
1237
|
+
engineVersion: '537.36',
|
1238
|
+
documentMode: undefined,
|
1239
|
+
browserInfo: {
|
1240
|
+
hasWebFontSupport: true,
|
1241
|
+
hasWebKitFallbackBug: false,
|
1242
|
+
hasWebKitMetricsBug: true
|
1243
|
+
}
|
1244
|
+
});
|
1245
|
+
});
|
1225
1246
|
});
|
1226
1247
|
|
1227
1248
|
describe('WebKit fallback bug', function () {
|
@@ -1429,5 +1450,28 @@ describe('UserAgentParser', function () {
|
|
1429
1450
|
});
|
1430
1451
|
});
|
1431
1452
|
});
|
1453
|
+
|
1454
|
+
describe('PhantomJS', function () {
|
1455
|
+
it('should detect PhantomJS as having web font support', function () {
|
1456
|
+
expect(parse('Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 (development) Safari/534.34'))
|
1457
|
+
.toMatchUserAgent({
|
1458
|
+
name: 'PhantomJS',
|
1459
|
+
parsedVersion: new Version(1, 9, 0),
|
1460
|
+
version: '1.9.0',
|
1461
|
+
platform: 'Macintosh',
|
1462
|
+
parsedPlatformVersion: new Version(),
|
1463
|
+
platformVersion: 'Unknown',
|
1464
|
+
engine: 'AppleWebKit',
|
1465
|
+
parsedEngineVersion: new Version(534, 34),
|
1466
|
+
engineVersion: '534.34',
|
1467
|
+
documentMode: undefined,
|
1468
|
+
browserInfo: {
|
1469
|
+
hasWebFontSupport: true,
|
1470
|
+
hasWebKitFallbackBug: true,
|
1471
|
+
hasWebKitMetricsBug: true
|
1472
|
+
}
|
1473
|
+
});
|
1474
|
+
});
|
1475
|
+
});
|
1432
1476
|
});
|
1433
1477
|
});
|
data/spec/index.html
CHANGED
@@ -13,7 +13,10 @@
|
|
13
13
|
<link rel="stylesheet" href="fonts/sourcesansc.css">
|
14
14
|
<link rel="stylesheet" href="fonts/sourcesanscbold.css">
|
15
15
|
</head>
|
16
|
-
|
16
|
+
<body>
|
17
|
+
<script>
|
18
|
+
CLOSURE_NO_DEPS = true;
|
19
|
+
</script>
|
17
20
|
<script src="../tools/jasmine/jasmine.js"></script>
|
18
21
|
<script src="../tools/jasmine/jasmine-html.js"></script>
|
19
22
|
<script src="../tools/jasmine-phantomjs/terminal-reporter.js"></script>
|
data/src/core/useragentparser.js
CHANGED
@@ -60,8 +60,10 @@ goog.scope(function () {
|
|
60
60
|
UserAgentParser.prototype.parse = function() {
|
61
61
|
if (this.isIe_()) {
|
62
62
|
return this.parseIeUserAgentString_();
|
63
|
+
} else if (this.isOldOpera_()) {
|
64
|
+
return this.parseOldOperaUserAgentString_();
|
63
65
|
} else if (this.isOpera_()) {
|
64
|
-
return this.
|
66
|
+
return this.parseWebKitUserAgentString_();
|
65
67
|
} else if (this.isWebKit_()) {
|
66
68
|
return this.parseWebKitUserAgentString_();
|
67
69
|
} else if (this.isGecko_()) {
|
@@ -175,14 +177,21 @@ goog.scope(function () {
|
|
175
177
|
/**
|
176
178
|
* @private
|
177
179
|
*/
|
178
|
-
UserAgentParser.prototype.
|
180
|
+
UserAgentParser.prototype.isOldOpera_ = function() {
|
179
181
|
return this.userAgent_.indexOf("Opera") != -1;
|
180
182
|
};
|
181
183
|
|
182
184
|
/**
|
183
185
|
* @private
|
184
186
|
*/
|
185
|
-
UserAgentParser.prototype.
|
187
|
+
UserAgentParser.prototype.isOpera_ = function () {
|
188
|
+
return /OPR\/[\d.]+/.test(this.userAgent_);
|
189
|
+
};
|
190
|
+
|
191
|
+
/**
|
192
|
+
* @private
|
193
|
+
*/
|
194
|
+
UserAgentParser.prototype.parseOldOperaUserAgentString_ = function() {
|
186
195
|
var engineName = UserAgentParser.UNKNOWN,
|
187
196
|
engineVersionString = this.getMatchingGroup_(this.userAgent_, /Presto\/([\d\w\.]+)/, 1),
|
188
197
|
engineVersion = Version.parse(engineVersionString),
|
@@ -295,7 +304,9 @@ goog.scope(function () {
|
|
295
304
|
browserVersionString = UserAgentParser.UNKNOWN,
|
296
305
|
supportWebFont = false;
|
297
306
|
|
298
|
-
if (this.userAgent_
|
307
|
+
if (/OPR\/[\d.]+/.test(this.userAgent_)) {
|
308
|
+
browserName = "Opera";
|
309
|
+
} else if (this.userAgent_.indexOf("Chrome") != -1 ||
|
299
310
|
this.userAgent_.indexOf("CrMo") != -1 ||
|
300
311
|
this.userAgent_.indexOf("CriOS") != -1) {
|
301
312
|
browserName = "Chrome";
|
@@ -303,6 +314,8 @@ goog.scope(function () {
|
|
303
314
|
browserName = "Silk";
|
304
315
|
} else if (platform == "BlackBerry" || platform == "Android") {
|
305
316
|
browserName = UserAgentParser.BUILTIN_BROWSER;
|
317
|
+
} else if (this.userAgent_.indexOf("PhantomJS") != -1) {
|
318
|
+
browserName = "PhantomJS";
|
306
319
|
} else if (this.userAgent_.indexOf("Safari") != -1) {
|
307
320
|
browserName = "Safari";
|
308
321
|
} else if (this.userAgent_.indexOf("AdobeAIR") != -1) {
|
@@ -319,6 +332,10 @@ goog.scope(function () {
|
|
319
332
|
browserVersionString = this.getMatchingGroup_(this.userAgent_, /Version\/([\d\.\w]+)/, 1);
|
320
333
|
} else if (browserName == "AdobeAIR") {
|
321
334
|
browserVersionString = this.getMatchingGroup_(this.userAgent_, /AdobeAIR\/([\d\.]+)/, 1);
|
335
|
+
} else if (browserName == "Opera") {
|
336
|
+
browserVersionString = this.getMatchingGroup_(this.userAgent_, /OPR\/([\d.]+)/, 1);
|
337
|
+
} else if (browserName == "PhantomJS") {
|
338
|
+
browserVersionString = this.getMatchingGroup_(this.userAgent_, /PhantomJS\/([\d.]+)/, 1);
|
322
339
|
}
|
323
340
|
browserVersion = Version.parse(browserVersionString);
|
324
341
|
|
data/tools/compiler/base.js
CHANGED
data/webfontloader.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'webfontloader'
|
16
|
-
s.version = '1.4.
|
17
|
-
s.date = '2013-06-
|
16
|
+
s.version = '1.4.8'
|
17
|
+
s.date = '2013-06-24'
|
18
18
|
|
19
19
|
## Make sure your summary is short. The description may be as long
|
20
20
|
## as you like.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webfontloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 8
|
10
|
+
version: 1.4.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Carver
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-06-
|
19
|
+
date: 2013-06-24 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: rake
|