diff --git a/static/css/theme.css b/static/css/theme.css index ed8d1b8931..82005f0f16 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -671,7 +671,7 @@ code { white-space: nowrap; } -.copy-to-clipboard { +span.copy-to-clipboard { display: inline-block; } diff --git a/static/js/theme.js b/static/js/theme.js index f60a24cd3b..865dfc3fde 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -368,9 +368,15 @@ jQuery(function() { } var parent = code.parent(); + var inPre = parent.prop('tagName') == 'PRE'; code.addClass('copy-to-clipboard-code'); - code.replaceWith($('', {'class': 'copy-to-clipboard'}).append(code.clone() )); - code = parent.children('.copy-to-clipboard').last().children('.copy-to-clipboard-code'); + if( inPre ){ + parent.addClass( 'copy-to-clipboard' ); + } + else{ + code.replaceWith($('', {'class': 'copy-to-clipboard'}).append(code.clone() )); + code = parent.children('.copy-to-clipboard').last().children('.copy-to-clipboard-code'); + } code.after( $('').addClass("copy-to-clipboard-button").attr("title", window.T_Copy_to_clipboard).append("") ); code.next('.copy-to-clipboard-button').on('mouseleave', function() { $(this).attr('aria-label', null).removeClass('tooltipped tooltipped-s tooltipped-w');