1 /** 2 * Object that is used to undo actions when figures are moved from front to back 3 * @this {ZOrderCommand} 4 * @constructor 5 * @param property {Null} 6 * @param previousValue {Number} index 7 * @param currentValue {Number} index 8 */ 9 function ZOrderCommand(objectId, typeOfObject, property, previousValue, currentValue){ 10 this.objectId = objectId; 11 this.typeOfObject = typeOfObject; 12 this.property = property; 13 this.previousValue = previousValue; 14 this.currentValue = currentValue; 15 this.oType = "Z-Order Action"; 16 } 17 18 ZOrderCommand.prototype = { 19 /**This method got called every time the Command must execute*/ 20 redo : function(){ 21 this._doAction(this.currentValue); 22 }, 23 24 25 /**This method should be called every time the Command should be undone*/ 26 undo : function(){ 27 this._doAction(this.previousValue); 28 }, 29 30 _doAction:function(value){ 31 var oldValue = stack.idToIndex[this.objectId] ; 32 if(oldValue + 1 == value || oldValue - 1 == value){ 33 stack.swapToPosition(this.objectId, value); 34 } 35 else{ 36 stack.setPosition(this.objectId, value); 37 } 38 } 39 } 40 41 42