1 var AddShapeAction, ClearAction;
3 ClearAction = (function() {
4 function ClearAction(lc1, oldShapes, newShapes1) {
6 this.oldShapes = oldShapes;
7 this.newShapes = newShapes1;
10 ClearAction.prototype["do"] = function() {
11 this.lc.shapes = this.newShapes;
12 return this.lc.repaintLayer('main');
15 ClearAction.prototype.undo = function() {
16 this.lc.shapes = this.oldShapes;
17 return this.lc.repaintLayer('main');
24 AddShapeAction = (function() {
25 function AddShapeAction(lc1, shape1, previousShapeId) {
28 this.previousShapeId = previousShapeId != null ? previousShapeId : null;
31 AddShapeAction.prototype["do"] = function() {
32 var found, i, len, newShapes, ref, shape;
33 if (!this.lc.shapes.length || this.lc.shapes[this.lc.shapes.length - 1].id === this.previousShapeId || this.previousShapeId === null) {
34 this.lc.shapes.push(this.shape);
39 for (i = 0, len = ref.length; i < len; i++) {
41 newShapes.push(shape);
42 if (shape.id === this.previousShapeId) {
43 newShapes.push(this.shape);
48 newShapes.push(this.shape);
50 this.lc.shapes = newShapes;
52 return this.lc.repaintLayer('main');
55 AddShapeAction.prototype.undo = function() {
56 var i, len, newShapes, ref, shape;
57 if (this.lc.shapes[this.lc.shapes.length - 1].id === this.shape.id) {
62 for (i = 0, len = ref.length; i < len; i++) {
64 if (shape.id !== this.shape.id) {
65 newShapes.push(shape);
68 lc.shapes = newShapes;
70 return this.lc.repaintLayer('main');
73 return AddShapeAction;
78 ClearAction: ClearAction,
79 AddShapeAction: AddShapeAction