CmdToggleBoolean.js 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * Created by Daniel on 21.07.15.
  3. */
  4. CmdToggleBoolean = function ( object, attributeName ) {
  5. Cmd.call( this );
  6. this.type = 'CmdToggleBoolean';
  7. this.object = object;
  8. this.attributeName = attributeName;
  9. this.objectUuid = object !== undefined ? object.uuid : undefined;
  10. };
  11. CmdToggleBoolean.prototype = {
  12. execute: function () {
  13. this.object[ this.attributeName ] = !this.object[ this.attributeName ];
  14. this.editor.signals.objectChanged.dispatch( this.object );
  15. },
  16. undo: function () {
  17. this.object[ this.attributeName ] = !this.object[ this.attributeName ];
  18. this.editor.signals.objectChanged.dispatch( this.object );
  19. },
  20. toJSON: function () {
  21. var output = Cmd.prototype.toJSON.call( this );
  22. output.objectUuid = this.objectUuid;
  23. output.attributeName = this.attributeName;
  24. return output;
  25. },
  26. fromJSON: function ( json ) {
  27. Cmd.prototype.fromJSON.call( this, json );
  28. this.object = this.editor.objectByUuid( json.objectUuid );
  29. this.attributeName = json.attributeName;
  30. }
  31. };