From a267f54e8650ad5f9d245583304074f2f2f68e42 Mon Sep 17 00:00:00 2001 From: Jake Jarrett Date: Fri, 4 Dec 2015 15:54:07 +1100 Subject: [PATCH] Scale window & Save scale across sessions Sets scale of window with mod+shift + +/-/0 This will be useful for users on HiDPI screens --- app/public/js/app.js | 24 ++++++++++++++++++++ app/public/js/system/core.js | 1 + app/public/js/system/userConfig.js | 36 +++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/app/public/js/app.js b/app/public/js/app.js index 8fc4a55c..fdd29871 100755 --- a/app/public/js/app.js +++ b/app/public/js/app.js @@ -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); diff --git a/app/public/js/system/core.js b/app/public/js/system/core.js index e102dded..ec482aaf 100644 --- a/app/public/js/system/core.js +++ b/app/public/js/system/core.js @@ -3,4 +3,5 @@ // Initialize modules authentication.init(); userConfig.windowState(); +userConfig.scaleState(); guiConfig.init(); diff --git a/app/public/js/system/userConfig.js b/app/public/js/system/userConfig.js index 7d86b657..3e0ba1e9 100644 --- a/app/public/js/system/userConfig.js +++ b/app/public/js/system/userConfig.js @@ -49,4 +49,38 @@ userConfig.saveWindow = function(width, height) { window.localStorage.width = Math.round(width); window.localStorage.height = Math.round(height); } -}; \ No newline at end of file +}; + +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; + } +};