diff options
| author | Jacob Thornton <[email protected]> | 2012-02-18 23:31:37 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-02-18 23:31:37 -0800 |
| commit | ac6e667ad9ae57c5caa977fd6593a2299887737a (patch) | |
| tree | d6616980eb7de863c2a9083f6646ba8a4f102272 | |
| parent | 1948e985a355c519b8f3940af0ce83d9fd3c5f83 (diff) | |
| parent | 3d58b4622671bc51c22c857641db3b988e73632a (diff) | |
| download | bootstrap-ac6e667ad9ae57c5caa977fd6593a2299887737a.tar.xz bootstrap-ac6e667ad9ae57c5caa977fd6593a2299887737a.zip | |
Merge branch 'master' into 2.0.2-wip
Conflicts:
docs/assets/bootstrap.zip
| -rw-r--r-- | docs/assets/bootstrap.zip | bin | 53361 -> 53408 bytes | |||
| -rw-r--r-- | docs/assets/js/bootstrap-button.js | 4 | ||||
| -rw-r--r-- | js/bootstrap-button.js | 4 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-button.js | 25 |
4 files changed, 30 insertions, 3 deletions
diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip Binary files differindex b10d1d3c6..df4dc7ff2 100644 --- a/docs/assets/bootstrap.zip +++ b/docs/assets/bootstrap.zip diff --git a/docs/assets/js/bootstrap-button.js b/docs/assets/js/bootstrap-button.js index a0e053547..0238ca3cb 100644 --- a/docs/assets/js/bootstrap-button.js +++ b/docs/assets/js/bootstrap-button.js @@ -91,7 +91,9 @@ $(function () { $('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') }) }) diff --git a/js/bootstrap-button.js b/js/bootstrap-button.js index a0e053547..0238ca3cb 100644 --- a/js/bootstrap-button.js +++ b/js/bootstrap-button.js @@ -91,7 +91,9 @@ $(function () { $('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') }) }) diff --git a/js/tests/unit/bootstrap-button.js b/js/tests/unit/bootstrap-button.js index 8aed857e1..03c4a8e9d 100644 --- a/js/tests/unit/bootstrap-button.js +++ b/js/tests/unit/bootstrap-button.js @@ -45,10 +45,33 @@ $(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') btn.button('toggle') 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') + }) + })
\ No newline at end of file |
