Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
Support zooming and unzooming
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinduks committed Oct 14, 2015
1 parent b9b666d commit 979ed88
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions stage.js
@@ -1,6 +1,7 @@
(function() {
var gui = require('nw.gui');
var iframe = document.querySelector('iframe');
var win = gui.Window.get();

var handleClick = function(e) {
var checkForLink = function(el) {
Expand Down Expand Up @@ -29,18 +30,31 @@

checkForLink(e.target);
};


var zoom = function () { win.zoomLevel += 1; }
var unzoom = function () { win.zoomLevel -= 1; }
var resetZoom = function () { win.zoomLevel = 0; }

var handleKeydown = function (e) {
if (e.ctrlKey) {
if (e.keyCode == 187) zoom();
else if (e.keyCode == 189) unzoom();
else if (e.keyCode == 48) resetZoom();
}
};

var init = function() {
if (iframe &&
iframe.contentWindow &&
iframe.contentWindow.document &&
iframe.contentWindow.document.body &&
iframe.contentWindow.document.body.innerHTML) {
iframe.contentWindow.document.body.addEventListener('click', handleClick, false);
iframe.contentWindow.document.body.addEventListener('keydown', handleKeydown, false);
} else {
setTimeout(init, 100);
}
};

init();
}).apply(this);

0 comments on commit 979ed88

Please sign in to comment.