diff options
| author | Johann-S <[email protected]> | 2017-04-17 14:26:40 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2017-05-14 11:41:19 +0200 |
| commit | 53ee455bc735af9fc54de586ed4d23ac56b69ab8 (patch) | |
| tree | 8a29be55e1f709a3604c898360e0c31b8ac75cba | |
| parent | 69de65180f750cadf5f96a774d2524f69d19beab (diff) | |
| download | bootstrap-53ee455bc735af9fc54de586ed4d23ac56b69ab8.tar.xz bootstrap-53ee455bc735af9fc54de586ed4d23ac56b69ab8.zip | |
Handle dropup for Dropdown
| -rw-r--r-- | js/src/dropdown.js | 11 | ||||
| -rw-r--r-- | js/tests/unit/tooltip.js | 9 | ||||
| -rw-r--r-- | js/tests/visual/dropdown.html | 13 | ||||
| -rw-r--r-- | scss/_dropdown.scss | 8 |
4 files changed, 31 insertions, 10 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index ce25e9671..33171cf20 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -64,8 +64,13 @@ const Dropdown = (($) => { VISIBLE_ITEMS : '.dropdown-menu .dropdown-item:not(.disabled)' } + const AttachmentMap = { + TOP : 'top', + BOTTOM : 'bottom' + } + const Default = { - placement : 'bottom', + placement : AttachmentMap.BOTTOM, offset : 0 } @@ -141,8 +146,10 @@ const Dropdown = (($) => { return false } + // Handle dropup + const dropdownPlacement = $(this).parent().hasClass('dropup') ? AttachmentMap.TOP : context._config.placement this._popper = new Popper(this, context._menu, { - placement : context._config.placement, + placement : dropdownPlacement, modifiers : { offset : { offset : context._config.offset diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index f47a97e30..c0cafefe5 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -456,7 +456,7 @@ $(function () { assert.expect(1) var done = assert.async() - var containerHTML = '<div>' + var containerHTML = '<div id="test">' + '<p style="margin-top: 200px">' + '<a href="#" title="very very very very very very very long tooltip">Hover me</a>' + '</p>' @@ -482,7 +482,12 @@ $(function () { }) .on('shown.bs.tooltip', function () { var $tooltip = $($(this).data('bs.tooltip').tip) - assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + if (/iPhone|iPad|iPod/.test(navigator.userAgent)) { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) <= Math.round($(this).offset().top)) + } + else { + assert.ok(Math.round($tooltip.offset().top + $tooltip.outerHeight()) >= Math.round($(this).offset().top)) + } done() }) .bootstrapTooltip('show') diff --git a/js/tests/visual/dropdown.html b/js/tests/visual/dropdown.html index d96b367e9..45c5d5172 100644 --- a/js/tests/visual/dropdown.html +++ b/js/tests/visual/dropdown.html @@ -58,6 +58,19 @@ </div> </li> </ul> + + <!-- Default dropup button --> + <div class="btn-group dropup" style="margin-top: 60px;"> + <button type="button" class="btn btn-secondary">Dropup</button> + <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> + <span class="sr-only">Toggle Dropdown</span> + </button> + <div class="dropdown-menu"> + <a class="dropdown-item" href="#">Action</a> + <a class="dropdown-item" href="#">Another action</a> + <a class="dropdown-item" href="#">Something else here</a> + </div> + </div> </div> <script src="../../../docs/assets/js/vendor/jquery-slim.min.js"></script> diff --git a/scss/_dropdown.scss b/scss/_dropdown.scss index 4f0e6fcce..7826e0212 100644 --- a/scss/_dropdown.scss +++ b/scss/_dropdown.scss @@ -23,6 +23,8 @@ } } +// Allow for dropdowns to go bottom up (aka, dropup-menu) +// Just add .dropup after the standard .dropdown class and you're set. .dropup { .dropdown-toggle { &::after { @@ -133,9 +135,3 @@ color: $dropdown-header-color; white-space: nowrap; // as with > li > a } - -// Allow for dropdowns to go bottom up (aka, dropup-menu) -// -// Just add .dropup after the standard .dropdown class and you're set. - -//.dropup {} |
