diff options
| author | Jacob <[email protected]> | 2014-07-16 21:56:13 -0700 |
|---|---|---|
| committer | Jacob <[email protected]> | 2014-07-16 21:56:13 -0700 |
| commit | 541a75f92c9b9e5b13fe1c331f9d10ba2e12b4de (patch) | |
| tree | 00fd029732fdda1449029dda61e91faa0e3cd211 | |
| parent | dd22f599998cc07c18b6643a856d5acda6c5c122 (diff) | |
| parent | cc7fab893d2e3c24fdc0e26fd47478cc0006200b (diff) | |
| download | bootstrap-541a75f92c9b9e5b13fe1c331f9d10ba2e12b4de.tar.xz bootstrap-541a75f92c9b9e5b13fe1c331f9d10ba2e12b4de.zip | |
Merge pull request #14160 from hnrch02/simplify-button-focus-logic
Follow-up to #13907: simplify JS logic for focus shim
| -rw-r--r-- | js/button.js | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/js/button.js b/js/button.js index 7e2a6e4e8..b3e944c59 100644 --- a/js/button.js +++ b/js/button.js @@ -97,15 +97,6 @@ } - // FOCUS SHIM (FOR BUTTON GROUPS) - // ============================== - - function getBtnTarget(target) { - var $target = $(target) - return $target.hasClass('btn') ? $target : $target.parent('.btn') - } - - // BUTTON DATA-API // =============== @@ -116,11 +107,8 @@ Plugin.call($btn, 'toggle') e.preventDefault() }) - .on('focus.bs.button.data-api', '[data-toggle^="button"]', function (e) { - getBtnTarget(e.target).addClass('focus') - }) - .on('blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { - getBtnTarget(e.target).removeClass('focus') + .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { + $(e.target).closest('.btn').toggleClass('focus', e.type == 'focus') }) }(jQuery); |
