diff options
author | Jacob Thornton <jacobthornton@gmail.com> | 2012-04-15 03:29:53 +0400 |
---|---|---|
committer | Jacob Thornton <jacobthornton@gmail.com> | 2012-04-15 03:29:53 +0400 |
commit | 575f18aaf49abb0289185f6409bee031947ccf69 (patch) | |
tree | d3548124fab9ba1affe9e056665a46a20432a5c7 /js/bootstrap-button.js | |
parent | 8575a452942001bce522e8e258d9e192d24cb6ec (diff) |
add jshint support + a few minor stylistic changes
Diffstat (limited to 'js/bootstrap-button.js')
-rw-r--r-- | js/bootstrap-button.js | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/js/bootstrap-button.js b/js/bootstrap-button.js index 77af03760b..49e88e49ad 100644 --- a/js/bootstrap-button.js +++ b/js/bootstrap-button.js @@ -18,58 +18,53 @@ * ============================================================ */ -!function ( $ ) { +!function ($) { + + "use strict"; // jshint ;_; - "use strict" /* BUTTON PUBLIC CLASS DEFINITION * ============================== */ - var Button = function ( element, options ) { + var Button = function (element, options) { this.$element = $(element) this.options = $.extend({}, $.fn.button.defaults, options) } - Button.prototype = { - - constructor: Button - - , setState: function ( state ) { - var d = 'disabled' - , $el = this.$element - , data = $el.data() - , val = $el.is('input') ? 'val' : 'html' + Button.prototype.setState = function (state) { + var d = 'disabled' + , $el = this.$element + , data = $el.data() + , val = $el.is('input') ? 'val' : 'html' - state = state + 'Text' - data.resetText || $el.data('resetText', $el[val]()) + state = state + 'Text' + data.resetText || $el.data('resetText', $el[val]()) - $el[val](data[state] || this.options[state]) + $el[val](data[state] || this.options[state]) - // push to event loop to allow forms to submit - setTimeout(function () { - state == 'loadingText' ? - $el.addClass(d).attr(d, d) : - $el.removeClass(d).removeAttr(d) - }, 0) - } - - , toggle: function () { - var $parent = this.$element.parent('[data-toggle="buttons-radio"]') + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d) + }, 0) + } - $parent && $parent - .find('.active') - .removeClass('active') + Button.prototype.toggle = function () { + var $parent = this.$element.parent('[data-toggle="buttons-radio"]') - this.$element.toggleClass('active') - } + $parent && $parent + .find('.active') + .removeClass('active') + this.$element.toggleClass('active') } /* BUTTON PLUGIN DEFINITION * ======================== */ - $.fn.button = function ( option ) { + $.fn.button = function (option) { return this.each(function () { var $this = $(this) , data = $this.data('button') @@ -98,4 +93,4 @@ }) }) -}( window.jQuery );
\ No newline at end of file +}(window.jQuery);
\ No newline at end of file |