2014-06-27 04:08:00 +04:00
|
|
|
(function () {
|
|
|
|
var ns = $.namespace('pskl.service');
|
|
|
|
|
|
|
|
ns.BeforeUnloadService = function (piskelController) {
|
|
|
|
this.piskelController = piskelController;
|
|
|
|
};
|
|
|
|
|
|
|
|
ns.BeforeUnloadService.prototype.init = function () {
|
2015-04-14 19:02:33 +03:00
|
|
|
window.addEventListener('beforeunload', this.onBeforeUnload.bind(this));
|
2014-06-27 04:08:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
ns.BeforeUnloadService.prototype.onBeforeUnload = function (evt) {
|
|
|
|
pskl.app.backupService.backup();
|
|
|
|
if (pskl.app.savedStatusService.isDirty()) {
|
2015-04-14 19:02:33 +03:00
|
|
|
var confirmationMessage = 'Your Piskel seems to have unsaved changes';
|
2014-06-27 04:08:00 +04:00
|
|
|
|
|
|
|
(evt || window.event).returnValue = confirmationMessage;
|
|
|
|
return confirmationMessage;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-04-14 19:02:33 +03:00
|
|
|
})();
|