1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/js/bootstrap-button.js Fri Jul 04 16:42:41 2014 +0400
1.3 @@ -0,0 +1,105 @@
1.4 +/* ============================================================
1.5 + * bootstrap-button.js v2.3.1
1.6 + * http://twitter.github.com/bootstrap/javascript.html#buttons
1.7 + * ============================================================
1.8 + * Copyright 2012 Twitter, Inc.
1.9 + *
1.10 + * Licensed under the Apache License, Version 2.0 (the "License");
1.11 + * you may not use this file except in compliance with the License.
1.12 + * You may obtain a copy of the License at
1.13 + *
1.14 + * http://www.apache.org/licenses/LICENSE-2.0
1.15 + *
1.16 + * Unless required by applicable law or agreed to in writing, software
1.17 + * distributed under the License is distributed on an "AS IS" BASIS,
1.18 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1.19 + * See the License for the specific language governing permissions and
1.20 + * limitations under the License.
1.21 + * ============================================================ */
1.22 +
1.23 +
1.24 +!function ($) {
1.25 +
1.26 + "use strict"; // jshint ;_;
1.27 +
1.28 +
1.29 + /* BUTTON PUBLIC CLASS DEFINITION
1.30 + * ============================== */
1.31 +
1.32 + var Button = function (element, options) {
1.33 + this.$element = $(element)
1.34 + this.options = $.extend({}, $.fn.button.defaults, options)
1.35 + }
1.36 +
1.37 + Button.prototype.setState = function (state) {
1.38 + var d = 'disabled'
1.39 + , $el = this.$element
1.40 + , data = $el.data()
1.41 + , val = $el.is('input') ? 'val' : 'html'
1.42 +
1.43 + state = state + 'Text'
1.44 + data.resetText || $el.data('resetText', $el[val]())
1.45 +
1.46 + $el[val](data[state] || this.options[state])
1.47 +
1.48 + // push to event loop to allow forms to submit
1.49 + setTimeout(function () {
1.50 + state == 'loadingText' ?
1.51 + $el.addClass(d).attr(d, d) :
1.52 + $el.removeClass(d).removeAttr(d)
1.53 + }, 0)
1.54 + }
1.55 +
1.56 + Button.prototype.toggle = function () {
1.57 + var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
1.58 +
1.59 + $parent && $parent
1.60 + .find('.active')
1.61 + .removeClass('active')
1.62 +
1.63 + this.$element.toggleClass('active')
1.64 + }
1.65 +
1.66 +
1.67 + /* BUTTON PLUGIN DEFINITION
1.68 + * ======================== */
1.69 +
1.70 + var old = $.fn.button
1.71 +
1.72 + $.fn.button = function (option) {
1.73 + return this.each(function () {
1.74 + var $this = $(this)
1.75 + , data = $this.data('button')
1.76 + , options = typeof option == 'object' && option
1.77 + if (!data) $this.data('button', (data = new Button(this, options)))
1.78 + if (option == 'toggle') data.toggle()
1.79 + else if (option) data.setState(option)
1.80 + })
1.81 + }
1.82 +
1.83 + $.fn.button.defaults = {
1.84 + loadingText: 'loading...'
1.85 + }
1.86 +
1.87 + $.fn.button.Constructor = Button
1.88 +
1.89 +
1.90 + /* BUTTON NO CONFLICT
1.91 + * ================== */
1.92 +
1.93 + $.fn.button.noConflict = function () {
1.94 + $.fn.button = old
1.95 + return this
1.96 + }
1.97 +
1.98 +
1.99 + /* BUTTON DATA-API
1.100 + * =============== */
1.101 +
1.102 + $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
1.103 + var $btn = $(e.target)
1.104 + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1.105 + $btn.button('toggle')
1.106 + })
1.107 +
1.108 +}(window.jQuery);
1.109 \ No newline at end of file