mirror of
https://github.com/Hopiu/bootstrap.git
synced 2026-05-25 19:43:43 +00:00
Merge pull request #14160 from hnrch02/simplify-button-focus-logic
Follow-up to #13907: simplify JS logic for focus shim
This commit is contained in:
commit
541a75f92c
1 changed files with 2 additions and 14 deletions
16
js/button.js
16
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
|
// BUTTON DATA-API
|
||||||
// ===============
|
// ===============
|
||||||
|
|
||||||
|
|
@ -116,11 +107,8 @@
|
||||||
Plugin.call($btn, 'toggle')
|
Plugin.call($btn, 'toggle')
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
})
|
})
|
||||||
.on('focus.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
|
||||||
getBtnTarget(e.target).addClass('focus')
|
$(e.target).closest('.btn').toggleClass('focus', e.type == '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