Merge pull request #523 from aeosynth/key

slight refactor of keybinds; meta
This commit is contained in:
Mayhem 2012-06-04 03:41:53 -07:00
commit 55a036708e
2 changed files with 23 additions and 15 deletions

View File

@ -1054,10 +1054,16 @@
return $.on(d, 'keydown', Keybinds.keydown);
},
keydown: function(e) {
var key, link, o, ta, thread;
if (!(key = Keybinds.keyCode(e)) || /TEXTAREA|INPUT/.test(e.target.nodeName) && !(e.altKey || e.ctrlKey || e.keyCode === 27)) {
var key, link, o, target, thread;
if (!(key = Keybinds.keyCode(e))) {
return;
}
target = e.target;
if (/TEXTAREA|INPUT/.test(target.nodeName)) {
if (!((key === 'Esc') || (/\+/.test(key)))) {
return;
}
}
thread = Nav.getThread();
switch (key) {
case Conf.openQR:
@ -1084,15 +1090,13 @@
}
break;
case Conf.spoiler:
ta = e.target;
if (ta.nodeName !== 'TEXTAREA') {
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('spoiler', ta);
break;
case Conf.code:
ta = e.target;
if (ta.nodeName !== 'TEXTAREA') {
if (target.nodeName !== 'TEXTAREA') {
return;
}
Keybinds.tags('code', ta);
@ -1233,6 +1237,9 @@
if (e.ctrlKey) {
key = 'ctrl+' + key;
}
if (e.metaKey) {
key = 'meta+' + key;
}
}
return key;
},
@ -2280,7 +2287,7 @@
<input type=radio name=tab hidden id=keybinds_tab>\
<div>\
<div class=warning><code>Keybinds</code> are disabled.</div>\
<div>Allowed keys: Ctrl, Alt, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>\
<div>Allowed keys: Ctrl, Alt, Meta, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>\
<table><tbody>\
<tr><th>Actions</th><th>Keybinds</th></tr>\
</tbody></table>\

View File

@ -793,8 +793,10 @@ Keybinds =
$.on d, 'keydown', Keybinds.keydown
keydown: (e) ->
if not (key = Keybinds.keyCode(e)) or /TEXTAREA|INPUT/.test(e.target.nodeName) and not (e.altKey or e.ctrlKey or e.keyCode is 27)
return
return unless key = Keybinds.keyCode e
{target} = e
if /TEXTAREA|INPUT/.test target.nodeName
return unless (key is 'Esc') or (/\+/.test key)
thread = Nav.getThread()
switch key
@ -813,12 +815,10 @@ Keybinds =
when Conf.submit
QR.submit() if QR.el and !QR.status()
when Conf.spoiler
ta = e.target
return if ta.nodeName isnt 'TEXTAREA'
return if target.nodeName isnt 'TEXTAREA'
Keybinds.tags 'spoiler', ta
when Conf.code
ta = e.target
return if ta.nodeName isnt 'TEXTAREA'
return if target.nodeName isnt 'TEXTAREA'
Keybinds.tags 'code', ta
# Thread related
when Conf.watch
@ -886,8 +886,9 @@ Keybinds =
else
null
if key
if e.altKey then key = 'alt+' + key
if e.altKey then key = 'alt+' + key
if e.ctrlKey then key = 'ctrl+' + key
if e.metaKey then key = 'meta+' + key
key
tags: (tag, ta) ->
@ -1760,7 +1761,7 @@ Options =
<input type=radio name=tab hidden id=keybinds_tab>
<div>
<div class=warning><code>Keybinds</code> are disabled.</div>
<div>Allowed keys: Ctrl, Alt, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>
<div>Allowed keys: Ctrl, Alt, Meta, a-z, A-Z, 0-9, Up, Down, Right, Left.</div>
<table><tbody>
<tr><th>Actions</th><th>Keybinds</th></tr>
</tbody></table>