mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
Merge pull request #13907 from twbs/fat-12145
add "focus" to focused btns with button plugin
This commit is contained in:
commit
907b3b2892
1 changed files with 22 additions and 6 deletions
18
js/button.js
18
js/button.js
|
@ -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
|
// BUTTON DATA-API
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
$(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.hasClass('btn')) $btn = $btn.closest('.btn')
|
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
|
||||||
Plugin.call($btn, 'toggle')
|
Plugin.call($btn, 'toggle')
|
||||||
e.preventDefault()
|
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);
|
}(jQuery);
|
||||||
|
|
Loading…
Reference in a new issue