Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var Snowman = (function(){
var S = window.S = function(selector){
return new S.fn.init(selector);
};
S.fn = S.prototype = {
element: null,
selector: null,
init: function(selector){
this.selector = selector;
this.element = document.getElementById(selector);
// use a real selector engine..
// really, this only gives us 0 or 1 elements
this.length = this.element ? 1 : 0;
},
addClass:function(newClass){
this.element.className += newClass;
return this;
},
removeClass: function(oldClass){
this.element.className = this.element.className.replace(new Regex(oldClass,'gi'),'');
return this;
},
hide: function(){
this.element.style.display = "none";
return this;
},
show: function(){
this.element.style.display = "block";
return this;
}
};
S.fn.init.prototype = S.fn;
return S;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment