Skip to content

Commit 059956d

Browse files
currentCell instead of exquis.targetCell
1 parent 4fdb592 commit 059956d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

public/editorController.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ define(['ui', 'net', 'evileval'], function(ui, net, evileval){
8585
});
8686
}
8787
};
88+
89+
var displayInvalidity = function(err, canvasAnim){
90+
if(currentCanvasAnim === canvasAnim){
91+
console.log(err);
92+
view.displayCodeValidity(false);
93+
}
94+
};
8895

8996
return function(exquis, makeEditorView){
9097
var controller = {
@@ -96,7 +103,7 @@ define(['ui', 'net', 'evileval'], function(ui, net, evileval){
96103
view = makeEditorView(controller);
97104
controller.hide = view.hide;
98105
controller.show = view.show;
99-
controller.displayInvalidity = view.displayInvalidity;
106+
controller.displayInvalidity = displayInvalidity;
100107
return controller;
101108
};
102109

public/editorView.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ define([], function(){
100100
// unselect edition
101101
editor.className = "invisible";
102102
},
103-
displayInvalidity : function(err){
104-
console.log(err);
105-
displayCodeValidity(false);
106-
}
103+
displayCodeValidity: displayCodeValidity
107104
};
108105
return theView;
109106
};

public/exquis.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,16 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
175175
};
176176

177177

178-
178+
var currentCell;
179179
var addEditor = function(exquis, makeEditorView, makeEditorController){
180180
exquis.editorController = makeEditorController(exquis, makeEditorView);
181181

182182
iter2d.forEach2dArray(exquis.cells, function(cell){
183183
var edit = function(){
184-
if (exquis.targetCell) { csshelper.removeClass(exquis.targetCell.hint, "visible-cell"); }
185-
exquis.targetCell = cell;
186-
csshelper.addClass(exquis.targetCell.hint, "visible-cell");
184+
if (currentCell) { csshelper.removeClass(currentCell.hint, "visible-cell"); }
185+
currentCell = cell;
186+
exquis.currentCell = currentCell; //only for debugging
187+
csshelper.addClass(currentCell.hint, "visible-cell");
187188
exquis.editorController.updateWithCanvasAnim(cell.canvasAnim);
188189
exquis.editorController.show();
189190
};
@@ -197,7 +198,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
197198
if (event.target.tagName === "HTML"){
198199
// unselect edition
199200
exquis.editorController.hide();
200-
if (exquis.targetCell) { csshelper.removeClass(exquis.targetCell.hint, "visible-cell"); }
201+
if (currentCell) { csshelper.removeClass(currentCell.hint, "visible-cell"); }
201202
}
202203
};
203204
document.addEventListener('click', possiblyHideEditor, true);
@@ -261,9 +262,7 @@ define(["iter2d", "csshelper", "evileval", "net", "ui"], function(iter2d, csshel
261262
try{
262263
canvasAnim.draw(neighbouringBorders);
263264
}catch(e){
264-
if(exquis.targetCell === cell ){
265-
exquis.editorController.displayInvalidity(e);
266-
}
265+
exquis.editorController.displayInvalidity(e, cell.canvasAnim);
267266
}
268267
});
269268
};

0 commit comments

Comments
 (0)