Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed undo behavior after deleting tie points

  • Loading branch information...
commit 5b57d45bfa86a47709bc535d6360ae455c3d7341 1 parent 6f270f1
Trey Smith trey0 authored
2  geocamTiePoint/static/geocamTiePoint/js/backbone/models.js
View
@@ -114,6 +114,8 @@ $(function($) {
},
deleteTiepoint: function(index) {
+ actionPerformed();
+
points = this.get('points');
points.splice(index, 1);
this.set('points', points);
1  geocamTiePoint/static/geocamTiePoint/js/backbone/views.js
View
@@ -604,6 +604,7 @@ $(function($) {
this.model.on('add_point redraw_markers', this.initMarkerSelectHandlers, this);
this.renderHelp();
+ enableUndoButtons();
},
renderHelp: function() {
36 geocamTiePoint/static/geocamTiePoint/js/undo.js
View
@@ -52,16 +52,47 @@ function popState(stack) {
setStateJson(stack.pop());
}
+/*
+function lengthTrace(stack) {
+ var result = [];
+ $.each(stack, function (i, rec) {
+ result.push(JSON.parse(rec).points.length);
+ });
+ return result;
+}
+
+function debugUndo() {
+ console.log('debugUndo:');
+ console.log(' undo stack: ' + lengthTrace(undoStackG));
+ console.log(' redo stack: ' + lengthTrace(redoStackG));
+}
+*/
+
function undo() {
if (undoStackG.length < 1) return;
pushState(redoStackG);
popState(undoStackG);
+ enableUndoButtons();
}
function redo() {
if (redoStackG.length < 1) return;
pushState(undoStackG);
popState(redoStackG);
+ enableUndoButtons();
+}
+
+function enableUndoButtons() {
+ if (undoStackG.length < 1) {
+ $('#undo').attr('disabled', 'disabled');
+ } else {
+ $('#undo').removeAttr('disabled');
+ }
+ if (redoStackG.length < 1) {
+ $('#redo').attr('disabled', 'disabled');
+ } else {
+ $('#redo').removeAttr('disabled');
+ }
}
function actionPerformed() {
@@ -70,5 +101,8 @@ function actionPerformed() {
undoStackG.push(redoStackG.pop());
}
}
- return pushState(undoStackG);
+ var result = pushState(undoStackG);
+ enableUndoButtons();
+
+ return result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.