11document . addEventListener ( 'DOMContentLoaded' , function ( ) {
22 /**
3- * Finds the closest parent element with an ID matching the pattern "c\d+".
4- * @param {HTMLElement } element - The starting element.
5- * @returns {HTMLElement|null } - The closest matching element or null if not found.
6- */
3+ * Finds the closest parent element with an ID matching the pattern "c\d+".
4+ * @param {HTMLElement } element - The starting element.
5+ * @returns {HTMLElement|null } - The closest matching element or null if not found.
6+ */
77 const getClosestElementWithId = ( element ) => {
88 while ( element && ! element . id . match ( / c \d + / ) ) {
99 element = element . parentElement ;
@@ -12,10 +12,10 @@ document.addEventListener('DOMContentLoaded', function () {
1212 } ;
1313
1414 /**
15- * Collects data items from elements with the class "xima-typo3-frontend-edit--data".
16- * Groups the data by the closest element's ID.
17- * @returns {Object } - A dictionary of data items grouped by ID.
18- */
15+ * Collects data items from elements with the class "xima-typo3-frontend-edit--data".
16+ * Groups the data by the closest element's ID.
17+ * @returns {Object } - A dictionary of data items grouped by ID.
18+ */
1919 const collectDataItems = ( ) => {
2020 const dataItems = { } ;
2121 document . querySelectorAll ( '.xima-typo3-frontend-edit--data' ) . forEach ( ( element ) => {
@@ -34,11 +34,11 @@ document.addEventListener('DOMContentLoaded', function () {
3434 } ;
3535
3636 /**
37- * Sends a POST request to fetch content elements based on the provided data items.
38- * @param {Object } dataItems - The data items to send in the request body.
39- * @returns {Promise<Object> } - The JSON response from the server.
40- * @throws {Error } - If the request fails.
41- */
37+ * Sends a POST request to fetch content elements based on the provided data items.
38+ * @param {Object } dataItems - The data items to send in the request body.
39+ * @returns {Promise<Object> } - The JSON response from the server.
40+ * @throws {Error } - If the request fails.
41+ */
4242 const fetchContentElements = async ( dataItems ) => {
4343 const url = new URL ( window . location . href ) ;
4444 url . searchParams . set ( 'type' , '1729341864' ) ;
@@ -55,11 +55,11 @@ document.addEventListener('DOMContentLoaded', function () {
5555 } ;
5656
5757 /**
58- * Creates an edit button for a content element.
59- * @param {string } uid - The unique ID of the content element.
60- * @param {Object } contentElement - The content element data.
61- * @returns {HTMLButtonElement } - The created edit button.
62- */
58+ * Creates an edit button for a content element.
59+ * @param {string } uid - The unique ID of the content element.
60+ * @param {Object } contentElement - The content element data.
61+ * @returns {HTMLButtonElement } - The created edit button.
62+ */
6363 const createEditButton = ( uid , contentElement ) => {
6464 const editButton = contentElement . menu . url ? document . createElement ( 'a' ) : document . createElement ( 'button' ) ;
6565 editButton . className = 'xima-typo3-frontend-edit--edit-button' ;
@@ -74,11 +74,11 @@ document.addEventListener('DOMContentLoaded', function () {
7474 } ;
7575
7676 /**
77- * Creates a dropdown menu for a content element.
78- * @param {string } uid - The unique ID of the content element.
79- * @param {Object } contentElement - The content element data.
80- * @returns {HTMLDivElement } - The created dropdown menu.
81- */
77+ * Creates a dropdown menu for a content element.
78+ * @param {string } uid - The unique ID of the content element.
79+ * @param {Object } contentElement - The content element data.
80+ * @returns {HTMLDivElement } - The created dropdown menu.
81+ */
8282 const createDropdownMenu = ( uid , contentElement ) => {
8383 const dropdownMenu = document . createElement ( 'div' ) ;
8484 dropdownMenu . className = 'xima-typo3-frontend-edit--dropdown-menu' ;
@@ -106,12 +106,12 @@ document.addEventListener('DOMContentLoaded', function () {
106106 } ;
107107
108108 /**
109- * Positions the edit button and dropdown menu relative to the target element.
110- * @param {HTMLElement } element - The target element.
111- * @param {HTMLElement } wrapperElement - The wrapper element containing the button and menu.
112- * @param {HTMLElement } editButton - The edit button.
113- * @param {HTMLElement } dropdownMenu - The dropdown menu.
114- */
109+ * Positions the edit button and dropdown menu relative to the target element.
110+ * @param {HTMLElement } element - The target element.
111+ * @param {HTMLElement } wrapperElement - The wrapper element containing the button and menu.
112+ * @param {HTMLElement } editButton - The edit button.
113+ * @param {HTMLElement } dropdownMenu - The dropdown menu.
114+ */
115115 const positionElements = ( element , wrapperElement , editButton , dropdownMenu ) => {
116116 const rect = element . getBoundingClientRect ( ) ;
117117 const rectInPageContext = {
@@ -146,12 +146,12 @@ document.addEventListener('DOMContentLoaded', function () {
146146 } ;
147147
148148 /**
149- * Sets up hover events for the target element, edit button, and dropdown menu.
150- * @param {HTMLElement } element - The target element.
151- * @param {HTMLElement } wrapperElement - The wrapper element containing the button and menu.
152- * @param {HTMLElement } editButton - The edit button.
153- * @param {HTMLElement } dropdownMenu - The dropdown menu.
154- */
149+ * Sets up hover events for the target element, edit button, and dropdown menu.
150+ * @param {HTMLElement } element - The target element.
151+ * @param {HTMLElement } wrapperElement - The wrapper element containing the button and menu.
152+ * @param {HTMLElement } editButton - The edit button.
153+ * @param {HTMLElement } dropdownMenu - The dropdown menu.
154+ */
155155 const setupHoverEvents = ( element , wrapperElement , editButton , dropdownMenu ) => {
156156 element . addEventListener ( 'mouseover' , ( ) => {
157157 positionElements ( element , wrapperElement , editButton , dropdownMenu ) ;
@@ -167,8 +167,8 @@ document.addEventListener('DOMContentLoaded', function () {
167167 } ;
168168
169169 /**
170- * Sets up events for dropdown menus to handle mouse leave and click outside.
171- */
170+ * Sets up events for dropdown menus to handle mouse leave and click outside.
171+ */
172172 const setupDropdownMenuEvents = ( ) => {
173173 document . querySelectorAll ( '.xima-typo3-frontend-edit--dropdown-menu' ) . forEach ( ( menu ) => {
174174 menu . addEventListener ( 'mouseleave' , ( event ) => {
@@ -190,9 +190,9 @@ document.addEventListener('DOMContentLoaded', function () {
190190 } ;
191191
192192 /**
193- * Renders content elements by creating edit buttons and dropdown menus for each.
194- * @param {Object } jsonResponse - The JSON response containing content element data.
195- */
193+ * Renders content elements by creating edit buttons and dropdown menus for each.
194+ * @param {Object } jsonResponse - The JSON response containing content element data.
195+ */
196196 const renderContentElements = ( jsonResponse ) => {
197197 for ( let uid in jsonResponse ) {
198198 const contentElement = jsonResponse [ uid ] ;
@@ -228,9 +228,9 @@ document.addEventListener('DOMContentLoaded', function () {
228228 } ;
229229
230230 /**
231- * Main function to collect data, fetch content elements, and render them.
232- * Handles errors during the process.
233- */
231+ * Main function to collect data, fetch content elements, and render them.
232+ * Handles errors during the process.
233+ */
234234 const getContentElements = async ( ) => {
235235 try {
236236 const dataItems = collectDataItems ( ) ;
0 commit comments