Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added copy url button #8806

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions openlibrary/macros/ShareModal.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@
</a>
<div class="share-source">$_('Embed')</div>
</li>

<li>
<a class="copy-url-btn" title="$_('Copy url to clipboard')" data-ol-link-track="Share|CopyURL">
<img
alt="$_('Copy URL icon')"
class="share-link"
src="$static_url('images/copy_url.png')"
loading="lazy"
>
</a>
<div class="share-source">$_('Copy URL')</div>
</li>

</ul>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions openlibrary/plugins/openlibrary/js/modals/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@ import { FadingToast } from '../Toast.js';
import '../../../../../static/css/components/metadata-form.less';


/**
* Initializes share modal.
*/
export function initShareModal($modalLinks) {
addClickListeners($modalLinks, '400px');
addShareModalButtonListeners();
}
/**
* Adds click listeners to buttons in all notes modals on a page.
*/
Comment on lines +12 to +14
Copy link
Collaborator

@jimchamp jimchamp Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Adds click listeners to buttons in all notes modals on a page.
*/
/**
* Adds click listener which copies the current page's URL to the clipboard.
*/

function addShareModalButtonListeners (){
$('#social-modal-content .copy-url-btn').on('click', function(event){
event.preventDefault();
navigator.clipboard.writeText(window.location.href);
showToast('URL copied to clipboard')
$.colorbox.close()
})
}

/**
Expand Down
Binary file added static/images/copy_url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading