vendor: 2,975 bytes, lines 1-110
1/* ======================================================================== 2 * Bootstrap: button.js v3.2.0 3 * http://getbootstrap.com/javascript/#buttons 4 * ======================================================================== 5 * Copyright 2011-2014 Twitter, Inc. 6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 7 * ======================================================================== */ 8 9 10+function ($) { 11 'use strict'; 12 13 // BUTTON PUBLIC CLASS DEFINITION 14 // ============================== 15 16 var Button = function (element, options) { 17 this.$element = $(element) 18 this.options = $.extend({}, Button.DEFAULTS, options) 19 this.isLoading = false 20 } 21 22 Button.VERSION = '3.2.0' 23 24 Button.DEFAULTS = { 25 loadingText: 'loading...' 26 } 27 28 Button.prototype.setState = function (state) { 29 var d = 'disabled' 30 var $el = this.$element 31 var val = $el.is('input') ? 'val' : 'html' 32 var data = $el.data() 33 34 state = state + 'Text' 35 36 if (data.resetText == null) $el.data('resetText', $el[val]()) 37 38 $el[val](data[state] == null ? this.options[state] : data[state]) 39 40 // push to event loop to allow forms to submit 41 setTimeout($.proxy(function () { 42 if (state == 'loadingText') { 43 this.isLoading = true 44 $el.addClass(d).attr(d, d) 45 } else if (this.isLoading) { 46 this.isLoading = false 47 $el.removeClass(d).removeAttr(d) 48 } 49 }, this), 0) 50 } 51 52 Button.prototype.toggle = function () { 53 var changed = true 54 var $parent = this.$element.closest('[data-toggle="buttons"]') 55 56 if ($parent.length) { 57 var $input = this.$element.find('input') 58 if ($input.prop('type') == 'radio') { 59 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false 60 else $parent.find('.active').removeClass('active') 61 } 62 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') 63 } 64 65 if (changed) this.$element.toggleClass('active') 66 } 67 68 69 // BUTTON PLUGIN DEFINITION 70 // ======================== 71 72 function Plugin(option) { 73 return this.each(function () { 74 var $this = $(this) 75 var data = $this.data('bs.button') 76 var options = typeof option == 'object' && option 77 78 if (!data) $this.data('bs.button', (data = new Button(this, options))) 79 80 if (option == 'toggle') data.toggle() 81 else if (option) data.setState(option) 82 }) 83 } 84 85 var old = $.fn.button 86 87 $.fn.button = Plugin 88 $.fn.button.Constructor = Button 89 90 91 // BUTTON NO CONFLICT 92 // ================== 93 94 $.fn.button.noConflict = function () { 95 $.fn.button = old 96 return this 97 } 98 99 100 // BUTTON DATA-API 101 // =============== 102 103 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 104 var $btn = $(e.target) 105 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') 106 Plugin.call($btn, 'toggle') 107 e.preventDefault() 108 }) 109 110}(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.