1 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
4 * @file view/theme/frio/js/mod_group.js
5 * The javascript for the group module
8 $(document).ready(function () {
9 // Add an event listeners on buttons for switching the contact list view
10 $("body").on("click", ".group-list-switcher", function () {
11 switchGroupViewMode(this);
16 * Change the group membership of the contacts and fetch the new grup list
19 * @param {int} gid The group ID
20 * @param {int} cid The contact ID
21 * @param {string} sec_token The security token
23 * @returns {undefined}
25 function groupChangeMember(gid, cid, sec_token) {
26 $("#contact-entry-wrapper-" + cid).fadeTo("fast", 0.33);
27 $(".tooltip").tooltip("hide");
28 $("body").css("cursor", "wait");
30 $.get("group/" + gid + "/" + cid + "?t=" + sec_token, function (data) {
31 // Insert the new group member list
32 $("#group-update-wrapper").html(data);
34 // Apply the actual gropu list view mode to the new
36 var activeMode = $(".group-list-switcher.active");
37 switchGroupViewMode(activeMode[0]);
39 $("body").css("cursor", "auto");
44 * Change the group list view mode
46 * @param {object} elm The button element of the view mode switcher
47 * @returns {undefined}
49 function switchGroupViewMode(elm) {
50 // Remove the active class from group list switcher buttons
51 $(".group-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 group list with regard to the active view mode
56 if (elm.id === "group-list-small") {
57 $("#contact-group-list > li").addClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
59 $("#contact-group-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
64 * Filter the group member list for contacts
66 * @returns {undefined}
68 function filterList() {
70 var input, filter, ul, li, a, i;
71 input = document.getElementById("contacts-search");
72 filter = input.value.toUpperCase();
73 li = document.querySelectorAll("#contact-group-list>li");
75 // Loop through all list items, and hide those who don't match the search query
76 for (i = 0; i < li.length; i++) {
77 // Get the heading element
78 var mh = li[i].getElementsByClassName("media-heading")[0];
79 // The first child of the heading element should contain
80 // the text which we want to filter
82 if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
83 li[i].style.display = "";
85 li[i].style.display = "none";