From 5f4e30ed1d33f83b0fad3afc9174e193e6c3fdf4 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 9 Sep 2011 22:47:49 -0700 Subject: move js plugins to root dir, begin writing tests, and change modal plugin to be more boss like --- js/bootstrap-tabs.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 js/bootstrap-tabs.js (limited to 'js/bootstrap-tabs.js') diff --git a/js/bootstrap-tabs.js b/js/bootstrap-tabs.js new file mode 100644 index 000000000..029ccc65c --- /dev/null +++ b/js/bootstrap-tabs.js @@ -0,0 +1,38 @@ +(function( $ ){ + + function activate ( element, container ) { + container.find('.active').removeClass('active') + element.addClass('active') + } + + function tab( e ) { + var $this = $(this) + , href = $this.attr('href') + , $ul = $(e.liveFired) + , $controlled + + if (/^#\w+/.test(href)) { + e.preventDefault() + + if ($this.hasClass('active')) { + return + } + + $href = $(href) + + activate($this.parent('li'), $ul) + activate($href, $href.parent()) + } + } + + + /* TABS/PILLS PLUGIN DEFINITION + * ============================ */ + + $.fn.tabs = $.fn.pills = function () { + return this.each(function () { + $(this).delegate('.tabs > li > a, .pills > li > a, .dropdown-menu > li > a', 'click', tab) + }) + } + +})( jQuery || ender ) \ No newline at end of file -- cgit v1.2.3