twbs--bootstrap/js/bootstrap-tabs.js

38 lines
787 B
JavaScript
Raw Normal View History

2011-09-09 02:13:08 +00:00
(function( $ ){
function activate ( element, container ) {
container.find('.active').removeClass('active')
element.addClass('active')
2011-09-09 02:13:08 +00:00
}
function tab( e ) {
var $this = $(this)
, href = $this.attr('href')
, $ul = $(e.liveFired)
, $controlled
2011-09-09 02:13:08 +00:00
2011-09-09 07:00:03 +00:00
if (/^#\w+/.test(href)) {
e.preventDefault()
2011-09-09 02:13:08 +00:00
if ($this.hasClass('active')) {
return
}
2011-09-09 07:00:03 +00:00
$href = $(href)
activate($this.parent('li'), $ul)
2011-09-09 07:00:03 +00:00
activate($href, $href.parent())
}
2011-09-09 02:13:08 +00:00
}
/* TABS/PILLS PLUGIN DEFINITION
* ============================ */
2011-09-09 02:13:08 +00:00
$.fn.tabs = $.fn.pills = function () {
2011-09-09 02:13:08 +00:00
return this.each(function () {
2011-09-09 07:00:03 +00:00
$(this).delegate('.tabs > li > a, .pills > li > a, .dropdown-menu > li > a', 'click', tab)
2011-09-09 02:13:08 +00:00
})
}
})( jQuery || ender )