[Navigation] remove mct-before-unload

Remove mct-before-unload, and move the functionality to the navigation
service.  The navigation service considers "unload" to be a navigation
event and prompts in much the same way as it would before any other
navigation event.

https://github.com/nasa/openmct/issues/1360
This commit is contained in:
Pete Richards
2016-12-20 15:10:07 -08:00
parent f2d61604f7
commit daa71c4f69
8 changed files with 20 additions and 282 deletions

View File

@ -39,6 +39,9 @@ define(
this.callbacks = [];
this.checks = [];
this.$window = $window;
this.oldUnload = $window.onbeforeunload;
$window.onbeforeunload = this.onBeforeUnload.bind(this);
}
/**
@ -173,6 +176,22 @@ define(
return false;
};
/**
* Listener for window on before unload event-- will warn before
* navigation is allowed.
*
* @private
*/
NavigationService.prototype.onBeforeUnload = function () {
var shouldWarnBeforeNavigate = this.shouldWarnBeforeNavigate();
if (shouldWarnBeforeNavigate) {
return shouldWarnBeforeNavigate;
}
if (this.oldUnload) {
return this.oldUnload.apply(undefined, [].slice.apply(arguments));
}
};
return NavigationService;
}
);