0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

add "focus" to focused btns with button plugin

This commit is contained in:
fat 2014-06-23 23:32:52 -07:00
parent a0e98adebf
commit 6b6476fcd9

View File

@ -97,14 +97,30 @@
}
// FOCUS SHIM (FOR BUTTON GROUPS)
// ==============================
function getBtnTarget(target) {
var $target = $(target)
return $target.hasClass('btn') ? $target : $target.parent('.btn')
}
// BUTTON DATA-API
// ===============
$(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
Plugin.call($btn, 'toggle')
e.preventDefault()
})
$(document)
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
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')
})
}(jQuery);