Add sage toggle, close #23

This commit is contained in:
Jordan Bates 2013-04-24 03:01:58 -07:00
parent b7b95fdc71
commit 7181d008fe
5 changed files with 65 additions and 4 deletions

View File

@ -183,7 +183,8 @@
'Code tags': ['Alt+c', 'Insert code tags.'],
'Eqn tags': ['Alt+e', 'Insert eqn tags.'],
'Math tags': ['Alt+m', 'Insert math tags.'],
'Submit QR': ['Alt+s', 'Submit post.'],
'Toggle sage': ['Alt+s', 'Toggle sage in email field'],
'Submit QR': ['Ctrl+Enter', 'Submit post.'],
'Watch': ['w', 'Watch thread.'],
'Update': ['r', 'Update the thread now.'],
'Expand image': ['Shift+e', 'Expand selected image.'],
@ -5096,6 +5097,11 @@
}
Keybinds.tags('math', target);
break;
case Conf['Toggle sage']:
if (QR.nodes) {
Keybinds.sage();
}
break;
case Conf['Submit QR']:
if (QR.nodes && !QR.status()) {
QR.submit();
@ -5247,6 +5253,16 @@
ta.setSelectionRange(range, range);
return $.event('input', null, ta);
},
sage: function() {
var isSage;
isSage = /sage/i.test(QR.nodes.email.value);
if (isSage) {
return QR.nodes.email.value = "";
} else {
return QR.nodes.email.value = "sage";
}
},
img: function(thread, all) {
var post;

View File

@ -184,7 +184,8 @@
'Code tags': ['Alt+c', 'Insert code tags.'],
'Eqn tags': ['Alt+e', 'Insert eqn tags.'],
'Math tags': ['Alt+m', 'Insert math tags.'],
'Submit QR': ['Alt+s', 'Submit post.'],
'Toggle sage': ['Alt+s', 'Toggle sage in email field'],
'Submit QR': ['Ctrl+Enter', 'Submit post.'],
'Watch': ['w', 'Watch thread.'],
'Update': ['r', 'Update the thread now.'],
'Expand image': ['Shift+e', 'Expand selected image.'],
@ -5087,6 +5088,11 @@
}
Keybinds.tags('math', target);
break;
case Conf['Toggle sage']:
if (QR.nodes) {
Keybinds.sage();
}
break;
case Conf['Submit QR']:
if (QR.nodes && !QR.status()) {
QR.submit();
@ -5238,6 +5244,16 @@
ta.setSelectionRange(range, range);
return $.event('input', null, ta);
},
sage: function() {
var isSage;
isSage = /sage/i.test(QR.nodes.email.value);
if (isSage) {
return QR.nodes.email.value = "";
} else {
return QR.nodes.email.value = "sage";
}
},
img: function(thread, all) {
var post;

View File

@ -140,7 +140,8 @@
'Code tags': ['Alt+c', 'Insert code tags.'],
'Eqn tags': ['Alt+e', 'Insert eqn tags.'],
'Math tags': ['Alt+m', 'Insert math tags.'],
'Submit QR': ['Alt+s', 'Submit post.'],
'Toggle sage': ['Alt+s', 'Toggle sage in email field'],
'Submit QR': ['Ctrl+Enter', 'Submit post.'],
'Watch': ['w', 'Watch thread.'],
'Update': ['r', 'Update the thread now.'],
'Expand image': ['Shift+e', 'Expand selected image.'],
@ -5010,6 +5011,11 @@
}
Keybinds.tags('math', target);
break;
case Conf['Toggle sage']:
if (QR.nodes) {
Keybinds.sage();
}
break;
case Conf['Submit QR']:
if (QR.nodes && !QR.status()) {
QR.submit();
@ -5161,6 +5167,16 @@
ta.setSelectionRange(range, range);
return $.event('input', null, ta);
},
sage: function() {
var isSage;
isSage = /sage/i.test(QR.nodes.email.value);
if (isSage) {
return QR.nodes.email.value = "";
} else {
return QR.nodes.email.value = "sage";
}
},
img: function(thread, all) {
var post;

View File

@ -446,8 +446,12 @@ http://iqdb.org/?url=%TURL
'Alt+m'
'Insert math tags.'
]
'Submit QR': [
'Toggle sage': [
'Alt+s'
'Toggle sage in email field'
]
'Submit QR': [
'Ctrl+Enter'
'Submit post.'
]
# Thread related

View File

@ -50,6 +50,8 @@ Keybinds =
when Conf['Math tags']
return if target.nodeName isnt 'TEXTAREA'
Keybinds.tags 'math', target
when Conf['Toggle sage']
do Keybinds.sage if QR.nodes
when Conf['Submit QR']
QR.submit() if QR.nodes and !QR.status()
# Thread related
@ -161,6 +163,13 @@ Keybinds =
# Fire the 'input' event
$.event 'input', null, ta
sage: ->
isSage = /sage/i.test QR.nodes.email.value
if isSage
QR.nodes.email.value = ""
else
QR.nodes.email.value = "sage"
img: (thread, all) ->
if all
ImageExpand.cb.toggleAll()