1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-11 16:14:04 +02:00

Remove placement attribute from our Dropdown plugin

This commit is contained in:
Johann-S
2017-09-07 12:47:43 +02:00
parent 7983ba9473
commit b822b5a17f
2 changed files with 3 additions and 18 deletions

View File

@@ -574,7 +574,7 @@ Regardless of whether you call your dropdown via JavaScript or instead use the d
### Options ### Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-placement=""`. Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-offset=""`.
<table class="table table-bordered table-striped table-responsive"> <table class="table table-bordered table-striped table-responsive">
<thead> <thead>
@@ -586,14 +586,6 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<td>placement</td>
<td>string</td>
<td>'bottom'</td>
<td>
<p>How to position the popover - top | bottom.</p>
</td>
</tr>
<tr> <tr>
<td>offset</td> <td>offset</td>
<td>number | string</td> <td>number | string</td>

View File

@@ -75,13 +75,11 @@ const Dropdown = (() => {
} }
const Default = { const Default = {
placement : AttachmentMap.BOTTOM,
offset : 0, offset : 0,
flip : true flip : true
} }
const DefaultType = { const DefaultType = {
placement : 'string',
offset : '(number|string)', offset : '(number|string)',
flip : 'boolean' flip : 'boolean'
} }
@@ -203,11 +201,6 @@ const Dropdown = (() => {
} }
_getConfig(config) { _getConfig(config) {
const elementData = $(this._element).data()
if (typeof elementData.placement !== 'undefined') {
elementData.placement = AttachmentMap[elementData.placement.toUpperCase()]
}
config = $.extend( config = $.extend(
{}, {},
this.constructor.Default, this.constructor.Default,
@@ -234,10 +227,10 @@ const Dropdown = (() => {
_getPlacement() { _getPlacement() {
const $parentDropdown = $(this._element).parent() const $parentDropdown = $(this._element).parent()
let placement = this._config.placement let placement = AttachmentMap.BOTTOM
// Handle dropup // Handle dropup
if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) { if ($parentDropdown.hasClass(ClassName.DROPUP)) {
placement = AttachmentMap.TOP placement = AttachmentMap.TOP
if ($(this._menu).hasClass(ClassName.MENURIGHT)) { if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
placement = AttachmentMap.TOPEND placement = AttachmentMap.TOPEND