webfontloader 1.5.21 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/lib/webfontloader.rb +1 -1
- data/spec/core/fontwatcher_spec.js +11 -24
- data/spec/core/fontwatchrunner_spec.js +4 -10
- data/spec/core/nativefontwatchrunner_spec.js +0 -6
- data/spec/core/webfont_spec.js +11 -144
- data/spec/deps.js +1 -5
- data/spec/index.html +0 -2
- data/spec/modules/fontdeck_spec.js +2 -10
- data/spec/modules/monotype_spec.js +0 -13
- data/spec/modules/typekit_spec.js +7 -8
- data/src/core/fontmodule.js +0 -6
- data/src/core/fontwatcher.js +2 -6
- data/src/core/fontwatchrunner.js +32 -4
- data/src/core/webfont.js +5 -38
- data/src/modules.yml +0 -4
- data/src/modules/custom.js +0 -4
- data/src/modules/fontdeck.js +4 -8
- data/src/modules/google/googlefontapi.js +1 -17
- data/src/modules/monotype.js +24 -29
- data/src/modules/typekit.js +9 -13
- data/webfontloader.gemspec +2 -8
- data/webfontloader.js +17 -29
- metadata +2 -8
- data/spec/core/useragentparser_spec.js +0 -1301
- data/spec/core/version_spec.js +0 -143
- data/src/core/browserinfo.js +0 -76
- data/src/core/useragent.js +0 -93
- data/src/core/useragentparser.js +0 -422
- data/src/core/version.js +0 -180
data/src/core/version.js
DELETED
@@ -1,180 +0,0 @@
|
|
1
|
-
goog.provide('webfont.Version');
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Represents a version as used in user agent strings. Note
|
5
|
-
* that this does not represent any sort of reliable versioning
|
6
|
-
* scheme (like Semantic Versioning) but merely a best effort
|
7
|
-
* at parsing a large amount of wildly different version strings.
|
8
|
-
*
|
9
|
-
* @constructor
|
10
|
-
* @param {?number=} opt_major
|
11
|
-
* @param {?number=} opt_minor
|
12
|
-
* @param {?number=} opt_patch
|
13
|
-
* @param {?(number|string)=} opt_build
|
14
|
-
*/
|
15
|
-
webfont.Version = function(opt_major, opt_minor, opt_patch, opt_build) {
|
16
|
-
/**
|
17
|
-
* @type {?number}
|
18
|
-
*/
|
19
|
-
this.major = goog.isDefAndNotNull(opt_major) ? opt_major : null;
|
20
|
-
|
21
|
-
/**
|
22
|
-
* @type {?number}
|
23
|
-
*/
|
24
|
-
this.minor = goog.isDefAndNotNull(opt_minor) ? opt_minor : null;
|
25
|
-
|
26
|
-
/**
|
27
|
-
* @type {?number}
|
28
|
-
*/
|
29
|
-
this.patch = goog.isDefAndNotNull(opt_patch) ? opt_patch : null;
|
30
|
-
|
31
|
-
/**
|
32
|
-
* @type {?(number|string)}
|
33
|
-
*/
|
34
|
-
this.build = goog.isDefAndNotNull(opt_build) ? opt_build : null;
|
35
|
-
}
|
36
|
-
|
37
|
-
goog.scope(function () {
|
38
|
-
var Version = webfont.Version;
|
39
|
-
|
40
|
-
Version.TOKENIZER = new RegExp(
|
41
|
-
"^" +
|
42
|
-
"([0-9]+)" + // major
|
43
|
-
"(?:" +
|
44
|
-
"[\\._-]([0-9]+)" + // minor
|
45
|
-
")?" +
|
46
|
-
"(?:" +
|
47
|
-
"[\\._-]([0-9]+)" + // patch
|
48
|
-
")?" +
|
49
|
-
"(?:" +
|
50
|
-
"[\\._+-]?(.*)" + // build
|
51
|
-
")?$"
|
52
|
-
);
|
53
|
-
|
54
|
-
/**
|
55
|
-
* Returns true if the version is valid. A
|
56
|
-
* version is considered valid if it has at
|
57
|
-
* least a major version number.
|
58
|
-
*
|
59
|
-
* @return {boolean}
|
60
|
-
*/
|
61
|
-
Version.prototype.isValid = function () {
|
62
|
-
return !goog.isNull(this.major);
|
63
|
-
};
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Compares two versions. Returns -1 if this
|
67
|
-
* is smaller than version. Returns 1 if this
|
68
|
-
* is greater than version. Returns 0 if this
|
69
|
-
* equals version.
|
70
|
-
*
|
71
|
-
* Build strings or numbers are ignored when
|
72
|
-
* comparing versions.
|
73
|
-
*
|
74
|
-
* @param {webfont.Version} version
|
75
|
-
* @return {number}
|
76
|
-
*/
|
77
|
-
Version.prototype.compare = function (version) {
|
78
|
-
if (this.major > version.major ||
|
79
|
-
((this.major === version.major && this.minor > version.minor) ||
|
80
|
-
(this.major === version.major && this.minor === version.minor && this.patch > version.patch))) {
|
81
|
-
return 1;
|
82
|
-
} else if (this.major < version.major ||
|
83
|
-
((this.major === version.major && this.minor < version.minor) ||
|
84
|
-
(this.major === version.major && this.minor === version.minor && this.patch < version.patch))) {
|
85
|
-
return -1;
|
86
|
-
}
|
87
|
-
return 0;
|
88
|
-
};
|
89
|
-
|
90
|
-
/**
|
91
|
-
* @param {webfont.Version} version
|
92
|
-
* @return {boolean}
|
93
|
-
*/
|
94
|
-
Version.prototype.gt = function (version) {
|
95
|
-
return this.compare(version) === 1;
|
96
|
-
};
|
97
|
-
|
98
|
-
/**
|
99
|
-
* @param {webfont.Version} version
|
100
|
-
* @return {boolean}
|
101
|
-
*/
|
102
|
-
Version.prototype.lt = function (version) {
|
103
|
-
return this.compare(version) === -1;
|
104
|
-
};
|
105
|
-
|
106
|
-
/**
|
107
|
-
* @param {webfont.Version} version
|
108
|
-
* @return {boolean}
|
109
|
-
*/
|
110
|
-
Version.prototype.ge = function (version) {
|
111
|
-
return this.compare(version) === 0 || this.compare(version) === 1;
|
112
|
-
};
|
113
|
-
|
114
|
-
/**
|
115
|
-
* @param {webfont.Version} version
|
116
|
-
* @return {boolean}
|
117
|
-
*/
|
118
|
-
Version.prototype.le = function (version) {
|
119
|
-
return this.compare(version) === 0 || this.compare(version) === -1;
|
120
|
-
};
|
121
|
-
|
122
|
-
/**
|
123
|
-
* @param {webfont.Version} version
|
124
|
-
* @return {boolean}
|
125
|
-
*/
|
126
|
-
Version.prototype.eq = function (version) {
|
127
|
-
return this.compare(version) === 0;
|
128
|
-
};
|
129
|
-
|
130
|
-
/**
|
131
|
-
* @param {webfont.Version} version
|
132
|
-
* @return {boolean}
|
133
|
-
*/
|
134
|
-
Version.prototype.ne = function (version) {
|
135
|
-
return this.compare(version) !== 0;
|
136
|
-
};
|
137
|
-
|
138
|
-
/**
|
139
|
-
* @return {string}
|
140
|
-
*/
|
141
|
-
Version.prototype.toString = function () {
|
142
|
-
return [this.major, this.minor || '', this.patch || '', this.build || ''].join('');
|
143
|
-
};
|
144
|
-
|
145
|
-
/**
|
146
|
-
* @param {string} str
|
147
|
-
* @return {!webfont.Version}
|
148
|
-
*/
|
149
|
-
Version.parse = function (str) {
|
150
|
-
var match = Version.TOKENIZER.exec(str),
|
151
|
-
major = null,
|
152
|
-
minor = null,
|
153
|
-
patch = null,
|
154
|
-
build = null;
|
155
|
-
|
156
|
-
if (match) {
|
157
|
-
if (!goog.isNull(match[1]) && !!match[1]) {
|
158
|
-
major = parseInt(match[1], 10);
|
159
|
-
}
|
160
|
-
|
161
|
-
if (!goog.isNull(match[2]) && !!match[2]) {
|
162
|
-
minor = parseInt(match[2], 10);
|
163
|
-
}
|
164
|
-
|
165
|
-
if (!goog.isNull(match[3]) && !!match[3]) {
|
166
|
-
patch = parseInt(match[3], 10);
|
167
|
-
}
|
168
|
-
|
169
|
-
if (!goog.isNull(match[4]) && !!match[4]) {
|
170
|
-
if (/^[0-9]+$/.test(match[4])) {
|
171
|
-
build = parseInt(match[4], 10);
|
172
|
-
} else {
|
173
|
-
build = match[4];
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
|
178
|
-
return new Version(major, minor, patch, build);
|
179
|
-
};
|
180
|
-
});
|