Skip to content

Instantly share code, notes, and snippets.

@stefanpenner
Created March 1, 2011 04:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanpenner/90fcfe46b6ff2fe13998 to your computer and use it in GitHub Desktop.
Save stefanpenner/90fcfe46b6ff2fe13998 to your computer and use it in GitHub Desktop.
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