Skip to content
Draft
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
19 changes: 18 additions & 1 deletion src/js/23-page-format-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
;(() => {
'use strict'

const pushCtaLink = (clickText, clickUrl) => {
const h1 = document.querySelector('h1')
window.dataLayer = window.dataLayer || []
window.dataLayer.push({
event: 'content_click',
clickText,
itemTitle: h1 ? h1.textContent.trim() : document.title,
clickUrl,
elementType: 'link',
contentType: 'Page Options Dropdown',
})
}

const dropdowns = document.querySelectorAll('.page-options-dropdown')
if (!dropdowns.length) return

Expand Down Expand Up @@ -115,9 +128,11 @@
theme: 'copy-link-popover',
zIndex: 'var(--z-nav-mobile)',
})
}

// Primary button directly copies
if (primaryBtn) {
primaryBtn.addEventListener('click', () => {
pushCtaLink(primaryBtn.textContent.trim(), mdUrl)
copyMd()
})
}
Expand All @@ -126,6 +141,7 @@
const menuCopyBtn = optionsPanel.querySelector('[data-action="copy-md"]')
if (menuCopyBtn) {
menuCopyBtn.addEventListener('click', () => {
pushCtaLink(menuCopyBtn.textContent.trim(), mdUrl)
copyMd()
closeMenu(true)
})
Expand Down Expand Up @@ -182,6 +198,7 @@
// Close after clicking a link item
optionsPanel.querySelectorAll('a[role="menuitem"]').forEach((link) => {
link.addEventListener('click', () => {
pushCtaLink(link.textContent.trim(), link.href)
closeMenu(false)
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/partials/page-actions-dropdown.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="page-options-menu-group" role="group">
<a role="menuitem" tabindex="-1" data-action="view-md" rel="noopener" target="_blank">View as Markdown <img class="external-link-image" src="{{@root.uiRootPath}}/img/icons/external-link.svg" alt="" aria-hidden="true"><span class="sr-only">(opens in new tab)</span></a>
{{#if (or preview (and (ne (site-profile) "archive") (or (and page.fileUri (not env.CI)) (and page.editUrl (not page.origin.private))))) }}
<a role="menuitem" tabindex="-1" rel="noopener" target="_blank"
<a role="menuitem" tabindex="-1" data-action="view-github" rel="noopener" target="_blank"
{{#if (and page.fileUri (not env.CI))}}
href="{{page.fileUri}}"
{{else}}
Expand Down
Loading