1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 13:29:06 +02:00

some more js love - update the docs with tabs/pills plugin

This commit is contained in:
Jacob Thornton
2011-09-08 20:21:03 -07:00
parent 346122a0c7
commit 5960711d0f
11 changed files with 143 additions and 120 deletions

View File

@@ -2,33 +2,36 @@
function activate ( element, container ) {
container.find('.active').removeClass('active')
element.addClass('active')
element.addClass('active')
}
function tab( e ) {
debugger
var $this = $(this)
, href = $this.attr('href')
var $this = $(this)
, href = $this.attr('href')
, $ul = $(e.liveFired)
, $controlled
if (/^#/.test(href)) {
e.preventDefault()
if (/^#/.test(href)) {
e.preventDefault()
if ($this.hasClass('active')) {
return
}
activate($this, $ul)
activate($(href), $content)
}
$controlled = $('#' + $ul.attr('aria-controls'))
activate($this.parent('li'), $ul)
activate($(href, $controlled), $controlled)
}
}
/* TABS PLUGIN DEFINITION
* ====================== */
/* TABS/PILLS PLUGIN DEFINITION
* ============================ */
$.fn.tabs = function ( content ) {
$.fn.tabs = $.fn.pills = function () {
return this.each(function () {
$(this).delegate('> li > a', 'click', tab)
$(this).delegate('.tabs > li > a, .pills > li > a', 'click', tab)
})
}