<div class="efl-learner-profile-in-page-bookmark" data-behavior="in-page-bookmark" data-user-fan-id="123456" data-bookmark-page-id="" data-bookmark-category="Article">
<div class="efl-learner-profile-in-page-bookmark__wrapper">
<a class="efl-learner-profile-in-page-bookmark__download" href="/" tabindex="0" aria-label="download"></a>
<button class="efl-learner-profile-in-page-bookmark__link logged-in" aria-label="bookmark this page"><span>Bookmark</span></button>
<button class="efl-learner-profile-in-page-bookmark__share-button" aria-label="share this page"></button>
<div class="efl-learner-profile-in-page-bookmark__list hidden">
<p class="title" data-bookmark-title-add="Add to list" data-bookmark-title-remove="Remove bookmark from">Add to list</p>
<a class="bookmark-remove-all hidden" tabindex="0">Remove from all</a>
<div class="bookmark-list">
<div aria-checked="true" class="bookmark-list--item">
<input type="checkbox" id="checkbox--my-bookmark-list" value="My Bookmark list" class="">
<label for="checkbox--my-bookmark-list">My Bookmark list</label>
</div>
<div aria-checked="false" class="bookmark-list--item">
<input type="checkbox" id="checkbox--attacking-list" value="Attacking list" class="">
<label for="checkbox---attacking-list">Attacking list</label>
</div>
<div aria-checked="false" class="bookmark-list--item">
<input type="checkbox" id="checkbox--defending-list" value="Defending list" class="">
<label for="checkbox---defending-list">Defending list</label>
</div>
<div aria-checked="false" class="bookmark-list--item">
<input type="checkbox" id="checkbox--defending-list" value="coaching" class="">
<label for="checkbox---coaching">Coaching</label>
</div>
</div>
<a class="bookmark-create-list" tabindex="0">Create a new bookmark list</a>
<a class="bookmark-done">Done</a>
<a href="#" class="cta cta--primary view-all-bookmarks" tabindex="0">View all bookmarks</a>
</div>
<div class="efl-learner-profile-in-page-bookmark__share--popup hidden jump-to-hide">
<div class="efl-learner-profile__social-links__list">
<div>
<div class="copy" data-copied-text="Link Copied!" data-copy-url="http://www.google.co.uk/" role="button" aria-label="Copy link" tabindex="0">
<img src=/assets/example-content/learner-profile/copy.svg>
</div>
<p>Copy link</p>
</div>
<div>
<a href="#" aria-label="Facebook">
<img src=/assets/example-content/learner-profile/facebook.svg>
</a>
<p>Facebook</p>
</div>
<div>
<a href="#" aria-label="Twitter">
<img src=/assets/example-content/learner-profile/twitter.svg>
</a>
<p>Twitter</p>
</div>
<div>
<a href="#" aria-label="Linkedin">
<img src=/assets/example-content/learner-profile/linkedin.svg>
</a>
<p>Linkedin</p>
</div>
<div>
<a href="#" aria-label="Whatsapp">
<img src=/assets/example-content/learner-profile/whatsapp.svg>
</a>
<p>Whatsapp</p>
</div>
</div>
</div>
</div>
<div class="efl-learner-profile-in-page-bookmark__signin-popup hidden">
<h3><span class="jumpTohide">SIGN IN</span></h3>
<div class="popup-copy">
In order to bookmark this article, please Sign In or Create an EFL Account.
</div>
<a href="#" class="cta cta--primary in-page-bookmark-login" tabindex="0">Login</a>
<a href="#" class="cta cta--primary in-page-bookmark-signup" tabindex="0">Sign up</a>
</div>
<div class="efl-learner-profile__section efl-learner-profile-bookmark__popup hidden">
<div class="steps step1">
<div class="efl-learner-profile__section--header">
<h4 class="create-bookmark-list" data-create-heading="Create list" data-edit-heading="Rename list">Create list</h4>
</div>
<div class="efl-learner-profile-bookmark__popup--copy" data-create-text="Give your list a name, then select 'create'." data-update-text="Give your list a name, then select 'save'.">
Give your list a name, then select 'create'.
</div>
<div class="efl-learner-profile-bookmark__popup--form">
<label>List name</label>
<input type="text" placeholder="Prompt text" maxlength="100" class="bookmark-list-name" aria-label="list name" />
<p><span class="bookmark-list-name-count">0</span>/100</p>
<div class="bookmark-desc-wrapper hidden">
<label>List description</label>
<textarea placeholder="Prompt text" maxlength="500" class="bookmark-list-desc" aria-label="list description"></textarea>
<p><span class="bookmark-list-desc-count">0</span>/500</p>
</div>
<div class="bookmark-add-desc" role="button" tabindex="0" data-add-text="Optional - add list description" data-cancel-text="Cancel adding list description" aria-label="Optional - add list description">Optional - add list description</div>
<button class="cta cta--primary create-new-bookmark" aria-label="create new bookmark">
<span>create</span>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="20px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<rect x="0" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="8" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="16" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
</svg>
</button>
<button class="cta cta--primary edit-bookmark-list hidden" aria-label="save bookmark list">
<span>save</span>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="20px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<rect x="0" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="8" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="16" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
</svg>
</button>
<button class="cta cta--primary cancel-create-bookmark" aria-label="cancel create bookmark">cancel</button>
<input type="hidden" class="bookmark-list-article-link" value="/articles">
<input type="hidden" class="bookmark-list-session-link" value="/sessions">
</div>
</div>
<div class="steps step2 hidden">
<div class="efl-learner-profile__section--header">
<h4 class="exist">List already exists</h4>
</div>
<div class="efl-learner-profile__section--nocourse-copy">
The name you've chosen for this list already exists.
</div>
<button class="cta cta--primary edit-bookmark-name" aria-label="edit name bookmark">Edit name</button>
</div>
<div class="steps step3 hidden">
<div class="efl-learner-profile__section--header">
<h4 class="exist">Delete list</h4>
</div>
<div class="efl-learner-profile__section--nocourse-copy no-border">
Are you sure you want to delete this list?
</div>
<button class="cta cta--primary delete-bookmark-list" aria-label="yes, delete this list">
<span>Yes, delete this list</span>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="20px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<rect x="0" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="8" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
<rect x="16" y="10" width="4" height="10" fill="#fff" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
<animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite"></animate>
</rect>
</svg>
</button>
<button class="cta cta--primary cancel-bookmark-delete" aria-label="no, return to list">no, return to list</button>
</div>
<div class="steps step4 hidden">
<div class="efl-learner-profile__section--header">
<h4 class="exist">Remove Bookmark</h4>
</div>
<div class="efl-learner-profile__section--nocourse-copy no-border">
Are you sure you want to remove this bookmark?
</div>
<button class="cta cta--primary remove-bookmark-item" aria-label="yes, remove bookmark item">Yes, remove this bookmark</button>
<button class="cta cta--primary cancel-remove-bookmark" aria-label="no, return to list">No, return to list</button>
</div>
<div class="steps step5 hidden">
<div class="efl-learner-profile__section--header">
<h4 class="exist">Innapropriate content</h4>
</div>
<div class="efl-learner-profile__section--nocourse-copy">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<button class="cta cta--primary error-bookmark-name" aria-label="edit name error bookmark">Edit name</button>
</div>
<div class="steps step6 hidden">
<div class="efl-learner-profile__section--header">
<h4 class="exist">Error</h4>
</div>
<div class="efl-learner-profile__section--nocourse-copy">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<button class="cta cta--primary server-error-bookmark" aria-label="try again bookmark">Try again</button>
</div>
</div>
</div>
No notes defined.
{
"view-all-bookmarks": {
"href": "#",
"copy": "View all bookmarks",
"additionalClass": "view-all-bookmarks"
},
"login-cta": {
"href": "#",
"copy": "Login",
"additionalClass": "in-page-bookmark-login"
},
"signup-cta": {
"href": "#",
"copy": "Sign up",
"additionalClass": "in-page-bookmark-signup"
},
"links": [
{
"image": "/assets/example-content/learner-profile/copy.svg",
"copy": "Copy link",
"copyLink": true
},
{
"image": "/assets/example-content/learner-profile/facebook.svg",
"copy": "Facebook"
},
{
"image": "/assets/example-content/learner-profile/twitter.svg",
"copy": "Twitter"
},
{
"image": "/assets/example-content/learner-profile/linkedin.svg",
"copy": "Linkedin"
},
{
"image": "/assets/example-content/learner-profile/whatsapp.svg",
"copy": "Whatsapp"
}
]
}
import { findPos } from '../efl-filter-bar/efl-filter-bar';
import { Dialog } from '../lightbox-overlay/lightbox-overlay';
export default parentElement => {
const DIALOG_ID = 'in-page-bookmark-signin';
const bookmarkCta = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__link'
);
const inPageshareCta = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__share-button'
);
const bookmarkAllCta = document.querySelectorAll(
'.efl-learner-profile-in-page-bookmark__link'
);
const MOBILE_BREAKPOINT = 820;
const craateBookmarkCta = parentElement.querySelector(
'.bookmark-create-list'
);
const removeFromAll = parentElement.querySelector('.bookmark-remove-all');
const bookmarkDone = parentElement.querySelector('.bookmark-done');
const checkbokDiv = parentElement.querySelector('.bookmark-list');
const { userFanId } = parentElement.dataset;
let bookmarkLink = decodeURI(window.location.pathname);
let bookmarkImage;
let bookmarkHeadline;
let bookmarkPageId;
let bookmarkCategory;
const inPageSharePopup = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__share--popup'
);
// eslint-disable-next-line
const jumpToSection = bookmarkCta.closest('.jump-to-section__actions') ? true : false;
bookmarkLink = bookmarkLink.replaceAll(' ', '-');
const generateLightBox = (labelId, popupType) => {
let popupClass;
let containerClass;
if (popupType === 'signin') {
popupClass = 'efl-learner-profile-in-page-bookmark__signin-popup';
containerClass = 'efl-learner-profile-in-page-bookmark';
} else {
popupClass = 'efl-learner-profile-bookmark__popup';
containerClass = 'efl-learner-profile';
}
const popupDiv = parentElement.querySelector(`.${popupClass}`);
let html = popupDiv.outerHTML;
html = html.replace(`${popupClass} hidden`, `${popupClass}`);
return `
<div role="dialog" id="${DIALOG_ID}" aria-labelledby="${labelId}" aria-modal="true" class="lightbox-overlay">
<div class="${containerClass}">
${html}
</div>
</div>`;
};
const removeLightBox = () => {
if (document.getElementById(DIALOG_ID)) {
document.getElementById(DIALOG_ID).remove();
}
};
const swithScreen = screen => {
const lightbox = document.querySelector(`#${DIALOG_ID}`);
const allSteps = lightbox.querySelectorAll('.steps');
const activeStep = lightbox.querySelector(`.${screen}`);
allSteps.forEach(steps => {
steps.classList.add('hidden');
});
activeStep.classList.remove('hidden');
};
const checkNameExist = name => {
const bookmarkLists = localStorage.getItem('bookmarkListData');
if (bookmarkLists) {
const bookmarkListJson = JSON.parse(bookmarkLists);
const bookmarkJson = [];
bookmarkListJson.eflBookmarks.forEach(bookmark => {
bookmarkJson.push(bookmark.tag);
});
if (bookmarkJson.includes(name)) {
return true;
}
}
return false;
};
const checkboxEvent = e => {
const isChecked = e.target.checked;
const bookmarkName = e.target.value;
// to sync other bookmark checkbox
const bookmarkAllItem = document.querySelectorAll('.bookmark-list--item');
bookmarkAllItem.forEach(checkboxItem => {
const checkbox = checkboxItem.querySelector('input[type=checkbox]');
if (e.target !== checkbox && e.target.value === checkbox.value) {
checkbox.checked = isChecked;
}
});
// console.log(bookmarkName);
// console.log(isChecked);
// eslint-disable-next-line no-use-before-define
updateBookmark(isChecked, bookmarkName);
};
async function updateBookmarkListCallback(bookmarklist) {
const url = `/Personalisation/UpdateUserBookmark`;
// eslint-disable-next-line compat/compat
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
body: JSON.stringify(bookmarklist),
});
return response.json();
}
function updateBookmarkList(updateBookmark) {
try {
// isAjaxRuning = true;
updateBookmarkListCallback(updateBookmark).then(response => {
console.log(response);
});
} catch (e) {
throw new Error('Unable to update player data ::', e);
}
}
function createBookmarkGroup(name, desc, saveButton) {
try {
// isAjaxRuning = true;
let oldBookmark = [];
let updateBookmark = [];
saveButton.classList.add('loading-bar');
saveButton.setAttribute('aria-disabled', 'true');
const newBookmarkDetail = `{
"tag": "${name}",
"description": "${desc}",
"bookmarks": []
}`;
if (localStorage.getItem('bookmarkListUpdateData')) {
oldBookmark = JSON.parse(localStorage.getItem('bookmarkListData'));
updateBookmark = JSON.parse(
localStorage.getItem('bookmarkListUpdateData')
);
const bookmarLength = oldBookmark.eflBookmarks.length;
oldBookmark.eflBookmarks[bookmarLength] = JSON.parse(newBookmarkDetail);
updateBookmark.eflBookmarks[bookmarLength] = JSON.parse(
newBookmarkDetail
);
} else {
const defaultBookmark = `{
"bookmark": {
"id": "${userFanId}",
"eflBookmarks": [${newBookmarkDetail}]
}
}`;
oldBookmark = JSON.parse(defaultBookmark);
updateBookmark = JSON.parse(defaultBookmark);
}
updateBookmarkListCallback(updateBookmark).then(response => {
if (
response &&
response.FAIWFResponse &&
response.FAIWFResponse.IsAbusive
) {
swithScreen('step5');
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
} else if (response && !response.FAIWFResponse && response.Error) {
swithScreen('step6');
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
} else {
localStorage.setItem('bookmarkListData', JSON.stringify(oldBookmark));
localStorage.setItem(
'bookmarkListUpdateData',
JSON.stringify(updateBookmark)
);
// eslint-disable-next-line no-useless-escape
let idName = name.replace(/[&\/\\#,+()$~%.'":*?<>{}\s]/g, '-');
idName = idName.replaceAll(' ', '-');
const item = `<div aria-checked="false" class="bookmark-list--item">
<input type="checkbox" id="checkbox--${idName}" value="${name}" class="">
<label for="checkbox---${idName}">${name}</label>
</div>`;
const bookmarkList = parentElement.querySelector('.bookmark-list');
const allPageBookmarkList = document.querySelectorAll(
'[data-behavior="in-page-bookmark"]'
);
bookmarkList.insertAdjacentHTML('beforeend', item);
const checkBox = bookmarkList.querySelector(`#checkbox--${idName}`);
checkBox.addEventListener('click', event => {
checkboxEvent(event);
});
allPageBookmarkList.forEach(inPageBookmark => {
if (parentElement !== inPageBookmark) {
const otherBookmarkList = inPageBookmark.querySelector(
'.bookmark-list'
);
otherBookmarkList.insertAdjacentHTML('beforeend', item);
const otherCheckBox = otherBookmarkList.querySelector(
`#checkbox--${idName}`
);
otherCheckBox.addEventListener('click', event => {
checkboxEvent(event);
});
}
});
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
removeLightBox();
}
});
} catch (e) {
throw new Error('Unable to update player data ::', e);
}
}
async function getBookmarkIdCallback() {
const url = `/Personalisation/GetBookmarkItemId?urlPath=${bookmarkLink}`;
// eslint-disable-next-line compat/compat
const response = await fetch(url, {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
});
return response.json();
}
function getBookmarkId() {
try {
// isAjaxRuning = true;
localStorage.setItem('bookmarkPageDetails', '');
getBookmarkIdCallback().then(response => {
if (response) {
localStorage.setItem(
'bookmarkPageDetails',
JSON.stringify(response.bookmark.results[0])
);
// console.log(bookmarkPageId);
}
});
} catch (e) {
throw new Error('Unable to update player data ::', e);
}
}
const initBookmarkCheckbox = () => {
const checkBoxs = checkbokDiv.querySelectorAll('input[type="checkbox"]');
checkBoxs.forEach(checkbox => {
checkbox.addEventListener('click', e => {
checkboxEvent(e);
});
});
};
const openLightbox = (focusBtn, popupType) => {
// Create the lightbox
const lightboxContainer = document.createElement('div');
lightboxContainer.innerHTML = generateLightBox(
{
labelId: focusBtn.getAttribute('id'),
},
popupType
);
document.body.appendChild(lightboxContainer);
let firstFocus;
if (popupType === 'signin') {
firstFocus = lightboxContainer.querySelector('.in-page-bookmark-login');
} else {
firstFocus = lightboxContainer.querySelector('input[type=text]');
}
// eslint-disable-next-line no-new
new Dialog({
dialogId: DIALOG_ID,
focusAfterClosed: focusBtn,
focusFirst: firstFocus,
closeCallBack: () => removeLightBox(),
});
const bookmarkDescCta = lightboxContainer.querySelector(
'.bookmark-add-desc'
);
const bookmarkDesc = lightboxContainer.querySelector(
'.bookmark-desc-wrapper'
);
const listName = lightboxContainer.querySelector('.bookmark-list-name');
const listCount = lightboxContainer.querySelector(
'.bookmark-list-name-count'
);
const listDesc = lightboxContainer.querySelector('.bookmark-list-desc');
const listDescCount = lightboxContainer.querySelector(
'.bookmark-list-desc-count'
);
const createCta = lightboxContainer.querySelector('.create-new-bookmark');
const cancelList = lightboxContainer.querySelector(
'.cancel-create-bookmark'
);
const editBookmarkCta = lightboxContainer.querySelector(
'.edit-bookmark-name'
);
const errorBookmarkCta = lightboxContainer.querySelector(
'.error-bookmark-name'
);
const serverErrorBookmarkCta = lightboxContainer.querySelector(
'.server-error-bookmark'
);
if (bookmarkDescCta) {
const { addText, cancelText } = bookmarkDescCta.dataset;
bookmarkDescCta.addEventListener('click', e => {
e.preventDefault();
bookmarkDesc.classList.toggle('hidden');
if (bookmarkDesc.classList.contains('hidden')) {
bookmarkDescCta.innerText = addText;
} else {
bookmarkDescCta.innerText = cancelText;
listDesc.value = '';
}
});
}
if (listName) {
listName.addEventListener('input', e => {
listCount.innerHTML = `${e.target.value.length}/100`;
});
}
if (listDesc) {
listDesc.addEventListener('input', e => {
listDescCount.innerHTML = `${e.target.value.length}/500`;
});
}
if (createCta) {
createCta.addEventListener('click', e => {
e.preventDefault();
if (
!listName.value ||
e.target.getAttribute('aria-disabled') === 'true'
) {
return;
}
if (checkNameExist(listName.value)) {
swithScreen('step2');
} else {
createBookmarkGroup(listName.value, listDesc.value, createCta);
}
});
}
if (cancelList) {
cancelList.addEventListener('click', e => {
e.preventDefault();
removeLightBox();
});
}
if (editBookmarkCta) {
editBookmarkCta.addEventListener('click', e => {
e.preventDefault();
swithScreen('step1');
});
}
if (errorBookmarkCta) {
errorBookmarkCta.addEventListener('click', e => {
e.preventDefault();
swithScreen('step1');
});
}
if (serverErrorBookmarkCta) {
serverErrorBookmarkCta.addEventListener('click', e => {
e.preventDefault();
swithScreen('step1');
});
}
};
const updatePageBookmark = (bookmarkName, type) => {
const bookmarkPageDetails = JSON.parse(
localStorage.getItem('bookmarkPageDetails')
);
bookmarkPageId = bookmarkPageDetails.itemId;
bookmarkCategory = bookmarkPageDetails.categoryTagName;
bookmarkHeadline = bookmarkPageDetails.bookmarkHeadline;
bookmarkLink = bookmarkPageDetails.bookmarkLink;
bookmarkImage = bookmarkPageDetails.bookmarkImage;
const BookmarkItem = `{
"pageId": "${bookmarkPageId}"
}`;
const BookmarkItem2 = `{
"pageId": "${bookmarkPageId}",
"bookmarkHeadline": "${bookmarkHeadline}",
"categoryTagName": "${bookmarkCategory}",
"bookmarkImage": "${bookmarkImage}",
"bookmarkLink": "${bookmarkLink}"
}`;
const oldBookmark = JSON.parse(localStorage.getItem('bookmarkListData'));
const updateBookmark = JSON.parse(
localStorage.getItem('bookmarkListUpdateData')
);
const eflBookmarkList = oldBookmark.eflBookmarks;
eflBookmarkList.forEach((eflBookmark, index) => {
if (
eflBookmark.tag === bookmarkName ||
(bookmarkName.toLowerCase() === 'my bookmark list' &&
eflBookmark.tag === '')
) {
if (type === 'add') {
const eflBookmarkLength = eflBookmark.bookmarks.length;
// eslint-disable-next-line no-param-reassign
eflBookmark.bookmarks[eflBookmarkLength] = JSON.parse(BookmarkItem2);
oldBookmark.eflBookmarks[index].bookmarks[
eflBookmarkLength
] = JSON.parse(BookmarkItem2);
updateBookmark.eflBookmarks[index].bookmarks[
eflBookmarkLength
] = JSON.parse(BookmarkItem);
localStorage.setItem('bookmarkListData', JSON.stringify(oldBookmark));
localStorage.setItem(
'bookmarkListUpdateData',
JSON.stringify(updateBookmark)
);
updateBookmarkList(updateBookmark);
bookmarkAllCta.forEach(bookmarkSingle => {
bookmarkSingle.classList.add('active');
});
} else if (type === 'remove') {
oldBookmark.eflBookmarks[index].bookmarks.forEach((bookmak, i) => {
if (bookmak.pageId === bookmarkPageId) {
oldBookmark.eflBookmarks[index].bookmarks.splice(i, 1);
updateBookmark.eflBookmarks[index].bookmarks.splice(i, 1);
localStorage.setItem(
'bookmarkListData',
JSON.stringify(oldBookmark)
);
localStorage.setItem(
'bookmarkListUpdateData',
JSON.stringify(updateBookmark)
);
updateBookmarkList(updateBookmark);
}
});
}
}
});
};
const updateBookmark = (isChecked, bookmarkName) => {
if (isChecked) {
updatePageBookmark(bookmarkName, 'add');
} else {
updatePageBookmark(bookmarkName, 'remove');
const checkBoxs = checkbokDiv.querySelectorAll('input[type="checkbox"]');
let checkFlag = false;
checkBoxs.forEach(checkbox => {
if (checkbox.checked) {
checkFlag = true;
}
});
if (!checkFlag) {
bookmarkAllCta.forEach(bookmarkSingle => {
bookmarkSingle.classList.remove('active');
});
}
}
};
const limitToolTipHeight = toolTip => {
// Limit height of desktop ToolTip within document height
if (jumpToSection && window.innerWidth > MOBILE_BREAKPOINT) {
const bottomOfElementOnScreen =
findPos(parentElement) +
parentElement.clientHeight +
toolTip.clientHeight;
const designMargin = 22;
const overlap = bottomOfElementOnScreen - window.innerHeight;
const calculatedHeight = toolTip.clientHeight - overlap - designMargin;
// flip pop-up if it gets too small
if (calculatedHeight < 180) {
// eslint-disable-next-line
toolTip.style.maxHeight = null;
toolTip.classList.add('flipped');
} else {
// eslint-disable-next-line
toolTip.style.maxHeight = `${calculatedHeight}px`;
toolTip.classList.remove('flipped');
}
// toolTip.style.maxHeight = `${calculatedHeight}px`;
}
};
const updateToolTip = event => {
const toolTipWrapper = event.target.closest(
'.efl-learner-profile-in-page-bookmark__wrapper'
);
const toolTip = toolTipWrapper.querySelector(
'.efl-learner-profile-in-page-bookmark__list'
);
const { bookmarkTitleAdd, bookmarkTitleRemove } = toolTip.querySelector(
'.title'
).dataset;
const removeAllCta = toolTip.querySelector('.bookmark-remove-all');
const createCta = toolTip.querySelector('.bookmark-create-list');
const doneCta = toolTip.querySelector('.bookmark-done');
if (jumpToSection) {
document.querySelector('.jump-to-section__actions').style.overflow =
'visible';
document.querySelector('.jump-to-section__social-links').style.display =
'none';
}
if (!bookmarkCta.classList.contains('active')) {
// bookmarkCta.classList.toggle('active');
toolTip.querySelector('.title').innerText = bookmarkTitleAdd;
removeAllCta.classList.add('hidden');
createCta.classList.remove('hidden');
doneCta.classList.remove('update-bookmark');
} else {
toolTip.querySelector('.title').innerText = bookmarkTitleRemove;
removeAllCta.classList.remove('hidden');
createCta.classList.add('hidden');
doneCta.classList.add('update-bookmark');
}
toolTip.classList.remove('hidden');
toolTip.removeAttribute('style');
limitToolTipHeight(toolTip);
};
const initBookmark = () => {
if (window.innerWidth >= MOBILE_BREAKPOINT) {
if (bookmarkCta) {
bookmarkCta.addEventListener('click', e => {
e.preventDefault();
if (bookmarkCta.classList.contains('logged-in')) {
updateToolTip(e);
} else {
openLightbox(bookmarkCta, 'signin');
}
});
document.addEventListener('click', e => {
if (
!(
e.target.closest('.efl-learner-profile-in-page-bookmark__list') ||
e.target.closest('.efl-learner-profile-in-page-bookmark__link')
)
) {
parentElement
.querySelector('.efl-learner-profile-in-page-bookmark__list')
.classList.add('hidden');
if (jumpToSection) {
document.querySelector(
'.jump-to-section__actions'
).style.overflow = '';
document.querySelector(
'.jump-to-section__social-links'
).style.display = '';
}
}
});
bookmarkCta.addEventListener('keydown', e => {
if (e.keyCode === 13) {
e.preventDefault();
if (bookmarkCta.classList.contains('logged-in')) {
updateToolTip(e);
if (!bookmarkCta.classList.contains('active')) {
parentElement
.querySelector(
'.efl-learner-profile-in-page-bookmark__list input[type=checkbox]'
)
.focus();
} else {
removeFromAll.focus();
}
} else {
openLightbox(bookmarkCta, 'signin');
}
}
});
}
} else {
// eslint-disable-next-line no-lonely-if
if (bookmarkCta) {
bookmarkCta.addEventListener('click', e => {
e.preventDefault();
if (bookmarkCta.classList.contains('logged-in')) {
if (!jumpToSection) {
if (window.innerWidth < MOBILE_BREAKPOINT) {
parentElement.classList.add('efl-profile-dark-overlay');
document.body.style.overflow = 'hidden';
}
}
updateToolTip(e);
setTimeout(() => {
const toolTipWrapper = e.target.closest(
'.efl-learner-profile-in-page-bookmark__wrapper'
);
const toolTip = toolTipWrapper.querySelector(
'.efl-learner-profile-in-page-bookmark__list'
);
toolTip.classList.add('add-animation');
if (document.querySelector('.efl-page-content__tray')) {
document
.querySelector('.efl-page-content__tray')
.classList.add('page-bookmark');
}
}, 50);
} else {
openLightbox(bookmarkCta, 'signin');
}
});
document.addEventListener('click', e => {
if (
!(
e.target.closest('.efl-learner-profile-in-page-bookmark__list') ||
e.target.closest('.efl-learner-profile-in-page-bookmark__link')
)
) {
const tooltip = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__list'
);
if (tooltip) {
if (document.querySelector('.efl-page-content__tray')) {
document
.querySelector('.efl-page-content__tray')
.classList.remove('page-bookmark');
}
tooltip.classList.remove('add-animation');
setTimeout(() => {
tooltip.classList.add('hidden');
if (!jumpToSection) {
parentElement.classList.remove('efl-profile-dark-overlay');
document.body.removeAttribute('style');
}
}, 300);
}
}
});
}
}
};
if (craateBookmarkCta) {
craateBookmarkCta.addEventListener('click', e => {
e.preventDefault();
openLightbox(craateBookmarkCta, 'createbookmark');
});
craateBookmarkCta.addEventListener('keydown', e => {
if (e.keyCode === 13) {
e.preventDefault();
openLightbox(craateBookmarkCta, 'createbookmark');
}
});
}
const removeAllBookmark = () => {
const checkboxes = parentElement
.querySelector('.bookmark-list')
.querySelectorAll('[type="checkbox"]');
checkboxes.forEach(checkbox => {
const bookmarkName = checkbox.value;
// eslint-disable-next-line no-param-reassign
checkbox.checked = false;
checkbox.removeAttribute('checked');
checkbox.closest('div').setAttribute('aria-checked', 'false');
updatePageBookmark(bookmarkName, 'remove');
});
bookmarkAllCta.forEach(bookmarkSingle => {
bookmarkSingle.classList.remove('active');
});
};
if (removeFromAll) {
removeFromAll.addEventListener('click', e => {
e.preventDefault();
removeAllBookmark();
});
removeFromAll.addEventListener('keydown', e => {
if (e.keyCode === 13) {
e.preventDefault();
removeAllBookmark();
}
});
}
if (bookmarkDone) {
bookmarkDone.addEventListener('click', e => {
e.preventDefault();
const tooltip = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__list'
);
if (document.querySelector('.efl-page-content__tray')) {
document
.querySelector('.efl-page-content__tray')
.classList.remove('page-bookmark');
}
tooltip.classList.remove('add-animation');
setTimeout(() => {
tooltip.classList.add('hidden');
if (!jumpToSection) {
parentElement.classList.remove('efl-profile-dark-overlay');
document.body.removeAttribute('style');
}
}, 300);
});
}
if (inPageshareCta) {
inPageshareCta.addEventListener('click', e => {
e.preventDefault();
if (window.innerWidth >= MOBILE_BREAKPOINT) {
if (inPageSharePopup) {
inPageSharePopup.classList.toggle('hidden');
}
} else {
if (!navigator.share) {
return;
}
navigator
.share({
title: document.title,
url: window.location.href,
})
.catch(console.error);
}
});
}
document.addEventListener('click', e => {
if (
!(
e.target.closest(
'.efl-learner-profile-in-page-bookmark__share-button'
) ||
e.target.closest('.efl-learner-profile-in-page-bookmark__share--popup')
)
) {
if (inPageSharePopup) {
inPageSharePopup.classList.add('hidden');
}
}
});
window.addEventListener('scroll', () => {
const toolTip = parentElement.querySelector(
'.efl-learner-profile-in-page-bookmark__list'
);
limitToolTipHeight(toolTip);
});
initBookmark();
getBookmarkId();
initBookmarkCheckbox();
};
.efl-learner-profile-in-page-bookmark {
span {
display: none;
}
&__wrapper {
position: absolute;
top: 0;
right: 3.2rem;
display: flex;
}
&__download {
background: url('./assets/images/session-download.svg') no-repeat center;
width: 3.4rem;
height: 3.4rem;
cursor: pointer;
margin-right: 0.8rem;
border-radius: 50%;
background-size: contain;
display: none;
}
&__link {
background: url('./assets/images/global-bookmark.svg') no-repeat center;
width: 3.4rem;
height: 3.4rem;
display: flex;
cursor: pointer;
border-radius: 50%;
border: none;
padding: 0;
&:hover {
background-color: $light-blue;
}
&.active {
background-image: url('./assets/images/global-bookmark-active.svg');
}
}
&__share-button {
display: flex;
align-items: center;
border: none;
background-color: transparent;
text-decoration: none;
font-size: 16px;
font-weight: 700;
line-height: 1.6rem;
letter-spacing: 0.14em;
color: $color-interface-light;
text-transform: uppercase;
cursor: pointer;
padding: 0;
margin-left: 0.8rem;
&::before {
content: '';
display: block;
width: 3.4rem;
height: 3.4rem;
margin-right: 0.9rem;
border: 0.2rem solid $light-blue;
border-radius: 100%;
background-image: url('./assets/images/jump-to-section-share.svg');
background-repeat: no-repeat;
background-position: center;
}
&:hover {
color: $blue;
&::before {
background-color: $light-blue;
}
}
span {
display: block;
}
}
&__share {
&--popup {
position: fixed;
display: flex;
background: white;
flex-direction: column;
border-radius: 2.4rem 2.4rem 0 0;
padding: 3.2rem;
bottom: -30rem;
left: 0;
width: 100%;
z-index: 110;
transition: bottom 0.3s ease-in-out;
&.add-animation {
bottom: 0;
}
&::before {
content: '';
position: absolute;
width: 6.4rem;
height: 0.3rem;
background-color: $color-interface-light;
left: calc(50% - 3.2rem);
top: 0.8rem;
}
}
}
&__list {
position: fixed;
display: flex;
background: $white;
flex-direction: column;
border-radius: 2.4rem 2.4rem 0 0;
padding: 3.2rem 2rem 1.6rem 4rem;
bottom: -80vh;
left: 0;
width: 100%;
z-index: 110;
transition: bottom 0.3s ease-in-out;
max-height: 80vh;
&.add-animation {
bottom: 0;
}
p {
@extend .efl-p-medium;
font-weight: 700;
color: $blue;
margin-bottom: 2.4rem;
}
a {
@extend .efl-p-medium;
font-weight: 700;
color: $blue !important;
display: flex;
align-items: center;
text-decoration: none;
cursor: pointer;
}
&::before {
content: '';
position: absolute;
width: 6.4rem;
height: 0.3rem;
background-color: $color-interface-light;
left: calc(50% - 3.2rem);
top: 0.8rem;
}
.bookmark-list {
@include efl-scrollbar();
display: flex;
flex-direction: column;
overflow-y: scroll;
max-height: 100%;
&--item {
padding-bottom: 1.6rem;
margin-bottom: 1.6rem;
border-bottom: 1px solid $grey-light;
display: flex;
align-items: center;
label {
@extend .efl-p-medium;
font-weight: 700;
color: $blue;
}
input[type='checkbox'] {
background: url('./assets/images/profile-icons/checkbox.svg')
no-repeat center;
width: 2.4rem;
height: 2.4rem;
flex-shrink: 0;
appearance: none;
-webkit-appearance: none;
margin: 0;
margin-right: 0.8rem;
&:checked {
background-image: url('./assets/images/profile-icons/checkbox-checked.svg');
}
}
}
}
.bookmark-remove-all {
text-decoration: underline;
padding-bottom: 1.6rem;
margin-bottom: 1.6rem;
border-bottom: 1px solid $grey-light;
}
.bookmark-create-list {
text-decoration: underline;
margin-bottom: 2.4rem;
border-bottom: none;
&::before {
content: '';
background: url('./assets/images/profile-icons/plus-icon-blue.svg')
no-repeat center;
width: 2.4rem;
height: 2.4rem;
display: flex;
margin-right: 0.9rem;
}
}
.view-all-bookmarks {
font-weight: 400;
font-size: 1.4rem;
letter-spacing: 0.02em;
color: $blue !important;
background: none;
text-decoration: none;
border: none;
min-height: 2.4rem;
max-width: 100%;
}
.bookmark-done {
border: 0.2rem solid $light-blue;
border-radius: 0.2rem;
height: 5.2rem;
text-decoration: none;
justify-content: center;
padding: 0 50%;
margin-bottom: 2rem;
}
}
&__signin-popup {
display: flex;
flex-direction: column;
gap: 1.6rem;
background: $white;
box-shadow: 0 0 16px rgba(0, 0, 0, 0.4);
border-radius: 8px;
padding: 2.4rem;
h3 {
@extend .efl-p-1;
font-weight: 700;
letter-spacing: 0.16em;
text-transform: uppercase;
display: flex;
align-items: center;
margin-bottom: 0 !important;
&::before {
content: '';
background-image: url('./assets/images/profile-icons/about-me.svg');
width: 1.8rem;
height: 1.8rem;
background-size: contain;
background-repeat: no-repeat;
display: inline-block;
margin-right: 0.8rem;
}
}
.popup-copy {
@extend .efl-p-medium;
color: $color-interface-light;
}
}
.cta {
&.in-page-bookmark-login {
background-color: $red;
border-color: transparent;
color: $white;
text-decoration: none;
max-width: 100%;
&:hover {
border-color: $red;
color: $red;
background-color: $white;
}
}
&.in-page-bookmark-signup {
min-width: 100%;
color: $blue;
text-decoration: none;
border-color: $light-blue;
background-color: $white;
&:hover {
border: none;
color: $blue;
background-color: $light-blue;
}
}
}
@media screen and (min-width: $mq-medium) {
&__list {
position: absolute;
right: 0;
box-shadow: 0 0 16px rgba(91, 104, 133, 0.36);
padding: 4rem;
top: 38px;
transform: translateX(43%);
min-width: 32.4rem;
width: initial;
left: initial;
bottom: initial;
border-radius: 0;
max-height: 40rem;
min-height: 22rem;
&::before {
content: '';
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 15px solid white;
width: 30px;
position: absolute;
top: -15px;
left: calc(50% - 10px);
background-color: transparent;
height: auto;
}
&.flipped {
top: unset;
bottom: 38px;
&::before {
display: none;
}
&::after {
content: '';
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 15px solid white;
width: 30px;
position: absolute;
bottom: -12px;
left: calc(50% - 10px);
background-color: transparent;
height: auto;
}
}
p,
.bookmark-done {
display: none;
}
.bookmark-create-list {
padding-bottom: 1.6rem;
margin-bottom: 1.8rem;
border-bottom: 1px solid $grey-light;
}
}
&__link {
&.active + .efl-learner-profile-in-page-bookmark__list {
max-height: 45rem;
}
}
&__share {
&--popup {
position: absolute;
right: 0;
filter: drop-shadow(0 0 16px rgba(91, 104, 133, 0.37));
padding: 3.2rem;
top: 48px;
transform: translateX(43%);
min-width: 21.2rem;
width: initial;
left: initial;
bottom: initial;
border-radius: 0;
&::before {
content: '';
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 15px solid white;
width: 30px;
position: absolute;
top: -15px;
left: calc(50% - 10px);
background-color: transparent;
height: auto;
}
.efl-learner-profile__social-links__list {
display: flex;
gap: 1.6rem;
padding: 0;
margin: 0;
div {
display: flex;
align-items: center;
a,
.copy {
display: flex;
align-items: center;
justify-content: center;
width: 6.1rem;
height: 6.1rem;
border: 0.3rem solid $light-blue;
border-radius: 50%;
position: relative;
cursor: pointer;
img {
width: 3.1rem;
height: 3.1rem;
}
.canvas {
width: 3.1rem !important;
height: 3.1rem !important;
position: absolute;
top: 8px !important;
display: flex;
canvas {
width: 4rem !important;
height: 4rem !important;
}
&.transparent {
opacity: 0;
}
}
}
}
}
}
}
}
}
#in-page-bookmark-signin .efl-learner-profile-in-page-bookmark {
max-width: 32rem;
width: calc(100% - 4.8rem);
@media screen and (min-width: $mq-medium) {
max-width: 70.6rem;
}
}
#in-page-bookmark-signin .efl-learner-profile {
max-width: 70.6rem;
width: calc(100% - 1.6rem);
}
<div class="efl-learner-profile-in-page-bookmark" data-behavior="in-page-bookmark" data-user-fan-id="123456" data-bookmark-page-id="" data-bookmark-category="Article">
<div class="efl-learner-profile-in-page-bookmark__wrapper">
<a class="efl-learner-profile-in-page-bookmark__download" href="/" tabindex="0" aria-label="download"></a>
<button class="efl-learner-profile-in-page-bookmark__link logged-in" aria-label="bookmark this page"><span>Bookmark</span></button>
<button class="efl-learner-profile-in-page-bookmark__share-button" aria-label="share this page"></button>
<div class="efl-learner-profile-in-page-bookmark__list hidden">
<p class="title" data-bookmark-title-add="Add to list" data-bookmark-title-remove="Remove bookmark from">Add to list</p>
<a class="bookmark-remove-all hidden" tabindex="0">Remove from all</a>
<div class="bookmark-list">
<div aria-checked="true" class="bookmark-list--item" >
<input type="checkbox" id="checkbox--my-bookmark-list" value="My Bookmark list" class="">
<label for="checkbox--my-bookmark-list">My Bookmark list</label>
</div>
<div aria-checked="false" class="bookmark-list--item" >
<input type="checkbox" id="checkbox--attacking-list" value="Attacking list" class="">
<label for="checkbox---attacking-list">Attacking list</label>
</div>
<div aria-checked="false" class="bookmark-list--item" >
<input type="checkbox" id="checkbox--defending-list" value="Defending list" class="">
<label for="checkbox---defending-list">Defending list</label>
</div>
<div aria-checked="false" class="bookmark-list--item" >
<input type="checkbox" id="checkbox--defending-list" value="coaching" class="">
<label for="checkbox---coaching">Coaching</label>
</div>
</div>
<a class="bookmark-create-list" tabindex="0">Create a new bookmark list</a>
<a class="bookmark-done">Done</a>
{{render '@cta' view-all-bookmarks merge='true'}}
</div>
<div class="efl-learner-profile-in-page-bookmark__share--popup hidden jump-to-hide">
<div class="efl-learner-profile__social-links__list">
{{#each links}}
<div>
{{#if copyLink}}
<div class="copy" data-copied-text="Link Copied!" data-copy-url="http://www.google.co.uk/" role="button"
aria-label="Copy link" tabindex="0">
<img src={{image}}>
</div>
{{/if}}
{{#unless copyLink}}
<a {{#if linkedIn}} class="linkedin" {{/if}} href="#" aria-label="{{copy}}">
<img src={{image}}>
</a>
{{/unless}}
<p>{{copy}}</p>
</div>
{{/each}}
</div>
</div>
</div>
<div class="efl-learner-profile-in-page-bookmark__signin-popup hidden">
<h3><span class="jumpTohide">SIGN IN</span></h3>
<div class="popup-copy">
In order to bookmark this article, please Sign In or Create an EFL Account.
</div>
{{render '@cta' login-cta merge='true'}}
{{render '@cta' signup-cta merge='true'}}
</div>
{{render '@efl-learner-profile-create-bookmark'}}
</div>