1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-09 15:16:51 +02:00

cleaner way of preventing double click events + clean up tests for jshint

This commit is contained in:
fat
2013-07-18 01:07:11 -07:00
parent 37e899d766
commit 4b40ee692d
4 changed files with 15 additions and 15 deletions

View File

@@ -242,9 +242,9 @@
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target) var $btn = $(e.target)
if ($btn.has('input').length) return // throw away double event for inputs
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle') $btn.button('toggle')
e.preventDefault()
}) })
}(window.jQuery); }(window.jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -99,9 +99,9 @@
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target) var $btn = $(e.target)
if ($btn.has('input').length) return // throw away double event for inputs
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle') $btn.button('toggle')
e.preventDefault()
}) })
}(window.jQuery); }(window.jQuery);

View File

@@ -81,19 +81,19 @@ $(function () {
}) })
test("should check for closest matching toggle", function () { test("should check for closest matching toggle", function () {
var group = '<div class="btn-group" data-toggle="buttons"> \ var group = '<div class="btn-group" data-toggle="buttons">' +
<label class="btn btn-primary active"> \ '<label class="btn btn-primary active">' +
<input type="radio" name="options" id="option1" checked="true"> Option 1 \ '<input type="radio" name="options" id="option1" checked="true"> Option 1' +
</label> \ '</label>' +
<label class="btn btn-primary"> \ '<label class="btn btn-primary">' +
<input type="radio" name="options" id="option2"> Option 2 \ '<input type="radio" name="options" id="option2"> Option 2' +
</label> \ '</label>' +
<label class="btn btn-primary"> \ '<label class="btn btn-primary">' +
<input type="radio" name="options" id="option3"> Option 3 \ '<input type="radio" name="options" id="option3"> Option 3' +
</label> \ '</label>' +
</div>' '</div>'
var group = $(group) group = $(group)
var btn1 = $(group.children()[0]) var btn1 = $(group.children()[0])
var btn2 = $(group.children()[1]) var btn2 = $(group.children()[1])