forked from zombieFox/nightTab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeyboard.js
More file actions
119 lines (109 loc) · 2.86 KB
/
Copy pathkeyboard.js
File metadata and controls
119 lines (109 loc) · 2.86 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var keyboard = (function() {
var bind = {};
bind.esc = function() {
window.addEventListener("keydown", function(event) {
// esc
if (event.keyCode == 27) {
if (state.get().edge) {
edge.render.clear();
} else if (state.get().menu) {
menu.close();
shade.close();
} else if (state.get().autoSuggest) {
autoSuggest.close();
} else if (state.get().link.add) {
link.add.close();
shade.close();
} else if (state.get().modal) {
modal.close();
shade.close();
} else if (state.get().link.edit) {
helper.setObject({
object: state.get(),
path: "link.edit",
newValue: false
});
control.render.update();
control.render.class();
};
data.save();
};
}, false);
};
bind.ctrAltA = function() {
window.addEventListener("keydown", function(event) {
// ctrl+alt+a
if (event.ctrlKey && event.altKey && event.keyCode == 65) {
if (!state.get().link.add) {
if (state.get().menu) {
menu.close();
};
if (state.get().modal) {
modal.close();
};
link.add.open();
};
};
}, false);
};
bind.ctrAltD = function() {
window.addEventListener("keydown", function(event) {
// ctrl+alt+d
if (event.ctrlKey && event.altKey && event.keyCode == 68) {
theme.toggle();
control.render.update();
data.save();
};
}, false);
};
bind.ctrAltM = function() {
window.addEventListener("keydown", function(event) {
// ctrl+alt+m
if (event.ctrlKey && event.altKey && event.keyCode == 77) {
if (state.get().link.add) {
link.add.close();
shade.close();
} else if (state.get().modal) {
modal.close();
shade.close();
};
menu.toggle();
};
}, false);
};
bind.ctrAltE = function() {
window.addEventListener("keydown", function(event) {
// ctrl+alt+e
if (event.ctrlKey && event.altKey && event.keyCode == 69) {
link.edit();
link.tabindex();
control.render.update();
control.render.class();
data.save();
};
}, false);
};
bind.ctrAltR = function() {
window.addEventListener("keydown", function(event) {
// ctrl+alt+r
if (state.get().theme.accent.random.active && event.ctrlKey && event.altKey && event.keyCode == 82) {
theme.render.accent.random();
theme.render.accent.color();
link.items();
data.save();
};
}, false);
};
var init = function() {
bind.esc();
bind.ctrAltA();
bind.ctrAltD();
bind.ctrAltM();
bind.ctrAltE();
bind.ctrAltR();
};
return {
init: init,
bind: bind
};
})();