diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 626aaeba..ed0f65ff 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -194,6 +194,17 @@ function selectAddRow(field) { */ function bodyKeydown(event, button) { var target = event.target || event.srcElement; + if (event.keyCode == 27 && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) { // 27 - Esc + ajaxXmlhttp.aborted = true; + if (ajaxXmlhttp.abort) { + ajaxXmlhttp.abort(); + } + setHtml('loader', ''); + onblur = function () { }; + if (originalFavicon) { + replaceFavicon(originalFavicon); + } + } if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10) && !event.altKey && !event.metaKey && /select|textarea|input/i.test(target.tagName)) { // 13|10 - Enter, shiftKey allowed target.blur(); if (!ajaxForm(target.form, (button ? button + '=1' : ''))) { @@ -301,6 +312,7 @@ function replaceFavicon(href) { } var ajaxState = 0; +var ajaxXmlhttp = {}; /** Safely load content to #content * @param string @@ -313,6 +325,10 @@ function ajaxSend(url, data, popState, noscroll) { if (!history.pushState) { return false; } + ajaxXmlhttp.aborted = true; + if (ajaxXmlhttp.abort) { + ajaxXmlhttp.abort(); + } var currentState = ++ajaxState; onblur = function () { if (!originalFavicon) { @@ -321,8 +337,8 @@ function ajaxSend(url, data, popState, noscroll) { replaceFavicon('../adminer/static/loader.gif'); }; setHtml('loader', ''); - return ajax(url, function (xmlhttp) { - if (currentState == ajaxState) { + ajaxXmlhttp = ajax(url, function (xmlhttp) { + if (!xmlhttp.aborted && currentState == ajaxState) { var title = xmlhttp.getResponseHeader('X-AJAX-Title'); if (title) { document.title = decodeURIComponent(title); @@ -370,6 +386,7 @@ function ajaxSend(url, data, popState, noscroll) { } } }, data); + return ajaxXmlhttp; } /** Revive page from history diff --git a/changes.txt b/changes.txt index b2c01528..2086be44 100644 --- a/changes.txt +++ b/changes.txt @@ -1,10 +1,11 @@ Adminer 3.3.4-dev: Foreign keys default actions (bug #3397606) Fix minor parser bug in SQL command with webserver file -Ctrl+click on button opens form to blank window +Ctrl+click on button opens form to a blank window SET DEFAULT foreign key action Trim table and column names (bug #3405309) Error message with no response from server in AJAX +Esc to cancel AJAX request MySQL: set autocommit after connect PostgreSQL: fix alter foreign key PostgreSQL over PDO: connect if the eponymous database does not exist (bug #3391619)