Fix copy and expand

This commit is contained in:
Jeremy Thomas
2017-08-14 12:58:21 +01:00
parent cd2f886df2
commit 74146af03f
9 changed files with 72 additions and 72 deletions

View File

@@ -37,8 +37,8 @@ jQuery(document).ready(function ($) {
$highlights.each(function () {
var $el = $(this);
var copy = '<button class="copy">Copy</button>';
var expand = '<button class="expand">Expand</button>';
var copy = '<button class="bd-copy">Copy</button>';
var expand = '<button class="bd-expand">Expand</button>';
$el.append(copy);
if ($el.find('pre code').innerHeight() > 600) {
@@ -46,7 +46,7 @@ jQuery(document).ready(function ($) {
}
});
var $highlightButtons = $('.highlight .copy, .highlight .expand');
var $highlightButtons = $('.highlight .bd-copy, .highlight .bd-expand');
$highlightButtons.hover(function () {
$(this).parent().css('box-shadow', '0 0 0 1px #ed6c63');
@@ -54,11 +54,11 @@ jQuery(document).ready(function ($) {
$(this).parent().css('box-shadow', 'none');
});
$('.highlight .expand').click(function () {
$('.highlight .bd-expand').click(function () {
$(this).parent().children('pre').css('max-height', 'none');
});
new Clipboard('.copy', {
new Clipboard('.bd-copy', {
target: function target(trigger) {
return trigger.previousSibling;
}

View File

@@ -105,8 +105,8 @@ document.addEventListener('DOMContentLoaded', function () {
if ($highlights.length > 0) {
$highlights.forEach(function ($el) {
var copy = '<button class="copy">Copy</button>';
var expand = '<button class="expand">Expand</button>';
var copy = '<button class="bd-copy">Copy</button>';
var expand = '<button class="bd-expand">Expand</button>';
$el.insertAdjacentHTML('beforeend', copy);
if ($el.firstElementChild.scrollHeight > 480 && $el.firstElementChild.clientHeight <= 480) {
@@ -121,7 +121,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
function addHighlightControls() {
var $highlightButtons = getAll('.highlight .copy, .highlight .expand');
var $highlightButtons = getAll('.highlight .bd-copy, .highlight .bd-expand');
$highlightButtons.forEach(function ($el) {
$el.addEventListener('mouseenter', function () {
@@ -133,7 +133,7 @@ document.addEventListener('DOMContentLoaded', function () {
});
});
var $highlightExpands = getAll('.highlight .expand');
var $highlightExpands = getAll('.highlight .bd-expand');
$highlightExpands.forEach(function ($el) {
$el.addEventListener('click', function () {
@@ -142,7 +142,7 @@ document.addEventListener('DOMContentLoaded', function () {
});
}
new Clipboard('.copy', {
new Clipboard('.bd-copy', {
target: function target(trigger) {
return trigger.previousSibling;
}