;(function(defaults, $, window, document, undefined) {
'use strict';
$.extend({
// function to change the default properties of the plugin
// usage:
// jquery.tabifysetup({property:'custom value'});
tabifysetup : function(options) {
return $.extend(defaults, options);
}
}).fn.extend({
// usage:
// jquery(selector).tabify({property:'value'});
tabify : function(options) {
options = $.extend({}, defaults, options);
return $(this).each(function() {
var $element, tabhtml, $tabs, $sections;
$element = $(this);
$sections = $element.children();
// build tabhtml
tabhtml = '
';
// prepend navigation
$element.prepend(tabhtml);
// load tabs
$tabs = $element.find('.tab-nav li');
// functions
var activatetab = function(id) {
$tabs.filter('.active').removeclass('active');
$sections.filter('.active').removeclass('active');
$tabs.has('a[href="' + id + '"]').addclass('active');
$sections.filter(id).addclass('active');
}
// setup events
$tabs.on('click', function(e){
activatetab($(this).find('a').attr('href'));
e.preventdefault();
});
// activate first tab
activatetab($tabs.first().find('a').attr('href'));
});
}
});
})({
property : "value",
otherproperty : "value"
}, jquery, window, document);