forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindowEvents.js
More file actions
61 lines (46 loc) · 1.52 KB
/
windowEvents.js
File metadata and controls
61 lines (46 loc) · 1.52 KB
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
// add the platform to the HTML tag
setTimeout(function () {
document.getElementsByTagName('html')[0].className = window.mist.platform;
if (window.basePathHref) {
var base = document.createElement('base');
base.href = window.basePathHref;
document.getElementsByTagName('head')[0].appendChild(base);
}
}, 200);
$(window).on('blur', function (e) {
$('body').addClass('app-blur');
});
$(window).on('focus', function (e) {
$('body').removeClass('app-blur');
});
// make sure files can only be dropped in the browser webview
$(window).on('dragenter', function (e) {
LocalStore.set('selectedTab', 'browser');
ipc.send('backendAction_focusMainWindow');
});
$(window).on('keydown', function (e) {
// Select tab with index when number is 1-8
if (e.metaKey && e.keyCode >= 49 && e.keyCode <= 56) {
var index = parseInt(String.fromCharCode(e.keyCode), 10) - 1;
Helpers.selectTabWithIndex(index);
return;
}
// RELOAD current webview
if (e.metaKey && e.keyCode === 82) {
var webview = Helpers.getWebview(LocalStore.get('selectedTab'));
if (webview) {
webview.reloadIgnoringCache();
}
return;
}
// Select last tab on Ctrl + 9
if (e.metaKey && e.keyCode === 57) {
Helpers.selectLastTab();
return;
}
// Ctrl + tab || Ctrl + shift + tab
if (e.ctrlKey && e.keyCode === 9) {
var tabOffset = (e.shiftKey) ? -1 : 1;
Helpers.selectTabWithOffset(tabOffset);
}
});