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:
29
docs/assets/js/bootstrap-tabs.js
vendored
29
docs/assets/js/bootstrap-tabs.js
vendored
@@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user