Skip to content

Instantly share code, notes, and snippets.

@johnnysparks
Created May 10, 2012 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnnysparks/2653916 to your computer and use it in GitHub Desktop.
Save johnnysparks/2653916 to your computer and use it in GitHub Desktop.
Koi namespace / extend
/**
* 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