mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +02:00
Resolves #993 -- warn on before unloading
This commit is contained in:
parent
d9fe304038
commit
be58befe52
5 changed files with 26 additions and 2 deletions
|
@ -18,7 +18,14 @@ var LevelActions = {
|
||||||
AppDispatcher.handleViewAction({
|
AppDispatcher.handleViewAction({
|
||||||
type: ActionTypes.RESET_LEVELS_SOLVED
|
type: ActionTypes.RESET_LEVELS_SOLVED
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
setIsSolvingLevel: function(isSolvingLevel) {
|
||||||
|
AppDispatcher.handleViewAction({
|
||||||
|
type: ActionTypes.SET_IS_SOLVING_LEVEL,
|
||||||
|
isSolvingLevel: isSolvingLevel,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,10 @@ var init = function() {
|
||||||
window.LocaleStore = LocaleStore;
|
window.LocaleStore = LocaleStore;
|
||||||
window.LocaleActions = LocaleActions;
|
window.LocaleActions = LocaleActions;
|
||||||
window.intl = intl;
|
window.intl = intl;
|
||||||
|
|
||||||
|
$(window).on('beforeunload', function(e) {
|
||||||
|
return GlobalStateStore.getIsSolvingLevel() ? 'you have a level in progress' : null;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var vcsModeRefresh = function(eventData) {
|
var vcsModeRefresh = function(eventData) {
|
||||||
|
|
|
@ -32,7 +32,8 @@ module.exports = {
|
||||||
* solve the level, not ask for solution
|
* solve the level, not ask for solution
|
||||||
* or solve it again.
|
* or solve it again.
|
||||||
*/
|
*/
|
||||||
SOLVE_LEVEL: null
|
SOLVE_LEVEL: null,
|
||||||
|
SET_IS_SOLVING_LEVEL: null,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
PayloadSources: keyMirror({
|
PayloadSources: keyMirror({
|
||||||
|
|
|
@ -58,6 +58,7 @@ var Level = Sandbox.extend({
|
||||||
this.startOffCommand();
|
this.startOffCommand();
|
||||||
|
|
||||||
this.handleOpen(options.deferred);
|
this.handleOpen(options.deferred);
|
||||||
|
LevelActions.setIsSolvingLevel(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getIsGoalExpanded: function() {
|
getIsGoalExpanded: function() {
|
||||||
|
@ -65,6 +66,7 @@ var Level = Sandbox.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
handleOpen: function(deferred) {
|
handleOpen: function(deferred) {
|
||||||
|
LevelActions.setIsSolvingLevel(true);
|
||||||
deferred = deferred || Q.defer();
|
deferred = deferred || Q.defer();
|
||||||
|
|
||||||
// if there is a multiview in the beginning, open that
|
// if there is a multiview in the beginning, open that
|
||||||
|
@ -573,6 +575,7 @@ var Level = Sandbox.extend({
|
||||||
delete this.mainVis;
|
delete this.mainVis;
|
||||||
delete this.goalVis;
|
delete this.goalVis;
|
||||||
delete this.goalCanvasHolder;
|
delete this.goalCanvasHolder;
|
||||||
|
LevelActions.setIsSolvingLevel(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstantCommands: function() {
|
getInstantCommands: function() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ var _isAnimating = false;
|
||||||
var _flipTreeY = false;
|
var _flipTreeY = false;
|
||||||
var _numLevelsSolved = 0;
|
var _numLevelsSolved = 0;
|
||||||
var _disableLevelInstructions = false;
|
var _disableLevelInstructions = false;
|
||||||
|
var _isSolvingLevel = false;
|
||||||
|
|
||||||
var GlobalStateStore = Object.assign(
|
var GlobalStateStore = Object.assign(
|
||||||
{},
|
{},
|
||||||
|
@ -20,6 +21,10 @@ AppConstants.StoreSubscribePrototype,
|
||||||
return _isAnimating;
|
return _isAnimating;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getIsSolvingLevel: function() {
|
||||||
|
return _isSolvingLevel;
|
||||||
|
},
|
||||||
|
|
||||||
getFlipTreeY: function() {
|
getFlipTreeY: function() {
|
||||||
return _flipTreeY;
|
return _flipTreeY;
|
||||||
},
|
},
|
||||||
|
@ -37,6 +42,10 @@ AppConstants.StoreSubscribePrototype,
|
||||||
var shouldInform = false;
|
var shouldInform = false;
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
case ActionTypes.SET_IS_SOLVING_LEVEL:
|
||||||
|
_isSolvingLevel = action.isSolvingLevel;
|
||||||
|
shouldInform = true;
|
||||||
|
break;
|
||||||
case ActionTypes.CHANGE_IS_ANIMATING:
|
case ActionTypes.CHANGE_IS_ANIMATING:
|
||||||
_isAnimating = action.isAnimating;
|
_isAnimating = action.isAnimating;
|
||||||
shouldInform = true;
|
shouldInform = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue