indvd00m@0: /* ========================================================= indvd00m@0: * bootstrap-modal.js v2.3.1 indvd00m@0: * http://twitter.github.com/bootstrap/javascript.html#modals indvd00m@0: * ========================================================= indvd00m@0: * Copyright 2012 Twitter, Inc. indvd00m@0: * indvd00m@0: * Licensed under the Apache License, Version 2.0 (the "License"); indvd00m@0: * you may not use this file except in compliance with the License. indvd00m@0: * You may obtain a copy of the License at indvd00m@0: * indvd00m@0: * http://www.apache.org/licenses/LICENSE-2.0 indvd00m@0: * indvd00m@0: * Unless required by applicable law or agreed to in writing, software indvd00m@0: * distributed under the License is distributed on an "AS IS" BASIS, indvd00m@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. indvd00m@0: * See the License for the specific language governing permissions and indvd00m@0: * limitations under the License. indvd00m@0: * ========================================================= */ indvd00m@0: indvd00m@0: indvd00m@0: !function ($) { indvd00m@0: indvd00m@0: "use strict"; // jshint ;_; indvd00m@0: indvd00m@0: indvd00m@0: /* MODAL CLASS DEFINITION indvd00m@0: * ====================== */ indvd00m@0: indvd00m@0: var Modal = function (element, options) { indvd00m@0: this.options = options indvd00m@0: this.$element = $(element) indvd00m@0: .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) indvd00m@0: this.options.remote && this.$element.find('.modal-body').load(this.options.remote) indvd00m@0: } indvd00m@0: indvd00m@0: Modal.prototype = { indvd00m@0: indvd00m@0: constructor: Modal indvd00m@0: indvd00m@0: , toggle: function () { indvd00m@0: return this[!this.isShown ? 'show' : 'hide']() indvd00m@0: } indvd00m@0: indvd00m@0: , show: function () { indvd00m@0: var that = this indvd00m@0: , e = $.Event('show') indvd00m@0: indvd00m@0: this.$element.trigger(e) indvd00m@0: indvd00m@0: if (this.isShown || e.isDefaultPrevented()) return indvd00m@0: indvd00m@0: this.isShown = true indvd00m@0: indvd00m@0: this.escape() indvd00m@0: indvd00m@0: this.backdrop(function () { indvd00m@0: var transition = $.support.transition && that.$element.hasClass('fade') indvd00m@0: indvd00m@0: if (!that.$element.parent().length) { indvd00m@0: that.$element.appendTo(document.body) //don't move modals dom position indvd00m@0: } indvd00m@0: indvd00m@0: that.$element.show() indvd00m@0: indvd00m@0: if (transition) { indvd00m@0: that.$element[0].offsetWidth // force reflow indvd00m@0: } indvd00m@0: indvd00m@0: that.$element indvd00m@0: .addClass('in') indvd00m@0: .attr('aria-hidden', false) indvd00m@0: indvd00m@0: that.enforceFocus() indvd00m@0: indvd00m@0: transition ? indvd00m@0: that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : indvd00m@0: that.$element.focus().trigger('shown') indvd00m@0: indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: , hide: function (e) { indvd00m@0: e && e.preventDefault() indvd00m@0: indvd00m@0: var that = this indvd00m@0: indvd00m@0: e = $.Event('hide') indvd00m@0: indvd00m@0: this.$element.trigger(e) indvd00m@0: indvd00m@0: if (!this.isShown || e.isDefaultPrevented()) return indvd00m@0: indvd00m@0: this.isShown = false indvd00m@0: indvd00m@0: this.escape() indvd00m@0: indvd00m@0: $(document).off('focusin.modal') indvd00m@0: indvd00m@0: this.$element indvd00m@0: .removeClass('in') indvd00m@0: .attr('aria-hidden', true) indvd00m@0: indvd00m@0: $.support.transition && this.$element.hasClass('fade') ? indvd00m@0: this.hideWithTransition() : indvd00m@0: this.hideModal() indvd00m@0: } indvd00m@0: indvd00m@0: , enforceFocus: function () { indvd00m@0: var that = this indvd00m@0: $(document).on('focusin.modal', function (e) { indvd00m@0: if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { indvd00m@0: that.$element.focus() indvd00m@0: } indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: , escape: function () { indvd00m@0: var that = this indvd00m@0: if (this.isShown && this.options.keyboard) { indvd00m@0: this.$element.on('keyup.dismiss.modal', function ( e ) { indvd00m@0: e.which == 27 && that.hide() indvd00m@0: }) indvd00m@0: } else if (!this.isShown) { indvd00m@0: this.$element.off('keyup.dismiss.modal') indvd00m@0: } indvd00m@0: } indvd00m@0: indvd00m@0: , hideWithTransition: function () { indvd00m@0: var that = this indvd00m@0: , timeout = setTimeout(function () { indvd00m@0: that.$element.off($.support.transition.end) indvd00m@0: that.hideModal() indvd00m@0: }, 500) indvd00m@0: indvd00m@0: this.$element.one($.support.transition.end, function () { indvd00m@0: clearTimeout(timeout) indvd00m@0: that.hideModal() indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: , hideModal: function () { indvd00m@0: var that = this indvd00m@0: this.$element.hide() indvd00m@0: this.backdrop(function () { indvd00m@0: that.removeBackdrop() indvd00m@0: that.$element.trigger('hidden') indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: , removeBackdrop: function () { indvd00m@0: this.$backdrop && this.$backdrop.remove() indvd00m@0: this.$backdrop = null indvd00m@0: } indvd00m@0: indvd00m@0: , backdrop: function (callback) { indvd00m@0: var that = this indvd00m@0: , animate = this.$element.hasClass('fade') ? 'fade' : '' indvd00m@0: indvd00m@0: if (this.isShown && this.options.backdrop) { indvd00m@0: var doAnimate = $.support.transition && animate indvd00m@0: indvd00m@0: this.$backdrop = $('