mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-20 11:48:31 -06:00
Improvement for 'beforeunload' event, bind the event only from where it is required.
This commit is contained in:
parent
94e1820ccd
commit
05ae330030
@ -539,6 +539,28 @@ define('pgadmin.browser', [
|
|||||||
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
|
obj.Events.on('pgadmin:browser:tree:update', obj.onUpdateTreeNode, obj);
|
||||||
obj.Events.on('pgadmin:browser:tree:refresh', obj.onRefreshTreeNode, obj);
|
obj.Events.on('pgadmin:browser:tree:refresh', obj.onRefreshTreeNode, obj);
|
||||||
|
|
||||||
|
obj.bind_beforeunload();
|
||||||
|
},
|
||||||
|
|
||||||
|
bind_beforeunload: function() {
|
||||||
|
$(window).on('beforeunload', function(e) {
|
||||||
|
/* Can open you in new tab */
|
||||||
|
let openerBrowser = window.opener ?
|
||||||
|
window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
|
||||||
|
|
||||||
|
let tree_save_interval = pgBrowser.get_preference('browser', 'browser_tree_state_save_interval'),
|
||||||
|
confirm_on_refresh_close = openerBrowser.get_preference('browser', 'confirm_on_refresh_close');
|
||||||
|
|
||||||
|
if (!_.isUndefined(tree_save_interval) && tree_save_interval.value !== -1)
|
||||||
|
pgAdmin.Browser.browserTreeState.save_state();
|
||||||
|
|
||||||
|
if(!_.isUndefined(confirm_on_refresh_close) && confirm_on_refresh_close.value) {
|
||||||
|
/* This message will not be displayed in Chrome, Firefox, Safari as they have disabled it*/
|
||||||
|
let msg = S(gettext('Are you sure you want to close the %s browser?')).sprintf(pgBrowser.utils.app_name).value();
|
||||||
|
e.originalEvent.returnValue = msg;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
add_menu_category: function(
|
add_menu_category: function(
|
||||||
@ -1944,24 +1966,5 @@ define('pgadmin.browser', [
|
|||||||
pgAdmin.Browser.editor_shortcut_keys.Tab = 'insertSoftTab';
|
pgAdmin.Browser.editor_shortcut_keys.Tab = 'insertSoftTab';
|
||||||
}
|
}
|
||||||
|
|
||||||
$(window).on('beforeunload', function(e) {
|
|
||||||
/* Can open you in new tab */
|
|
||||||
let openerBrowser = window.opener ?
|
|
||||||
window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
|
|
||||||
|
|
||||||
let tree_save_interval = pgBrowser.get_preference('browser', 'browser_tree_state_save_interval'),
|
|
||||||
confirm_on_refresh_close = openerBrowser.get_preference('browser', 'confirm_on_refresh_close');
|
|
||||||
|
|
||||||
if (!_.isUndefined(tree_save_interval) && tree_save_interval.value !== -1)
|
|
||||||
pgAdmin.Browser.browserTreeState.save_state();
|
|
||||||
|
|
||||||
if(!_.isUndefined(confirm_on_refresh_close) && confirm_on_refresh_close.value) {
|
|
||||||
/* This message will not be displayed in Chrome, Firefox, Safari as they have disabled it*/
|
|
||||||
let msg = S(gettext('Are you sure you want to close the %s browser?')).sprintf(pgBrowser.utils.app_name).value();
|
|
||||||
e.originalEvent.returnValue = msg;
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return pgAdmin.Browser;
|
return pgAdmin.Browser;
|
||||||
});
|
});
|
||||||
|
@ -1572,6 +1572,8 @@ define([
|
|||||||
});
|
});
|
||||||
this.panels = [];
|
this.panels = [];
|
||||||
|
|
||||||
|
pgBrowser.bind_beforeunload();
|
||||||
|
|
||||||
// Below code will be executed for indirect debugging
|
// Below code will be executed for indirect debugging
|
||||||
// indirect debugging - 0 and for direct debugging - 1
|
// indirect debugging - 0 and for direct debugging - 1
|
||||||
if (trans_id != undefined && !debug_type) {
|
if (trans_id != undefined && !debug_type) {
|
||||||
|
@ -552,6 +552,8 @@ define('tools.querytool', [
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pgBrowser.bind_beforeunload();
|
||||||
|
|
||||||
/* If the screen width is small and we hover over the Explain Options,
|
/* If the screen width is small and we hover over the Explain Options,
|
||||||
* the submenu goes behind the screen on the right side.
|
* the submenu goes behind the screen on the right side.
|
||||||
* Below logic will make it appear on the left.
|
* Below logic will make it appear on the left.
|
||||||
|
Loading…
Reference in New Issue
Block a user