Skip to content

Instantly share code, notes, and snippets.

@patelprashant
Created November 10, 2013 22:22
Show Gist options
  • Select an option

  • Save patelprashant/7404728 to your computer and use it in GitHub Desktop.

Select an option

Save patelprashant/7404728 to your computer and use it in GitHub Desktop.
var Tabs = {
el: {
nav: $(".nav"),
tabs: $(".nav > li > a"),
panels: $(".nav > li > section")
},
init: function() {
Tabs.bindUIActions();
},
bindUIActions: function() {
Tabs.el.nav
.on(
'click',
'li > a:not(.active)',
function(event) {
Tabs.deactivateAll();
Tabs.activateTab(event);
event.preventDefault();
}
);
},
deactivateAll: function() {
Tabs.el.tabs.removeClass("active");
Tabs.el.panels.removeClass("is-open");
},
activateTab: function(event) {
$(event.target)
.addClass("active")
.next()
.addClass("is-open");
}
};
Tabs.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment