1 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
4 * @file view/theme/frio/js/mod_circle.js
5 * The javascript for the circle module
8 $(document).ready(function () {
9 // Add an event listeners on buttons for switching the contact list view
10 $("body").on("click", ".circle-list-switcher", function () {
11 switchCircleViewMode(this);
16 * Change the circle membership of the contacts and fetch the new grup list
19 * @param {int} gid The circle ID
20 * @param {int} cid The contact ID
21 * @param {string} sec_token The security token
23 * @returns {undefined}
25 function circleChangeMember(gid, cid, sec_token) {
26 $("#contact-entry-wrapper-" + cid).fadeTo("fast", 0.33);
27 $(".tooltip").tooltip("hide");
28 $("body").css("cursor", "wait");
30 $.get("circle/" + gid + "/" + cid + "?t=" + sec_token, function (data) {
31 // Insert the new circle member list
32 $("#circle-update-wrapper").html(data);
34 // Apply the actual circle list view mode to the new
36 var activeMode = $(".circle-list-switcher.active");
37 switchCircleViewMode(activeMode[0]);
39 $("body").css("cursor", "auto");
44 * Change the circle list view mode
46 * @param {object} elm The button element of the view mode switcher
47 * @returns {undefined}
49 function switchCircleViewMode(elm) {
50 // Remove the active class from circle list switcher buttons
51 $(".circle-list-switcher").removeClass("active");
52 // And add it to the active button element
53 $(elm).addClass("active");
55 // Add or remove the css classes for the circle list with regard to the active view mode
56 if (elm.id === "circle-list-small") {
57 $("#contact-circle-list > li").addClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
59 $("#contact-circle-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
64 * Filter the circle member list for contacts
66 * @returns {undefined}
68 function filterList() {
69 const search = document.getElementById("contacts-search").value.toUpperCase();
70 const li = document.querySelectorAll("#contact-circle-list>li");
72 for (let i = 0; i < li.length; i++) {
73 let foundInDisplayName = li[i].getElementsByClassName("media-heading")[0].firstChild.textContent.toUpperCase().indexOf(search) > -1;
74 let foundInAddr = li[i].getElementsByClassName("contact-entry-url")[0].textContent.toUpperCase().indexOf(search) > -1;
76 if (foundInDisplayName || foundInAddr) {
77 li[i].style.display = "";
79 li[i].style.display = "none";