|
1 | 1 | (function (global, doc, ibexa) {
|
2 | 2 | const SCROLL_POSITION_TO_FIT = 50;
|
3 |
| - const HEADER_RIGHT_MARGIN = 50; |
4 | 3 | const MIN_HEIGHT_DIFF_FOR_FITTING_HEADER = 150;
|
5 | 4 | const headerNode = doc.querySelector('.ibexa-edit-header');
|
6 | 5 | const contentNode = doc.querySelector('.ibexa-edit-content');
|
|
9 | 8 | return;
|
10 | 9 | }
|
11 | 10 |
|
12 |
| - const headerBottomRowNode = headerNode.querySelector('.ibexa-edit-header__row--bottom'); |
13 | 11 | const { height: expandedHeaderHeight } = headerNode.getBoundingClientRect();
|
14 | 12 | const scrolledContent = doc.querySelector('.ibexa-edit-content > :first-child');
|
15 | 13 | const { controlZIndex } = ibexa.helpers.modal;
|
16 |
| - const fitEllipsizedTitle = () => { |
17 |
| - const titleNode = headerBottomRowNode.querySelector('.ibexa-edit-header__name--ellipsized'); |
18 |
| - const firstMenuEntryNode = headerNode.querySelector('.ibexa-context-menu .ibexa-context-menu__item'); |
19 |
| - const { left: titleNodeLeft, width: titleNodeWidth } = titleNode.getBoundingClientRect(); |
20 |
| - const { left: firstMenuEntryNodeLeft } = firstMenuEntryNode.getBoundingClientRect(); |
21 |
| - const bottomRowNodeWidthNew = firstMenuEntryNodeLeft - titleNodeLeft; |
22 |
| - const titleNodeWidthNew = bottomRowNodeWidthNew - HEADER_RIGHT_MARGIN; |
23 |
| - |
24 |
| - headerBottomRowNode.style.width = `${bottomRowNodeWidthNew}px`; |
25 |
| - |
26 |
| - if (titleNodeWidth > titleNodeWidthNew) { |
27 |
| - titleNode.style.width = `${titleNodeWidthNew}px`; |
28 |
| - } |
29 |
| - }; |
30 | 14 | const fitHeader = (event) => {
|
31 | 15 | const { height: formHeight } = scrolledContent.getBoundingClientRect();
|
32 | 16 | const contentHeightWithExpandedHeader = formHeight + expandedHeaderHeight;
|
|
40 | 24 | const shouldHeaderBeSlim = scrollTop > SCROLL_POSITION_TO_FIT;
|
41 | 25 |
|
42 | 26 | headerNode.classList.toggle('ibexa-edit-header--slim', shouldHeaderBeSlim);
|
43 |
| - |
44 |
| - if (shouldHeaderBeSlim) { |
45 |
| - fitEllipsizedTitle(); |
46 |
| - } else { |
47 |
| - headerBottomRowNode.style.width = '100%'; |
48 |
| - } |
49 | 27 | };
|
50 | 28 |
|
51 | 29 | contentNode.addEventListener('scroll', fitHeader, false);
|
|
0 commit comments