mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-20 20:31:26 +02:00
Merge branch 'v4-dev' into fix-jumping-modal-on-resize
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Alert = (($) => {
|
||||
const Alert = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-beta): button.js
|
||||
@@ -5,7 +6,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Button = (($) => {
|
||||
const Button = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Carousel = (($) => {
|
||||
const Carousel = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Collapse = (($) => {
|
||||
const Collapse = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* global Popper */
|
||||
|
||||
import $ from 'jquery'
|
||||
import Popper from 'popper.js'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Dropdown = (($) => {
|
||||
const Dropdown = (() => {
|
||||
|
||||
/**
|
||||
* Check for Popper dependency
|
||||
@@ -445,6 +445,6 @@ const Dropdown = (($) => {
|
||||
|
||||
return Dropdown
|
||||
|
||||
})(jQuery)
|
||||
})(jQuery, Popper)
|
||||
|
||||
export default Dropdown
|
||||
|
46
js/src/index.js
Normal file
46
js/src/index.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import $ from 'jquery'
|
||||
import Alert from './alert'
|
||||
import Button from './button'
|
||||
import Carousel from './carousel'
|
||||
import Collapse from './collapse'
|
||||
import Dropdown from './dropdown'
|
||||
import Modal from './modal'
|
||||
import Popover from './popover'
|
||||
import Scrollspy from './scrollspy'
|
||||
import Tab from './tab'
|
||||
import Tooltip from './tooltip'
|
||||
import Util from './util'
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-alpha.6): index.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
(() => {
|
||||
if (typeof jQuery === 'undefined') {
|
||||
throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
|
||||
}
|
||||
|
||||
const version = $.fn.jquery.split(' ')[0].split('.')
|
||||
const min = 3
|
||||
const max = 4
|
||||
if (version[0] < min || version[0] >= max) {
|
||||
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0')
|
||||
}
|
||||
})(jQuery)
|
||||
|
||||
export {
|
||||
Util,
|
||||
Alert,
|
||||
Button,
|
||||
Carousel,
|
||||
Collapse,
|
||||
Dropdown,
|
||||
Modal,
|
||||
Popover,
|
||||
Scrollspy,
|
||||
Tab,
|
||||
Tooltip
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Modal = (($) => {
|
||||
const Modal = (() => {
|
||||
|
||||
|
||||
/**
|
||||
@@ -428,7 +429,8 @@ const Modal = (($) => {
|
||||
}
|
||||
|
||||
_checkScrollbar() {
|
||||
this._isBodyOverflowing = document.body.clientWidth < window.innerWidth
|
||||
const rect = document.body.getBoundingClientRect()
|
||||
this._isBodyOverflowing = rect.left + rect.right < window.innerWidth
|
||||
this._scrollbarWidth = this._getScrollbarWidth()
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Tooltip from './tooltip'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Tooltip from './tooltip'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Popover = (($) => {
|
||||
const Popover = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const ScrollSpy = (($) => {
|
||||
const ScrollSpy = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import $ from 'jquery'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -8,7 +9,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Tab = (($) => {
|
||||
const Tab = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* global Popper */
|
||||
|
||||
import $ from 'jquery'
|
||||
import Popper from 'popper.js'
|
||||
import Util from './util'
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import Util from './util'
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Tooltip = (($) => {
|
||||
const Tooltip = (() => {
|
||||
|
||||
/**
|
||||
* Check for Popper dependency
|
||||
@@ -728,6 +728,6 @@ const Tooltip = (($) => {
|
||||
|
||||
return Tooltip
|
||||
|
||||
})(jQuery)
|
||||
})(jQuery, Popper)
|
||||
|
||||
export default Tooltip
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import $ from 'jquery'
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.0.0-beta): util.js
|
||||
@@ -5,7 +7,7 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const Util = (($) => {
|
||||
const Util = (() => {
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -28,6 +28,7 @@
|
||||
"global-require": "off",
|
||||
"no-process-env": "off",
|
||||
"no-process-exit": "off",
|
||||
"no-sync": "off",
|
||||
|
||||
// Stylistic Issues
|
||||
"brace-style": "off",
|
||||
|
@@ -21,6 +21,8 @@ $(function () {
|
||||
document.body.removeChild(scrollDiv)
|
||||
return scrollbarWidth
|
||||
}
|
||||
// Simulate scrollbars in PhantomJS
|
||||
$('html').css('padding-right', '16px')
|
||||
},
|
||||
beforeEach: function () {
|
||||
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
|
||||
@@ -405,6 +407,30 @@ $(function () {
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should not adjust the inline body padding when it does not overflow', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
var $body = $(document.body)
|
||||
var originalPadding = $body.css('padding-right')
|
||||
|
||||
// Hide scrollbars to prevent the body overflowing
|
||||
$body.css('overflow', 'hidden') // real scrollbar (for in-browser testing)
|
||||
$('html').css('padding-right', '0px') // simulated scrollbar (for PhantomJS)
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('shown.bs.modal', function () {
|
||||
var currentPadding = $body.css('padding-right')
|
||||
assert.strictEqual(currentPadding, originalPadding, 'body padding should not be adjusted')
|
||||
$(this).bootstrapModal('hide')
|
||||
|
||||
// restore scrollbars
|
||||
$body.css('overflow', 'auto')
|
||||
$('html').css('padding-right', '16px')
|
||||
done()
|
||||
})
|
||||
.bootstrapModal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should adjust the inline padding of fixed elements when opening and restore when closing', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
@@ -539,7 +565,7 @@ $(function () {
|
||||
|
||||
$('<div id="modal-test"/>')
|
||||
.on('hidden.bs.modal', function () {
|
||||
assert.ok(!$body.attr('style'), 'body does not have inline padding set')
|
||||
assert.strictEqual($body.attr('style').indexOf('padding-right'), -1, 'body does not have inline padding set')
|
||||
$style.remove()
|
||||
done()
|
||||
})
|
||||
|
Reference in New Issue
Block a user