]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Follow-up to #13907: simplify JS logic for focus shim 14160/head
authorHeinrich Fenkart <hnrch02@gmail.com>
Wed, 16 Jul 2014 06:44:56 +0000 (08:44 +0200)
committerHeinrich Fenkart <hnrch02@gmail.com>
Wed, 16 Jul 2014 06:44:56 +0000 (08:44 +0200)
js/button.js

index 7e2a6e4e88f68f795ac9263f5ecbf612d307f8fc..b3e944c591425afddd56eb23b586e5d5ad513ad9 100644 (file)
   }
 
 
-  // FOCUS SHIM (FOR BUTTON GROUPS)
-  // ==============================
-
-  function getBtnTarget(target) {
-    var $target = $(target)
-    return $target.hasClass('btn') ? $target : $target.parent('.btn')
-  }
-
-
   // BUTTON DATA-API
   // ===============
 
       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);