aboutsummaryrefslogtreecommitdiff
path: root/js/bootstrap-buttons.js
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2011-10-29 18:49:35 -0700
committerJacob Thornton <[email protected]>2011-10-29 18:49:35 -0700
commitea50e8aeeed6616a61a7e44d28fe60ced327be0c (patch)
treec4b4e7a6c81da4145d638ede025ba14eac2f47ff /js/bootstrap-buttons.js
parente8b66a9626055957a378464e2b9204f156b34c17 (diff)
downloadbootstrap-ea50e8aeeed6616a61a7e44d28fe60ced327be0c.tar.xz
bootstrap-ea50e8aeeed6616a61a7e44d28fe60ced327be0c.zip
add active class to css for buttons, write new spec for button, "use strict"
Diffstat (limited to 'js/bootstrap-buttons.js')
-rw-r--r--js/bootstrap-buttons.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/js/bootstrap-buttons.js b/js/bootstrap-buttons.js
index fe6c9c599..1fcc5e505 100644
--- a/js/bootstrap-buttons.js
+++ b/js/bootstrap-buttons.js
@@ -36,10 +36,16 @@
$el.removeClass(d).removeAttr(d)
}
- $.fn.button = function(state) {
- var d = 'disabled'
+ function toggle(el) {
+ $(el).toggleClass('active')
+ }
+
+ $.fn.button = function(options) {
return this.each(function () {
- state && setState(this, state)
+ if (options == 'toggle') {
+ return toggle(this)
+ }
+ options && setState(this, options)
})
}
@@ -47,4 +53,10 @@
loadingText: 'loading...'
}
+ $(function () {
+ $('body').delegate('.btn[data-toggle]', 'click', function () {
+ $(this).button('toggle')
+ })
+ })
+
}( window.jQuery || window.ender ); \ No newline at end of file