1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 17:44:07 +02:00

Use function for common code

This commit is contained in:
Jakub Vrana
2012-02-29 11:24:01 -08:00
parent d35f83fb8d
commit 83113cbe67

View File

@@ -187,18 +187,28 @@ function selectAddRow(field) {
/** Abort AJAX request
* @uses ajaxRequest
*/
function ajaxAbort() {
ajaxRequest.aborted = true;
if (ajaxRequest.abort) {
ajaxRequest.abort();
}
}
/** Send form by Ctrl+Enter on <select> and <textarea> /** Send form by Ctrl+Enter on <select> and <textarea>
* @param KeyboardEvent * @param KeyboardEvent
* @param [string] * @param [string]
* @return boolean * @return boolean
* @uses ajaxRequest
*/ */
function bodyKeydown(event, button) { function bodyKeydown(event, button) {
var target = event.target || event.srcElement; var target = event.target || event.srcElement;
if (event.keyCode == 27 && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) { // 27 - Esc if (event.keyCode == 27 && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) { // 27 - Esc
ajaxRequest.aborted = true; ajaxAbort();
if (ajaxRequest.abort) {
ajaxRequest.abort();
}
document.body.className = document.body.className.replace(/ loading/g, ''); document.body.className = document.body.className.replace(/ loading/g, '');
onblur = function () { }; onblur = function () { };
if (originalFavicon) { if (originalFavicon) {
@@ -320,15 +330,13 @@ var ajaxRequest = {};
* @param [boolean] * @param [boolean]
* @param [boolean] * @param [boolean]
* @return XMLHttpRequest or false in case of an error * @return XMLHttpRequest or false in case of an error
* @uses ajaxState, ajaxRequest
*/ */
function ajaxSend(url, data, popState, noscroll) { function ajaxSend(url, data, popState, noscroll) {
if (!history.pushState) { if (!history.pushState) {
return false; return false;
} }
ajaxRequest.aborted = true; ajaxAbort();
if (ajaxRequest.abort) {
ajaxRequest.abort();
}
var currentState = ++ajaxState; var currentState = ++ajaxState;
onblur = function () { onblur = function () {
if (!originalFavicon) { if (!originalFavicon) {
@@ -392,6 +400,7 @@ function ajaxSend(url, data, popState, noscroll) {
/** Revive page from history /** Revive page from history
* @param PopStateEvent|history * @param PopStateEvent|history
* @uses ajaxState
*/ */
onpopstate = function (event) { onpopstate = function (event) {
if ((ajaxState || event.state) && !/#/.test(location.href)) { if ((ajaxState || event.state) && !/#/.test(location.href)) {