mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Merged in modal-scroll (pull request #49)
Upgraded modal.js bootstrap plugin. Fixes issue #147
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: modal.js v3.3.2
|
* Bootstrap: modal.js v3.3.5
|
||||||
* http://getbootstrap.com/javascript/#modals
|
* http://getbootstrap.com/javascript/#modals
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2015 Twitter, Inc.
|
||||||
@@ -14,12 +14,15 @@
|
|||||||
// ======================
|
// ======================
|
||||||
|
|
||||||
var Modal = function (element, options) {
|
var Modal = function (element, options) {
|
||||||
this.options = options
|
this.options = options
|
||||||
this.$body = $(document.body)
|
this.$body = $(document.body)
|
||||||
this.$element = $(element)
|
this.$element = $(element)
|
||||||
this.$backdrop =
|
this.$dialog = this.$element.find('.modal-dialog')
|
||||||
this.isShown = null
|
this.$backdrop = null
|
||||||
this.scrollbarWidth = 0
|
this.isShown = null
|
||||||
|
this.originalBodyPad = null
|
||||||
|
this.scrollbarWidth = 0
|
||||||
|
this.ignoreBackdropClick = false
|
||||||
|
|
||||||
if (this.options.remote) {
|
if (this.options.remote) {
|
||||||
this.$element
|
this.$element
|
||||||
@@ -30,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.VERSION = '3.3.2'
|
Modal.VERSION = '3.3.5'
|
||||||
|
|
||||||
Modal.TRANSITION_DURATION = 300
|
Modal.TRANSITION_DURATION = 300
|
||||||
Modal.BACKDROP_TRANSITION_DURATION = 150
|
Modal.BACKDROP_TRANSITION_DURATION = 150
|
||||||
@@ -64,6 +67,12 @@
|
|||||||
|
|
||||||
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
||||||
|
|
||||||
|
this.$dialog.on('mousedown.dismiss.bs.modal', function () {
|
||||||
|
that.$element.one('mouseup.dismiss.bs.modal', function (e) {
|
||||||
|
if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
this.backdrop(function () {
|
this.backdrop(function () {
|
||||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
var transition = $.support.transition && that.$element.hasClass('fade')
|
||||||
|
|
||||||
@@ -75,23 +84,20 @@
|
|||||||
.show()
|
.show()
|
||||||
.scrollTop(0)
|
.scrollTop(0)
|
||||||
|
|
||||||
if (that.options.backdrop) that.adjustBackdrop()
|
|
||||||
that.adjustDialog()
|
that.adjustDialog()
|
||||||
|
|
||||||
if (transition) {
|
if (transition) {
|
||||||
that.$element[0].offsetWidth // force reflow
|
that.$element[0].offsetWidth // force reflow
|
||||||
}
|
}
|
||||||
|
|
||||||
that.$element
|
that.$element.addClass('in')
|
||||||
.addClass('in')
|
|
||||||
.attr('aria-hidden', false)
|
|
||||||
|
|
||||||
that.enforceFocus()
|
that.enforceFocus()
|
||||||
|
|
||||||
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
||||||
|
|
||||||
transition ?
|
transition ?
|
||||||
that.$element.find('.modal-dialog') // wait for modal to slide in
|
that.$dialog // wait for modal to slide in
|
||||||
.one('bsTransitionEnd', function () {
|
.one('bsTransitionEnd', function () {
|
||||||
that.$element.trigger('focus').trigger(e)
|
that.$element.trigger('focus').trigger(e)
|
||||||
})
|
})
|
||||||
@@ -118,8 +124,10 @@
|
|||||||
|
|
||||||
this.$element
|
this.$element
|
||||||
.removeClass('in')
|
.removeClass('in')
|
||||||
.attr('aria-hidden', true)
|
|
||||||
.off('click.dismiss.bs.modal')
|
.off('click.dismiss.bs.modal')
|
||||||
|
.off('mouseup.dismiss.bs.modal')
|
||||||
|
|
||||||
|
this.$dialog.off('mousedown.dismiss.bs.modal')
|
||||||
|
|
||||||
$.support.transition && this.$element.hasClass('fade') ?
|
$.support.transition && this.$element.hasClass('fade') ?
|
||||||
this.$element
|
this.$element
|
||||||
@@ -179,14 +187,20 @@
|
|||||||
if (this.isShown && this.options.backdrop) {
|
if (this.isShown && this.options.backdrop) {
|
||||||
var doAnimate = $.support.transition && animate
|
var doAnimate = $.support.transition && animate
|
||||||
|
|
||||||
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
this.$backdrop = $(document.createElement('div'))
|
||||||
.prependTo(this.$element)
|
.addClass('modal-backdrop ' + animate)
|
||||||
.on('click.dismiss.bs.modal', $.proxy(function (e) {
|
.appendTo(this.$body)
|
||||||
if (e.target !== e.currentTarget) return
|
|
||||||
this.options.backdrop == 'static'
|
this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
|
||||||
? this.$element[0].focus.call(this.$element[0])
|
if (this.ignoreBackdropClick) {
|
||||||
: this.hide.call(this)
|
this.ignoreBackdropClick = false
|
||||||
}, this))
|
return
|
||||||
|
}
|
||||||
|
if (e.target !== e.currentTarget) return
|
||||||
|
this.options.backdrop == 'static'
|
||||||
|
? this.$element[0].focus()
|
||||||
|
: this.hide()
|
||||||
|
}, this))
|
||||||
|
|
||||||
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
||||||
|
|
||||||
@@ -221,16 +235,9 @@
|
|||||||
// these following methods are used to handle overflowing modals
|
// these following methods are used to handle overflowing modals
|
||||||
|
|
||||||
Modal.prototype.handleUpdate = function () {
|
Modal.prototype.handleUpdate = function () {
|
||||||
if (this.options.backdrop) this.adjustBackdrop()
|
|
||||||
this.adjustDialog()
|
this.adjustDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.adjustBackdrop = function () {
|
|
||||||
this.$backdrop
|
|
||||||
.css('height', 0)
|
|
||||||
.css('height', this.$element[0].scrollHeight)
|
|
||||||
}
|
|
||||||
|
|
||||||
Modal.prototype.adjustDialog = function () {
|
Modal.prototype.adjustDialog = function () {
|
||||||
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
|
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
|
||||||
|
|
||||||
@@ -248,17 +255,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.checkScrollbar = function () {
|
Modal.prototype.checkScrollbar = function () {
|
||||||
this.bodyIsOverflowing = document.body.scrollHeight > document.documentElement.clientHeight
|
var fullWindowWidth = window.innerWidth
|
||||||
|
if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
|
||||||
|
var documentElementRect = document.documentElement.getBoundingClientRect()
|
||||||
|
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
|
||||||
|
}
|
||||||
|
this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
|
||||||
this.scrollbarWidth = this.measureScrollbar()
|
this.scrollbarWidth = this.measureScrollbar()
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.setScrollbar = function () {
|
Modal.prototype.setScrollbar = function () {
|
||||||
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
||||||
|
this.originalBodyPad = document.body.style.paddingRight || ''
|
||||||
if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
|
if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.resetScrollbar = function () {
|
Modal.prototype.resetScrollbar = function () {
|
||||||
this.$body.css('padding-right', '')
|
this.$body.css('padding-right', this.originalBodyPad)
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.measureScrollbar = function () { // thx walsh
|
Modal.prototype.measureScrollbar = function () { // thx walsh
|
||||||
|
|||||||
Reference in New Issue
Block a user