summaryrefslogtreecommitdiff
path: root/lib/scripts
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2015-01-08 12:11:43 +0100
committerAndreas Gohr <andi@splitbrain.org>2015-01-08 12:11:43 +0100
commit9ecd86800ad1bca5158e00a1cf42f7d212d7a269 (patch)
tree4068f046eac5b777c42a1816c375aa23575e6185 /lib/scripts
parent32e9be23a7c06ab5c4515e1f72809c67da2e9441 (diff)
parent52ec63bf12e618947c2ee9f558db04932d0a1ae4 (diff)
downloadrpg-9ecd86800ad1bca5158e00a1cf42f7d212d7a269.tar.gz
rpg-9ecd86800ad1bca5158e00a1cf42f7d212d7a269.tar.bz2
Merge pull request #927 from cstuder/ctrlenter2submit
Handles CTRL-Enter event to save in the editor
Diffstat (limited to 'lib/scripts')
-rw-r--r--lib/scripts/editor.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/scripts/editor.js b/lib/scripts/editor.js
index 74919cb98..f4143f0bc 100644
--- a/lib/scripts/editor.js
+++ b/lib/scripts/editor.js
@@ -124,14 +124,15 @@ var dw_editor = {
* Listens to all key inputs and handle indentions
* of lists and code blocks
*
- * Currently handles space, backspce and enter presses
+ * Currently handles space, backspace, enter and
+ * ctrl-enter presses
*
* @author Andreas Gohr <andi@splitbrain.org>
* @fixme handle tabs
* @param event e - the key press event object
*/
keyHandler: function(e){
- if(jQuery.inArray(e.keyCode,[8, 13, 32]) === -1) {
+ if(jQuery.inArray(e.keyCode,[8, 10, 13, 32]) === -1) {
return;
}
var selection = DWgetSelection(this);
@@ -143,7 +144,12 @@ var dw_editor = {
search.lastIndexOf("\r")); //IE workaround
search = search.substr(linestart);
- if(e.keyCode == 13){ // Enter
+ if((e.keyCode == 13 || e.keyCode == 10) && e.ctrlKey) { // Ctrl-Enter (With Chrome workaround)
+ // Submit current edit
+ jQuery('input#edbtn__save').click();
+ e.preventDefault(); // prevent enter key
+ return false;
+ }else if(e.keyCode == 13){ // Enter
// keep current indention for lists and code
var match = search.match(/(\n +([\*-] ?)?)/);
if(match){