mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 04:48:29 +08:00
DEV: upgrades bootstrap-modal (#7235)
This commit is contained in:
parent
da578e92f2
commit
c18a6069c2
|
@ -19,6 +19,9 @@ task 'javascript:update' do
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{
|
{
|
||||||
|
source: 'bootstrap/js/modal.js',
|
||||||
|
destination: 'bootstrap-modal.js'
|
||||||
|
}, {
|
||||||
source: 'ace-builds/src-min-noconflict/.',
|
source: 'ace-builds/src-min-noconflict/.',
|
||||||
destination: 'ace',
|
destination: 'ace',
|
||||||
public: true
|
public: true
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"ace-builds": "1.4.2",
|
"ace-builds": "1.4.2",
|
||||||
"bootbox": "3.2.0",
|
"bootbox": "3.2.0",
|
||||||
"chart.js": "2.7.3",
|
"chart.js": "2.7.3",
|
||||||
|
"bootstrap": "v3.4.1",
|
||||||
"favcount": "https://github.com/chrishunt/favcount",
|
"favcount": "https://github.com/chrishunt/favcount",
|
||||||
"handlebars": "4.0.12",
|
"handlebars": "4.0.12",
|
||||||
"highlight.js": "https://github.com/highlightjs/highlight.js",
|
"highlight.js": "https://github.com/highlightjs/highlight.js",
|
||||||
|
|
68
vendor/assets/javascripts/bootstrap-modal.js
vendored
68
vendor/assets/javascripts/bootstrap-modal.js
vendored
|
@ -1,8 +1,8 @@
|
||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: modal.js v3.3.4
|
* Bootstrap: modal.js v3.4.1
|
||||||
* http://getbootstrap.com/javascript/#modals
|
* https://getbootstrap.com/docs/3.4/javascript/#modals
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2011-2015 Twitter, Inc.
|
* Copyright 2011-2019 Twitter, Inc.
|
||||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||||
* ======================================================================== */
|
* ======================================================================== */
|
||||||
|
|
||||||
|
@ -14,15 +14,16 @@
|
||||||
// ======================
|
// ======================
|
||||||
|
|
||||||
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.$dialog = this.$element.find('.modal-dialog')
|
this.$dialog = this.$element.find('.modal-dialog')
|
||||||
this.$backdrop = null
|
this.$backdrop = null
|
||||||
this.isShown = null
|
this.isShown = null
|
||||||
this.originalBodyPad = null
|
this.originalBodyPad = null
|
||||||
this.scrollbarWidth = 0
|
this.scrollbarWidth = 0
|
||||||
this.ignoreBackdropClick = false
|
this.ignoreBackdropClick = false
|
||||||
|
this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'
|
||||||
|
|
||||||
if (this.options.remote) {
|
if (this.options.remote) {
|
||||||
this.$element
|
this.$element
|
||||||
|
@ -33,7 +34,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.VERSION = '3.3.4'
|
Modal.VERSION = '3.4.1'
|
||||||
|
|
||||||
Modal.TRANSITION_DURATION = 300
|
Modal.TRANSITION_DURATION = 300
|
||||||
Modal.BACKDROP_TRANSITION_DURATION = 150
|
Modal.BACKDROP_TRANSITION_DURATION = 150
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
|
|
||||||
Modal.prototype.show = function (_relatedTarget) {
|
Modal.prototype.show = function (_relatedTarget) {
|
||||||
var that = this
|
var that = this
|
||||||
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
||||||
|
|
||||||
this.$element.trigger(e)
|
this.$element.trigger(e)
|
||||||
|
|
||||||
|
@ -140,7 +141,9 @@
|
||||||
$(document)
|
$(document)
|
||||||
.off('focusin.bs.modal') // guard against infinite focus loop
|
.off('focusin.bs.modal') // guard against infinite focus loop
|
||||||
.on('focusin.bs.modal', $.proxy(function (e) {
|
.on('focusin.bs.modal', $.proxy(function (e) {
|
||||||
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
|
if (document !== e.target &&
|
||||||
|
this.$element[0] !== e.target &&
|
||||||
|
!this.$element.has(e.target).length) {
|
||||||
this.$element.trigger('focus')
|
this.$element.trigger('focus')
|
||||||
}
|
}
|
||||||
}, this))
|
}, this))
|
||||||
|
@ -242,7 +245,7 @@
|
||||||
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
|
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
|
||||||
|
|
||||||
this.$element.css({
|
this.$element.css({
|
||||||
paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
|
paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
|
||||||
paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
|
paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -267,11 +270,26 @@
|
||||||
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 || ''
|
this.originalBodyPad = document.body.style.paddingRight || ''
|
||||||
if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
|
var scrollbarWidth = this.scrollbarWidth
|
||||||
|
if (this.bodyIsOverflowing) {
|
||||||
|
this.$body.css('padding-right', bodyPad + scrollbarWidth)
|
||||||
|
$(this.fixedContent).each(function (index, element) {
|
||||||
|
var actualPadding = element.style.paddingRight
|
||||||
|
var calculatedPadding = $(element).css('padding-right')
|
||||||
|
$(element)
|
||||||
|
.data('padding-right', actualPadding)
|
||||||
|
.css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.resetScrollbar = function () {
|
Modal.prototype.resetScrollbar = function () {
|
||||||
this.$body.css('padding-right', this.originalBodyPad)
|
this.$body.css('padding-right', this.originalBodyPad)
|
||||||
|
$(this.fixedContent).each(function (index, element) {
|
||||||
|
var padding = $(element).data('padding-right')
|
||||||
|
$(element).removeData('padding-right')
|
||||||
|
element.style.paddingRight = padding ? padding : ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.measureScrollbar = function () { // thx walsh
|
Modal.prototype.measureScrollbar = function () { // thx walsh
|
||||||
|
@ -289,12 +307,11 @@
|
||||||
|
|
||||||
function Plugin(option, _relatedTarget) {
|
function Plugin(option, _relatedTarget) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
var data = $this.data('bs.modal')
|
var data = $this.data('bs.modal')
|
||||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||||
|
|
||||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
||||||
|
|
||||||
if (typeof option == 'string') data[option](_relatedTarget)
|
if (typeof option == 'string') data[option](_relatedTarget)
|
||||||
else if (options.show) data.show(_relatedTarget)
|
else if (options.show) data.show(_relatedTarget)
|
||||||
})
|
})
|
||||||
|
@ -302,7 +319,7 @@
|
||||||
|
|
||||||
var old = $.fn.modal
|
var old = $.fn.modal
|
||||||
|
|
||||||
$.fn.modal = Plugin
|
$.fn.modal = Plugin
|
||||||
$.fn.modal.Constructor = Modal
|
$.fn.modal.Constructor = Modal
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,10 +336,13 @@
|
||||||
// ==============
|
// ==============
|
||||||
|
|
||||||
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
|
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
var href = $this.attr('href')
|
var href = $this.attr('href')
|
||||||
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
|
var target = $this.attr('data-target') ||
|
||||||
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
|
(href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
|
||||||
|
|
||||||
|
var $target = $(document).find(target)
|
||||||
|
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
|
||||||
|
|
||||||
if ($this.is('a')) e.preventDefault()
|
if ($this.is('a')) e.preventDefault()
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,11 @@ bootbox@3.2.0:
|
||||||
resolved "https://registry.yarnpkg.com/bootbox/-/bootbox-3.2.0.tgz#00bf643fc9edefd9ae1e7c648c6b022db4be0aee"
|
resolved "https://registry.yarnpkg.com/bootbox/-/bootbox-3.2.0.tgz#00bf643fc9edefd9ae1e7c648c6b022db4be0aee"
|
||||||
integrity sha1-AL9kP8nt79muHnxkjGsCLbS+Cu4=
|
integrity sha1-AL9kP8nt79muHnxkjGsCLbS+Cu4=
|
||||||
|
|
||||||
|
bootstrap@v3.4.1:
|
||||||
|
version "3.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-3.4.1.tgz#c3a347d419e289ad11f4033e3c4132b87c081d72"
|
||||||
|
integrity sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==
|
||||||
|
|
||||||
brace-expansion@^1.1.7:
|
brace-expansion@^1.1.7:
|
||||||
version "1.1.11"
|
version "1.1.11"
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user