summaryrefslogtreecommitdiff
path: root/bower_components/bootstrap/js/modal.js
diff options
context:
space:
mode:
authorThomas Park <thomas@thomaspark.me>2014-11-12 15:34:02 -0500
committerThomas Park <thomas@thomaspark.me>2014-11-12 15:34:02 -0500
commit4e5b5fd0ee3d3e1856f32d5956cb7c8cc1029254 (patch)
treed32fa80285b3e7e0dd516794ccf382a706be2569 /bower_components/bootstrap/js/modal.js
parentfa6487a9732f63b66399829fe3463a6192a26554 (diff)
update bootstrap to 3.3.1
Diffstat (limited to 'bower_components/bootstrap/js/modal.js')
-rw-r--r--bower_components/bootstrap/js/modal.js53
1 files changed, 48 insertions, 5 deletions
diff --git a/bower_components/bootstrap/js/modal.js b/bower_components/bootstrap/js/modal.js
index 8b0e269b..93891aa4 100644
--- a/bower_components/bootstrap/js/modal.js
+++ b/bower_components/bootstrap/js/modal.js
@@ -1,5 +1,5 @@
/* ========================================================================
- * Bootstrap: modal.js v3.3.0
+ * Bootstrap: modal.js v3.3.1
* http://getbootstrap.com/javascript/#modals
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
@@ -30,7 +30,7 @@
}
}
- Modal.VERSION = '3.3.0'
+ Modal.VERSION = '3.3.1'
Modal.TRANSITION_DURATION = 300
Modal.BACKDROP_TRANSITION_DURATION = 150
@@ -56,10 +56,11 @@
this.isShown = true
this.checkScrollbar()
+ this.setScrollbar()
this.$body.addClass('modal-open')
- this.setScrollbar()
this.escape()
+ this.resize()
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
@@ -74,6 +75,9 @@
.show()
.scrollTop(0)
+ if (that.options.backdrop) that.adjustBackdrop()
+ that.adjustDialog()
+
if (transition) {
that.$element[0].offsetWidth // force reflow
}
@@ -108,6 +112,7 @@
this.isShown = false
this.escape()
+ this.resize()
$(document).off('focusin.bs.modal')
@@ -143,11 +148,20 @@
}
}
+ Modal.prototype.resize = function () {
+ if (this.isShown) {
+ $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
+ } else {
+ $(window).off('resize.bs.modal')
+ }
+ }
+
Modal.prototype.hideModal = function () {
var that = this
this.$element.hide()
this.backdrop(function () {
that.$body.removeClass('modal-open')
+ that.resetAdjustments()
that.resetScrollbar()
that.$element.trigger('hidden.bs.modal')
})
@@ -204,13 +218,43 @@
}
}
+ // 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 () {
@@ -218,7 +262,6 @@
}
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)