-
Notifications
You must be signed in to change notification settings - Fork 0
/
pending_changes.js
71 lines (56 loc) · 1.78 KB
/
pending_changes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var PendingChanges = function () {
this.pendingFontSizeChanges_ = {};
};
PendingChanges.prototype.getFontSize = function (fontSizeKey) {
return this.pendingFontSizeChanges_[fontSizeKey];
};
PendingChanges.prototype.setFontSize = function (fontSizeKey, size) {
if (this.pendingFontSizeChanges_[fontSizeKey] == size)
return;
this.pendingFontSizeChanges_[fontSizeKey] = size;
};
PendingChanges.prototype.apply = function () {
for (var script in this.pendingFontChanges_) {
for (var genericFamily in this.pendingFontChanges_[script]) {
var fontId = this.pendingFontChanges_[script][genericFamily];
if (fontId == null)
continue;
var details = {};
details.script = script;
details.genericFamily = genericFamily;
details.fontId = fontId;
chrome.fontSettings.setFont(details);
}
}
var size = this.pendingFontSizeChanges_['defaultFontSize'];
if (size != null)
chrome.fontSettings.setDefaultFontSize({
pixelSize: size
});
size = this.pendingFontSizeChanges_['minFontSize'];
if (size != null)
chrome.fontSettings.setMinimumFontSize({
pixelSize: size
});
this.clear();
};
PendingChanges.prototype.clearOneScript = function (script) {
this.pendingFontChanges_[script] = {};
};
PendingChanges.prototype.clear = function () {
this.pendingFontChanges_ = {};
this.pendingFontSizeChanges_ = {};
};
PendingChanges.prototype.isEmpty = function () {
for (var script in this.pendingFontChanges_) {
for (var genericFamily in this.pendingFontChanges_[script]) {
if (this.pendingFontChanges_[script][genericFamily] != null)
return false;
}
}
for (var name in this.pendingFontSizeChanges_) {
if (this.pendingFontSizeChanges_[name] != null)
return false;
}
return true;
};