PageSourceSearch

https://fc-eindhoven.nl/app/plugins/wp-table-builder/inc/frontend/js/wp-table-builder-frontend.js?ver=1.2.6

js fc-eindhoven.nl collected 2026-10-02 12:48:42 UTC 27,632 bytes, 722 lines download raw bytes

1(function ($) {
2	/**
3	 * All of the code for your public-facing JavaScript source
4	 * should reside in this file.
5	 *
6	 * Note: It has been assumed you will write jQuery code here, so the
7	 * $ function reference has been prepared for usage within the scope
8	 * of this function.
9	 *
10	 * This enables you to define handlers, for when the DOM is ready:
11	 *
12	 * $(function() {
13	 *
14	 * });
15	 *
16	 * When the window is loaded:
17	 *
18	 * $( window ).load(function() {
19	 *
20	 * });
21	 *
22	 * ...and/or other possibilities.
23	 *
24	 * Ideally, it is not considered best practise to attach more than a
25	 * single DOM-ready or window-load handler for a particular page.
26	 * Although scripts in the WordPress core, Plugins and Themes may be
27	 * practising this, we should strive to set a better example in our own work.
28	 *
29	 * The file is enqueued from inc/frontend/class-frontend.php.
30	 */
31
32	jQuery(document).ready(function ($) {
33		/**
34		 * Adds hover color change support for supported button elements.
35		 */
36		function addHoverSupport(querySelector) {
37			const buttons = Array.from(document.querySelectorAll(querySelector));
38
39			buttons.map((b) => {
40				b.addEventListener('mouseenter', (e) => {
41					const el = e.target;
42					// hover background-color
43					if (el.dataset.wptbElementHoverBgColor) {
44						el.style.backgroundColor = el.dataset.wptbElementHoverBgColor;
45					}
46					// hover color
47					if (el.dataset.wptbElementHoverTextColor) {
48						el.style.color = el.dataset.wptbElementHoverTextColor;
49					}
50					// hover scale
51					if (el.dataset.wptbElementHoverScale) {
52						el.style.transform = `scale(${b.dataset.wptbElementHoverScale})`;
53					}
54				});
55
56				b.addEventListener('mouseleave', (e) => {
57					// reset all supported hover properties to their default value
58					const el = e.target;
59					if (el.dataset.wptbElementHoverBgColor) {
60						el.style.backgroundColor = el.dataset.wptbElementBgColor;
61					}
62					if (el.dataset.wptbElementHoverTextColor) {
63						el.style.color = el.dataset.wptbElementColor;
64					}
65					if (el.dataset.wptbElementHoverScale) {
66						el.style.transform = 'scale(1)';
67					}
68				});
69			});
70		}
71
72		// add all kind of functions that have event listeners before responsive table reconstruction to make sure those event listeners are carried over to their clones
73		addHoverSupport('.wptb-preview-table .wptb-button');
74
75		/**
76		 * function wptb_tableContainerSectionSmall
77		 * add class ( wptb-section-small ) in small width
78		 * remove this class in large width
79		 * @returns {void}
80		 */
81		function wptb_tableContainerSectionSmall() {
82			const wptbTableContainer = jQuery('.wptb-table-container');
83			const sw = wptbTableContainer.width();
84			if (wptbTableContainer.length > 0) {
85				if (sw < 480) {
86					wptbTableContainer.addClass('wptb-section-small');
87				} else {
88					wptbTableContainer.removeClass('wptb-section-small');
89				}
90			}
91		}
92
93		/**
94		 * function wptb_tableGenerateMobile
95		 * generates a mobile view of the table
96		 * when the top row of the table is not a heading
97		 * @returns {void}
98		 */
99		function wptb_tableGenerateMobile() {
100			const wptbTableContainer = document.getElementsByClassName('wptb-table-container');
101			const wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
102			const wptbPreviewTableMobile = document.getElementsByClassName('wptb-preview-table-mobile');
103			if (wptbTableContainer.length > 0 && wptbPreviewTable.length > 0) {
104				const sw = wptbTableContainer[0].offsetWidth;
105				if (sw < 480) {
106					wptbPreviewTable[0].style.display = 'none';
107
108					if (wptbPreviewTableMobile.length == 0) {
109						const tableRows = wptbPreviewTable[0].rows;
110						const tableRowTop = tableRows[0];
111						const tableRowTopChildren = tableRowTop.children;
112						let columnCount = 0;
113
114						for (let i = 0; i < tableRowTopChildren.length; i++) {
115							columnCount += tableRowTopChildren[i].colSpan;
116						}
117
118						const newTableArray = [];
119
120						for (let i = 0; i < columnCount; i++) {
121							newTableArray[i] = [];
122						}
123
124						for (let i = 0; i < tableRows.length; i++) {
125							const rowChildren = tableRows[i].children;
126
127							for (let j = 0; j < columnCount; j++) {
128								if (rowChildren[j].dataset.xIndex == j) {
129									const tdNew = rowChildren[j].cloneNode(true);
130									if (tableRows[i].style.backgroundColor) {
131										tdNew.style.backgroundColor = tableRows[i].style.backgroundColor;
132									}
133									newTableArray[j].push(tdNew);
134								} else {
135									newTableArray[j].push('');
136								}
137							}
138						}
139
140						const table = document.createElement('table');
141						table.classList.add('wptb-preview-table-mobile');
142						const tableStyle = wptbPreviewTable[0].getAttribute('style');
143						table.setAttribute('style', tableStyle);
144						table.style.display = 'table';
145						for (let i = 0; i < columnCount; i++) {
146							const row = table.insertRow(-1);
147							row.classList.add('wptb-row');
148
149							for (let j = 0; j < tableRows.length; j++) {
150								if (newTableArray[i][j]) {
151									row.appendChild(newTableArray[i][j]);
152								}
153							}
154						}
155
156						wptbTableContainer[0].appendChild(table);
157					} else {
158						wptbPreviewTableMobile[0].style.display = 'table';
159					}
160				} else {
161					wptbPreviewTable[0].style.display = 'table';
162					if (wptbPreviewTableMobile.length > 0) {
163						wptbPreviewTableMobile[0].style.display = 'none';
164					}
165				}
166			}
167		}
168
169		wptb_tdDefaultWidth();
170		wptb_tableReconstraction();
171
172		// when window resize call wpcd_archiveSectionSmall and wptb_tableGenerateMobile
173		$(window).resize(function () {
174			wptb_tdDefaultWidth();
175			wptb_tableReconstraction();
176		});
177
178		function wptb_tableReconstraction() {
179			// get necessary elements on page
180			const tableContainers = document.getElementsByClassName('wptb-table-container');
181			for (let i = 0; i < tableContainers.length; i++) {
182				const tableContainer = tableContainers[i];
183
184				// Set default indicator of creating a new table in true
185				let createNewTableIndic = true;
186
187				let previewTable = tableContainer.getElementsByClassName('wptb-preview-table');
188				let tableContainerMatrix = tableContainer.getElementsByClassName('wptb-table-container-matrix');
189
190				if (previewTable.length > 0 && tableContainerMatrix.length > 0) {
191					previewTable = previewTable[0];
192					tableContainerMatrix = tableContainerMatrix[0];
193					previewTable.style.display = 'table';
194
195					if (previewTable.dataset.wptbTableAlignment) {
196						const { wptbTableAlignment } = previewTable.dataset;
197
198						const wptbTableContainerWidth = tableContainer.offsetWidth;
199						if (wptbTableContainerWidth < previewTable.offsetWidth) {
200							previewTable.style.float = null;
201						} else if (wptbTableAlignment == 'center') {
202							previewTable.style.float = null;
203						} else {
204							previewTable.style.float = wptbTableAlignment;
205						}
206
207						if (wptbTableAlignment == 'center') {
208							tableContainer.style.float = null;
209						} else {
210							tableContainer.style.float = wptbTableAlignment;
211						}
212					}
213
214					// check data parametrs reconstraction and wptbAdaptiveTable if they are both equal 1 then continue
215					if (previewTable.dataset.reconstraction == 1 && previewTable.dataset.wptbAdaptiveTable == 1) {
216						// get widths for wptb-table-container and wptb-preview-table
217						const tableContainerWidth = tableContainer.offsetWidth;
218						const previewTableWidth = previewTable.offsetWidth;
219
220						// get count of table columns
221						let tableColumns;
222						const previewTableRows = previewTable.rows;
223						if (previewTableRows.length > 0) {
224							const firstRow = previewTableRows[0];
225							const tdsRow = firstRow.querySelectorAll('td');
226
227							tableColumns = tdsRow.length;
228						}
229
230						// check the top line if it is presented as a title
231						const tablePreviewHeadIndic = previewTable.classList.contains('wptb-table-preview-head');
232
233						// check conditions: if table top row is as "header" - table must have more that two columns,
234						// otherwise table must have more taht one columns
235						if ((!tablePreviewHeadIndic || tableColumns > 2) && tableColumns > 1) {
236							// if width of wptb-table-container less then width of wptb-preview-table -
237							// continue the way creation new mobile table
238							if (tableContainerWidth < previewTableWidth) {
239								tableContainer.style.overflow = 'unset';
240
241								// hide wptb-table-container-matrix
242								if (tableContainerMatrix) tableContainerMatrix.classList.add('wptb-matrix-hide');
243
244								if (previewTable.rows && tableColumns) {
245									// we get the estimated cell width
246									const tdWidth = previewTableWidth / tableColumns;
247
248									// get the quantity of whole Columns that are can placed in the container
249									let wholeColumnsInContainer = Math.floor(tableContainerWidth / tdWidth);
250									if (wholeColumnsInContainer < 1) wholeColumnsInContainer = 1;
251
252									// check for the existence of a mobile table
253									// if it available, check this table for compliance
254									// with our conditions. If it compliance, remain this table
255									// and cancel creating a new table ( createNewTableIndic = false ).
256									if (tableContainer.getElementsByClassName('wptb-preview-table-mobile').length > 0) {
257										const wptbPreviewTableMobile = tableContainer.getElementsByClassName(
258											'wptb-preview-table-mobile'
259										)[0];
260										wptbPreviewTableMobile.classList.remove('wptb-mobile-hide');
261										const dataWholeColumnInContainer =
262											wptbPreviewTableMobile.dataset.wholeColumnsInContainer;
263
264										if (
265											dataWholeColumnInContainer == wholeColumnsInContainer &&
266											previewTable.classList.contains('wptb-table-preview-head')
267										) {
268											createNewTableIndic = false;
269										} else if (
270											dataWholeColumnInContainer == wholeColumnsInContainer &&
271											!previewTable.classList.contains('wptb-table-preview-head') &&
272											(tableContainerWidth > 480 || wptbPreviewTableMobile.column == 1)
273										) {
274											createNewTableIndic = false;
275										} else {
276											wptbPreviewTableMobile.parentNode.removeChild(wptbPreviewTableMobile);
277										}
278									}
279									//
280									// if indicator of creating of table "true" - continue
281									if (createNewTableIndic) {
282										// create new table for mobile devices
283										const newTable = document.createElement('table');
284
285										// add css class for new mobile table
286										newTable.classList.add('wptb-preview-table-mobile');
287										const infArr = previewTable.className.match(/wptb-element-main(.+)-(\d+)/i);
288										if (infArr && Array.isArray(infArr)) {
289											newTable.classList.add(infArr[0]);
290										}
291
292										// get number of rows for wptb-preview-table
293										const tableRows = previewTable.rows.length;
294
295										// In this variable must have quantity columns of the last section of the new table
296										let newTableLastSectionFilledColumns;
297
298										// set valuesIsSaved in 'false'
299										// if the parameters newTableLastSectionFilledColumns get
300										// optimal values, valuesIsSaved must have value 'true'
301										let valuesIsSaved = false;
302
303										// check if top row is as "header"
304										if (previewTable.classList.contains('wptb-table-preview-head')) {
305											// quantity rows without top row
306											const tableRowsWithoutHeader = tableRows - 1;
307
308											// this variable will have quantity columns in new mobile table
309											let newTableColumnsWithoutLeftHeader;
310
311											// if quantity of rows in desktop table more than
312											// quantity whole columns which are can placed in the container,
313											// execute "loop for"
314											if (tableRows > wholeColumnsInContainer) {
315												// this code, сyclical reduces the number of columns in the new table,
316												// until the optimal view is obtained so that the last block of the new table
317												// has more than half the columns compared to the previous blocks
318												for (let i = 0; i < tableRowsWithoutHeader; i++) {
319													newTableColumnsWithoutLeftHeader = wholeColumnsInContainer - 1 - i;
320													if (newTableColumnsWithoutLeftHeader <= 0)
321														newTableColumnsWithoutLeftHeader = 1;
322
323													newTableLastSectionFilledColumns =
324														tableRowsWithoutHeader % newTableColumnsWithoutLeftHeader;
325
326													if (newTableLastSectionFilledColumns == 0) {
327														valuesIsSaved = true;
328														break;
329													} else if (
330														newTableColumnsWithoutLeftHeader > 0 &&
331														newTableColumnsWithoutLeftHeader <= 6 &&
332														newTableColumnsWithoutLeftHeader -
333															2 * newTableLastSectionFilledColumns <
334															0 &&
335														newTableLastSectionFilledColumns <
336															newTableColumnsWithoutLeftHeader
337													) {
338														valuesIsSaved = true;
339														break;
340													} else if (
341														newTableColumnsWithoutLeftHeader > 6 &&
342														newTableColumnsWithoutLeftHeader <= 12 &&
343														newTableColumnsWithoutLeftHeader -
344															1.8 * newTableLastSectionFilledColumns <
345															0 &&
346														newTableLastSectionFilledColumns <
347															newTableColumnsWithoutLeftHeader
348													) {
349														valuesIsSaved = true;
350														break;
351													} else if (
352														newTableColumnsWithoutLeftHeader > 12 &&
353														newTableColumnsWithoutLeftHeader <= 18 &&
354														newTableColumnsWithoutLeftHeader -
355															1.6 * newTableLastSectionFilledColumns <
356															0 &&
357														newTableLastSectionFilledColumns <
358															newTableColumnsWithoutLeftHeader
359													) {
360														valuesIsSaved = true;
361														break;
362													} else {
363														continue;
364													}
365												}
366											} else {
367												newTableColumnsWithoutLeftHeader = tableRowsWithoutHeader;
368												newTableLastSectionFilledColumns = 0;
369												valuesIsSaved = true;
370											}
371
372											// if all necessary values ​​are available (  ), execute
373											if (valuesIsSaved) {
374												let countRows;
375												if (newTableColumnsWithoutLeftHeader > 0) {
376													countRows =
377														tableColumns *
378														Math.ceil(
379															tableRowsWithoutHeader / newTableColumnsWithoutLeftHeader
380														);
381												} else {
382													countRows = tableColumns;
383												}
384
385												const sectionNumberLast = Math.floor((countRows - 1) / tableColumns);
386												let tdStyles;
387												for (let j = 0; j < countRows; j++) {
388													const sectionNumber = Math.floor(j / tableColumns);
389													const tr = document.createElement('tr');
390													const tdLeftHeader = previewTable.rows[0].children[
391														j - sectionNumber * tableColumns
392													].cloneNode(true);
393													let td;
394													const rowFirstStyles = window.getComputedStyle(
395														previewTable.rows[0]
396													);
397													if (!tdLeftHeader.style.backgroundColor) {
398														tdLeftHeader.style.backgroundColor =
399															rowFirstStyles.backgroundColor;
400													}
401													tdLeftHeader.style.width = null;
402													tdLeftHeader.style.height = null;
403													tdLeftHeader.removeAttribute('data-x-index');
404													tdLeftHeader.removeAttribute('data-wptb-css-td-auto-width');
405													tdStyles = window.getComputedStyle(
406														previewTable.querySelector('td')
407													);
408													if (tdStyles.borderTopColor) {
409														tdLeftHeader.style.borderColor = tdStyles.borderTopColor;
410													} else {
411														tdLeftHeader.style.borderColor = tdStyles.borderBottomColor;
412													}
413													if (sectionNumber > 0 && j % tableColumns == 0) {
414														tdLeftHeader.style.borderTopWidth = '5px';
415													}
416													tr.appendChild(tdLeftHeader);
417
418													for (
419														let k = newTableColumnsWithoutLeftHeader * sectionNumber + 1;
420														k < newTableColumnsWithoutLeftHeader * (sectionNumber + 1) + 1;
421														k++
422													) {
423														if (k < previewTable.rows.length) {
424															td = previewTable.rows[k].children[
425																j - sectionNumber * tableColumns
426															].cloneNode(true);
427															const rowKStyles = window.getComputedStyle(
428																previewTable.rows[k]
429															);
430															if (!td.style.backgroundColor) {
431																td.style.backgroundColor = rowKStyles.backgroundColor;
432															}
433
434															td.style.width = null;
435															td.style.height = null;
436															td.removeAttribute('data-x-index');
437															td.removeAttribute('data-wptb-css-td-auto-width');
438														} else {
439															td = document.createElement('td');
440															td.style.borderWidth = '0px';
441
442															td.style.background = '#fff';
443														}
444
445														tdStyles = window.getComputedStyle(
446															previewTable.querySelector('td')
447														);
448														if (tdStyles.borderTopColor) {
449															td.style.borderColor = tdStyles.borderTopColor;
450														} else {
451															td.style.borderColor = tdStyles.borderBottomColor;
452														}
453
454														if (sectionNumber > 0 && j % tableColumns == 0) {
455															td.style.borderTopWidth = '5px';
456														}
457
458														tr.appendChild(td);
459													}
460
461													newTable.appendChild(tr);
462												}
463											}
464										} else {
465											let newTableColumns;
466											if (tableContainerWidth > 480) {
467												for (let i = 0; i < tableColumns; i++) {
468													newTableColumns = wholeColumnsInContainer - i;
469													if (newTableColumns == 0) newTableColumns = 1;
470													newTableLastSectionFilledColumns = tableColumns % newTableColumns;
471
472													if (newTableLastSectionFilledColumns == 0) {
473														valuesIsSaved = true;
474														break;
475													} else if (
476														newTableColumns > 0 &&
477														newTableColumns <= 6 &&
478														newTableColumns - 2 * newTableLastSectionFilledColumns <= 0 &&
479														newTableLastSectionFilledColumns < newTableColumns
480													) {
481														valuesIsSaved = true;
482														break;
483													} else if (
484														newTableColumns > 6 &&
485														newTableColumns <= 12 &&
486														newTableColumns - 1.8 * newTableLastSectionFilledColumns <= 0 &&
487														newTableLastSectionFilledColumns < newTableColumns
488													) {
489														valuesIsSaved = true;
490														break;
491													} else if (
492														newTableColumns > 12 &&
493														newTableColumns <= 18 &&
494														newTableColumns - 1.6 * newTableLastSectionFilledColumns <= 0 &&
495														newTableLastSectionFilledColumns < newTableColumns
496													) {
497														valuesIsSaved = true;
498														break;
499													} else {
500														continue;
501													}
502												}
503											} else {
504												newTableColumns = 1;
505												newTableLastSectionFilledColumns = 0;
506												valuesIsSaved = true;
507												newTable.column = 1;
508											}
509
510											const increaseRatioRows = Math.ceil(tableColumns / newTableColumns);
511
512											const newTableRows = increaseRatioRows * tableRows;
513
514											if (valuesIsSaved) {
515												for (let i = 0; i < newTableRows; i++) {
516													const sectionNumber = Math.floor(i / tableRows);
517													const tr = document.createElement('tr');
518													let jMax;
519													let jStart;
520													if (
521														sectionNumber != increaseRatioRows - 1 ||
522														newTableLastSectionFilledColumns == 0
523													) {
524														jStart = sectionNumber * newTableColumns;
525														jMax = newTableColumns * (1 + sectionNumber);
526													} else {
527														jStart = tableColumns - newTableLastSectionFilledColumns;
528														jMax = tableColumns;
529													}
530													const row = previewTable.rows[i - sectionNumber * tableRows];
531													tr.classList = row.classList;
532													tr.style.backgroundColor = row.style.backgroundColor;
533
534													for (let j = jStart; j < jMax; j++) {
535														const newTd = row.children[j].cloneNode(true);
536														if (!newTd.style.backgroundColor) {
537															const rowStyles = window.getComputedStyle(row);
538															newTd.style.backgroundColor = rowStyles.backgroundColor;
539														}
540														newTd.style.width = null;
541														newTd.style.height = null;
542														newTd.removeAttribute('data-x-index');
543														newTd.removeAttribute('data-wptb-css-td-auto-width');
544														tr.appendChild(newTd);
545													}
546
547													newTable.appendChild(tr);
548												}
549											}
550										}
551
552										newTable.dataset.wholeColumnsInContainer = wholeColumnsInContainer;
553										const images = newTable.querySelectorAll('[srcset]');
554										if (images.length > 0) {
555											for (let i = 0; i < images.length; i++) {
556												images[i].removeAttribute('srcset');
557											}
558										}
559
560										tableContainer.appendChild(newTable);
561									}
562								}
563							} else {
564								if (tableContainerMatrix) tableContainerMatrix.classList.remove('wptb-matrix-hide');
565								if (tableContainer.getElementsByClassName('wptb-preview-table-mobile').length > 0) {
566									tableContainer
567										.getElementsByClassName('wptb-preview-table-mobile')[0]
568										.classList.add('wptb-mobile-hide');
569								}
570								tableContainer.style.overflow = 'auto';
571							}
572						} else {
573							previewTable.style.minWidth = 'auto';
574						}
575					}
576				}
577			}
578		}
579
580		function wptb_tdDefaultWidth() {
581			const wptbTableContainers = document.getElementsByClassName('wptb-table-container');
582			// let frontendEditLink = document.querySelectorAll( '.wptb-frontend-table-edit-link' );
583			for (let i = 0; i < wptbTableContainers.length; i++) {
584				const wptbTableContainer = wptbTableContainers[i];
585
586				wptbTableContainer.classList.add(`wptb-table-container-${i}`);
587
588				let table = wptbTableContainer.getElementsByClassName('wptb-preview-table');
589				if (table.length > 0) {
590					table = table[0];
591
592					if (table.dataset.wptbTableContainerMaxWidth) {
593						wptbTableContainer.style.maxWidth = `${table.dataset.wptbTableContainerMaxWidth}px`;
594					}
595					table.classList.remove('wptb-table-preview-static-indic');
596
597					table.mergingСellsHorizontally = false;
598					const tds = table.querySelectorAll('td');
599					for (let j = 0; j < tds.length; j++) {
600						if (tds[j].colSpan > 1) {
601							table.mergingСellsHorizontally = true;
602						}
603					}
604					const wptbTableContainerWidth = wptbTableContainer.offsetWidth;
605
606					const td = table.querySelector('td');
607					const tdStyleObj = window.getComputedStyle(td, null);
608					const tdBorderLeftWidth = tdStyleObj.getPropertyValue('border-left-width');
609					const tdBorderRightWidth = tdStyleObj.getPropertyValue('border-right-width');
610					const tdPaddingLeftWidth = tdStyleObj.getPropertyValue('padding-left');
611					const tdPaddingRightWidth = tdStyleObj.getPropertyValue('padding-left');
612					const tdPaddingCommon = parseFloat(tdPaddingLeftWidth, 10) + parseFloat(tdPaddingRightWidth, 10);
613					const tableTdBorderCommonWidth =
614						parseFloat(tdBorderLeftWidth, 10) + parseFloat(tdBorderRightWidth, 10);
615					const { wptbTableTdsSumMaxWidth } = table.dataset;
616					const { wptbFixedWidthSize } = table.dataset;
617					const { wptbCellsWidthAutoCount } = table.dataset;
618					let styleElementCreate = false;
619					let tableTdWidthAuto;
620					if (wptbTableTdsSumMaxWidth < wptbTableContainerWidth) {
621						if (wptbCellsWidthAutoCount) {
622							table.style.minWidth = '100%';
623
624							//                        if( frontendEditLink && frontendEditLink[i] ) {
625							//                            frontendEditLink[i].style.minWidth = wptbTableTdsSumMaxWidth + 'px';
626							//                        }
627
628							if (table.mergingСellsHorizontally) {
629								table.style.width = 'auto';
630								const tableTdsWidthAutoCommon = wptbTableContainerWidth - wptbFixedWidthSize;
631								tableTdWidthAuto = tableTdsWidthAutoCommon / wptbCellsWidthAutoCount;
632								tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
633								styleElementCreate = true;
634							} else {
635								table.style.width = '100%';
636
637								//                            if( frontendEditLink && frontendEditLink[i] ) {
638								//                                frontendEditLink[i].style.width = '100%';
639								//                                frontendEditLink[i].style.maxWidth = '100%';
640								//                            }
641							}
642						} else {
643							table.style.width = 'auto';
644							table.style.minWidth = null;
645							table.style.maxWidth = `${wptbTableTdsSumMaxWidth}px`;
646
647							//                        if( frontendEditLink && frontendEditLink[i] ) {
648							//                            frontendEditLink[i].style.width = null;
649							//                            frontendEditLink[i].style.minWidth = null;
650							//                            frontendEditLink[i].style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
651							//                        }
652						}
653					} else {
654						table.style.maxWidth = null;
655						table.style.minWidth = `${table.dataset.wptbTableTdsSumMaxWidth}px`;
656						table.style.width = 'auto';
657						tableTdWidthAuto = table.dataset.wptbTdWidthAuto ? table.dataset.wptbTdWidthAuto : '100';
658						styleElementCreate = true;
659
660						//                    if( frontendEditLink && frontendEditLink[i] ) {
661						//                        frontendEditLink[i].style.maxWidth = '100%';
662						//                        frontendEditLink[i].style.minWidth = table.dataset.wptbTableTdsSumMaxWidth + 'px';
663						//                        frontendEditLink[i].style.width = null;
664						//                    }
665					}
666
667					const { head } = document;
668					if (head) {
669						const cssForTdsWidthAutoOld = head.querySelector(`style[data-wptb-td-auto-width-${i}="true"]`);
670
671						if (cssForTdsWidthAutoOld) {
672							head.removeChild(cssForTdsWidthAutoOld);
673						}
674					}
675
676					if (styleElementCreate) {
677						const cssForTdsWidthAuto = document.createElement('style');
678						cssForTdsWidthAuto.setAttribute(`data-wptb-td-auto-width-${i}`, true);
679						cssForTdsWidthAuto.innerHTML = `.wptb-table-container-${i} table td[data-wptb-css-td-auto-width=true]{width:${tableTdWidthAuto}px}`;
680						if (head) {
681							head.appendChild(cssForTdsWidthAuto);
682						}
683					}
684				}
685			}
686		}
687
688		// code for adding of old css styles for correct view
689		const elements = document.getElementsByClassName('wptb-ph-element');
690		for (let i = 0; i < elements.length; i++) {
691			const element = elements[i];
692			if (element.classList.contains('wptb-list-item-container')) {
693				element.classList.remove('wptb-list-item-container');
694				element.classList.add('wptb-list-container');
695			}
696
697			if (element.classList.contains('wptb-button-container')) {
698				const infArr = element.className.match(/wptb-size-([A-Z]+)/i);
699				if (infArr && Array.isArray(infArr)) {
700					const wptbSize = infArr[0];
701					const wptbSizeNew = wptbSize.toLowerCase();
702
703					element.classList.remove(wptbSize);
704
705					const wptbButtonWrapper = element.querySelector('.wptb-button-wrapper');
706					if (wptbButtonWrapper) {
707						wptbButtonWrapper.classList.add(wptbSizeNew);
708					}
709				}
710			}
711		}
712
713		// responsive setup
714		// eslint-disable-next-line no-unused-vars
715		const responsiveFront = new WPTB_ResponsiveFrontend({
716			query: '.wptb-preview-table',
717			bindToResize: true,
718		});
719
720		responsiveFront.rebuildTables();
721	});
722})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.