Fix options key/keybinds key variables.

This commit is contained in:
Nicolas Stepien 2011-07-24 11:26:39 +02:00
parent 908d9cf581
commit bd6b2303bb
3 changed files with 40 additions and 38 deletions

View File

@ -724,19 +724,19 @@
}, },
cb: { cb: {
keydown: function(e) { keydown: function(e) {
var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; var k, o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3;
if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) { if (((_ref = e.target.nodeName) === 'TEXTAREA' || _ref === 'INPUT') && !e.altKey && !e.ctrlKey && !(e.keyCode === 27)) {
return; return;
} }
key = keybinds.cb.keyCode(e); k = keybinds.cb.keyCode(e);
if (e.altKey) { if (e.altKey) {
key = 'alt+' + key; k = 'alt+' + k;
} }
if (e.ctrlKey) { if (e.ctrlKey) {
key = 'ctrl+' + key; k = 'ctrl+' + k;
} }
thread = nav.getThread(); thread = nav.getThread();
switch (key) { switch (k) {
case conf.close: case conf.close:
if (o = $('#overlay')) { if (o = $('#overlay')) {
$.rm(o); $.rm(o);
@ -827,21 +827,21 @@
return e.preventDefault(); return e.preventDefault();
}, },
keyCode: function(e, options) { keyCode: function(e, options) {
var kc; var k, kc;
kc = e.keyCode; kc = e.keyCode;
if ((65 <= kc && kc <= 90)) { if ((65 <= kc && kc <= 90)) {
key = String.fromCharCode(kc); k = String.fromCharCode(kc);
if (!e.shiftKey) { if (!e.shiftKey) {
key = key.toLowerCase(); k = k.toLowerCase();
} }
} else if ((48 <= kc && kc <= 57)) { } else if ((48 <= kc && kc <= 57)) {
key = String.fromCharCode(kc); k = String.fromCharCode(kc);
} else if (kc === 27) { } else if (kc === 27) {
key = 'Esc'; k = 'Esc';
} else if (options && kc === 8) { } else if (options && kc === 8) {
key = ''; k = '';
} }
return key; return k;
} }
}, },
img: function(thread, all) { img: function(thread, all) {
@ -1115,21 +1115,22 @@
return g.hiddenReplies = {}; return g.hiddenReplies = {};
}, },
keybind: function(e) { keybind: function(e) {
var k;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
key = keybinds.cb.keyCode(e, true); k = keybinds.cb.keyCode(e, true);
if (key != null) { if (k != null) {
if (key) { if (k) {
if (e.altKey) { if (e.altKey) {
key = 'alt+' + key; k = 'alt+' + k;
} }
if (e.ctrlKey) { if (e.ctrlKey) {
key = 'ctrl+' + key; k = 'ctrl+' + k;
} }
} }
this.value = key; this.value = k;
$.setValue(this.name, key); $.setValue(this.name, k);
return conf[this.name] = key; return conf[this.name] = k;
} }
}, },
time: function(e) { time: function(e) {

View File

@ -2,6 +2,7 @@ github
- mayhem: - mayhem:
- Make updater's settings dynamic - Make updater's settings dynamic
- fix remember updater's interval settings - fix remember updater's interval settings
- fix wrong keybind input in options
2.16.1 2.16.1
- mayhem: - mayhem:

View File

@ -519,12 +519,12 @@ keybinds =
cb: cb:
keydown: (e) -> keydown: (e) ->
return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27) return if e.target.nodeName in ['TEXTAREA', 'INPUT'] and not e.altKey and not e.ctrlKey and not (e.keyCode is 27)
key = keybinds.cb.keyCode e k = keybinds.cb.keyCode e
if e.altKey then key = 'alt+' + key if e.altKey then k = 'alt+' + k
if e.ctrlKey then key = 'ctrl+' + key if e.ctrlKey then k = 'ctrl+' + k
thread = nav.getThread() thread = nav.getThread()
switch key switch k
when conf.close when conf.close
if o = $ '#overlay' if o = $ '#overlay'
$.rm o $.rm o
@ -591,16 +591,16 @@ keybinds =
keyCode: (e, options) -> keyCode: (e, options) ->
kc = e.keyCode kc = e.keyCode
if 65 <= kc <= 90 #A-Z if 65 <= kc <= 90 #A-Z
key = String.fromCharCode kc k = String.fromCharCode kc
if !e.shiftKey if !e.shiftKey
key = key.toLowerCase() k = k.toLowerCase()
else if 48 <= kc <= 57 #0-9 else if 48 <= kc <= 57 #0-9
key = String.fromCharCode kc k = String.fromCharCode kc
else if kc is 27 else if kc is 27
key = 'Esc' k = 'Esc'
else if options and kc is 8 else if options and kc is 8
key = '' k = ''
key k
img: (thread, all) -> img: (thread, all) ->
if all if all
@ -884,15 +884,15 @@ options =
keybind: (e) -> keybind: (e) ->
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
key = keybinds.cb.keyCode e, true k = keybinds.cb.keyCode e, true
if key? if k?
if key if k
key = 'alt+' + key if e.altKey k = 'alt+' + k if e.altKey
key = 'ctrl+' + key if e.ctrlKey k = 'ctrl+' + k if e.ctrlKey
@value = key @value = k
$.setValue @name, key $.setValue @name, k
conf[@name] = key conf[@name] = k
time: (e) -> time: (e) ->
$.setValue 'time', @value $.setValue 'time', @value
Time.foo() Time.foo()