mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
code: show copy-to-clipboard marker for blocklevel code #298
This commit is contained in:
parent
87c8120bd7
commit
3e83d03bce
1 changed files with 5 additions and 5 deletions
|
@ -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();
|
||||
|
@ -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' );
|
||||
|
|
Loading…
Reference in a new issue