Provide support for browsers which don't have beforeunload event.
This commit is contained in:
parent
8616af418a
commit
085d91b546
14
converse.js
14
converse.js
@ -141,6 +141,16 @@
|
||||
|
||||
converse.initialize = function (settings, callback) {
|
||||
var converse = this;
|
||||
var unloadevent;
|
||||
if ('onbeforeunload' in window) {
|
||||
unloadevent = 'beforeunload';
|
||||
} else if ('onunload' in window) {
|
||||
unloadevent = 'unload';
|
||||
} else if ('onpagehide' in window) {
|
||||
// Mobile Safari (at least older versions) doesn't support unload or beforeunload.
|
||||
// Apple recommends "pagehide" instead.
|
||||
unloadevent = 'pagehide';
|
||||
}
|
||||
|
||||
// Logging
|
||||
Strophe.log = function (level, msg) { converse.log(level+' '+msg, level); };
|
||||
@ -412,7 +422,7 @@
|
||||
$(window).on('mousemove' , function () { converse.autoAwayReset(); });
|
||||
$(window).on('keypress' , function () { converse.autoAwayReset(); });
|
||||
$(window).on('focus' , function () { converse.autoAwayReset(); });
|
||||
$(window).on('beforeunload' , function () { converse.autoAwayReset(); });
|
||||
$(window).on(unloadevent , function () { converse.autoAwayReset(); });
|
||||
|
||||
window.setInterval(function () {
|
||||
if ((this._idleCounter <= this.auto_away || (this.auto_xa > 0 && this._idleCounter <= this.auto_xa)) &&
|
||||
@ -643,7 +653,7 @@
|
||||
this.session.id = id; // Appears to be necessary for backbone.browserStorage
|
||||
this.session.browserStorage = new Backbone.BrowserStorage[converse.storage](id);
|
||||
this.session.fetch();
|
||||
$(window).on('beforeunload', $.proxy(function () {
|
||||
$(window).on(unloadevent, $.proxy(function () {
|
||||
if (converse.connection.authenticated) {
|
||||
this.setSession();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user