]> git.joonet.de Git - adminer.git/commitdiff
Esc to cancel AJAX request
authorJakub Vrana <jakub@vrana.cz>
Mon, 10 Oct 2011 07:13:05 +0000 (00:13 -0700)
committerJakub Vrana <jakub@vrana.cz>
Mon, 10 Oct 2011 07:13:05 +0000 (00:13 -0700)
adminer/static/functions.js
changes.txt

index 626aaeba946d4d6ab77ec014f1f09fa1185c84d6..ed0f65ffe1fad10c45449923051667ac8d2175a5 100644 (file)
@@ -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
index b2c01528995fd5b52ad2a28076dcc3ab5669f781..2086be4458baa1d0a9657549b2fc5e5c1732496f 100644 (file)
@@ -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 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)