1/* ========================================================= 2 * bootstrap-modal.js v2.0.4 3 * http://twitter.github.com/bootstrap/javascript.html#modals 4 * ========================================================= 5 * Copyright 2012 Twitter, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 * ========================================================= */ 19 20 21!function ($) { 22 23 "use strict"; // jshint ;_; 24 25 26 /* MODAL CLASS DEFINITION 27 * ====================== */ 28 29 var Modal = function (content, options) { 30 this.options = options 31 this.$element = $(content) 32 .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) 33 } 34 35 Modal.prototype = { 36 37 constructor: Modal 38 39 , toggle: function () { 40 return this[!this.isShown ? 'show' : 'hide']() 41 } 42 43 , show: function () { 44 var that = this 45 , e = $.Event('show') 46 47 this.$element.trigger(e) 48 49 if (this.isShown || e.isDefaultPrevented()) return 50 51 $('body').addClass('modal-open') 52 53 this.isShown = true 54 55 escape.call(this) 56 backdrop.call(this, function () { 57 var transition = $.support.transition && that.$element.hasClass('fade') 58 59 if (!that.$element.parent().length) { 60 that.$element.appendTo(document.body) //don't move modals dom position 61 } 62 63 that.$element 64 .show() 65 66 if (transition) { 67 that.$element[0].offsetWidth // force reflow 68 } 69 70 that.$element.addClass('in') 71 72 transition ? 73 that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : 74 that.$element.trigger('shown') 75 76 }) 77 } 78 79 , hide: function (e) { 80 e && e.preventDefault() 81 82 var that = this 83 84 e = $.Event('hide') 85 86 this.$element.trigger(e) 87 88 if (!this.isShown || e.isDefaultPrevented()) return 89 90 this.isShown = false 91 92 $('body').removeClass('modal-open') 93 94 escape.call(this) 95 96 this.$element.removeClass('in') 97 98 $.support.transition && this.$element.hasClass('fade') ? 99 hideWithTransition.call(this) : 100 hideModal.call(this) 101 } 102 103 } 104 105 106 /* MODAL PRIVATE METHODS 107 * ===================== */ 108 109 function hideWithTransition() { 110 var that = this 111 , timeout = setTimeout(function () { 112 that.$element.off($.support.transition.end) 113 hideModal.call(that) 114 }, 500) 115 116 this.$element.one($.support.transition.end, function () { 117 clearTimeout(timeout) 118 hideModal.call(that) 119 }) 120 } 121 122 function hideModal(that) { 123 this.$element 124 .hide() 125 .trigger('hidden') 126 127 backdrop.call(this) 128 } 129 130 function backdrop(callback) { 131 var that = this 132 , animate = this.$element.hasClass('fade') ? 'fade' : '' 133 134 if (this.isShown && this.options.backdrop) { 135 var doAnimate = $.support.transition && animate 136 137 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') 138 .appendTo(document.body) 139 140 if (this.options.backdrop != 'static') { 141 this.$backdrop.click($.proxy(this.hide, this)) 142 } 143 144 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 145 146 this.$backdrop.addClass('in') 147 148 doAnimate ? 149 this.$backdrop.one($.support.transition.end, callback) : 150 callback() 151 152 } else if (!this.isShown && this.$backdrop) { 153 this.$backdrop.removeClass('in') 154 155 $.support.transition && this.$element.hasClass('fade')? 156 this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) : 157 removeBackdrop.call(this) 158 159 } else if (callback) { 160 callback() 161 } 162 } 163 164 function removeBackdrop() { 165 this.$backdrop.remove() 166 this.$backdrop = null 167 } 168 169 function escape() { 170 var that = this 171 if (this.isShown && this.options.keyboard) { 172 $(document).on('keyup.dismiss.modal', function ( e ) {
173 e.which == 27 && that.hide() 174 }) 175 } else if (!this.isShown) { 176 $(document).off('keyup.dismiss.modal') 177 } 178 } 179 180 181 /* MODAL PLUGIN DEFINITION 182 * ======================= */ 183 184 $.fn.modal = function (option) { 185 return this.each(function () { 186 var $this = $(this) 187 , data = $this.data('modal') 188 , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) 189 if (!data) $this.data('modal', (data = new Modal(this, options))) 190 if (typeof option == 'string') data[option]() 191 else if (options.show) data.show() 192 }) 193 } 194 195 $.fn.modal.defaults = { 196 backdrop: true 197 , keyboard: true 198 , show: true 199 } 200 201 $.fn.modal.Constructor = Modal 202 203 204 /* MODAL DATA-API 205 * ============== */ 206 207 $(function () { 208 $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) { 209 var $this = $(this), href 210 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 211 , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data()) 212 213 e.preventDefault() 214 $target.modal(option) 215 }) 216 }) 217 218}(window.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.