From c2c19a4d2d45d8ccb5c84d293dea35a94148c9a4 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 23 Jun 2014 11:07:18 -0700 Subject: Revert UMD (#13772 & friends) for now, due to #13812. Will hopefully revert this reversion and land a fully-working version of UMD in v3.3.0. Revert "some changes from #13801 - add strict mode back and ==" This reverts commit 2b302f69eea416bc85e7827b7d7a74d49f879662. Revert "Fix regression of #10038 introduced by #13772" This reverts commit e9d6756a1ac76a9db31a41e8e03f663bedc41b70. Revert "MD/CommonJS/Globals #12909" This reverts commit 1c6fa9010daf0d0c21de9e20fe6ac4dba1788d90. Revert "address #13811" This reverts commit f347d7d955bbb17234b8e12c68efae7d516ce62c. Conflicts: js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/tab.js js/tooltip.js --- js/modal.js | 410 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 202 insertions(+), 208 deletions(-) (limited to 'js/modal.js') diff --git a/js/modal.js b/js/modal.js index 359e1fc67..edbb6c1c9 100644 --- a/js/modal.js +++ b/js/modal.js @@ -7,280 +7,274 @@ * ======================================================================== */ -+function () { 'use strict'; - - (function (o_o) { - typeof define == 'function' && define.amd ? define(['jquery'], o_o) : - typeof exports == 'object' ? o_o(require('jquery')) : o_o(jQuery) - })(function ($) { - - // MODAL CLASS DEFINITION - // ====================== - - var Modal = function (element, options) { - this.options = options - this.$body = $(document.body) - this.$element = $(element) - this.$backdrop = - this.isShown = null - this.scrollbarWidth = 0 - - if (this.options.remote) { - this.$element - .find('.modal-content') - .load(this.options.remote, $.proxy(function () { - this.$element.trigger('loaded.bs.modal') - }, this)) - } - } ++function ($) { + 'use strict'; - Modal.VERSION = '3.1.1' + // MODAL CLASS DEFINITION + // ====================== - Modal.DEFAULTS = { - backdrop: true, - keyboard: true, - show: true - } + var Modal = function (element, options) { + this.options = options + this.$body = $(document.body) + this.$element = $(element) + this.$backdrop = + this.isShown = null + this.scrollbarWidth = 0 - Modal.prototype.toggle = function (_relatedTarget) { - return this.isShown ? this.hide() : this.show(_relatedTarget) + if (this.options.remote) { + this.$element + .find('.modal-content') + .load(this.options.remote, $.proxy(function () { + this.$element.trigger('loaded.bs.modal') + }, this)) } + } - Modal.prototype.show = function (_relatedTarget) { - var that = this - var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) + Modal.VERSION = '3.1.1' - this.$element.trigger(e) + Modal.DEFAULTS = { + backdrop: true, + keyboard: true, + show: true + } - if (this.isShown || e.isDefaultPrevented()) return + Modal.prototype.toggle = function (_relatedTarget) { + return this.isShown ? this.hide() : this.show(_relatedTarget) + } - this.isShown = true + Modal.prototype.show = function (_relatedTarget) { + var that = this + var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) - this.checkScrollbar() - this.$body.addClass('modal-open') + this.$element.trigger(e) - this.setScrollbar() - this.escape() + if (this.isShown || e.isDefaultPrevented()) return - this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) + this.isShown = true - this.backdrop(function () { - var transition = $.support.transition && that.$element.hasClass('fade') + this.checkScrollbar() + this.$body.addClass('modal-open') - if (!that.$element.parent().length) { - that.$element.appendTo(that.$body) // don't move modals dom position - } + this.setScrollbar() + this.escape() - that.$element - .show() - .scrollTop(0) + this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) - if (transition) { - that.$element[0].offsetWidth // force reflow - } + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') - that.$element - .addClass('in') - .attr('aria-hidden', false) + if (!that.$element.parent().length) { + that.$element.appendTo(that.$body) // don't move modals dom position + } - that.enforceFocus() + that.$element + .show() + .scrollTop(0) - var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) + if (transition) { + that.$element[0].offsetWidth // force reflow + } - transition ? - that.$element.find('.modal-dialog') // wait for modal to slide in - .one('bsTransitionEnd', function () { - that.$element.trigger('focus').trigger(e) - }) - .emulateTransitionEnd(300) : - that.$element.trigger('focus').trigger(e) - }) - } + that.$element + .addClass('in') + .attr('aria-hidden', false) - Modal.prototype.hide = function (e) { - if (e) e.preventDefault() + that.enforceFocus() - e = $.Event('hide.bs.modal') + var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) - this.$element.trigger(e) + transition ? + that.$element.find('.modal-dialog') // wait for modal to slide in + .one('bsTransitionEnd', function () { + that.$element.trigger('focus').trigger(e) + }) + .emulateTransitionEnd(300) : + that.$element.trigger('focus').trigger(e) + }) + } - if (!this.isShown || e.isDefaultPrevented()) return + Modal.prototype.hide = function (e) { + if (e) e.preventDefault() - this.isShown = false + e = $.Event('hide.bs.modal') - this.$body.removeClass('modal-open') + this.$element.trigger(e) - this.resetScrollbar() - this.escape() + if (!this.isShown || e.isDefaultPrevented()) return - $(document).off('focusin.bs.modal') + this.isShown = false - this.$element - .removeClass('in') - .attr('aria-hidden', true) - .off('click.dismiss.bs.modal') + this.$body.removeClass('modal-open') - $.support.transition && this.$element.hasClass('fade') ? - this.$element - .one('bsTransitionEnd', $.proxy(this.hideModal, this)) - .emulateTransitionEnd(300) : - this.hideModal() - } + this.resetScrollbar() + this.escape() - Modal.prototype.enforceFocus = function () { - $(document) - .off('focusin.bs.modal') // guard against infinite focus loop - .on('focusin.bs.modal', $.proxy(function (e) { - if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { - this.$element.trigger('focus') - } - }, this)) - } + $(document).off('focusin.bs.modal') - Modal.prototype.escape = function () { - if (this.isShown && this.options.keyboard) { - this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { - e.which == 27 && this.hide() - }, this)) - } else if (!this.isShown) { - this.$element.off('keyup.dismiss.bs.modal') - } - } + this.$element + .removeClass('in') + .attr('aria-hidden', true) + .off('click.dismiss.bs.modal') - Modal.prototype.hideModal = function () { - var that = this - this.$element.hide() - this.backdrop(function () { - that.$element.trigger('hidden.bs.modal') - }) + $.support.transition && this.$element.hasClass('fade') ? + this.$element + .one('bsTransitionEnd', $.proxy(this.hideModal, this)) + .emulateTransitionEnd(300) : + this.hideModal() + } + + Modal.prototype.enforceFocus = function () { + $(document) + .off('focusin.bs.modal') // guard against infinite focus loop + .on('focusin.bs.modal', $.proxy(function (e) { + if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { + this.$element.trigger('focus') + } + }, this)) + } + + Modal.prototype.escape = function () { + if (this.isShown && this.options.keyboard) { + this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { + e.which == 27 && this.hide() + }, this)) + } else if (!this.isShown) { + this.$element.off('keyup.dismiss.bs.modal') } + } - Modal.prototype.removeBackdrop = function () { - this.$backdrop && this.$backdrop.remove() - this.$backdrop = null - } + Modal.prototype.hideModal = function () { + var that = this + this.$element.hide() + this.backdrop(function () { + that.$element.trigger('hidden.bs.modal') + }) + } - Modal.prototype.backdrop = function (callback) { - var that = this - var animate = this.$element.hasClass('fade') ? 'fade' : '' + Modal.prototype.removeBackdrop = function () { + this.$backdrop && this.$backdrop.remove() + this.$backdrop = null + } - if (this.isShown && this.options.backdrop) { - var doAnimate = $.support.transition && animate + Modal.prototype.backdrop = function (callback) { + var that = this + var animate = this.$element.hasClass('fade') ? 'fade' : '' - this.$backdrop = $('