Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a56e934
loading the launch script eagerly
kmurugulla Jan 22, 2025
ffa4d87
loading the launch script before eager
kmurugulla Jan 22, 2025
fb07587
loading martech lazily
kmurugulla Jan 22, 2025
551f555
loading eagerly
kmurugulla Jan 22, 2025
b3510d6
loading martech eagerly
kmurugulla Jan 22, 2025
28d9e05
loading the martech after main element added in eager phase
kmurugulla Jan 22, 2025
50f870f
loading martech lazily
kmurugulla Jan 24, 2025
b63e017
test: not loading the analytics-lib.js
kmurugulla Jan 27, 2025
aa54dc2
Adding individual martech lib files, creating an instance and setting…
kmurugulla Jan 27, 2025
f3589e5
fix: the scope of analyticsInstance to window
kmurugulla Jan 27, 2025
b5877f1
fix: adding instance function to window object
kmurugulla Jan 27, 2025
b92c360
reading analytics instance from global context window object
kmurugulla Jan 27, 2025
50242e3
fix: reading analyticsInstance from window in calendar and search
kmurugulla Jan 27, 2025
e3b2e2f
adding sample code to instantiate analytics instance
kmurugulla Jan 27, 2025
dcd6f5d
reverting to a version that was working but reading analytics instanc…
kmurugulla Jan 27, 2025
bd597e3
removing the creation of proxy object
kmurugulla Jan 28, 2025
4d93334
adding the logic to track modal open, close events
kmurugulla Jan 28, 2025
9f101fa
adding default value for modal name as modal
kmurugulla Jan 28, 2025
8145f6d
adding default value for modal name as modal and setting it to fragme…
kmurugulla Jan 28, 2025
6be6762
loading the martech as first thing before page loads
kmurugulla Jan 28, 2025
5935e27
reading the analytics function from window object
kmurugulla Jan 28, 2025
8ab251d
adding martech loading to head.html
kmurugulla Jan 28, 2025
5cfa440
removing unused code to load martech stack from scripts
kmurugulla Jan 28, 2025
4316785
loading launch script as regular script and not module
kmurugulla Jan 28, 2025
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
12 changes: 8 additions & 4 deletions aemedge/blocks/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import {
buildBlock, decorateBlock, decorateIcons, loadBlock, loadCSS,
} from '../../scripts/aem.js';

// const getAnalyticsInstance = window.analyticsInstance;
const analytics = window.analyticsInstance('modal');
// This is not a traditional block, so there is no decorate function. Instead, links to
// a */modals/* path are automatically transformed into a modal. Other blocks can also use
// the createModal() and openModal() functions.

let modalName = 'modal';
export async function createModal(contentNodes) {
await loadCSS(`${window.hlx.codeBasePath}/blocks/modal/modal.css`);
const dialog = document.createElement('dialog');
Expand Down Expand Up @@ -37,9 +39,10 @@ export async function createModal(contentNodes) {
decorateBlock(block);
await loadBlock(block);
decorateIcons(closeButton);

dialog.addEventListener('close', () => {
document.body.classList.remove('modal-open');
modalName = document.querySelector('.modal-content')?.querySelector('h1,h2,h3,h4,h5,h6')?.innerText || modalName;
analytics.modalClose({ name: modalName });
block.remove();
});

Expand All @@ -51,8 +54,9 @@ export async function createModal(contentNodes) {
// Google Chrome restores the scroll position when the dialog is reopened,
// so we need to reset it.
setTimeout(() => { dialogContent.scrollTop = 0; }, 0);

document.body.classList.add('modal-open');
modalName = document.querySelector('.modal-content')?.querySelector('h1,h2,h3,h4,h5,h6')?.innerText || modalName;
analytics.modalOpen({ name: modalName });
},
};
}
Expand All @@ -61,7 +65,7 @@ export async function openModal(fragmentUrl) {
const path = fragmentUrl.startsWith('http')
? new URL(fragmentUrl, window.location).pathname
: fragmentUrl;

modalName = path;
const fragment = await loadFragment(path);
const { showModal } = await createModal(fragment.childNodes);
showModal();
Expand Down
24 changes: 0 additions & 24 deletions aemedge/scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
// eslint-disable-next-line import/no-cycle

const loadScript = async (url, attrs) => {
const head = document.querySelector('head');
const script = document.createElement('script');
script.src = url;
if (attrs) {
// eslint-disable-next-line no-restricted-syntax, guard-for-in
for (const attr in attrs) {
script.setAttribute(attr, attrs[attr]);
}
}
head.append(script);
return script;
};

await loadScript('/aemedge/scripts/sling-martech/analytics-lib.js');

if (window.location.host.startsWith('localhost')) {
await loadScript('https://assets.adobedtm.com/f4211b096882/26f71ad376c4/launch-b69ac51c7dcd-development.min.js');
} else if (window.location.host.startsWith('www.sling.com') || window.location.host.endsWith('.live')) {
await loadScript('https://assets.adobedtm.com/f4211b096882/26f71ad376c4/launch-c846c0e0cbc6.min.js');
} else if (window.location.host.endsWith('.page')) {
await loadScript('https://assets.adobedtm.com/f4211b096882/26f71ad376c4/launch-6367a8aeb307-staging.min.js');
}
Loading