Skip to content
Merged
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
57 changes: 34 additions & 23 deletions ietf/static/js/list.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import * as List from "list.js";

var dummy = new List();
import {
default as List
} from "list.js";

function text_sort(a, b, options) {

function prep(e, options) {
return $($.parseHTML(e.values()[options.valueName]))
.text()
.trim()
.replaceAll(/\s+/g, ' ');
}

// sort by text content
return dummy.utils.naturalSort.caseInsensitive($($.parseHTML(a.values()[options.valueName]))
.text()
.trim()
.replaceAll(/\s+/g, ' '), $($.parseHTML(b.values()[options.valueName]))
.text()
.trim()
.replaceAll(/\s+/g, ' '));
return prep(a, options).localeCompare(prep(b, options), "en", {
sensitivity: "base",
ignorePunctuation: true
});
}

function replace_with_internal(table, internal_table, i) {
Expand Down Expand Up @@ -204,12 +209,12 @@ $(document)
}

let newlist = new List(hook, pagination ? {
valueNames: fields,
pagination: pagination,
page: items_per_page
} : {
valueNames: fields
});
valueNames: fields,
pagination: pagination,
page: items_per_page
} : {
valueNames: fields
});
// override search module with a patched version
// see https://github.com/javve/list.js/issues/699
// TODO: check if this is still needed if list.js ever sees an update
Expand All @@ -220,7 +225,7 @@ $(document)
if (enable_search) {
reset_search.on("click", function () {
search_field.val("");
$.each(list_instance, (i, e) => {
$.each(list_instance, (_, e) => {
e.search();
});
});
Expand All @@ -229,7 +234,7 @@ $(document)
if (event.key == "Escape") {
reset_search.trigger("click");
} else {
$.each(list_instance, (i, e) => {
$.each(list_instance, (_, e) => {
e.search($(this)
.val());
});
Expand All @@ -242,16 +247,19 @@ $(document)
.on("click", function () {
var order = $(this)
.hasClass("asc") ? "desc" : "asc";
$.each(list_instance, (i, e) => {
$.each(list_instance, (_, e) => {
e.sort($(this)
.attr("data-sort"), { order: order, sortFunction: text_sort });
.attr("data-sort"), {
order: order,
sortFunction: text_sort
});
});
});

$.each(list_instance, (i, e) => {
e.on("sortComplete", function () {
replace_with_internal(table, internal_table, i);
$(table).find("[data-bs-original-title]").tooltip();
$(table).find("[data-bs-original-title]").tooltip();
if (i == list_instance.length - 1) {
$(table)
.find("thead:first tr")
Expand Down Expand Up @@ -287,8 +295,11 @@ $(document)
if (presort_col) {
const order = presort_col.attr("data-default-sort");
if (order === "asc" || order === "desc") {
$.each(list_instance, (i, e) => {
e.sort(presort_col.attr("data-sort"), { order: order, sortFunction: text_sort });
$.each(list_instance, (_, e) => {
e.sort(presort_col.attr("data-sort"), {
order: order,
sortFunction: text_sort
});
});
}
}
Expand Down