diff --git a/js/ajax.js b/js/ajax.js index 41043f559e..b8cb7a7f54 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -160,6 +160,20 @@ 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 + var flag = false; + $("input[type='text']").each(function(index){ + if($(this).val().length > 0) { + flag = true; + } + }); + //trigger confirm dialog + if (event.type === 'click' && flag && confirm(PMA_messages['strConfirmNavigation']) === false) { + return 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 diff --git a/js/messages.php b/js/messages.php index bc9e1ada48..de12846715 100644 --- a/js/messages.php +++ b/js/messages.php @@ -43,6 +43,7 @@ $js_messages['strDroppingPrimaryKeyIndex'] = __('Dropping Primary Key/Index'); $js_messages['strOperationTakesLongTime'] = __('This operation could take a long time. Proceed anyway?'); $js_messages['strDropUserGroupWarning'] = __('Do you really want to delete user group "%s"?'); $js_messages['strConfirmDeleteQBESearch'] = __('Do you really want to delete the search "%s"?'); +$js_messages['strConfirmNavigation'] = __('Are you sure you want to navigate away from this page? Press OK to continue or Cancel to stay on the current page.'); /* For indexes */ $js_messages['strFormEmpty'] = __('Missing value in the form!');