Skip to content

Commit

Permalink
docs: switch to fenced codeblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 12, 2020
1 parent 5c69253 commit f8b848b
Show file tree
Hide file tree
Showing 43 changed files with 492 additions and 444 deletions.
20 changes: 10 additions & 10 deletions site/content/docs/5.0/components/alerts.md
Expand Up @@ -80,29 +80,29 @@ When an alert is dismissed, the element is completely removed from the page stru

Enable dismissal of an alert via JavaScript:

{{< highlight js >}}
```js
var alertList = document.querySelectorAll('.alert')
alertList.forEach(function (alert) {
new bootstrap.Alert(alert)
})
{{< /highlight >}}
```

Or with `data` attributes on a button **within the alert**, as demonstrated above:

{{< highlight html >}}
```html
<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
{{< /highlight >}}
```

Note that closing an alert will remove it from the DOM.

### Methods

You can create an alert instance with the alert constructor, for example:

{{< highlight js >}}
```js
var myAlert = document.getElementById('myAlert')
var bsAlert = new bootstrap.Alert(myAlert)
{{< /highlight >}}
```

This makes an alert listen for click events on descendant elements which have the `data-dismiss="alert"` attribute. (Not necessary when using the data-api's auto-initialization.)

Expand Down Expand Up @@ -141,11 +141,11 @@ This makes an alert listen for click events on descendant elements which have th
</tbody>
</table>

{{< highlight js >}}
```js
var alertNode = document.querySelector('.alert')
var alert = bootstrap.Alert.getInstance(alertNode)
alert.close()
{{< /highlight >}}
```

### Events

Expand Down Expand Up @@ -174,11 +174,11 @@ Bootstrap's alert plugin exposes a few events for hooking into alert functionali
</tbody>
</table>

{{< highlight js >}}
```js
var myAlert = document.getElementById('myAlert')
myAlert.addEventListener('closed.bs.alert', function () {
// do something, for instance, explicitly move focus to the most appropriate element,
// so it doesn't get lost/reset to the start of the page
// document.getElementById('...').focus()
})
{{< /highlight >}}
```
8 changes: 4 additions & 4 deletions site/content/docs/5.0/components/button-group.md
Expand Up @@ -163,11 +163,11 @@ Instead of applying button sizing classes to every button in a group, just add `
</div>
</div>

{{< highlight html >}}
```html
<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
<div class="btn-group" role="group" aria-label="...">...</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>
{{< /highlight >}}
```

## Nesting

Expand Down Expand Up @@ -261,8 +261,8 @@ Make a set of buttons appear vertically stacked rather than horizontally. **Spli
</div>
</div>

{{< highlight html >}}
```html
<div class="btn-group-vertical">
...
</div>
{{< /highlight >}}
```
8 changes: 4 additions & 4 deletions site/content/docs/5.0/components/buttons.md
Expand Up @@ -129,10 +129,10 @@ Add `data-toggle="button"` to toggle a button's `active` state. If you're pre-to

You can create a button instance with the button constructor, for example:

{{< highlight js >}}
```js
var button = document.getElementById('myButton')
var bsButton = new bootstrap.Button(button)
{{< /highlight >}}
```

<table class="table">
<thead>
Expand Down Expand Up @@ -163,10 +163,10 @@ var bsButton = new bootstrap.Button(button)

For example, to toggle all buttons

{{< highlight js >}}
```js
var buttons = document.querySelectorAll('.btn')
buttons.forEach(function (button) {
var button = new bootstrap.Button(button)
button.toggle()
})
{{< /highlight >}}
```
12 changes: 6 additions & 6 deletions site/content/docs/5.0/components/carousel.md
Expand Up @@ -263,10 +263,10 @@ The `data-ride="carousel"` attribute is used to mark a carousel as animating sta

Call carousel manually with:

{{< highlight js >}}
```js
var myCarousel = document.querySelector('#myCarousel')
var carousel = new bootstrap.Carousel(myCarousel)
{{< /highlight >}}
```

### Options

Expand Down Expand Up @@ -330,13 +330,13 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap

You can create a carousel instance with the carousel constructor, for example, to initialize with additional options and start cycling through items:

{{< highlight js >}}
```js
var myCarousel = document.querySelector('#myCarousel')
var carousel = new bootstrap.Carousel(myCarousel, {
interval: 2000,
wrap: false
})
{{< /highlight >}}
```

<table class="table">
<thead>
Expand Down Expand Up @@ -411,13 +411,13 @@ All carousel events are fired at the carousel itself (i.e. at the `<div class="c
</tbody>
</table>

{{< highlight js >}}
```js
var myCarousel = document.getElementById('myCarousel')

myCarousel.addEventListener('slide.bs.carousel', function () {
// do something...
})
{{< /highlight >}}
```

### Change transition duration

Expand Down
12 changes: 6 additions & 6 deletions site/content/docs/5.0/components/collapse.md
Expand Up @@ -149,12 +149,12 @@ To add accordion-like group management to a collapsible area, add the data attri

Enable manually with:

{{< highlight js >}}
```js
var collapseElementList = [].slice.call(document.querySelectorAll('.collapse'))
var collapseList = collapseElementList.map(function (collapseEl) {
return new bootstrap.Collapse(collapseEl)
})
{{< /highlight >}}
```

### Options

Expand Down Expand Up @@ -195,12 +195,12 @@ Activates your content as a collapsible element. Accepts an optional options `ob

You can create a collapse instance with the constructor, for example:

{{< highlight js >}}
```js
var myCollapse = document.getElementById('myCollapse')
var bsCollapse = new bootstrap.Collapse(myCollapse, {
toggle: false
})
{{< /highlight >}}
```

<table class="table">
<thead>
Expand Down Expand Up @@ -264,9 +264,9 @@ Bootstrap's collapse class exposes a few events for hooking into collapse functi
</tbody>
</table>

{{< highlight js >}}
```js
var myCollapsible = document.getElementById('myCollapsible')
myCollapsible.addEventListener('hidden.bs.collapse', function () {
// do something...
})
{{< /highlight >}}
```
36 changes: 18 additions & 18 deletions site/content/docs/5.0/components/dropdowns.md
Expand Up @@ -122,7 +122,7 @@ The best part is you can do this with any button variant, too:
</div><!-- /btn-group -->
</div>

{{< highlight html >}}
```html
<!-- Example single danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Expand All @@ -136,7 +136,7 @@ The best part is you can do this with any button variant, too:
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
{{< /highlight >}}
```

### Split button

Expand Down Expand Up @@ -225,7 +225,7 @@ We use this extra class to reduce the horizontal `padding` on either side of the
</div><!-- /btn-group -->
</div>

{{< highlight html >}}
```html
<!-- Example split danger button -->
<div class="btn-group">
<button type="button" class="btn btn-danger">Action</button>
Expand All @@ -240,7 +240,7 @@ We use this extra class to reduce the horizontal `padding` on either side of the
<li><a class="dropdown-item" href="#">Separated link</a></li>
</ul>
</div>
{{< /highlight >}}
```

## Sizing

Expand Down Expand Up @@ -303,7 +303,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
</div><!-- /btn-toolbar -->
</div>

{{< highlight html >}}
```html
<!-- Large button groups (default and split) -->
<div class="btn-group">
<button class="btn btn-secondary btn-lg dropdown-toggle" type="button" data-toggle="dropdown" aria-expanded="false">
Expand Down Expand Up @@ -345,7 +345,7 @@ Button dropdowns work with buttons of all sizes, including default and split dro
...
</ul>
</div>
{{< /highlight >}}
```

## Dark dropdowns

Expand Down Expand Up @@ -429,7 +429,7 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
</div>
</div>

{{< highlight html >}}
```html
<!-- Default dropup button -->
<div class="btn-group dropup">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Expand All @@ -452,7 +452,7 @@ Trigger dropdown menus above elements by adding `.dropup` to the parent element.
<!-- Dropdown menu links -->
</ul>
</div>
{{< /highlight >}}
```

### Dropright

Expand Down Expand Up @@ -488,7 +488,7 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
</div>
</div>

{{< highlight html >}}
```html
<!-- Default dropright button -->
<div class="btn-group dropright">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Expand All @@ -511,7 +511,7 @@ Trigger dropdown menus at the right of the elements by adding `.dropright` to th
<!-- Dropdown menu links -->
</ul>
</div>
{{< /highlight >}}
```

### Dropleft

Expand Down Expand Up @@ -549,7 +549,7 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
</div>
</div>

{{< highlight html >}}
```html
<!-- Default dropleft button -->
<div class="btn-group dropleft">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Expand All @@ -574,7 +574,7 @@ Trigger dropdown menus at the left of the elements by adding `.dropleft` to the
Split dropleft
</button>
</div>
{{< /highlight >}}
```

## Menu items

Expand Down Expand Up @@ -825,7 +825,7 @@ On touch-enabled devices, opening a dropdown adds empty `mouseover` handlers to

Add `data-toggle="dropdown"` to a link or button to toggle a dropdown.

{{< highlight html >}}
```html
<div class="dropdown">
<button id="dLabel" type="button" data-toggle="dropdown" aria-expanded="false">
Dropdown trigger
Expand All @@ -834,18 +834,18 @@ Add `data-toggle="dropdown"` to a link or button to toggle a dropdown.
...
</ul>
</div>
{{< /highlight >}}
```

### Via JavaScript

Call the dropdowns via JavaScript:

{{< highlight js >}}
```js
var dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'))
var dropdownList = dropdownElementList.map(function (dropdownToggleEl) {
return new bootstrap.Dropdown(dropdownToggleEl)
})
{{< /highlight >}}
```

{{% callout info %}}
##### `data-toggle="dropdown"` still required
Expand Down Expand Up @@ -1009,9 +1009,9 @@ All dropdown events are fired at the `.dropdown-menu`'s parent element and have
</tbody>
</table>

{{< highlight js >}}
```js
var myDropdown = document.getElementById('myDropdown')
myDropdown.addEventListener('show.bs.dropdown', function () {
// do something...
})
{{< /highlight >}}
```

0 comments on commit f8b848b

Please sign in to comment.