Store layout changes on each adjustment, rather than on unload which is unreliable. Fixes #1967

We also use an async request now, rather than a deprecated sync request.
This commit is contained in:
Neel Patel 2017-01-16 15:34:55 +00:00 committed by Dave Page
parent 024b664c21
commit 0d4bc0d27d

View File

@ -300,6 +300,17 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
$obj_mnu.append(create_submenu.$el);
}
},
save_current_layout: function(obj) {
if(obj.docker) {
state = obj.docker.save();
settings = { setting: "Browser/Layout", value: state };
$.ajax({
type: 'POST',
url: "{{ url_for('settings.store') }}",
data: settings
});
}
},
init: function() {
var obj=this;
if (obj.initialized) {
@ -307,21 +318,6 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
}
obj.initialized = true;
// Store the main browser layout
$(window).bind('unload', function() {
if(obj.docker) {
state = obj.docker.save();
settings = { setting: "Browser/Layout", value: state };
$.ajax({
type: 'POST',
url: "{{ url_for('settings.store') }}",
data: settings,
async:false
});
}
return true;
});
// Initialize the Docker
obj.docker = new wcDocker(
'#dockerContainer', {
@ -355,6 +351,19 @@ function(require, $, _, S, Bootstrap, pgAdmin, Alertify, CodeMirror) {
} else {
obj.buildDefaultLayout()
}
// Listen to panel attach/detach event so that last layout will be remembered
_.each(obj.panels, function(panel, name) {
panel.panel.on(wcDocker.EVENT.ATTACHED, function() {
obj.save_current_layout(obj);
});
panel.panel.on(wcDocker.EVENT.DETACHED, function() {
obj.save_current_layout(obj);
});
panel.panel.on(wcDocker.EVENT.MOVE_ENDED, function() {
obj.save_current_layout(obj);
});
});
}
// Syntax highlight the SQL Pane