mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 10:14:29 -07:00
Improve snippet
This commit is contained in:
@@ -107,15 +107,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const expandEl = '<button class="button is-small bd-expand">Expand</button>';
|
||||
$el.insertAdjacentHTML('beforeend', copyEl);
|
||||
|
||||
if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
|
||||
$el.insertAdjacentHTML('beforeend', expandEl);
|
||||
}
|
||||
|
||||
const $parent = $el.parentNode;
|
||||
if ($parent && $parent.className == 'bd-highlight-clipped') {
|
||||
if ($parent && $parent.classList.contains('bd-is-more')) {
|
||||
const showEl = '<button class="bd-show"><div><span class="icon"><i class="fa fa-code"></i></span> <strong>Show code</strong></div></button>';
|
||||
$el.classList.add('bd-is-clipped');
|
||||
$el.insertAdjacentHTML('beforeend', showEl);
|
||||
} else if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
|
||||
$el.insertAdjacentHTML('beforeend', expandEl);
|
||||
}
|
||||
|
||||
itemsProcessed++;
|
||||
@@ -146,11 +143,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const $highlightShows = getAll('.bd-highlight-clipped .bd-show');
|
||||
const $highlightShows = getAll('.highlight .bd-show');
|
||||
|
||||
$highlightShows.forEach($el => {
|
||||
$el.addEventListener('click', () => {
|
||||
$el.parentNode.classList.remove('bd-is-clipped');
|
||||
$el.parentNode.parentNode.classList.remove('bd-is-more-clipped');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user