info@54: /* ======================================================================== info@54: * Bootstrap: modal.js v3.0.3 info@54: * http://getbootstrap.com/javascript/#modals info@54: * ======================================================================== info@54: * Copyright 2013 Twitter, Inc. info@54: * info@54: * Licensed under the Apache License, Version 2.0 (the "License"); info@54: * you may not use this file except in compliance with the License. info@54: * You may obtain a copy of the License at info@54: * info@54: * http://www.apache.org/licenses/LICENSE-2.0 info@54: * info@54: * Unless required by applicable law or agreed to in writing, software info@54: * distributed under the License is distributed on an "AS IS" BASIS, info@54: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. info@54: * See the License for the specific language governing permissions and info@54: * limitations under the License. info@54: * ======================================================================== */ info@54: info@54: info@54: +function ($) { "use strict"; info@54: info@54: // MODAL CLASS DEFINITION info@54: // ====================== info@54: info@54: var Modal = function (element, options) { info@54: this.options = options info@54: this.$element = $(element) info@54: this.$backdrop = info@54: this.isShown = null info@54: info@54: if (this.options.remote) this.$element.load(this.options.remote) info@54: } info@54: info@54: Modal.DEFAULTS = { info@54: backdrop: true info@54: , keyboard: true info@54: , show: true info@54: } info@54: info@54: Modal.prototype.toggle = function (_relatedTarget) { info@54: return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) info@54: } info@54: info@54: Modal.prototype.show = function (_relatedTarget) { info@54: var that = this info@54: var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) info@54: info@54: this.$element.trigger(e) info@54: info@54: if (this.isShown || e.isDefaultPrevented()) return info@54: info@54: this.isShown = true info@54: info@54: this.escape() info@54: info@54: this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) info@54: info@54: this.backdrop(function () { info@54: var transition = $.support.transition && that.$element.hasClass('fade') info@54: info@54: if (!that.$element.parent().length) { info@54: that.$element.appendTo(document.body) // don't move modals dom position info@54: } info@54: info@54: that.$element.show() info@54: info@54: if (transition) { info@54: that.$element[0].offsetWidth // force reflow info@54: } info@54: info@54: that.$element info@54: .addClass('in') info@54: .attr('aria-hidden', false) info@54: info@54: that.enforceFocus() info@54: info@54: var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) info@54: info@54: transition ? info@54: that.$element.find('.modal-dialog') // wait for modal to slide in info@54: .one($.support.transition.end, function () { info@54: that.$element.focus().trigger(e) info@54: }) info@54: .emulateTransitionEnd(300) : info@54: that.$element.focus().trigger(e) info@54: }) info@54: } info@54: info@54: Modal.prototype.hide = function (e) { info@54: if (e) e.preventDefault() info@54: info@54: e = $.Event('hide.bs.modal') info@54: info@54: this.$element.trigger(e) info@54: info@54: if (!this.isShown || e.isDefaultPrevented()) return info@54: info@54: this.isShown = false info@54: info@54: this.escape() info@54: info@54: $(document).off('focusin.bs.modal') info@54: info@54: this.$element info@54: .removeClass('in') info@54: .attr('aria-hidden', true) info@54: .off('click.dismiss.modal') info@54: info@54: $.support.transition && this.$element.hasClass('fade') ? info@54: this.$element info@54: .one($.support.transition.end, $.proxy(this.hideModal, this)) info@54: .emulateTransitionEnd(300) : info@54: this.hideModal() info@54: } info@54: info@54: Modal.prototype.enforceFocus = function () { info@54: $(document) info@54: .off('focusin.bs.modal') // guard against infinite focus loop info@54: .on('focusin.bs.modal', $.proxy(function (e) { info@54: if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { info@54: this.$element.focus() info@54: } info@54: }, this)) info@54: } info@54: info@54: Modal.prototype.escape = function () { info@54: if (this.isShown && this.options.keyboard) { info@54: this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { info@54: e.which == 27 && this.hide() info@54: }, this)) info@54: } else if (!this.isShown) { info@54: this.$element.off('keyup.dismiss.bs.modal') info@54: } info@54: } info@54: info@54: Modal.prototype.hideModal = function () { info@54: var that = this info@54: this.$element.hide() info@54: this.backdrop(function () { info@54: that.removeBackdrop() info@54: that.$element.trigger('hidden.bs.modal') info@54: }) info@54: } info@54: info@54: Modal.prototype.removeBackdrop = function () { info@54: this.$backdrop && this.$backdrop.remove() info@54: this.$backdrop = null info@54: } info@54: info@54: Modal.prototype.backdrop = function (callback) { info@54: var that = this info@54: var animate = this.$element.hasClass('fade') ? 'fade' : '' info@54: info@54: if (this.isShown && this.options.backdrop) { info@54: var doAnimate = $.support.transition && animate info@54: info@54: this.$backdrop = $('
') info@54: .appendTo(document.body) info@54: info@54: this.$element.on('click.dismiss.modal', $.proxy(function (e) { info@54: if (e.target !== e.currentTarget) return info@54: this.options.backdrop == 'static' info@54: ? this.$element[0].focus.call(this.$element[0]) info@54: : this.hide.call(this) info@54: }, this)) info@54: info@54: if (doAnimate) this.$backdrop[0].offsetWidth // force reflow info@54: info@54: this.$backdrop.addClass('in') info@54: info@54: if (!callback) return info@54: info@54: doAnimate ? info@54: this.$backdrop info@54: .one($.support.transition.end, callback) info@54: .emulateTransitionEnd(150) : info@54: callback() info@54: info@54: } else if (!this.isShown && this.$backdrop) { info@54: this.$backdrop.removeClass('in') info@54: info@54: $.support.transition && this.$element.hasClass('fade')? info@54: this.$backdrop info@54: .one($.support.transition.end, callback) info@54: .emulateTransitionEnd(150) : info@54: callback() info@54: info@54: } else if (callback) { info@54: callback() info@54: } info@54: } info@54: info@54: info@54: // MODAL PLUGIN DEFINITION info@54: // ======================= info@54: info@54: var old = $.fn.modal info@54: info@54: $.fn.modal = function (option, _relatedTarget) { info@54: return this.each(function () { info@54: var $this = $(this) info@54: var data = $this.data('bs.modal') info@54: var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) info@54: info@54: if (!data) $this.data('bs.modal', (data = new Modal(this, options))) info@54: if (typeof option == 'string') data[option](_relatedTarget) info@54: else if (options.show) data.show(_relatedTarget) info@54: }) info@54: } info@54: info@54: $.fn.modal.Constructor = Modal info@54: info@54: info@54: // MODAL NO CONFLICT info@54: // ================= info@54: info@54: $.fn.modal.noConflict = function () { info@54: $.fn.modal = old info@54: return this info@54: } info@54: info@54: info@54: // MODAL DATA-API info@54: // ============== info@54: info@54: $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { info@54: var $this = $(this) info@54: var href = $this.attr('href') info@54: var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 info@54: var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) info@54: info@54: e.preventDefault() info@54: info@54: $target info@54: .modal(option, this) info@54: .one('hide', function () { info@54: $this.is(':visible') && $this.focus() info@54: }) info@54: }) info@54: info@54: $(document) info@54: .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) info@54: .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') }) info@54: info@54: }(jQuery);