Skip to content

Commit 35ccd8a

Browse files
committed
Scale window & Save scale across sessions
sets scale of window with mod+shift + +/-/0 This will be useful for users on HiDPI screens
1 parent 3530a18 commit 35ccd8a

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

app/public/js/app.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@ app.run(function(
137137
}
138138
});
139139

140+
hotkeys.add({
141+
combo: ['mod+shift+0'],
142+
description: 'Reset Window Scale to 1',
143+
callback: function() {
144+
userConfig.scaleWindow("reset");
145+
}
146+
});
147+
148+
hotkeys.add({
149+
combo: ['mod+shift+=', 'mod+shift++'],
150+
description: 'Zoom in +0.1',
151+
callback: function() {
152+
userConfig.scaleWindow("plus");
153+
}
154+
});
155+
156+
hotkeys.add({
157+
combo: ['mod+shift+-'],
158+
description: 'Zoom out -0.1',
159+
callback: function() {
160+
userConfig.scaleWindow("minus");
161+
}
162+
});
163+
140164
});
141165

142166
angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 200);

app/public/js/system/core.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
// Initialize modules
44
authentication.init();
55
userConfig.windowState();
6+
userConfig.scaleState();
67
guiConfig.init();

app/public/js/system/userConfig.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,38 @@ userConfig.saveWindow = function(width, height) {
4949
window.localStorage.width = Math.round(width);
5050
window.localStorage.height = Math.round(height);
5151
}
52-
};
52+
};
53+
54+
userConfig.scaleWindow = function(scale){
55+
if("plus" === scale) {
56+
var currentScale = window.document.getElementsByTagName("body")[0].style.zoom;
57+
var newScale = (currentScale * 100 + 10);
58+
59+
window.document.getElementsByTagName("body")[0].style.zoom = newScale / 100;
60+
61+
userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
62+
}
63+
if("minus" === scale) {
64+
var currentScale = window.document.getElementsByTagName("body")[0].style.zoom;
65+
var newScale = newScale = (currentScale - .1);
66+
67+
window.document.getElementsByTagName("body")[0].style.zoom = newScale;
68+
69+
userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
70+
}
71+
if("reset" === scale) {
72+
window.document.getElementsByTagName("body")[0].style.zoom = 1;
73+
74+
userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
75+
}
76+
};
77+
78+
userConfig.saveScale = function(scale) {
79+
window.localStorage.scale = scale;
80+
};
81+
82+
userConfig.scaleState = function() {
83+
if(window.localStorage.scale) {
84+
window.document.getElementsByTagName("body")[0].style.zoom = window.localStorage.scale;
85+
}
86+
};

0 commit comments

Comments
 (0)