# contact-forms/trunk/assets/js/admin/submissions-list.js

Contact Forms by Cimatti, version trunk. 160 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/trunk/code/assets/js/admin/submissions-list.js
- Raw: https://pluginprobe.com/plugins/contact-forms/trunk/raw/assets/js/admin/submissions-list.js
- Modified: 2026-08-21T08:39:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/trunk/code/assets/js/admin/submissions-list.js#L10-L20`.

```javascript
/**
 * Submissions list page - export and essential columns functionality.
 *
 * @package ContactForms
 * @since 2.2.5
 */
/* global jQuery, ajaxurl, pagenow, accuaSubmissionsList */
( function( $ ) {
	var config = accuaSubmissionsList || {};

	window.set_parameter = function( sel_column ) {
		var stringa = '';
		var name_action = ajaxurl + '?action=accua_forms_submission_page_save_excel'
			+ config.exportParams
			+ '&_wpnonce=' + config.exportNonce;

		if ( sel_column ) {
			$( '#adv-settings input[type=checkbox]:checked' ).each( function() {
				stringa += this.value + '%2C';
			} );
		} else {
			$( '#adv-settings input[type=checkbox]' ).each( function() {
				stringa += this.value + '%2C';
			} );
		}

		var search = $( '#search_id-search-input' ).val();
		var pid = $( 'select[name="pid"]' ).val();
		var fid = $( 'select[name="fid"]' ).val();
		var year = $( 'select[name="year"]' ).val();
		var month = $( 'select[name="month"]' ).val();
		if ( search ) name_action += '&s=' + encodeURIComponent( search );
		if ( pid && pid !== '-1' ) name_action += '&pid=' + pid;
		if ( fid && fid !== '-1' ) name_action += '&fid=' + fid;
		if ( year && year !== '-1' ) name_action += '&year=' + year;
		if ( month && month !== '-1' ) name_action += '&month=' + month;
		if ( stringa ) name_action += '&accua_show_field=' + stringa;

		if ( sel_column ) {
			$( '#esporta_link_visible_column' ).attr( 'href', name_action );
		} else {
			$( '#esporta_link_all_column' ).attr( 'href', name_action );
		}
	};

	window.accuaToggleAllRows = function( open ) {
		$( '#accua_forms_submissions_list_page .wp-list-table .accua-expandable-cell' ).each( function() {
			if ( this.classList.contains( 'open' ) !== open ) {
				this.querySelector( '.accua-expandable-toggle' ).click();
			}
		} );
	};

	/**
	 * Sticky horizontal scrollbar for the submissions table.
	 *
	 * The table lives in .accua-table-scroll (see the display() override) so
	 * that a table wider than the screen scrolls on its own instead of
	 * dragging the whole admin page sideways. That box is as tall as the
	 * table, though, so its scrollbar sits at the foot of up to a hundred
	 * rows: invisible, and out of reach for anyone without a trackpad or the
	 * shift+wheel habit.
	 *
	 * So: a proxy scrollbar that rides the bottom of the viewport while the
	 * table is on screen, scrolling the box as it moves and following it back.
	 * The real scrollbar is hidden only once this is in place (the class is
	 * added here, not in the stylesheet), so the native one still works if
	 * this script never runs.
	 */
	function initStickyScrollbar() {
		var box = document.querySelector( '#accua_forms_submissions_list_page .accua-table-scroll' );
		if ( ! box || box.nextElementSibling && box.nextElementSibling.classList.contains( 'accua-table-scrollbar' ) ) {
			return;
		}

		var bar = document.createElement( 'div' );
		bar.className = 'accua-table-scrollbar';
		// It duplicates a scroll the box already offers; keep it out of the
		// accessibility tree and out of the tab order.
		bar.setAttribute( 'aria-hidden', 'true' );
		var inner = document.createElement( 'div' );
		bar.appendChild( inner );
		box.insertAdjacentElement( 'afterend', bar );

		// Mirroring scrollLeft both ways means each assignment fires a scroll
		// event on the other element, which would bounce straight back. The
		// guard is the comparison, not a flag: by the time the echo arrives
		// the two already agree and it stops there. A flag would be worse than
		// useless here - scroll events are asynchronous, and assigning a value
		// the element already has fires nothing at all, so a flag set on the
		// way out could sit raised forever and swallow the next real scroll.
		function mirror( from, to ) {
			return function () {
				if ( to.scrollLeft !== from.scrollLeft ) {
					to.scrollLeft = from.scrollLeft;
				}
			};
		}
		bar.addEventListener( 'scroll', mirror( bar, box ) );
		box.addEventListener( 'scroll', mirror( box, bar ) );

		function refresh() {
			var overflows = box.scrollWidth > box.clientWidth;
			bar.style.display = overflows ? '' : 'none';
			box.classList.toggle( 'has-sticky-scrollbar', overflows );
			inner.style.width = box.scrollWidth + 'px';
		}

		refresh();
		window.addEventListener( 'resize', refresh );

		// Expanding a cell rewraps its content, which can change how wide the
		// table wants to be; so can showing or hiding a column.
		if ( window.ResizeObserver ) {
			new window.ResizeObserver( refresh ).observe( box.firstElementChild || box );
		}
	}

	$( window ).on( 'load', function () {
		// expandable-cells.js measures and rewrites cells on load too; let it
		// finish first so the width read here is the final one.
		window.setTimeout( initStickyScrollbar, 0 );
	} );

	window.setEssentialColumns = function() {
		// Canonical list comes from Accua_Forms_Submissions_List_Table::essential_columns()
		// (always-essential main columns + the fields flagged "Show in essential
		// columns" on the Fields page); the literal is only a fallback.
		var essentialCols = config.essentialCols || [ 'singlesub', 'ID', 'form_title', 'submitted' ];
		var changed = false;

		$( '#adv-settings input.hide-column-tog' ).each( function() {
			var col = this.value;
			var shouldBeVisible = essentialCols.indexOf( col ) !== -1;
			if ( $( this ).prop( 'checked' ) !== shouldBeVisible ) {
				changed = true;
				$( this ).prop( 'checked', shouldBeVisible );
				$( 'th[id="' + col + '"]' ).toggleClass( 'hidden', ! shouldBeVisible );
			}
		} );

		if ( ! changed ) {
			return;
		}

		var hidden = $( '.manage-column[id]' ).filter( '.hidden' ).map( function() {
			return this.id;
		} ).get().join( ',' );

		$.post( ajaxurl, {
			action: 'hidden-columns',
			hidden: hidden,
			screenoptionnonce: $( '#screenoptionnonce' ).val(),
			page: pagenow
		} ).always( function() {
			location.reload();
		} );
	};
}( jQuery ) );

```
