Created
May 10, 2012 15:29
-
-
Save johnnysparks/2653916 to your computer and use it in GitHub Desktop.
Koi namespace / extend
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
/** | |
* Checkout bobbitt's base koi examples here: | |
* https://github.com/ericb/Koi/blob/master/examples.js | |
*/ | |
// use koi namespace to define a new object level ( this is basically if !tmplMethods, tmplMethods = {} ) | |
Koi.namespace('tmplMethods'); | |
// if there are methods used across a section of the application, you could nest deeper ( common ajax calls or something ) | |
Koi.namespace('Publications', tmplMethods ); | |
Koi.namespace('Contests', tmplMethods.Publications ); | |
// Shoutlet.base could be any koi class. We could even do Shoutlet.tmpls or something to keep the global namespace even cleaner | |
// ie. Shoutlet.tmpls.Publications.Contests | |
tmplMethods.Publications.Contests = Koi.extend(Shoutlet.base, { | |
$guide: null, | |
selector: null, | |
init: function( selector ) { | |
this.$guide = $('.guide-catagory'); | |
this.selector = selector; | |
}, | |
showCategory:function(){ | |
this.$guide.hide(); | |
$('#'+this.selector+'GuidesSelection .toggle-content').not(":visible")); | |
$('#'+this.selector+'GuidesSelection .toggle-content').show(); | |
} | |
} | |
// use the code | |
contest = new tmplMethods.Publications.Contests("setUp"); | |
contest.showCategory(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment