forked from dapphp/keyboard_shortcuts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard_shortcuts.js
274 lines (236 loc) · 5.64 KB
/
keyboard_shortcuts.js
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
function keyboard_shortcuts_show_help()
{
$('#keyboard_shortcuts_help').dialog('open')
}
$(function ()
{
// initialize a dialog window
$('#keyboard_shortcuts_help').dialog({
autoOpen: false,
draggable: true,
modal: true,
resizable: false,
width: 950,
title: rcmail.gettext("keyboard_shortcuts.keyboard_shortcuts")
})
// fire up the keypress event listener
$(document).keydown(function (e)
{
return key_pressed(e)
})
function key_pressed(e)
{
// special case. If we hit ctrl-enter, and we're composing, and we have focus, then send email
if (rcmail.env.action == 'compose' && e.which == 13 && e.ctrlKey && $("*:focus").is("#composebody"))
{
$('.button.send').click()
return false
}
// check if some element has focus. If it does, skip this plugin.
if ($("*:focus").is("textarea, input"))
return true
if (rcmail.env.action == 'compose' || rcmail.env.task == 'login' || e.ctrlKey || e.metaKey)
return true
//BOITE DE RECEPTION
if (rcmail.env.action == '')
{
//? = help
if (e.shiftKey == true && e.keyCode == 188)
{
$('#keyboard_shortcuts_help').dialog('open')
return false
}
//F3 = locate folder
if (e.shiftKey == false && e.keyCode == 114)
{
rcmail.command('plugin.contextmenu_folder.folder_locate')
return false
}
//F4 = create folder
if (e.shiftKey == false && e.keyCode == 115)
{
rcmail.command('plugin.contextmenu_folder.contact_folder_create')
return false
}
//F5 = copy to folder
if (e.shiftKey == false && e.keyCode == 116)
if (rcmail.message_list.get_selection().length > 0)
{
rcmail.command('plugin.contextmenu_folder.message_copy')
return false
}
//F6 = move to folder
if (e.shiftKey == false && e.keyCode == 117)
if (rcmail.message_list.get_selection().length > 0)
{
rcmail.command('plugin.contextmenu_folder.message_move')
return false
}
//A = mark all as read
if (e.shiftKey == true && e.keyCode == 65)
{
rcmail.command('select-all', 'page')
rcmail.command('mark', 'read')
return false
}
//C = collapse-all
if (e.shiftKey == true && e.keyCode == 67)
{
rcmail.command('collapse-all')
return false
}
//E = expand-all
if (e.shiftKey == true && e.keyCode == 69)
{
rcmail.command('expand-all')
return false
}
//R = reply-all
if (e.shiftKey == true && e.keyCode == 82)
{
if (rcmail.message_list.selection.length == 1)
rcmail.command('reply-all')
return false
}
//U = expand-unread
if (e.shiftKey == true && e.keyCode == 85)
{
rcmail.command('expand-unread')
return false
}
//a = select all
if (e.shiftKey == false && e.keyCode == 65)
{
rcmail.command('select-all', 'page')
return false
}
//c = compose
if (e.shiftKey == false && e.keyCode == 67)
{
rcmail.command('compose')
return false
}
//d = delete
if (e.shiftKey == false && e.keyCode == 68)
{
rcmail.command('delete', '', rcmail)
return false
}
//f = forward
if (e.shiftKey == false && e.keyCode == 70)
{
if (rcmail.message_list.selection.length == 1)
rcmail.command('forward')
return false
}
//j = previous page (similar to Gmail)
if (e.shiftKey == false && e.keyCode == 74)
{
rcmail.command('previouspage')
return false
}
//k = next page (similar to Gmail)
if (e.shiftKey == false && e.keyCode == 75)
{
rcmail.command('nextpage')
return false
}
//m = mark read/unread (similar to Thunderbird)
if (e.shiftKey == false && e.keyCode == 77)
{
var uid = rcmail.message_list.get_selection()
if (uid && uid.length > 0)
{
var mid = rcmail.message_list.rows[uid[0]].id
if ($('tr#' + mid).hasClass('unread'))
rcmail.command('mark', 'read')
else
rcmail.command('mark', 'unread')
}
else
return true
}
//p = print
if (e.shiftKey == false && e.keyCode == 80)
{
if (rcmail.message_list.selection.length == 1)
rcmail.command('print')
return false
}
//r = reply
if (e.shiftKey == false && e.keyCode == 82)
{
if (rcmail.message_list.selection.length == 1)
rcmail.command('reply')
return false
}
//s = search
if (e.shiftKey == false && e.keyCode == 83)
{
$('#mailsearchform').focus()
$('#mailsearchform').select()
return false
}
//u = update (check for mail)
if (e.shiftKey == false && e.keyCode == 85)
{
rcmail.command('checkmail')
return false
}
return false
}
//VISUALISATION DE COURRIEL
else if (rcmail.env.action == 'show' || rcmail.env.action == 'preview')
{
// R = reply-all
if (e.shiftKey == true && e.keyCode == 82)
{
rcmail.command('reply-all')
return false
}
// c = compose
if (e.shiftKey == false && e.keyCode == 67)
{
rcmail.command('compose')
return false
}
// d = delete
if (e.shiftKey == false && e.keyCode == 68)
{
rcmail.command('delete')
return false
}
// f = forward
if (e.shiftKey == false && e.keyCode == 70)
{
rcmail.command('forward')
return false
}
// j = previous message (similar to Gmail)
if (e.shiftKey == false && e.keyCode == 74)
{
rcmail.command('previousmessage')
return false
}
// k = next message (similar to Gmail)
if (e.shiftKey == false && e.keyCode == 75)
{
rcmail.command('nextmessage')
return false
}
// p = print
if (e.shiftKey == false && e.keyCode == 80)
{
rcmail.command('print')
return false
}
// r = reply
if (e.shiftKey == false && e.keyCode == 82)
{
rcmail.command('reply')
return false
}
return false
}
}
})