Convert beforeunload listeners
This commit is contained in:
parent
002ff45312
commit
7afd0a02e8
4 changed files with 12 additions and 4 deletions
|
@ -133,6 +133,14 @@
|
|||
return appWindow.contentWindow;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
beforeUnload: function(callback) {
|
||||
if (chrome.runtime) {
|
||||
chrome.runtime.onSuspend.addListener(callback);
|
||||
} else {
|
||||
window.addEventListener('beforeunload', callback);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
windowMap.add({ windowId: windowInfo.id, modelId: modelId });
|
||||
|
||||
// close the panel if background.html is refreshed
|
||||
window.addEventListener('beforeunload', function () {
|
||||
extension.windows.beforeUnload(function() {
|
||||
// TODO: reattach after reload instead of closing.
|
||||
extension.windows.remove(windowInfo.id);
|
||||
});
|
||||
|
@ -125,7 +125,7 @@
|
|||
inboxWindowId = windowInfo.id;
|
||||
|
||||
// close the panel if background.html is refreshed
|
||||
window.addEventListener('beforeunload', function () {
|
||||
extension.windows.beforeUnload(function() {
|
||||
// TODO: reattach after reload instead of closing.
|
||||
extension.windows.remove(windowInfo.id);
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
initialize: function() {
|
||||
this.listenTo(this.model, 'change', this.render); // auto update
|
||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||
window.addEventListener('beforeunload', function () {
|
||||
extension.windows.beforeUnload(function() {
|
||||
this.stopListening();
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
new SocketView().render().$el.appendTo(this.$('.socket-status'));
|
||||
|
||||
window.addEventListener('beforeunload', function () {
|
||||
extension.windows.beforeUnload(function() {
|
||||
this.inbox.stopListening();
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue