-
-
Save stefanpenner/90fcfe46b6ff2fe13998 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 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