From 5e8ec57c34d2b280f9a7991f0b418dbeb51c87a6 Mon Sep 17 00:00:00 2001 From: jous Date: Wed, 9 Jan 2013 05:33:52 +0200 Subject: [PATCH] moved $inline_editor.focus() to a better place. changed function name catch_keypresses_from_sql_textboxes -> catchKeypressesFromSqlTextboxes. lots of tab to spaces conversions. --- js/functions.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/js/functions.js b/js/functions.js index a0bc1d4bb7..a54d1aec5d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1438,7 +1438,7 @@ AJAX.registerOnload('functions.js', function() { function bindCodeMirrorToInlineEditor() { var $inline_editor = $('#sql_query_edit'); if ($inline_editor.length > 0) { - if (typeof CodeMirror !== 'undefined') { + if (typeof CodeMirror !== 'undefined') { var height = $('#sql_query_edit').css('height'); codemirror_inline_editor = CodeMirror.fromTextArea($inline_editor[0], { lineNumbers: true, @@ -1450,20 +1450,20 @@ function bindCodeMirrorToInlineEditor() { codemirror_inline_editor.getScrollerElement().style.height = height; codemirror_inline_editor.refresh(); codemirror_inline_editor.focus(); - $(codemirror_inline_editor.getWrapperElement()).bind('keypress', catch_keypresses_from_sql_textboxes); + $(codemirror_inline_editor.getWrapperElement()).bind('keypress', catchKeypressesFromSqlTextboxes); } else { - $($inline_editor).bind('keypress', catch_keypresses_from_sql_textboxes); + $inline_editor.focus(); + $inline_editor.bind('keypress', catchKeypressesFromSqlTextboxes); } - $inline_editor.focus(); } } -function catch_keypresses_from_sql_textboxes(event) { +function catchKeypressesFromSqlTextboxes(event) { // ctrl-enter is 10 in chrome and ie, but 13 in ff if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) { if ($('#sql_query_edit').length > 0) { $("#sql_query_edit_save").trigger('click'); - } else if ($('#sqlquery').length > 0) { + } else if ($('#sqlquery').length > 0) { $("#button_submit_query").trigger('click'); } } @@ -3402,12 +3402,12 @@ AJAX.registerOnload('functions.js', function() { lineWrapping: true }); codemirror_editor.focus(); - $(codemirror_editor.getWrapperElement()).bind('keypress', catch_keypresses_from_sql_textboxes); - return false; + $(codemirror_editor.getWrapperElement()).bind('keypress', catchKeypressesFromSqlTextboxes); + return false; // without codemirror } else { $elm.focus(); - $($elm).bind('keypress', catch_keypresses_from_sql_textboxes); + $($elm).bind('keypress', catchKeypressesFromSqlTextboxes); } } });