From cc7fab893d2e3c24fdc0e26fd47478cc0006200b Mon Sep 17 00:00:00 2001 From: Heinrich Fenkart Date: Wed, 16 Jul 2014 08:44:56 +0200 Subject: [PATCH] Follow-up to #13907: simplify JS logic for focus shim --- js/button.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/js/button.js b/js/button.js index 7e2a6e4e88..b3e944c591 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);