1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 05:19:15 +02:00

start updating to data- driven js

This commit is contained in:
Jacob Thornton
2011-10-04 21:48:53 -07:00
parent 913338f930
commit a91a407bd6
6 changed files with 80 additions and 52 deletions

18
js/bootstrap-tabs.js vendored
View File

@@ -18,30 +18,36 @@
* ======================================================== */
(function( $ ){
!function( $ ){
function activate ( element, container ) {
container.find('.active').removeClass('active')
container.find('> .active').removeClass('active')
element.addClass('active')
}
function tab( e ) {
var $this = $(this)
, $ul = $this.closest('ul')
, href = $this.attr('href')
, $ul = $(e.liveFired)
, $controlled
, previous
if (/^#\w+/.test(href)) {
e.preventDefault()
if ($this.hasClass('active')) {
if ($this.parent('li').hasClass('active')) {
return
}
previous = $ul.find('.active a')[0]
$href = $(href)
activate($this.parent('li'), $ul)
activate($href, $href.parent())
$this.trigger({
type: 'change'
, relatedTarget: previous
})
}
}
@@ -59,4 +65,4 @@
$('body').tabs('ul[data-tabs] li > a, ul[data-pills] > li > a')
})
})( window.jQuery || window.ender )
}( window.jQuery || window.ender );