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 = $('