Fixed exit confirmation
This commit is contained in:
parent
d2447045dd
commit
77365e500a
1 changed files with 14 additions and 12 deletions
|
@ -53,6 +53,20 @@ App.Router = function(pathJs, _, jQuery, util, appState, presenterManager) {
|
||||||
|
|
||||||
function inject(path, presenterName, additionalParams) {
|
function inject(path, presenterName, additionalParams) {
|
||||||
pathJs.map(path).to(function() {
|
pathJs.map(path).to(function() {
|
||||||
|
if (util.isExitConfirmationEnabled()) {
|
||||||
|
if (window.location.href === previousLocation) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (window.confirm('Are you sure you want to leave this page? Data will be lost.')) {
|
||||||
|
util.disableExitConfirmation();
|
||||||
|
} else {
|
||||||
|
window.location.href = previousLocation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
previousLocation = window.location.href;
|
||||||
|
|
||||||
var finalParams = _.extend(
|
var finalParams = _.extend(
|
||||||
this.params,
|
this.params,
|
||||||
additionalParams,
|
additionalParams,
|
||||||
|
@ -61,18 +75,6 @@ App.Router = function(pathJs, _, jQuery, util, appState, presenterManager) {
|
||||||
var presenter = App.DI.get(presenterName);
|
var presenter = App.DI.get(presenterName);
|
||||||
presenter.name = presenterName;
|
presenter.name = presenterName;
|
||||||
presenterManager.switchContentPresenter(presenter, finalParams);
|
presenterManager.switchContentPresenter(presenter, finalParams);
|
||||||
}).enter(function(e) {
|
|
||||||
if (util.isExitConfirmationEnabled()) {
|
|
||||||
if (window.location.href !== previousLocation) {
|
|
||||||
if (!window.confirm('Are you sure you want to leave this page? Data will be lost.')) {
|
|
||||||
window.location.href = previousLocation;
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
util.disableExitConfirmation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
previousLocation = window.location.href;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue