diff --git a/site/content/docs/5.0/components/alerts.md b/site/content/docs/5.0/components/alerts.md index f35a044ae..aaa306169 100644 --- a/site/content/docs/5.0/components/alerts.md +++ b/site/content/docs/5.0/components/alerts.md @@ -103,40 +103,13 @@ var bsAlert = new bootstrap.Alert(myAlert) This makes an alert listen for click events on descendant elements which have the `data-bs-dismiss="alert"` attribute. (Not necessary when using the data-api's auto-initialization.) -
| Method | -Description | -
|---|---|
- close
- |
-
- Closes an alert by removing it from the DOM. If the .fade and .show classes are present on the element, the alert will fade out before it is removed.
- |
-
- dispose
- |
- - Destroys an element's alert. (Removes stored data on the DOM element) - | -
- getInstance
- |
-
- Static method which allows you to get the alert instance associated to a DOM element, you can use it like this: bootstrap.Alert.getInstance(alert)
- |
-
| Event | -Description | -
|---|---|
close.bs.alert |
-
- Fires immediately when the close instance method is called.
- |
-
closed.bs.alert |
- - Fired when the alert has been closed and CSS transitions have completed. - | -
| Method | -Description | -
|---|---|
- toggle
- |
- - Toggles push state. Gives the button the appearance that it has been activated. - | -
- dispose
- |
- - Destroys an element's button. (Removes stored data on the DOM element) - | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
interval |
- number | -5000 |
- The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. | -
keyboard |
- boolean | -true |
- Whether the carousel should react to keyboard events. | -
pause |
- string | boolean | -"hover" |
- If set to On touch-enabled devices, when set to |
-
slide |
- string | boolean | -false |
- Autoplays the carousel after the user manually cycles the first item. If "carousel", autoplays the carousel on load. | -
wrap |
- boolean | -true |
- Whether the carousel should cycle continuously or have hard stops. | -
touch |
- boolean | -true |
- Whether the carousel should support left/right swipe interactions on touchscreen devices. | -
| Method | -Description | -
|---|---|
cycle |
- Cycles through the carousel items from left to right. | -
pause |
- Stops the carousel from cycling through items. | -
prev |
- Cycles to the previous item. Returns to the caller before the previous item has been shown (e.g., before the slid.bs.carousel event occurs). |
-
next |
- Cycles to the next item. Returns to the caller before the next item has been shown (e.g., before the slid.bs.carousel event occurs). |
-
nextWhenVisible |
- Don't cycle carousel to next when the page isn't visible or the carousel or its parent isn't visible. Returns to the caller before the target item has been shown - |
to |
- Cycles the carousel to a particular frame (0 based, similar to an array). Returns to the caller before the target item has been shown (e.g., before the slid.bs.carousel event occurs). |
-
dispose |
- Destroys an element's carousel. (Removes stored data on the DOM element) | -
getInstance |
- Static method which allows you to get the carousel instance associated with a DOM element. | -
| Event type | -Description | -
|---|---|
slide.bs.carousel |
- Fires immediately when the slide instance method is invoked. |
-
slid.bs.carousel |
- Fired when the carousel has completed its slide transition. | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
parent |
- selector | jQuery object | DOM element | -false |
- If parent is provided, then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this is dependent on the card class). The attribute has to be set on the target collapsible area. |
-
toggle |
- boolean | -true |
- Toggles the collapsible element on invocation | -
| Method | -Description | -
|---|---|
toggle |
- Toggles a collapsible element to shown or hidden. Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the shown.bs.collapse or hidden.bs.collapse event occurs). |
-
show |
- Shows a collapsible element. Returns to the caller before the collapsible element has actually been shown (e.g., before the shown.bs.collapse event occurs). |
-
hide |
- Hides a collapsible element. Returns to the caller before the collapsible element has actually been hidden (e.g., before the hidden.bs.collapse event occurs). |
-
dispose |
- Destroys an element's collapse. (Removes stored data on the DOM element) | -
getInstance |
- Static method which allows you to get the collapse instance associated with a DOM element. | -
| Event type | -Description | -
|---|---|
show.bs.collapse |
- This event fires immediately when the show instance method is called. |
-
shown.bs.collapse |
- This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). | -
hide.bs.collapse |
- This event is fired immediately when the hide method has been called. |
-
hidden.bs.collapse |
- This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
offset |
- number | string | function | -0 |
-
- Offset of the dropdown relative to its target. -When a function is used to determine the offset, it is called with an object containing the offset data as its first argument. The function must return an object with the same structure. The triggering element DOM node is passed as the second argument. -For more information refer to Popper's offset docs. - |
-
flip |
- boolean | -true |
- Allow Dropdown to flip in case of an overlapping on the reference element. For more information refer to Popper's flip docs. | -
boundary |
- string | element | -'scrollParent' |
- Overflow constraint boundary of the dropdown menu. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper's preventOverflow docs. |
-
reference |
- string | element | -'toggle' |
- Reference element of the dropdown menu. Accepts the values of 'toggle', 'parent', or an HTMLElement reference. For more information refer to Popper's referenceObject docs. |
-
display |
- string | -'dynamic' |
- By default, we use Popper for dynamic positioning. Disable this with static. |
-
popperConfig |
- null | object | -null |
- To change Bootstrap's default Popper config, see Popper's configuration | -
| Method | -Description | -
|---|---|
toggle |
- - Toggles the dropdown menu of a given navbar or tabbed navigation. - | -
show |
- - Shows the dropdown menu of a given navbar or tabbed navigation. - | -
hide |
- - Hides the dropdown menu of a given navbar or tabbed navigation. - | -
update |
- - Updates the position of an element's dropdown. - | -
dispose |
- - Destroys an element's dropdown. (Removes stored data on the DOM element) - | -
getInstance |
- - Static method which allows you to get the dropdown instance associated with a DOM element. - | -
| Method | -Description | -
|---|---|
- show.bs.dropdown
- |
- - Fires immediately when the show instance method is called. - | -
- shown.bs.dropdown
- |
- - Fired when the dropdown has been made visible to the user and CSS transitions have completed. - | -
- hide.bs.dropdown
- |
- - Fires immediately when the hide instance method has been called. - | -
- hidden.bs.dropdown
- |
- - Fired when the dropdown has finished being hidden from the user and CSS transitions have completed. - | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
backdrop |
- boolean or the string 'static' |
- true |
- Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click. |
-
keyboard |
- boolean | -true |
- Closes the modal when escape key is pressed | -
focus |
- boolean | -true |
- Puts the focus on the modal when initialized. | -
show |
- boolean | -true |
- Shows the modal when initialized. | -
| Event type | -Description | -
|---|---|
show.bs.modal |
- This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event. |
-
shown.bs.modal |
- This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event. |
-
hide.bs.modal |
- This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.modal |
- This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). | -
hidePrevented.bs.modal |
- This event is fired when the modal is shown, its backdrop is static and a click outside the modal or an escape key press is performed with the keyboard option or data-bs-keyboard set to false. |
-
| Name | -Type | -Default | -Description | -
|---|---|---|---|
animation |
- boolean | -true |
- Apply a CSS fade transition to the popover | -
container |
- string | element | false | -false |
-
- Appends the popover to a specific element. Example: |
-
content |
- string | element | function | -'' |
-
- Default content value if If a function is given, it will be called with its |
-
delay |
- number | object | -0 |
-
- Delay showing and hiding the popover (ms) - does not apply to manual trigger type -If a number is supplied, delay is applied to both hide/show -Object structure is: |
-
html |
- boolean | -false |
- Insert HTML into the popover. If false, innerText property will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
-
placement |
- string | function | -'right' |
-
- How to position the popover - auto | top | bottom | left | right. When a function is used to determine the placement, it is called with the popover DOM node as its first argument and the triggering element DOM node as its second. The |
-
selector |
- string | false | -false |
- If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example. | -
template |
- string | -'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>' |
-
- Base HTML to use when creating the popover. -The popover's The popover's
The outermost wrapper element should have the |
-
title |
- string | element | function | -'' |
-
- Default title value if If a function is given, it will be called with its |
-
trigger |
- string | -'click' |
- How popover is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot be combined with any other trigger. |
-
offset |
- number | string | -0 |
- Offset of the popover relative to its target. For more information refer to Popper's offset docs. | -
fallbackPlacement |
- string | array | -'flip' |
- Allow to specify which position Popper will use on fallback. For more information refer to - Popper's behavior docs | -
boundary |
- string | element | -'scrollParent' |
- Overflow constraint boundary of the popover. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper's preventOverflow docs. |
-
sanitize |
- boolean | -true |
- Enable or disable the sanitization. If activated 'template', 'content' and 'title' options will be sanitized. |
-
allowList |
- object | -}}">Default value | -Object which contains allowed attributes and tags | -
sanitizeFn |
- null | function | -null |
- Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. | -
popperConfig |
- null | object | -null |
- To change Bootstrap's default Popper config, see Popper's configuration | -
| Event type | -Description | -
|---|---|
| show.bs.popover | -This event fires immediately when the show instance method is called. |
-
| shown.bs.popover | -This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). | -
| hide.bs.popover | -This event is fired immediately when the hide instance method has been called. |
-
| hidden.bs.popover | -This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). | -
| inserted.bs.popover | -This event is fired after the show.bs.popover event when the popover template has been added to the DOM. |
-
show instance method is called. |
+| `shown.bs.popover` | This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). |
+| `hide.bs.popover` | This event is fired immediately when the hide instance method has been called. |
+| `hidden.bs.popover` | This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). |
+| `inserted.bs.popover` | This event is fired after the show.bs.popover event when the popover template has been added to the DOM. |
+{{< /bs-table >}}
```js
var myPopoverTrigger = document.getElementById('myPopover')
diff --git a/site/content/docs/5.0/components/scrollspy.md b/site/content/docs/5.0/components/scrollspy.md
index 5606860d3..b30b0cf07 100644
--- a/site/content/docs/5.0/components/scrollspy.md
+++ b/site/content/docs/5.0/components/scrollspy.md
@@ -274,11 +274,29 @@ Navbar links must have resolvable id targets. For example, a `ho
Target elements that are not visible will be ignored and their corresponding nav items will never be highlighted.
{{< /callout >}}
+### Options
+
+Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-bs-`, as in `data-bs-offset=""`.
+
+{{< bs-table "table bs-js-table" >}}
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `offset` | number | 10 | Pixels to offset from top when calculating position of scroll. |
+| `method` | string | `auto` | Finds which section the spied element is in. `auto` will choose the best method to get scroll coordinates. `offset` will use the [`Element.getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) method to get scroll coordinates. `position` will use the [`HTMLElement.offsetTop`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop) and [`HTMLElement.offsetLeft`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft) properties to get scroll coordinates.` |
+| `target` | string, jQuery object, DOM element | | Specifies element to apply Scrollspy plugin. |
+{{< /bs-table >}}
+
### Methods
-#### refresh
+{{< bs-table "table bs-js-table" >}}
+| Method | Description |
+| --- | --- |
+| `refresh` | When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method. |
+| `dispose` | Destroys an element's scrollspy. (Removes stored data on the DOM element) |
+| `getInstance` | *Static* method which allows you to get the scrollspy instance associated with a DOM element |
+{{< /bs-table >}}
-When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
+Here's an example using the refresh method:
```js
var dataSpyList = [].slice.call(document.querySelectorAll('[data-bs-spy="scroll"]'))
@@ -288,70 +306,13 @@ dataSpyList.forEach(function (dataSpyEl) {
})
```
-#### dispose
-
-Destroys an element's scrollspy. (Removes stored data on the DOM element)
-
-#### getInstance
-
-*Static* method which allows you to get the scrollspy instance associated with a DOM element
-
-```js
-var scrollSpyContentEl = document.getElementById('content')
-var scrollSpy = bootstrap.ScrollSpy.getInstance(scrollSpyContentEl) // Returns a Bootstrap scrollspy instance
-```
-
-### Options
-
-Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-bs-`, as in `data-bs-offset=""`.
-
-| Name | -Type | -Default | -Description | -
|---|---|---|---|
offset |
- number | -10 |
- Pixels to offset from top when calculating position of scroll. | -
method |
- string | -auto |
- Finds which section the spied element is in. auto will choose the best method to get scroll coordinates. offset will use the Element.getBoundingClientRect() method to get scroll coordinates. position will use the HTMLElement.offsetTop and HTMLElement.offsetLeft properties to get scroll coordinates. |
-
target |
- string | jQuery object | DOM element | -- | Specifies element to apply Scrollspy plugin. | -
| Event type | -Description | -
|---|---|
activate.bs.scrollspy |
- This event fires on the scroll element whenever a new item becomes activated by the scrollspy. | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
animation |
- boolean | -true |
- Apply a CSS fade transition to the toast | -
autohide |
- boolean | -true |
- Auto hide the toast | -
delay |
- number | -
- 5000
- |
- Delay hiding the toast (ms) | -
| Event type | -Description | -
|---|---|
show.bs.toast |
- This event fires immediately when the show instance method is called. |
-
shown.bs.toast |
- This event is fired when the toast has been made visible to the user. | -
hide.bs.toast |
- This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.toast |
- This event is fired when the toast has finished being hidden from the user. | -
| Name | -Type | -Default | -Description | -
|---|---|---|---|
animation |
- boolean | -true |
- Apply a CSS fade transition to the tooltip | -
container |
- string | element | false | -false |
-
- Appends the tooltip to a specific element. Example: |
-
delay |
- number | object | -0 |
-
- Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type -If a number is supplied, delay is applied to both hide/show -Object structure is: |
-
html |
- boolean | -false |
-
- Allow HTML in the tooltip. -If true, HTML tags in the tooltip's Use text if you're worried about XSS attacks. - |
-
placement |
- string | function | -'top' |
-
- How to position the tooltip - auto | top | bottom | left | right. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The |
-
selector |
- string | false | -false |
- If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this and an informative example. |
-
template |
- string | -'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' |
-
- Base HTML to use when creating the tooltip. -The tooltip's
The outermost wrapper element should have the |
-
title |
- string | element | function | -'' |
-
- Default title value if If a function is given, it will be called with its |
-
trigger |
- string | -'hover focus' |
-
- How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. -
|
-
offset |
- number | string | function | -0 |
-
- Offset of the tooltip relative to its target. -When a function is used to determine the offset, it is called with an object containing the offset data as its first argument. The function must return an object with the same structure. The triggering element DOM node is passed as the second argument. -For more information refer to Popper's offset docs. - |
-
fallbackPlacement |
- string | array | -'flip' |
- Allow to specify which position Popper will use on fallback. For more information refer to - Popper's behavior docs | -
boundary |
- string | element | -'scrollParent' |
- Overflow constraint boundary of the tooltip. Accepts the values of 'viewport', 'window', 'scrollParent', or an HTMLElement reference (JavaScript only). For more information refer to Popper's preventOverflow docs. |
-
sanitize |
- boolean | -true |
- Enable or disable the sanitization. If activated 'template' and 'title' options will be sanitized. |
-
allowList |
- object | -}}">Default value | -Object which contains allowed attributes and tags | -
sanitizeFn |
- null | function | -null |
- Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. | -
popperConfig |
- null | object | -null |
- To change Bootstrap's default Popper config, see Popper's configuration | -
container: 'body'. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize. |
+| `delay` | number, object | `0` | Delay showing and hiding the tooltip (ms)—doesn't apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: `delay: { "show": 500, "hide": 100 }`. |
+| `html` | boolean | `false` | Allow HTML in the tooltip. If true, HTML tags in the tooltip's `title` will be rendered in the tooltip. If false, `innerText` property will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
+| `placement` | string, function | `'top'` | How to position the tooltip: auto, top, bottom, left, right. When `auto` is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The `this` context is set to the tooltip instance. |
+| `selector` | string, false | `false` | If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (`jQuery.on` support). See [this issue]({{< param repo >}}/issues/4215) and [an informative example](https://codepen.io/Johann-S/pen/djJYPb). |
+| `template` | string | `'| Event type | -Description | -
|---|---|
show.bs.tooltip |
- This event fires immediately when the show instance method is called. |
-
shown.bs.tooltip |
- This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete). | -
hide.bs.tooltip |
- This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.tooltip |
- This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete). | -
inserted.bs.tooltip |
- This event is fired after the show.bs.tooltip event when the tooltip template has been added to the DOM. |
-
show instance method is called. |
+| `shown.bs.tooltip` | This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). |
+| `hide.bs.tooltip` | This event is fired immediately when the hide instance method has been called. |
+| `hidden.bs.tooltip` | This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). |
+| `inserted.bs.tooltip` | This event is fired after the show.bs.tooltip event when the tooltip template has been added to the DOM. |
+{{< /bs-table >}}
```js
var myTooltipEl = document.getElementById('myTooltip')