-
AuthorPosts
-
August 12, 2024 at 4:45 pm #1464464
I need to create a small gallery to copy some URL codes. What is the best approach for this?
Simple example.
I create an icon or icon box with a clipboard button.
Hover over the clipboard icon button and it displays a tooltip that says “copy”.
Click the icon, it copies a text and it displays a tooltip with “copied”.
And then you can paste that wherever you need.Using a tooltip script (tooltip JS and jQuery) uses something like this.
<button type="button" class="btn btn-default btn-copy js-tooltip js-copy pull-right" data-toggle="tooltip" data-placement="bottom" data-copy="https://urltocopy.com/test/" title="Copy URL">
The idea is to create it without external stuff, just Enfold. If the button has to say copy, it is ok, the idea is to have a workaround.
Any suggestions?
August 13, 2024 at 5:25 am #1464499Hey peterolle,
Thank you for the inquiry.
If I understand correctly, you wanted to copy the value of the data-copy attribute when the button is clicked? If so, you can try this html:
<button type="button" class="btn btn-default btn-copy js-tooltip js-copy pull-right" data-toggle="tooltip" data-placement="bottom" data-copy="https://urltocopy.com/test/" title="Copy URL" onclick="var tempInput = document.createElement('textarea'); tempInput.value = this.getAttribute('data-copy'); document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); alert('URL copied to clipboard: ' + tempInput.value);"> Copy URL </button>
If you want to remove the notification, just delete this line:
alert('URL copied to clipboard: ' + tempInput.value);
Best regards,
IsmaelAugust 13, 2024 at 5:10 pm #1464545Thank you Ismael.
Is there a way to use Enfold elements for this?
Like icon box, buttons, etc…August 14, 2024 at 4:50 am #1464574Hi,
Thank you for the update.
The implementation above relies on the “data-copy” attribute, which cannot be added to any builder elements. You may need to manually copy the HTML into a code or text block. If you need it to look like a default builder button, you can try this html:
<div class="avia-button-wrap avia-button-center"> <a href="javascript:void(0);" class="avia-button av-lzt94u23-6a241e487832b9aa657eb8d56d62aa80 av-link-btn avia-icon_select-yes-left-icon avia-size-small avia-position-center avia-color-theme-color btn-copy js-tooltip js-copy" data-toggle="tooltip" data-placement="bottom" data-copy="https://urltocopy.com/test/" title="Copy URL" onclick="var tempInput = document.createElement('textarea'); tempInput.value = this.getAttribute('data-copy'); document.body.appendChild(tempInput); tempInput.select(); document.execCommand('copy'); document.body.removeChild(tempInput); alert('URL copied to clipboard: ' + tempInput.value);"> <span class="avia_button_icon avia_button_icon_left" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span> <span class="avia_iconbox_title">Click me</span> </a></div>
Best regards,
IsmaelAugust 15, 2024 at 4:57 pm #1464708Thank you Ismael.
Still testing to decide which one to use.
How can I change the music icon to a clipboard one or any other?
August 16, 2024 at 6:23 am #1464750Hi,
How can I change the music icon to a clipboard one or any other?
You can create a button with your preferred icon, then copy the value of the data-av_icon attribute. It may appear as a tilted rectangle, but it actually contains the character code for the icon.
<span class="avia_button_icon avia_button_icon_left" aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span>
Best regards,
IsmaelAugust 18, 2024 at 10:50 am #1464846It may appear as a tilted rectangle, but it actually contains the character code for the icon.
That was the confusion, thank you Ismael, you can mark this as solved.
-
AuthorPosts
- The topic ‘Tooltip with copy’ is closed to new replies.