Requires

Provides

Element.Shortcuts.js

Extends the Element native object to include some shortcut methods.

License:
MIT-style license
Authors:
Aaron Newton
  1. 25
  2. 26
  3. 27
  4. 28
  5. 29
  6. 30
  7. 31
  8. 32
  9. 33
  10. 34
  11. 35
  12. 36
  13. 37
  14. 38
  15. 39
  16. 40
  17. 41
  18. 42
  19. 43
Element.implement({ isDisplayed: function(){ return this.style.display != 'none'; }, isVisible: function(){ var w = this.offsetWidth, h = this.offsetHeight; return (w == 0 && h == 0) ? false : (w > 0 && h > 0) ? true : this.style.display != 'none'; }, toggle: function(){ return this[this.isDisplayed() ? 'hide' : 'show'](); }, hide: function(){ var d; try {

IE fails here if the element is not in the dom

  1. 45
  2. 46
  3. 47
  4. 48
  5. 49
  6. 50
  7. 51
  8. 52
  9. 53
  10. 54
  11. 55
  12. 56
  13. 57
  14. 58
  15. 59
  16. 60
  17. 61
  18. 62
  19. 63
  20. 64
  21. 65
  22. 66
  23. 67
  24. 68
  25. 69
d = this.getStyle('display'); } catch(e){} return this.store('element:_originalDisplay', d || '').setStyle('display', 'none'); }, show: function(display){ display = display || this.retrieve('element:_originalDisplay') || 'block'; return this.setStyle('display', (display == 'none') ? 'block' : display); }, swapClass: function(remove, add){ return this.removeClass(remove).addClass(add); } }); Document.implement({ clearSelection: function(){ if (document.selection && document.selection.empty) { document.selection.empty(); } else if (window.getSelection) { var selection = window.getSelection(); if (selection && selection.removeAllRanges) selection.removeAllRanges(); } } });