diff options
| author | Heinrich Fenkart <[email protected]> | 2014-11-05 01:45:16 +0100 |
|---|---|---|
| committer | Heinrich Fenkart <[email protected]> | 2014-11-05 01:45:16 +0100 |
| commit | db90ff6df7a1a3e3cc914a3edc0dad0518462f0d (patch) | |
| tree | f6add56a876ee0409192511f4d808c9f9ab65e5a /docs/dist/js/bootstrap.js | |
| parent | 72ad89b0777278044bd852c3ac4520b42d5504bb (diff) | |
| download | bootstrap-db90ff6df7a1a3e3cc914a3edc0dad0518462f0d.tar.xz bootstrap-db90ff6df7a1a3e3cc914a3edc0dad0518462f0d.zip | |
grunt
Diffstat (limited to 'docs/dist/js/bootstrap.js')
| -rw-r--r-- | docs/dist/js/bootstrap.js | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/docs/dist/js/bootstrap.js b/docs/dist/js/bootstrap.js index b66a59f99..4333b76af 100644 --- a/docs/dist/js/bootstrap.js +++ b/docs/dist/js/bootstrap.js @@ -959,11 +959,11 @@ if (typeof jQuery === 'undefined') { this.isShown = true this.checkScrollbar() + this.setScrollbar() this.$body.addClass('modal-open') - this.setScrollbar() this.escape() - if (this.options.backdrop) this.resize() + this.resize() this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) @@ -978,7 +978,8 @@ if (typeof jQuery === 'undefined') { .show() .scrollTop(0) - if (that.options.backdrop) that.setBackdropHeight() + if (that.options.backdrop) that.adjustBackdrop() + that.adjustDialog() if (transition) { that.$element[0].offsetWidth // force reflow @@ -1014,7 +1015,7 @@ if (typeof jQuery === 'undefined') { this.isShown = false this.escape() - if (this.options.backdrop) this.resize() + this.resize() $(document).off('focusin.bs.modal') @@ -1052,7 +1053,7 @@ if (typeof jQuery === 'undefined') { Modal.prototype.resize = function () { if (this.isShown) { - $(window).on('resize.bs.modal', $.proxy(this.setBackdropHeight, this)) + $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) } else { $(window).off('resize.bs.modal') } @@ -1063,6 +1064,7 @@ if (typeof jQuery === 'undefined') { this.$element.hide() this.backdrop(function () { that.$body.removeClass('modal-open') + that.resetAdjustments() that.resetScrollbar() that.$element.trigger('hidden.bs.modal') }) @@ -1119,19 +1121,43 @@ if (typeof jQuery === 'undefined') { } } - Modal.prototype.setBackdropHeight = function () { + // these following methods are used to handle overflowing modals + + Modal.prototype.handleUpdate = function () { + if (this.options.backdrop) this.adjustBackdrop() + this.adjustDialog() + } + + Modal.prototype.adjustBackdrop = function () { this.$backdrop .css('height', 0) .css('height', this.$element[0].scrollHeight) } + Modal.prototype.adjustDialog = function () { + var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight + + this.$element.css({ + paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', + paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' + }) + } + + Modal.prototype.resetAdjustments = function () { + this.$element.css({ + paddingLeft: '', + paddingRight: '' + }) + } + Modal.prototype.checkScrollbar = function () { + this.bodyIsOverflowing = document.body.scrollHeight > document.documentElement.clientHeight this.scrollbarWidth = this.measureScrollbar() } Modal.prototype.setScrollbar = function () { var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) - if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) + if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) } Modal.prototype.resetScrollbar = function () { @@ -1139,7 +1165,6 @@ if (typeof jQuery === 'undefined') { } Modal.prototype.measureScrollbar = function () { // thx walsh - if (document.body.clientWidth >= window.innerWidth) return 0 var scrollDiv = document.createElement('div') scrollDiv.className = 'modal-scrollbar-measure' this.$body.append(scrollDiv) |
