Skip to content

Commit

Permalink
code: show copy-to-clipboard marker for blocklevel code matcornic#298
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Jul 3, 2022
1 parent 87c8120 commit 3e83d03
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ function initCodeClipboard(){
}

$('code').each(function() {
var code = $(this),
text = code.text();
var code = $(this);
var text = code.text();
var parent = code.parent();
var inPre = parent.prop('tagName') == 'PRE';

if (text.length > 5) {
if (inPre || text.length > 5) {
var clip = new ClipboardJS('.copy-to-clipboard-button', {
text: function(trigger) {
var text = $(trigger).prev('code').text();
Expand All @@ -272,8 +274,6 @@ function initCodeClipboard(){
});
});

var parent = code.parent();
var inPre = parent.prop('tagName') == 'PRE';
code.addClass('copy-to-clipboard-code');
if( inPre ){
parent.addClass( 'copy-to-clipboard' );
Expand Down

0 comments on commit 3e83d03

Please sign in to comment.