mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
clipboard: removed jquery #224
this was an unsuccessful attempt to fix #224 but as we want to get rid of jQuery in the long run anyways, we keep this change
This commit is contained in:
parent
e4e6e2d187
commit
8c7896af4c
1 changed files with 9 additions and 6 deletions
|
@ -95,19 +95,22 @@ function initMermaid() {
|
|||
}
|
||||
|
||||
function initAnchorClipboard(){
|
||||
var clip = new ClipboardJS('.anchor');
|
||||
$("h1~h2,h1~h3,h1~h4,h1~h5,h1~h6").append(function(index, html){
|
||||
var element = $(this);
|
||||
document.querySelectorAll( 'h1~h2,h1~h3,h1~h4,h1~h5,h1~h6').forEach( function( element ){
|
||||
var url = encodeURI(document.location.origin + document.location.pathname);
|
||||
var link = url + "#"+element[0].id;
|
||||
var html = " " + $( '<span>' ).addClass("anchor").attr("title", window.T_Copy_link_to_clipboard).attr("data-clipboard-text", link).append("<i class='fas fa-link fa-lg'></i>").get(0).outerHTML;
|
||||
return html;
|
||||
var link = url + "#"+element.id;
|
||||
var new_element = document.createElement( 'span' );
|
||||
new_element.classList.add( 'anchor' );
|
||||
new_element.setAttribute( 'title', window.T_Copy_link_to_clipboard );
|
||||
new_element.setAttribute( 'data-clipboard-text', link );
|
||||
new_element.innerHTML = '<i class="fas fa-link fa-lg"></i>';
|
||||
element.append( new_element );
|
||||
});
|
||||
|
||||
$(".anchor").on('mouseleave', function(e) {
|
||||
$(this).attr('aria-label', null).removeClass('tooltipped tooltipped-s tooltipped-w');
|
||||
});
|
||||
|
||||
var clip = new ClipboardJS('.anchor');
|
||||
clip.on('success', function(e) {
|
||||
e.clearSelection();
|
||||
$(e.trigger).attr('aria-label', window.T_Link_copied_to_clipboard).addClass('tooltipped tooltipped-s');
|
||||
|
|
Loading…
Reference in a new issue