-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into 4129-new-findaproject-performance
- Loading branch information
Showing
169 changed files
with
7,538 additions
and
270,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Author: willnigeldejesus@gmail.com | ||
* Date: 22th Oct 2024 | ||
*/ | ||
|
||
(function($) { | ||
|
||
$.fn.filterableTable = function(options) { | ||
|
||
const selector = this.attr('data-filterable-table-selector'); | ||
|
||
const $form = this; | ||
const $table = this.find(`#${selector}`); | ||
|
||
$form.on('keydown', 'input', function(event) { | ||
if (event.key === 'Enter') { | ||
event.preventDefault(); | ||
$(this).trigger('change'); | ||
} | ||
}); | ||
|
||
$form.on('change', function() { | ||
$('html').addClass('page-busy'); | ||
|
||
const formData = $form.serialize(); | ||
const queryParams = new URLSearchParams(formData).toString(); | ||
const newUrl = `${window.location.pathname}?${queryParams}`; | ||
history.pushState(null, '', newUrl); | ||
|
||
$.ajax({ | ||
url: $form.attr('action'), | ||
method: $form.attr('method'), | ||
data: formData, | ||
success: function(response) { | ||
$table.html(response) | ||
bindSortingClickEvent($table, $form); | ||
$table.find('.dataTables_empty').attr('colspan', $table.find('th').length); | ||
$table.find('.dataTables_empty').css('display', ''); | ||
|
||
$('html').removeClass('page-busy'); | ||
}, | ||
error: function(jqXHR, textStatus, errorThrown) { | ||
console.error('Error:', textStatus, errorThrown); | ||
|
||
$('html').removeClass('page-busy'); | ||
} | ||
}); | ||
}); | ||
|
||
bindSortingClickEvent($table, $form); | ||
$table.find('.dataTables_empty').attr('colspan', $table.find('th').length); | ||
$table.find('.dataTables_empty').css('display', ''); | ||
|
||
function bindSortingClickEvent($table, $form) { | ||
$table.off('click', '.sorting'); | ||
$table.on('click', '.sorting', function(event) { | ||
const $sortElement = $(this); | ||
const sortParam = $sortElement.attr('data-sort'); | ||
const order = $sortElement.hasClass('sorting_asc') ? 'desc' : 'asc'; | ||
|
||
$form.find('#sort').val(sortParam); | ||
$form.find('#order').val(order); | ||
|
||
$form.trigger('change'); | ||
}); | ||
} | ||
} | ||
|
||
})(jQuery); |
Oops, something went wrong.