]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/mod_group.js
spelling: special
[friendica.git] / view / theme / frio / js / mod_group.js
1 // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
2
3 /**
4  * @file view/theme/frio/js/mod_group.js
5  * The javascript for the group module
6  */
7
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);
12         });
13 });
14
15 /**
16  * Change the group membership of the contacts and fetch the new grup list
17  * as html
18  *
19  * @param {int} gid The group ID
20  * @param {int} cid The contact ID
21  * @param {string} sec_token The security token
22  *
23  * @returns {undefined}
24  */
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");
29
30         $.get("group/" + gid + "/" + cid + "?t=" + sec_token, function (data) {
31                 // Insert the new group member list
32                 $("#group-update-wrapper").html(data);
33
34                 // Apply the actual group list view mode to the new
35                 // group list html
36                 var activeMode = $(".group-list-switcher.active");
37                 switchGroupViewMode(activeMode[0]);
38
39                 $("body").css("cursor", "auto");
40         });
41 }
42
43 /**
44  * Change the group list view mode
45  *
46  * @param {object} elm The button element of the view mode switcher
47  * @returns {undefined}
48  */
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");
54
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");
58         } else {
59                 $("#contact-group-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
60         }
61 }
62
63 /**
64  * Filter the group member list for contacts
65  *
66  * @returns {undefined}
67  */
68 function filterList() {
69         // Declare variables
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");
74
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
81                 a = mh.firstChild;
82                 if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
83                         li[i].style.display = "";
84                 } else {
85                         li[i].style.display = "none";
86                 }
87         }
88 }
89 // @license-end