diff options
author | Johann-S <johann.servoire@gmail.com> | 2017-09-03 13:56:04 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-03 13:56:04 +0300 |
commit | e04e42d08c059732153ff6925fa712464cf12207 (patch) | |
tree | a4c5d188bf8416fe7b801fbac79a2ad21af7012e /js | |
parent | 45baa15932dd9c546c4618acca0b02d6f661e657 (diff) | |
parent | 2e5f1e22860a892f5abdbb65abc14172e0129c1a (diff) |
Merge branch 'v4-dev' into fix-jumping-modal-on-resize
Diffstat (limited to 'js')
-rw-r--r-- | js/src/alert.js | 3 | ||||
-rw-r--r-- | js/src/button.js | 3 | ||||
-rw-r--r-- | js/src/carousel.js | 3 | ||||
-rw-r--r-- | js/src/collapse.js | 3 | ||||
-rw-r--r-- | js/src/dropdown.js | 8 | ||||
-rw-r--r-- | js/src/index.js | 46 | ||||
-rw-r--r-- | js/src/modal.js | 6 | ||||
-rw-r--r-- | js/src/popover.js | 3 | ||||
-rw-r--r-- | js/src/scrollspy.js | 3 | ||||
-rw-r--r-- | js/src/tab.js | 3 | ||||
-rw-r--r-- | js/src/tooltip.js | 8 | ||||
-rw-r--r-- | js/src/util.js | 4 | ||||
-rw-r--r-- | js/tests/.eslintrc.json | 1 | ||||
-rw-r--r-- | js/tests/unit/modal.js | 28 |
14 files changed, 103 insertions, 19 deletions
diff --git a/js/src/alert.js b/js/src/alert.js index b6b9336af7..9fcf088b12 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Alert = (($) => { +const Alert = (() => { /** diff --git a/js/src/button.js b/js/src/button.js index a8a72ef569..a121b8e13a 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,3 +1,4 @@ +import $ from 'jquery' /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): button.js @@ -5,7 +6,7 @@ * -------------------------------------------------------------------------- */ -const Button = (($) => { +const Button = (() => { /** diff --git a/js/src/carousel.js b/js/src/carousel.js index 8736605190..a5ad02541a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Carousel = (($) => { +const Carousel = (() => { /** diff --git a/js/src/collapse.js b/js/src/collapse.js index 7d1ba4c54f..acc959d40c 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Collapse = (($) => { +const Collapse = (() => { /** diff --git a/js/src/dropdown.js b/js/src/dropdown.js index e1c48ac6e5..adb54f0f21 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -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 diff --git a/js/src/index.js b/js/src/index.js new file mode 100644 index 0000000000..84a27880e9 --- /dev/null +++ b/js/src/index.js @@ -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 +} diff --git a/js/src/modal.js b/js/src/modal.js index 5892ed0451..689e93bc15 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -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() } diff --git a/js/src/popover.js b/js/src/popover.js index f5820ecbed..aeccdf7501 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Tooltip from './tooltip' @@ -8,7 +9,7 @@ import Tooltip from './tooltip' * -------------------------------------------------------------------------- */ -const Popover = (($) => { +const Popover = (() => { /** diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 588f652988..70067c0b35 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const ScrollSpy = (($) => { +const ScrollSpy = (() => { /** diff --git a/js/src/tab.js b/js/src/tab.js index c32cd3776f..18af4e7e27 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -1,3 +1,4 @@ +import $ from 'jquery' import Util from './util' @@ -8,7 +9,7 @@ import Util from './util' * -------------------------------------------------------------------------- */ -const Tab = (($) => { +const Tab = (() => { /** diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 37573cf498..5dc28ab7ef 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -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 diff --git a/js/src/util.js b/js/src/util.js index cd3f1fb6a2..b18d0f776d 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -1,3 +1,5 @@ +import $ from 'jquery' + /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): util.js @@ -5,7 +7,7 @@ * -------------------------------------------------------------------------- */ -const Util = (($) => { +const Util = (() => { /** diff --git a/js/tests/.eslintrc.json b/js/tests/.eslintrc.json index a05a3a3900..b039801444 100644 --- a/js/tests/.eslintrc.json +++ b/js/tests/.eslintrc.json @@ -28,6 +28,7 @@ "global-require": "off", "no-process-env": "off", "no-process-exit": "off", + "no-sync": "off", // Stylistic Issues "brace-style": "off", diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index d22b818d26..e026cd7f14 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -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() }) |