From ea50e8aeeed6616a61a7e44d28fe60ced327be0c Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 29 Oct 2011 18:49:35 -0700 Subject: add active class to css for buttons, write new spec for button, "use strict" --- js/bootstrap-buttons.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'js/bootstrap-buttons.js') 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 -- cgit v1.2.3