Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Esc to cancel AJAX request

  • Loading branch information...
commit fd7e8cbaae5fb55f57c5c19de498213370f3549f 1 parent 468644e
Jakub Vrána authored
Showing with 21 additions and 3 deletions.
  1. +19 −2 adminer/static/functions.js
  2. +2 −1  changes.txt
21 adminer/static/functions.js
View
@@ -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', '<img src="../adminer/static/loader.gif" alt="">');
- 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
3  changes.txt
View
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.