0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-10 22:24:19 +01:00

Merge branch 'master' into 2.0.2-wip

Conflicts:
	docs/assets/bootstrap.zip
This commit is contained in:
Jacob Thornton 2012-02-18 23:31:37 -08:00
commit ac6e667ad9
4 changed files with 30 additions and 3 deletions

Binary file not shown.

View File

@ -91,7 +91,9 @@
$(function () { $(function () {
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) { $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
$(e.currentTarget).button('toggle') var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
}) })
}) })

View File

@ -91,7 +91,9 @@
$(function () { $(function () {
$('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) { $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
$(e.currentTarget).button('toggle') var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
}) })
}) })

View File

@ -45,10 +45,33 @@ $(function () {
}) })
test("should toggle active", function () { test("should toggle active", function () {
var btn = $('<button class="btn" data-loading-text="fat">mdo</button>') var btn = $('<button class="btn">mdo</button>')
ok(!btn.hasClass('active'), 'btn does not have active class') ok(!btn.hasClass('active'), 'btn does not have active class')
btn.button('toggle') btn.button('toggle')
ok(btn.hasClass('active'), 'btn has class active') ok(btn.hasClass('active'), 'btn has class active')
}) })
test("should toggle active when btn children are clicked", function () {
var btn = $('<button class="btn" data-toggle="button">mdo</button>')
, inner = $('<i></i>')
btn
.append(inner)
.appendTo($('#qunit-fixture'))
ok(!btn.hasClass('active'), 'btn does not have active class')
inner.click()
ok(btn.hasClass('active'), 'btn has class active')
})
test("should toggle active when btn children are clicked within btn-group", function () {
var btngroup = $('<div class="btn-group" data-toggle="buttons-checkbox"></div>')
, btn = $('<button class="btn">fat</button>')
, inner = $('<i></i>')
btngroup
.append(btn.append(inner))
.appendTo($('#qunit-fixture'))
ok(!btn.hasClass('active'), 'btn does not have active class')
inner.click()
ok(btn.hasClass('active'), 'btn has class active')
})
}) })