Skip to content

Commit

Permalink
Scale window & Save scale across sessions
Browse files Browse the repository at this point in the history
Sets scale of window with mod+shift + +/-/0

This will be useful for users on HiDPI screens
  • Loading branch information
jakejarrett committed Dec 4, 2015
1 parent 3530a18 commit a267f54
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
24 changes: 24 additions & 0 deletions app/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,30 @@ app.run(function(
}
});

hotkeys.add({
combo: ['mod+0'],
description: 'Reset Window Scale to 1',
callback: function() {
userConfig.scaleWindow("reset");
}
});

hotkeys.add({
combo: ['mod+=', 'mod++'],
description: 'Zoom in +0.1',
callback: function() {
userConfig.scaleWindow("plus");
}
});

hotkeys.add({
combo: ['mod+-'],
description: 'Zoom out -0.1',
callback: function() {
userConfig.scaleWindow("minus");
}
});

});

angular.module('infinite-scroll').value('THROTTLE_MILLISECONDS', 200);
1 change: 1 addition & 0 deletions app/public/js/system/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// Initialize modules
authentication.init();
userConfig.windowState();
userConfig.scaleState();
guiConfig.init();
36 changes: 35 additions & 1 deletion app/public/js/system/userConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,38 @@ userConfig.saveWindow = function(width, height) {
window.localStorage.width = Math.round(width);
window.localStorage.height = Math.round(height);
}
};
};

userConfig.scaleWindow = function(scale){
if("plus" === scale) {
var currentScale = window.document.getElementsByTagName("body")[0].style.zoom;
var newScale = (currentScale * 100 + 10);

window.document.getElementsByTagName("body")[0].style.zoom = newScale / 100;

userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
}
if("minus" === scale) {
var currentScale = window.document.getElementsByTagName("body")[0].style.zoom;
var newScale = newScale = (currentScale - .1);

window.document.getElementsByTagName("body")[0].style.zoom = newScale;

userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
}
if("reset" === scale) {
window.document.getElementsByTagName("body")[0].style.zoom = 1;

userConfig.saveScale(window.document.getElementsByTagName("body")[0].style.zoom);
}
};

userConfig.saveScale = function(scale) {
window.localStorage.scale = scale;
};

userConfig.scaleState = function() {
if(window.localStorage.scale) {
window.document.getElementsByTagName("body")[0].style.zoom = window.localStorage.scale;
}
};

0 comments on commit a267f54

Please sign in to comment.