Requires

Provides

Command.js

A command getter that watches attributes to redefine command

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin

Usually a widget that does something interactive defines command automatically.

The default type is ‘command’, but there are possible values of ‘radio’ and ‘checkbox’.

Type type can be changed via options.command.type (equals to ‘command-type’ attribute).

You can specify a command id in command attribute to link a widget to already initialized command.

  1. 39
  2. 40
  3. 41
  4. 42
  5. 43
  6. 44
  7. 45
  8. 46
  9. 47
  10. 48
  11. 49
  12. 50
  13. 51
  14. 52
  15. 53
  16. 54
  17. 55
  18. 56
  19. 57
  20. 58
  21. 59
  22. 60
  23. 61
  24. 62
  25. 63
  26. 64
  27. 65
  28. 66
  29. 67
  30. 68
  31. 69
  32. 70
  33. 71
  34. 72
  35. 73
  36. 74
  37. 75
  38. 76
  39. 77
  40. 78
  41. 79
  42. 80
  43. 81
  44. 82
  45. 83
LSD.Module.Command = new Class({ options: { command: {}, expectations: { '[radiogroup]': ['getCommand', true], '[command]': ['getCommand', true], }, chain: { commandaction: function() { var action = this.getCommandAction.apply(this, arguments); if (action) return {name: action, priority: 10} } } }, getCommand: function(force) { if (!force && this.command) return this.command; if (!this.attributes.command || !this.document.commands) { var options = this.options.command || {}; var type = options.type || 'command', command; options = Object.append({id: this.options.id, name: this.attributes.name}, options); if (this.attributes.radiogroup) { options.radiogroup = this.attributes.radiogroup; type = 'radio' }; if (!command) command = new LSD.Command[type.capitalize()](this.document, options); } else command = this.document.commands[this.attributes.command]; command.attach(this); if (force && this.command) this.command.detach(this); return this.command = command; }, click: function() { this.fireEvent('click', arguments); this.clearChain.apply(this, arguments); var command = this.getCommand(); command.click.apply(command, arguments); return this.callChain.apply(this, arguments); }, getCommandAction: function() { return this.attributes.commandaction; } });