Requires

Provides

Label.js

Supplementary field for any kind of widgets that take focus

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 22
  2. 23
  3. 24
  4. 25
  5. 26
  6. 27
  7. 28
  8. 29
  9. 30
  10. 31
  11. 32
  12. 33
  13. 34
  14. 35
  15. 36
  16. 37
  17. 38
  18. 39
  19. 40
  20. 41
  21. 42
  22. 43
  23. 44
  24. 45
  25. 46
  26. 47
  27. 48
  28. 49
  29. 50
  30. 51
  31. 52
  32. 53
LSD.Widget.Label = new Class({ Extends: LSD.Widget.Element, options: { tag: 'label', element: { tag: 'label' }, events: { element: { click: 'focusRelatedWidget' } }, }, getInput: function() { if (!this.input) this.input = new Element('textarea'); return this.input; }, focusRelatedWidget: function() { var parent = this; var target = this.attributes['for']; if (!target || target.match(/\^s*$/)) return; while (parent.parentNode && parent.parentNode != this.document) parent = parent.parentNode; //search by id in topmost widget var element = parent.getElement("#" + target); if (!element) return; if (element.retain) element.retain(); if (element.click) element.click(); } });