Add show code

This commit is contained in:
Jeremy Thomas
2017-10-09 12:27:08 +01:00
parent 927f7ebb38
commit 3ac5137192
4 changed files with 229 additions and 1 deletions

View File

@@ -107,12 +107,24 @@ document.addEventListener('DOMContentLoaded', () => {
const expandEl = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copyEl);
<<<<<<< HEAD
const $parent = $el.parentNode;
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.insertAdjacentHTML('beforeend', showEl);
} else if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
$el.insertAdjacentHTML('beforeend', expandEl);
=======
if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
$el.insertAdjacentHTML('beforeend', expandEl);
}
const $parent = $el.parentNode;
if ($parent && $parent.className == 'bd-highlight-clipped') {
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);
>>>>>>> Add show code
}
itemsProcessed++;
@@ -147,7 +159,7 @@ document.addEventListener('DOMContentLoaded', () => {
$highlightShows.forEach($el => {
$el.addEventListener('click', () => {
$el.parentNode.parentNode.classList.remove('bd-is-more-clipped');
$el.parentNode.classList.remove('bd-is-clipped');
});
});
}