Requires

Provides

Placeholder.js

Placeholder for form fileds.

License:
Public domain (http://unlicense.org).
Authors:
Yaroslaff Fedin
  1. 24
  2. 25
  3. 26
  4. 27
  5. 28
  6. 29
  7. 30
  8. 31
  9. 32
  10. 33
  11. 34
  12. 35
  13. 36
  14. 37
  15. 38
  16. 39
  17. 40
  18. 41
  19. 42
  20. 43
  21. 44
  22. 45
  23. 46
  24. 47
  25. 48
  26. 49
  27. 50
  28. 51
  29. 52
  30. 53
  31. 54
  32. 55
  33. 56
  34. 57
  35. 58
  36. 59
  37. 60
  38. 61
  39. 62
  40. 63
  41. 64
  42. 65
  43. 66
  44. 67
  45. 68
  46. 69
  47. 70
  48. 71
  49. 72
  50. 73
  51. 74
LSD.Mixin.Placeholder = new Class({ behaviour: '[placeholder]', options: { actions: { placeholder: { enable: function(){ this.element.set('autocomplete', 'off'); this.onPlacehold(); } } }, events: { enabled: { element: { 'focus': 'onUnplacehold', 'blur': 'onPlacehold', 'keypress': 'onUnplacehold' } } }, states: { placeholding: { enabler: 'placehold', disabler: 'unplacehold' } } }, getPlaceholder: Macro.getter('placeholder', function(){ return this.attributes.placeholder; }), onUnplacehold: function(){ if(this.placeholdered){ this.applyValue(''); this.unplacehold(); return true; }; }, onPlacehold: function(){ var value = this.getRawValue(); if(value.match(/^\s*$/) || value == this.getPlaceholder()){ this.applyValue(this.getPlaceholder()); this.placehold(); return true; }; } });