Added jQuery custom tab extension

This commit is contained in:
Elliot Hesp
2014-12-01 22:39:41 +00:00
parent 52b8d9a2d4
commit 1b9490b093
9 changed files with 114 additions and 29 deletions

25
app/assets/js/plugins/jquery/tabs.js vendored Normal file
View File

@@ -0,0 +1,25 @@
/**
* jQuery Tab Plugin
*/
$.fn.tabs = function(options) {
// Default Settings
var settings = $.extend({
state: "active",
active: 1,
}, options );
// Ensure only one given tab is displaying
$(this).next().children().not("#tab-" + settings.active).css("display", "none");
// When an tab andchor is clicked
$(this).on("click", "a", function (event) {
event.preventDefault();
$(this).parent().addClass(settings.state);
$(this).parent().siblings().removeClass(settings.state);
var tab = $(this).attr("href");
$('.tab-content').children().not(tab).css("display", "none");
$(tab).css("display", "block");
});
};