-
Notifications
You must be signed in to change notification settings - Fork 16
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
IBX-3523: Introduced tabs to left sidebar in Content Edit interface #526
Changes from all commits
6829ced
10bc683
2a018db
df7594b
8b0fd9f
603b4c2
bb364f6
6f9fe19
65eb399
d80ea28
b5370b4
9f6499b
0f38e93
f08c3d4
7e3e188
a0d2bda
4226b86
e160597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
system: | ||
admin_group: | ||
admin_ui_forms: | ||
content_edit_form_templates: | ||
- { template: '@ibexadesign/content/form_fields.html.twig', priority: 0 } | ||
content_edit: | ||
form_templates: | ||
- { template: '@ibexadesign/content/form_fields.html.twig', priority: 0 } | ||
|
||
field_templates: | ||
- { template: '@ibexadesign/ui/field_type/preview/content_fields.html.twig', priority: 20 } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
(function (global, doc, ibexa) { | ||
const navigationMenu = doc.querySelector('.ibexa-navigation-menu'); | ||
|
||
if (!navigationMenu) { | ||
return; | ||
} | ||
|
||
const SECTION_ADJUST_MARGIN_TOP = 20; | ||
const formContainerNode = doc.querySelector('.ibexa-edit-content'); | ||
const getSecondarySectionActiveItems = () => { | ||
const secondarySectionItems = formContainerNode.querySelectorAll( | ||
'.ibexa-edit-content__primary-section--active .ibexa-edit-content__secondary-section', | ||
); | ||
|
||
return [...secondarySectionItems]; | ||
}; | ||
let currentlyVisibleSections = getSecondarySectionActiveItems(); | ||
const fitSecondarySections = () => { | ||
const primarySection = doc.querySelector('.ibexa-edit-content__primary-section--active'); | ||
const contentColumn = doc.querySelector('.ibexa-main-container__content-column'); | ||
const firstSection = primarySection.firstElementChild; | ||
const lastSection = primarySection.lastElementChild; | ||
const contentContainer = contentColumn.querySelector('.ibexa-edit-content__container'); | ||
|
||
contentContainer.style.paddingBottom = '0px'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have to set it even for a case in which we are setting it below again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's kinda of a reset, notice that we set this style after two |
||
|
||
if (!firstSection.isSameNode(lastSection) && lastSection.offsetHeight) { | ||
const headerContainer = doc.querySelector('.ibexa-edit-header__container'); | ||
const heightFromLastSection = contentContainer.offsetHeight - lastSection.offsetTop; | ||
const contentColumnBodyHeight = contentColumn.offsetHeight - headerContainer.offsetHeight; | ||
const heightDiff = contentColumnBodyHeight - heightFromLastSection; | ||
|
||
if (heightDiff > 0) { | ||
contentContainer.style.paddingBottom = `${heightDiff}px`; | ||
} | ||
} | ||
}; | ||
const navigateTo = (targetId) => { | ||
const secondarySectionNode = formContainerNode.querySelector(`.ibexa-edit-content__secondary-section[data-id="${targetId}"]`); | ||
|
||
formContainerNode.scrollTo({ | ||
top: secondarySectionNode.offsetTop, | ||
behavior: 'smooth', | ||
}); | ||
}; | ||
const setActiveSecondaryMenu = (node) => { | ||
const secondaryMenuItems = doc.querySelectorAll( | ||
'.ibexa-navigation-menu__secondary--active .ibexa-navigation-menu__secondary-item-btn', | ||
); | ||
|
||
secondaryMenuItems.forEach((item) => { | ||
item.classList.toggle('ibexa-navigation-menu__secondary-item-btn--active', item.isSameNode(node)); | ||
}); | ||
}; | ||
const showPrimarySection = (id) => { | ||
const primarySectionItems = formContainerNode.querySelectorAll('.ibexa-edit-content__primary-section'); | ||
|
||
primarySectionItems.forEach((item) => { | ||
item.classList.toggle('ibexa-edit-content__primary-section--active', item.dataset.id === id); | ||
}); | ||
|
||
currentlyVisibleSections = getSecondarySectionActiveItems(); | ||
|
||
fitSecondarySections(); | ||
}; | ||
const showSecondaryMenu = (node) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have such a function also for the primary menu. |
||
const items = doc.querySelectorAll('.ibexa-navigation-menu__secondary'); | ||
|
||
items.forEach((item) => item.classList.toggle('ibexa-navigation-menu__secondary--active', item.isSameNode(node))); | ||
}; | ||
const onSelectPrimaryMenuList = (event) => { | ||
const { targetId } = event.currentTarget.dataset; | ||
const secondaryMenuNode = doc.querySelector(`.ibexa-navigation-menu__secondary[data-id="${targetId}"]`); | ||
const primaryMenuItems = doc.querySelectorAll('.ibexa-navigation-menu__primary--list .ibexa-navigation-menu__primary-item'); | ||
|
||
primaryMenuItems.forEach((item) => { | ||
item.classList.toggle('ibexa-navigation-menu__primary-item--active', item.isSameNode(event.currentTarget)); | ||
}); | ||
showPrimarySection(targetId); | ||
|
||
if (secondaryMenuNode) { | ||
showSecondaryMenu(secondaryMenuNode); | ||
} | ||
}; | ||
const onSelectPrimaryMenuDropdown = (event) => { | ||
const targetId = event.currentTarget.value; | ||
const secondaryMenuNode = doc.querySelector(`.ibexa-navigation-menu__secondary[data-id="${targetId}"]`); | ||
|
||
showPrimarySection(targetId); | ||
|
||
if (secondaryMenuNode) { | ||
showSecondaryMenu(secondaryMenuNode); | ||
} | ||
}; | ||
const onSelectSecondaryMenu = (event) => { | ||
const { targetId } = event.currentTarget.dataset; | ||
|
||
navigateTo(targetId); | ||
}; | ||
const attachPrimaryMenuListEvents = () => { | ||
const items = doc.querySelectorAll('.ibexa-navigation-menu__primary--list .ibexa-navigation-menu__primary-item'); | ||
|
||
items.forEach((item) => item.addEventListener('click', onSelectPrimaryMenuList, false)); | ||
}; | ||
const attachPrimaryMenuDropdownEvents = () => { | ||
const sourceSelect = doc.querySelector('.ibexa-navigation-menu__primary--dropdown .ibexa-dropdown__source .ibexa-input'); | ||
|
||
if (!sourceSelect) { | ||
return; | ||
} | ||
|
||
sourceSelect.addEventListener('change', onSelectPrimaryMenuDropdown, false); | ||
}; | ||
const attachSecondaryMenuEvents = () => { | ||
const items = doc.querySelectorAll('.ibexa-navigation-menu .ibexa-navigation-menu__secondary-item-btn'); | ||
|
||
items.forEach((item) => item.addEventListener('click', onSelectSecondaryMenu, false)); | ||
}; | ||
const attachScrollContainerEvents = () => { | ||
const allSections = [...formContainerNode.querySelectorAll('.ibexa-edit-content__secondary-section')]; | ||
const headerContainer = doc.querySelector('.ibexa-edit-header__container'); | ||
let previousFirstVisibleSection = null; | ||
|
||
if (formContainerNode && allSections.length) { | ||
formContainerNode.addEventListener('scroll', () => { | ||
let firstVisibleSection = currentlyVisibleSections.find((section) => { | ||
const { top, height } = section.getBoundingClientRect(); | ||
|
||
return top + height >= headerContainer.offsetHeight + SECTION_ADJUST_MARGIN_TOP; | ||
}); | ||
|
||
if (!firstVisibleSection) { | ||
firstVisibleSection = currentlyVisibleSections.at(-1); | ||
} | ||
|
||
if (previousFirstVisibleSection === firstVisibleSection) { | ||
return; | ||
} | ||
|
||
previousFirstVisibleSection = firstVisibleSection; | ||
|
||
const targetId = firstVisibleSection.dataset.id; | ||
|
||
const secondaryMenuNode = doc.querySelector( | ||
`.ibexa-navigation-menu__secondary--active .ibexa-navigation-menu__secondary-item-btn[data-target-id="${targetId}"]`, | ||
); | ||
|
||
setActiveSecondaryMenu(secondaryMenuNode); | ||
}); | ||
} | ||
}; | ||
|
||
attachPrimaryMenuListEvents(); | ||
attachPrimaryMenuDropdownEvents(); | ||
attachSecondaryMenuEvents(); | ||
attachScrollContainerEvents(); | ||
fitSecondarySections(); | ||
ibexa.helpers.tooltips.parse(navigationMenu); | ||
})(window, window.document, window.ibexa); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,12 @@ | |
max-width: calculateRem(1600px); | ||
} | ||
} | ||
|
||
&__primary-section { | ||
display: none; | ||
|
||
&--active { | ||
display: block; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes you are using
formContainerNode
and sometimes not, is there any reason behind it?