Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name="itemtype"
type="itemtype"
filtermode="selector"
onchange="jQuery('select[id^=\'filter_\']').val('');jQuery('select[id^=\'list_\']').val('');this.form.submit();"
onchange="Joomla.resetFilters(this)"
>
<option value="">COM_ASSOCIATIONS_FILTER_SELECT_ITEM_TYPE</option>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<field
name="client_id"
type="list"
onchange="jQuery('#filter_search, select[id^=filter_], #list_fullordering').val('');this.form.submit();"
onchange="Joomla.resetFilters(this)"
filtermode="selector"
>
<option value="0">JSITE</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
label=""
filtermode="selector"
layout="default"
onchange="jQuery('#filter_position, #filter_module, #filter_language').val('');this.form.submit();"
onchange="Joomla.resetFilters(this)"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name="client_id"
type="list"
filtermode="selector"
onchange="jQuery('#filter_search, select[id^=filter_], #list_fullordering').val('');this.form.submit();"
onchange="Joomla.resetFilters(this)"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name="client_id"
type="list"
filtermode="selector"
onchange="jQuery('#filter_search, select[id^=filter_], #list_fullordering').val('');this.form.submit();"
onchange="Joomla.resetFilters(this)"
>
<option value="0">JSITE</option>
<option value="1">JADMINISTRATOR</option>
Expand Down
39 changes: 39 additions & 0 deletions build/media_src/system/js/core.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,45 @@ window.Joomla.Modal = window.Joomla.Modal || {
};

/**
* Method that resets the filter inputs and submits the relative form
*
* @param {HTMLElement} The element that initiates the call
* @returns {void}
* @since 4.0
*/
Joomla.resetFilters = (element) => {
const { form } = element;

if (!form) {
throw new Error('Element must be inside a form!');
}

const elementsArray = [].slice.call(form.elements);

if (elementsArray.length) {
const newElementsArray = [];
elementsArray.forEach((elem) => {
// Skip the token, the task, the boxchecked and the calling element
if (elem.getAttribute('name') === 'task'
|| elem.getAttribute('name') === 'boxchecked'
|| (elem.value === '1' && /^[0-9A-F]{32}$/i.test(elem.name))
|| elem === element) {
return;
}

newElementsArray.push(elem);
});

// Reset all filters
newElementsArray.forEach((elem) => {
elem.value = '';
});

form.submit();
}
};

/*
* Method to invoke a click on button inside an iframe
*
* @param {object} options Object with the css selector for the parent element of an iframe
Expand Down