Add show code

This commit is contained in:
Jeremy Thomas
2017-10-09 12:27:08 +01:00
parent 5491eb4d8c
commit 02f7b216f1
4 changed files with 182 additions and 28 deletions

View File

@@ -109,12 +109,24 @@ document.addEventListener('DOMContentLoaded', function () {
var expandEl = '<button class="button is-small bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copyEl);
<<<<<<< HEAD
var $parent = $el.parentNode;
if ($parent && $parent.classList.contains('bd-is-more')) {
var 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);
}
var $parent = $el.parentNode;
if ($parent && $parent.className == 'bd-highlight-clipped') {
var 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++;
@@ -145,11 +157,19 @@ document.addEventListener('DOMContentLoaded', function () {
});
});
<<<<<<< HEAD
var $highlightShows = getAll('.highlight .bd-show');
$highlightShows.forEach(function ($el) {
$el.addEventListener('click', function () {
$el.parentNode.parentNode.classList.remove('bd-is-more-clipped');
=======
var $highlightShows = getAll('.bd-highlight-clipped .bd-show');
$highlightShows.forEach(function ($el) {
$el.addEventListener('click', function () {
$el.parentNode.classList.remove('bd-is-clipped');
>>>>>>> Add show code
});
});
}