Sha256: f188fb1b4ffef3da6c017855264a97d8da044a0515528e23c4fb3156a4eceef3
Contents?: true
Size: 1.58 KB
Versions: 7
Compression:
Stored size: 1.58 KB
Contents
/* --- script: Element.Shortcuts.js name: Element.Shortcuts description: Extends the Element native object to include some shortcut methods. license: MIT-style license authors: - Aaron Newton requires: - Core/Element.Style - /MooTools.More provides: [Element.Shortcuts] ... */ Element.implement({ isDisplayed: function(){ return this.getStyle('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 d = this.getStyle('display'); } catch(e){} if (d == 'none') return this; return this.store('element:_originalDisplay', d || '').setStyle('display', 'none'); }, show: function(display){ if (!display && this.isDisplayed()) return this; 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 (window.getSelection){ var selection = window.getSelection(); if (selection && selection.removeAllRanges) selection.removeAllRanges(); } else if (document.selection && document.selection.empty){ try { //IE fails here if selected element is not in dom document.selection.empty(); } catch(e){} } } });
Version data entries
7 entries across 7 versions & 1 rubygems