Cmd.js 732 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * @author dforrer / https://github.com/dforrer
  3. */
  4. /**
  5. * @param editorRef pointer to main editor object used to initialize
  6. * each command object with a reference to the editor
  7. * @constructor
  8. */
  9. Cmd = function ( editorRef ) {
  10. this.id = -1;
  11. this.inMemory = false;
  12. this.updatable = false;
  13. this.type = '';
  14. this.name = '';
  15. if ( editorRef !== undefined ) {
  16. Cmd.editor = editorRef;
  17. }
  18. this.editor = Cmd.editor;
  19. };
  20. Cmd.prototype.toJSON = function () {
  21. var output = {};
  22. output.type = this.type;
  23. output.id = this.id;
  24. output.name = this.name;
  25. return output;
  26. };
  27. Cmd.prototype.fromJSON = function ( json ) {
  28. this.inMemory = true;
  29. this.type = json.type;
  30. this.id = json.id;
  31. this.name = json.name;
  32. };