Created
January 26, 2010 18:56
-
-
Save roccogalluzzo/287100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Element = { | |
visible: function() {return (!this.hasClassName('toggle'));}, | |
toggle: function() {if (this.visible()) { this.hide();} else {this.show();}}, | |
hide: function() {this.addClassName('toggle'); return this;}, | |
show: function() { this.removeClassName('toggle'); return this;}, | |
remove: function() { this.getParentNode().removeChild(this);return null;}, | |
empty: function() {while (this.getLastChild()) { this.removeChild(this.getLastChild());}} | |
} | |
function $(element) { | |
if (typeof element == "string"){ | |
element = document.getElementById(element); | |
if (element){ extend(element,Element);return element;}} | |
} | |
function extend(instance,fn) { | |
for (var name in fn) { | |
instance[name] = fn[name]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment