1 line
1002 B
JavaScript
1 line
1002 B
JavaScript
!function(a){"use strict";var s=function(t,e){this.$element=a(t),this.options=a.extend({},a.fn.button.defaults,e)};s.prototype.setState=function(t){var e="disabled",n=this.$element,o=n.data(),a=n.is("input")?"val":"html";t+="Text",o.resetText||n.data("resetText",n[a]()),n[a](o[t]||this.options[t]),setTimeout(function(){"loadingText"==t?n.addClass(e).attr(e,e):n.removeClass(e).removeAttr(e)},0)},s.prototype.toggle=function(){var t=this.$element.closest('[data-toggle="buttons-radio"]');t&&t.find(".active").removeClass("active"),this.$element.toggleClass("active")},a.fn.button=function(o){return this.each(function(){var t=a(this),e=t.data("button"),n="object"==typeof o&&o;e||t.data("button",e=new s(this,n)),"toggle"==o?e.toggle():o&&e.setState(o)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=s,a(document).on("click.button.data-api","[data-toggle^=button]",function(t){var e=a(t.target);e.hasClass("btn")||(e=e.closest(".btn")),e.button("toggle")})}(window.jQuery); |