Requires

Provides

Radio.js

A command that is linked with others by name (one of many)

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

Radio groupping is a way to links commands together to allow only one in the group be active at the moment of time.

Activation (checking) of the commands deactivates all other commands in a radiogroup.

Examples: – Tabs on top of a content window – List of currently open documents in a context menu that shows which of them is the one you edit now and an ability to switch between documents

  1. 36
  2. 37
  3. 38
  4. 39
  5. 40
  6. 41
  7. 42
  8. 43
  9. 44
  10. 45
  11. 46
  12. 47
  13. 48
  14. 49
  15. 50
  16. 51
  17. 52
  18. 53
  19. 54
  20. 55
  21. 56
  22. 57
  23. 58
  24. 59
  25. 60
  26. 61
  27. 62
  28. 63
  29. 64
  30. 65
  31. 66
  32. 67
LSD.Command.Radio = new Class({ Extends: LSD.Command, options: { radiogroup: false }, initialize: function() { this.parent.apply(this, arguments); var name = this.options.radiogroup || this.options.name; if (name) { var groups = this.document.radiogroups; if (!groups) groups = this.document.radiogroups = {}; var group = groups[name]; if (!group) group = groups[name] = []; group.push(this); this.group = group; } this.addEvent('check', function() { group.each(function(command) { if (command != this) command.uncheck() }, this); }.bind(this)) }, click: function() { this.parent.apply(this, arguments); this.check(); } }); LSD.Command.prototype.addState('checked');