1/* ========================================================= 2 * bootstrap-modal.js v2.2.1 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 (element, options) { 30 this.options = options 31 this.$element = $(element) 32 .delegate('[data-dismiss="modal"]', 'click.dismiss.wl-modal', $.proxy(this.hide, this)) 33 this.options.remote && this.$element.find('.wl-modal-body').load(this.options.remote) 34 } 35 36 Modal.prototype = { 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()) 50 return 51 52 this.isShown = true 53 54 this.escape() 55 56 this.backdrop(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 71 .addClass('in') 72 .attr('aria-hidden', false) 73 74 that.enforceFocus() 75 76 transition ? 77 that.$element.one($.support.transition.end, function () { 78 that.$element.focus().trigger('shown') 79 }) : 80 that.$element.focus().trigger('shown') 81 82 }) 83 } 84 85 , hide: function (e) { 86 e && e.preventDefault() 87 88 var that = this 89 90 e = $.Event('hide') 91 92 this.$element.trigger(e) 93 94 if (!this.isShown || e.isDefaultPrevented()) 95 return 96 97 this.isShown = false 98 99 this.escape() 100 101 $(document).off('focusin.wl-modal') 102 103 this.$element 104 .removeClass('in') 105 .attr('aria-hidden', true) 106 107 $.support.transition && this.$element.hasClass('fade') ? 108 this.hideWithTransition() : 109 this.hideModal() 110 } 111 112 , enforceFocus: function () { 113 var that = this 114 $(document).on('focusin.wl-modal', function (e) { 115 if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { 116 that.$element.focus() 117 } 118 }) 119 } 120 121 , escape: function () { 122 var that = this 123 if (this.isShown && this.options.keyboard) { 124 this.$element.on('keyup.dismiss.wl-modal', function (e) { 125 e.which == 27 && that.hide() 126 }) 127 } else if (!this.isShown) { 128 this.$element.off('keyup.dismiss.wl-modal') 129 } 130 } 131 132 , hideWithTransition: function () { 133 var that = this 134 , timeout = setTimeout(function () { 135 that.$element.off($.support.transition.end) 136 that.hideModal() 137 }, 500) 138 139 this.$element.one($.support.transition.end, function () { 140 clearTimeout(timeout) 141 that.hideModal() 142 }) 143 } 144 145 , hideModal: function (that) { 146 this.$element 147 .hide() 148 .trigger('hidden') 149 150 this.backdrop() 151 } 152 153 , removeBackdrop: function () { 154 this.$backdrop.remove() 155 this.$backdrop = null 156 } 157 158 , backdrop: function (callback) { 159 var that = this 160 , animate = this.$element.hasClass('fade') ? 'fade' : '' 161 162 if (this.isShown && this.options.backdrop) { 163 var doAnimate = $.support.transition && animate 164 165 this.$backdrop = $('<div class="wl-modal-backdrop ' + animate + '" />') 166 .appendTo(document.body) 167 168 this.$backdrop.click( 169 this.options.backdrop == 'static' ? 170 $.proxy(this.$element[0].focus, this.$element[0]) 171 : $.proxy(this.hide, this) 172 ) 173 174 if (doAnimate) 175 this.$backdrop[0].offsetWidth // force reflow 176 177 this.$backdrop.addClass('in') 178 179 doAnimate ? 180 this.$backdrop.one($.support.transition.end, callback) : 181 callback() 182 183 } else if (!this.isShown && this.$backdrop) { 184 this.$backdrop.removeClass('in') 185 186 $.support.transition && this.$element.hasClass('fade') ? 187 this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) : 188 this.removeBackdrop() 189 190 } else if (callback) { 191 callback() 192 } 193 } 194 } 195 196 197 /* MODAL PLUGIN DEFINITION 198 * ======================= */ 199 200 $.fn.modal = function (option) { 201 return this.each(function () { 202 var $this = $(this) 203 , data = $this.data('modal') 204 , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) 205 if (!data) 206 $this.data('modal', (data = new Modal(this, options))) 207 if (typeof option == 'string') 208 data[option]() 209 else if (options.show) 210 data.show() 211 }) 212 } 213 214 $.fn.modal.defaults = { 215 backdrop: true 216 , keyboard: true 217 , show: true 218 } 219 220 $.fn.modal.Constructor = Modal 221 222 223 /* MODAL DATA-API 224 * ============== */ 225 $(document).ready(function () { 226 227 228 $('.wl-email-button').click(function (e) { 229 var $this = $(this) 230 , href = $this.attr('href') 231 , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 232 , 233 option = $target.data('modal') ? 'toggle' : $.extend({remote: !/#/.test(href) && href}, $target.data(), $this.data()) 234 235 e.preventDefault() 236 237 $target 238 .modal(option) 239 .one('hide', function () { 240 $this.focus() 241 }) 242 }); 243 }); 244 245 246}(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.