Skip to content

Commit

Permalink
Restore the legacy limit_height script
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Nov 13, 2023
1 parent de7d7a2 commit 76603d0
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 45 deletions.
1 change: 1 addition & 0 deletions core-bundle/assets/backend.js
Expand Up @@ -4,6 +4,7 @@ import { definitionForModuleAndIdentifier, identifierForContextKey } from '@hotw
import './scripts/mootao.js'
import './scripts/core.js'
import './scripts/autofocus.js'
import './scripts/limit-height.js'
import './scripts/modulewizard.js'
import './scripts/sectionwizard.js'
import './scripts/tips.js'
Expand Down
31 changes: 0 additions & 31 deletions core-bundle/assets/controllers/limit-height-controller.js
Expand Up @@ -21,37 +21,6 @@ export default class extends Controller {
this.togglerMap = new WeakMap();
}

/**
* Automatically register target on all legacy ".limit_height" classes
*/
connect () {
const registerLegacy = () => {
document.querySelectorAll('div.limit_height').forEach((div) => {
const parent = div.parentNode.closest('.tl_content');

// Return if the node is a wrapper
if (parent && (parent.classList.contains('wrapper_start') || parent.classList.contains('wrapper_stop'))) return;

const hgt = Number(div.className.replace(/[^0-9]*/, ''))

// Return if there is no height value
if (!hgt) return;

// Use the last found max height as the controller value
this.maxValue = hgt;

div.setAttribute(this.application.schema.targetAttributeForScope(this.identifier), 'node');
});
};

// called as soon as registered so DOM may not have loaded yet
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", registerLegacy)
} else {
registerLegacy()
}
}

operationTargetConnected () {
this.updateOperation();
}
Expand Down
47 changes: 47 additions & 0 deletions core-bundle/assets/scripts/limit-height.js
@@ -0,0 +1,47 @@
window.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('div.limit_height').forEach(function(div) {
window.console && console.warn('Using "limit_height" class on child_record_callback is deprecated. Set a list.sorting.limitHeight in your DCA instead.');

const parent = div.parentNode.closest('.tl_content');

// Return if the element is a wrapper
if (parent && (parent.classList.contains('wrapper_start') || parent.classList.contains('wrapper_stop'))) return;

const hgt = Number(div.className.replace(/[^0-9]*/, ''))

// Return if there is no height value
if (!hgt) return;

const style = window.getComputedStyle(div, null);
const padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
const height = div.clientHeight - padding;

// Do not add the toggle if the preview height is below the max-height
if (height <= hgt) return;

// Resize the element if it is higher than the maximum height
div.style.height = hgt+'px';

const button = document.createElement('button');
button.setAttribute('type', 'button');
button.title = Contao.lang.expand;
button.innerHTML = '<span>...</span>';
button.classList.add('unselectable');

button.addEventListener('click', function() {
if (div.style.height == 'auto') {
div.style.height = hgt+'px';
button.title = Contao.lang.expand;
} else {
div.style.height = 'auto';
button.title = Contao.lang.collapse;
}
});

const toggler = document.createElement('div');
toggler.classList.add('limit_toggler');
toggler.append(button);

div.append(toggler);
});
});

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core-bundle/contao/themes/flexible/entrypoints.json
Expand Up @@ -2,7 +2,7 @@
"entrypoints": {
"backend": {
"css": [
"/system/themes/flexible/backend.c0eb0f53.css"
"/system/themes/flexible/backend.d98ca954.css"
]
},
"confirm": {
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/contao/themes/flexible/manifest.json
@@ -1,5 +1,5 @@
{
"backend.css": "/system/themes/flexible/backend.c0eb0f53.css",
"backend.css": "/system/themes/flexible/backend.d98ca954.css",
"confirm.css": "/system/themes/flexible/confirm.919d7476.css",
"conflict.css": "/system/themes/flexible/conflict.7fbc711f.css",
"diff.css": "/system/themes/flexible/diff.366f5cdb.css",
Expand All @@ -8,7 +8,7 @@
"popup.css": "/system/themes/flexible/popup.48ecd1b2.css",
"tinymce.css": "/system/themes/flexible/tinymce.e5009f94.css",
"tinymce-dark.css": "/system/themes/flexible/tinymce-dark.596023db.css",
"backend.c0eb0f53.css.map": "/system/themes/flexible/backend.c0eb0f53.css.map",
"backend.d98ca954.css.map": "/system/themes/flexible/backend.d98ca954.css.map",
"confirm.919d7476.css.map": "/system/themes/flexible/confirm.919d7476.css.map",
"conflict.7fbc711f.css.map": "/system/themes/flexible/conflict.7fbc711f.css.map",
"diff.366f5cdb.css.map": "/system/themes/flexible/diff.366f5cdb.css.map",
Expand Down
11 changes: 9 additions & 2 deletions core-bundle/contao/themes/flexible/styles/main.css
Expand Up @@ -1613,6 +1613,10 @@ table.tl_listing {
border-top: 1px solid var(--border);
}

.limit_height {
overflow: hidden;
}

.limit_toggler {
width: 100%;
position: absolute;
Expand Down Expand Up @@ -1824,6 +1828,11 @@ label.tl_change_selected {
height: auto;
}

.selector_container .limit_height {
height: auto !important;
max-height: 190px;
}

.selector_container .limit_toggler {
display: none;
}
Expand Down Expand Up @@ -2501,10 +2510,8 @@ time[title] {
.header_icon, .header_clipboard, .header_back, .header_new, .header_rss, .header_edit_all, .header_delete_all,
.header_new_folder, .header_css_import, .header_theme_import, .header_store, .header_toggle, .header_sync {
padding: 3px 0 3px 21px;
background-color: transparent;
background-position: left center;
background-repeat: no-repeat;
border: none;
margin-left: 15px;
}

Expand Down
2 changes: 0 additions & 2 deletions core-bundle/public/backend.10759865.js

This file was deleted.

1 change: 0 additions & 1 deletion core-bundle/public/backend.10759865.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions core-bundle/public/backend.d672c357.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/public/backend.d672c357.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core-bundle/public/entrypoints.json
Expand Up @@ -2,7 +2,7 @@
"entrypoints": {
"backend": {
"js": [
"/bundles/contaocore/backend.10759865.js"
"/bundles/contaocore/backend.d672c357.js"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/public/manifest.json
@@ -1,4 +1,4 @@
{
"backend.js": "/bundles/contaocore/backend.10759865.js",
"backend.10759865.js.map": "/bundles/contaocore/backend.10759865.js.map"
"backend.js": "/bundles/contaocore/backend.d672c357.js",
"backend.d672c357.js.map": "/bundles/contaocore/backend.d672c357.js.map"
}

0 comments on commit 76603d0

Please sign in to comment.