3 * @file view/theme/frio/js/mod_group.js
4 * @brief 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 * @brief 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 $(".tooltip").tooltip("hide");
27 $("body").css("cursor", "wait");
28 $.get('group/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
29 // Insert the new group member list
30 $("#group-update-wrapper").html(data);
32 // Apply the actual gropu list view mode to the new
34 var activeMode = $(".group-list-switcher.active");
35 switchGroupViewMode(activeMode[0]);
37 $("body").css("cursor", "auto");
42 * @brief Change the group list view mode
44 * @param {object} elm The button element of the view mode switcher
45 * @returns {undefined}
47 function switchGroupViewMode(elm) {
48 // Remove the active class from group list switcher buttons
49 $(".group-list-switcher").removeClass("active");
50 // And add it to the active button element
51 $(elm).addClass("active");
53 // Add or remove the css classes for the group list with regard to the active view mode
54 if (elm.id === "group-list-small") {
55 $("#contact-group-list > li").addClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
57 $("#contact-group-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
62 * @brief Filter the group member list for contacts
64 * @returns {undefined}
66 function filterList() {
68 var input, filter, ul, li, a, i;
69 input = document.getElementById("contacts-search");
70 filter = input.value.toUpperCase();
71 li = document.querySelectorAll("#contact-group-list>li");
73 // Loop through all list items, and hide those who don't match the search query
74 for (i = 0; i < li.length; i++) {
75 // Get the heading element
76 var mh = li[i].getElementsByClassName("media-heading")[0];
77 // The first child of the heading element should contain
78 // the text which we want to filter
80 if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
81 li[i].style.display = "";
83 li[i].style.display = "none";