Skip to content

Commit

Permalink
Merge pull request #14160 from hnrch02/simplify-button-focus-logic
Browse files Browse the repository at this point in the history
Follow-up to #13907: simplify JS logic for focus shim
  • Loading branch information
fat committed Jul 17, 2014
2 parents dd22f59 + cc7fab8 commit 541a75f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ===============

Expand All @@ -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);

0 comments on commit 541a75f

Please sign in to comment.