<section aria-expanded="true" class="efl-learner-profile__section" data-behavior="efl-learner-profile-about-me">
<div class="efl-learner-profile__section--header">
<h3 class="about-me">About Me</h3>
<button aria-label="edit about me" class="efl-learner-profile__section--edit"></button>
</div>
<p class="read-only-section">Write a short introduction about yourself, relevant experience and a touch of your personality</p>
<div class="efl-profile-left-popup about-me" role="dialog" aria-modal="true" data-behavior="efl-profile-left-popup">
<button class="efl-profile-left-popup__close" aria-label="close about me popup window"></button>
<div class="efl-learner-profile__section--header">
<h3 class="about-me">About Me</h3>
</div>
<div class="efl-profile-left-popup--inner">
<p>Keen on coaching or raring to ref? It's time to introduce yourself.</p>
<textarea id="about-me" maxlength="500" placeholder="Let people know who you are and why you're here..."></textarea>
<div class="options">
<p><span class="character-count">0</span>/500 characters</p>
<div class="clear-text" role="button" aria-label="clear text about me" tabindex="0">Clear Text</div>
</div>
<button class="cta cta--efl " id="about-me-save-button" aria-label="save about me" aria-disabled="true">
<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>
</div>
<div class="efl-profile-left-popup__toast-notification" tabindex="-1" aria-label=""><canvas id="rive" width="36" height="36"></canvas>About Me Saved</div>
<div class="efl-profile-left-popup__alert-modal" role="dialog" aria-modal="true" aria-live="polite" data-unsaved-changes-header="You have unsaved changes" data-unsaved-changes-copy="Continue editing to save your changes." data-fill-all-fields-header="you must fill in all fields" data-fill-all-fields-copy="Continue editing to save your changes." data-make-bio-public-header="Time to make your bio public?" data-make-bio-public-copy="Publishing your bio allows others to view your information. This is a great way to connect with clubs, coaches and the football community." data-innapropriate-content-header="Innapropriate content" data-innapropriate-content-copy="Lorem ipsum dolor sit amet, consectetur adipiscing elit." data-iwf-error-content-header="Error" data-iwf-error-content-copy="Lorem ipsum dolor sit amet, consectetur adipiscing elit.">
<h5 class="efl-category-title">This Image is Not Appropriate</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ultricies, nibh sit amet varius faucibus, est ipsum commodo mi, a rutrum urna mauris ut.</p>
<button class="cta cta--efl " id="about-me-continue-editing-button" aria-label="Continue Editing">Continue Editing</button>
<button class="cta cta--secondary " id="about-me-lose-my-changes-button" aria-label="Lose My Changes">Lose My Changes</button>
<button class="cta cta--efl " id="about-me-make-bio-public-button" aria-label="Make Bio Public">Make Bio Public</button>
<button class="cta cta--secondary " id="about-me-keep-bio-private-button" aria-label="Keep Bio Private">Keep Bio Private</button>
<button class="cta cta--efl " id="efl-learner-profile-edit-about-me-button" aria-label="Edit About Me">Edit About Me</button>
<button class="cta cta--efl " id="efl-learner-profile-error-about-me-button" aria-label="Try again">Try again</button>
</div>
</div>
</section>
No notes defined.
{
"save-button": {
"copy": "Save",
"modifier": "efl",
"id": "about-me-save-button"
},
"continue-editing-button": {
"href": "#",
"copy": "Continue Editing",
"id": "about-me-continue-editing-button",
"modifier": "efl"
},
"lose-changes-button": {
"href": "#",
"copy": "Lose My Changes",
"id": "about-me-lose-my-changes-button",
"modifier": "secondary"
},
"make-bio-public-button": {
"href": "#",
"copy": "Make Bio Public",
"id": "about-me-make-bio-public-button",
"modifier": "efl"
},
"keep-bio-private-button": {
"href": "#",
"copy": "Keep Bio Private",
"id": "about-me-keep-bio-private-button",
"modifier": "secondary"
},
"edit-about-me-button": {
"href": "",
"copy": "Edit About Me",
"id": "efl-learner-profile-edit-about-me-button",
"modifier": "efl"
},
"error-about-me-button": {
"href": "",
"copy": "Try again",
"id": "efl-learner-profile-error-about-me-button",
"modifier": "efl"
}
}
import {
updatePlayerProfile,
updateProfileCompletion,
} from '../efl-learner-profile/efl-learner-profile-update';
export default parentElement => {
// Read-Only Section
const readOnlyParagraph = parentElement.querySelector('.read-only-section');
// const eflProfileLayout = document.querySelector('.efl-profile-layout');
const editbtn = parentElement.querySelector(
'.efl-learner-profile__section--edit'
);
// Pop-up Section
const popUp = parentElement.querySelector('.efl-profile-left-popup');
const clearTextButton = popUp.querySelector('.clear-text');
const characterCount = popUp.querySelector('.character-count');
const textArea = popUp.querySelector('textarea');
const saveButton = popUp.querySelector('.cta[id=about-me-save-button]');
const closeButton = popUp.querySelector('.efl-profile-left-popup__close');
const toastNotification = popUp.querySelector(
'.efl-profile-left-popup__toast-notification'
);
// Alert Modal
const alertModal = popUp.querySelector(
'.efl-profile-left-popup__alert-modal'
);
const privacyInput = document.querySelector('#learner-profile-privacy-check');
// Alert Modal - Buttons
const continueEditingBtn = alertModal.querySelector(
'#about-me-continue-editing-button'
);
const loseChangesBtn = alertModal.querySelector(
'#about-me-lose-my-changes-button'
);
const makeBioPublicBtn = alertModal.querySelector(
'#about-me-make-bio-public-button'
);
const keepBioPrivateBtn = alertModal.querySelector(
'#about-me-keep-bio-private-button'
);
const editAboutMeBtn = alertModal.querySelector(
'#efl-learner-profile-edit-about-me-button'
);
const errorAboutMeBtn = alertModal.querySelector(
'#efl-learner-profile-error-about-me-button'
);
const MOBILE_BREAKPOINT = 820;
saveButton.setAttribute('aria-disabled', 'true');
characterCount.innerHTML = textArea.value.length;
// Functions
const modalAlert = type => {
const header = alertModal.getAttribute(`data-${type}-header`);
const copy = alertModal.getAttribute(`data-${type}-copy`);
// Reset Alert Modal ClassName
alertModal.removeAttribute('data-err');
alertModal.setAttribute('data-err', type);
alertModal.querySelector('h5').innerHTML = header;
alertModal.querySelector('p').innerHTML = copy;
alertModal.classList.add('add-animation');
popUp.classList.add('dark-overlay');
};
const makeBioPublic = status => {
privacyInput.checked = status;
};
const closeModal = e => {
e.preventDefault();
alertModal.classList.remove('add-animation');
setTimeout(() => {
popUp.classList.remove('dark-overlay');
}, 300);
};
// Event Listeners
clearTextButton.addEventListener('click', e => {
e.preventDefault();
textArea.value = '';
characterCount.innerHTML = '0';
saveButton.setAttribute('aria-disabled', 'true');
});
textArea.addEventListener('keydown', e => {
characterCount.innerHTML = e.target.value.length;
// Disable button on empty text
if (e.target.value.length > 0) {
saveButton.setAttribute('aria-disabled', 'false');
closeButton.classList.add('not-saved');
} else {
saveButton.setAttribute('aria-disabled', 'true');
closeButton.classList.remove('not-saved');
}
});
saveButton.addEventListener('click', e => {
e.preventDefault();
if (saveButton.getAttribute('aria-disabled') === 'true') {
if (textArea.value === '') {
modalAlert('fill-all-fields');
setTimeout(() => {
continueEditingBtn.focus();
}, 100);
}
return;
}
if (saveButton.getAttribute('aria-disabled') === 'false') {
saveButton.classList.add('loading-bar');
saveButton.setAttribute('aria-disabled', 'true');
updatePlayerProfile().then(abusiveContent => {
if (
abusiveContent &&
abusiveContent.FAIWFResponse &&
abusiveContent.FAIWFResponse.IsAbusive
) {
modalAlert('innapropriate-content');
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
} else if (
abusiveContent &&
!abusiveContent.FAIWFResponse &&
abusiveContent.Error
) {
modalAlert('iwf-error-content');
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
} else {
if (
!privacyInput.checked &&
popUp.getAttribute('data-initial-filled') !== 'true'
) {
popUp.setAttribute('data-initial-filled', 'true');
modalAlert('make-bio-public');
setTimeout(() => {
makeBioPublicBtn.focus();
}, 100);
saveButton.classList.remove('loading-bar');
saveButton.setAttribute('aria-disabled', 'false');
return;
}
saveButton.classList.remove('loading-bar');
readOnlyParagraph.innerHTML = textArea.value;
// profile completion notification
updateProfileCompletion(2);
saveButton.setAttribute('aria-disabled', 'true');
// Allow User to exit form once saved
closeButton.classList.remove('not-saved');
if (window.innerWidth >= MOBILE_BREAKPOINT) {
toastNotification.style.left = `${(431 -
toastNotification.offsetWidth) /
2}px`;
}
toastNotification.classList.add('enter-animation');
setTimeout(() => {
toastNotification.classList.remove('enter-animation');
}, 3000);
}
});
}
});
saveButton.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
saveButton.click();
} else {
setTimeout(() => {
closeButton.focus();
}, 10);
}
});
closeButton.addEventListener('click', e => {
if (saveButton.getAttribute('aria-disabled') === 'false') {
e.preventDefault();
modalAlert('unsaved-changes');
saveButton.classList.remove('loading-bar');
setTimeout(() => {
continueEditingBtn.focus();
}, 50);
} else {
setTimeout(() => {
editbtn.focus();
}, 50);
}
});
if (closeButton) {
closeButton.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
closeButton.click();
} else if (event.shiftKey && event.keyCode === 9) {
event.preventDefault();
}
});
}
// Alert Modal
continueEditingBtn.addEventListener('click', event => {
closeModal(event);
setTimeout(() => {
closeButton.focus();
}, 10);
});
continueEditingBtn.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
continueEditingBtn.click();
} else {
setTimeout(() => {
loseChangesBtn.focus();
}, 10);
}
});
loseChangesBtn.addEventListener('click', event => {
console.log(textArea.value);
if (textArea.value === '') {
textArea.value = '';
} else {
textArea.value = readOnlyParagraph.innerHTML;
}
characterCount.innerHTML = '0';
saveButton.setAttribute('aria-disabled', 'true');
closeButton.classList.remove('not-saved');
saveButton.classList.remove('loading-bar');
closeModal(event);
setTimeout(() => {
closeButton.focus();
}, 10);
});
loseChangesBtn.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
loseChangesBtn.click();
} else {
setTimeout(() => {
continueEditingBtn.focus();
}, 10);
}
});
makeBioPublicBtn.addEventListener('click', event => {
closeModal(event);
makeBioPublic(true);
setTimeout(() => {
saveButton.focus();
}, 10);
});
makeBioPublicBtn.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
makeBioPublicBtn.click();
} else {
setTimeout(() => {
keepBioPrivateBtn.focus();
}, 10);
}
});
keepBioPrivateBtn.addEventListener('click', event => {
closeModal(event);
makeBioPublic(false);
setTimeout(() => {
saveButton.focus();
}, 10);
});
keepBioPrivateBtn.addEventListener('keydown', event => {
if (event.keyCode === 13) {
event.preventDefault();
keepBioPrivateBtn.click();
} else {
setTimeout(() => {
makeBioPublicBtn.focus();
}, 10);
}
});
editAboutMeBtn.addEventListener('click', event => {
closeModal(event);
});
errorAboutMeBtn.addEventListener('click', event => {
closeModal(event);
});
};
<section aria-expanded="true" class="efl-learner-profile__section" data-behavior="efl-learner-profile-about-me">
<div class="efl-learner-profile__section--header">
<h3 class="about-me">About Me</h3>
<button aria-label="edit about me" class="efl-learner-profile__section--edit"></button>
</div>
<p class="read-only-section">Write a short introduction about yourself, relevant experience and a touch of your personality</p>
<div class="efl-profile-left-popup about-me" role="dialog" aria-modal="true" data-behavior="efl-profile-left-popup">
<button class="efl-profile-left-popup__close" aria-label="close about me popup window"></button>
<div class="efl-learner-profile__section--header">
<h3 class="about-me">About Me</h3>
</div>
<div class="efl-profile-left-popup--inner">
<p>Keen on coaching or raring to ref? It's time to introduce yourself.</p>
<textarea
id="about-me"
maxlength="500"
placeholder="Let people know who you are and why you're here..."
></textarea>
<div class="options">
<p><span class="character-count">0</span>/500 characters</p>
<div class="clear-text" role="button" aria-label="clear text about me" tabindex="0">Clear Text</div>
</div>
<button class="cta cta--efl " id="about-me-save-button" aria-label="save about me" aria-disabled="true">
<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>
</div>
<div class="efl-profile-left-popup__toast-notification" tabindex="-1" aria-label=""><canvas id="rive" width="36" height="36"></canvas>About Me Saved</div>
<div class="efl-profile-left-popup__alert-modal" role="dialog" aria-modal="true" aria-live="polite"
data-unsaved-changes-header="You have unsaved changes"
data-unsaved-changes-copy="Continue editing to save your changes."
data-fill-all-fields-header="you must fill in all fields"
data-fill-all-fields-copy="Continue editing to save your changes."
data-make-bio-public-header="Time to make your bio public?"
data-make-bio-public-copy="Publishing your bio allows others to view your information. This is a great way to connect with clubs, coaches and the football community."
data-innapropriate-content-header="Innapropriate content"
data-innapropriate-content-copy="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
data-iwf-error-content-header="Error"
data-iwf-error-content-copy="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
>
<h5 class="efl-category-title">This Image is Not Appropriate</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ultricies, nibh sit amet varius faucibus, est ipsum commodo mi, a rutrum urna mauris ut.</p>
<button class="cta cta--efl " id="about-me-continue-editing-button" aria-label="Continue Editing">Continue Editing</button>
<button class="cta cta--secondary " id="about-me-lose-my-changes-button" aria-label="Lose My Changes">Lose My Changes</button>
<button class="cta cta--efl " id="about-me-make-bio-public-button" aria-label="Make Bio Public">Make Bio Public</button>
<button class="cta cta--secondary " id="about-me-keep-bio-private-button" aria-label="Keep Bio Private">Keep Bio Private</button>
<button class="cta cta--efl " id="efl-learner-profile-edit-about-me-button" aria-label="Edit About Me">Edit About Me</button>
<button class="cta cta--efl " id="efl-learner-profile-error-about-me-button" aria-label="Try again">Try again</button>
</div>
</div>
</section>