mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
23 lines
652 B
JavaScript
23 lines
652 B
JavaScript
(function () {
|
|
var ns = $.namespace('pskl.service');
|
|
|
|
ns.BeforeUnloadService = function (piskelController) {
|
|
this.piskelController = piskelController;
|
|
};
|
|
|
|
ns.BeforeUnloadService.prototype.init = function () {
|
|
window.addEventListener('beforeunload', this.onBeforeUnload.bind(this));
|
|
};
|
|
|
|
ns.BeforeUnloadService.prototype.onBeforeUnload = function (evt) {
|
|
pskl.app.backupService.backup();
|
|
if (pskl.app.savedStatusService.isDirty()) {
|
|
var confirmationMessage = 'Your Piskel seems to have unsaved changes';
|
|
|
|
(evt || window.event).returnValue = confirmationMessage;
|
|
return confirmationMessage;
|
|
}
|
|
};
|
|
|
|
})();
|