New patch for feature request 1518
Signed-off-by: A V Minhaz <minhazav@gmail.com>
This commit is contained in:
parent
bb71166d9c
commit
4b8574aa4a
33
js/ajax.js
33
js/ajax.js
@ -16,6 +16,10 @@ var AJAX = {
|
||||
* @var object xhr A reference to the ajax request that is currently running
|
||||
*/
|
||||
xhr: null,
|
||||
/**
|
||||
* @var bool, tells if user input was altered before this event was called
|
||||
*/
|
||||
isInputAltered: false,
|
||||
/**
|
||||
* @var function Callback to execute after a successful request
|
||||
* Used by PMA_commonFunctions from common.js
|
||||
@ -128,6 +132,19 @@ var AJAX = {
|
||||
);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Registers a keyup function when changes are made in input field
|
||||
* @param event for the trigged function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
inputAltered: function(event) {
|
||||
if(event.target.value.length !== 0) {
|
||||
AJAX.isInputAltered = true;
|
||||
} else {
|
||||
AJAX.isInputAltered = false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Event handler for clicks on links and form submissions
|
||||
*
|
||||
@ -160,6 +177,16 @@ var AJAX = {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
//sometime we accidently click on a url,refresh button or back button
|
||||
//operation to confirm if user want to leave page in such cases
|
||||
//trigger confirm dialog
|
||||
if (event.type === 'click' && AJAX.isInputAltered && confirm(PMA_messages['strConfirmNavigation']) === false) {
|
||||
return false;
|
||||
}
|
||||
//reset the flag for confirm navigation
|
||||
AJAX.isInputAltered = false;
|
||||
|
||||
if (AJAX.active === true) {
|
||||
// Cancel the old request if abortable, when the user requests
|
||||
// something else. Otherwise silently bail out, as there is already
|
||||
@ -856,6 +883,12 @@ $(function () {
|
||||
$('a').live('click', AJAX.requestHandler);
|
||||
$('form').live('submit', AJAX.requestHandler);
|
||||
|
||||
/**
|
||||
* Attach event listener to events when user modify visible
|
||||
* Input fields to make changes in forms
|
||||
*/
|
||||
$('#page_content').live("keyup", "input[type='text']:visible", AJAX.inputAltered);
|
||||
|
||||
/**
|
||||
* Gracefully handle fatal server errors
|
||||
* (e.g: 500 - Internal server error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user