]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/mod_group.js
Merge pull request #9506 from annando/test-mysql-no-pdo
[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
9 $(document).ready(function() {
10         // Add an event listeners on buttons for switching the contact list view
11         $("body").on("click", ".group-list-switcher", function() {
12                 switchGroupViewMode(this);
13         });
14 });
15
16 /**
17  * Change the group membership of the contacts and fetch the new grup list
18  * as html
19  *
20  * @param {int} gid The group ID
21  * @param {int} cid The contact ID
22  * @param {string} sec_token The security token
23  *
24  * @returns {undefined}
25  */
26 function groupChangeMember(gid, cid, sec_token) {
27         $("#contact-entry-wrapper-" + cid).fadeTo("fast", 0.33);
28         $(".tooltip").tooltip("hide");
29         $("body").css("cursor", "wait");
30
31         $.get('group/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
32                         // Insert the new group member list
33                         $("#group-update-wrapper").html(data);
34
35                         // Apply the actual gropu list view mode to the new
36                         // group list html
37                         var activeMode = $(".group-list-switcher.active");
38                         switchGroupViewMode(activeMode[0]);
39
40                         $("body").css("cursor", "auto");
41         });
42 }
43
44 /**
45  * Change the group list view mode
46  *
47  * @param {object} elm The button element of the view mode switcher
48  * @returns {undefined}
49  */
50 function switchGroupViewMode(elm) {
51                 // Remove the active class from group list switcher buttons
52                 $(".group-list-switcher").removeClass("active");
53                 // And add it to the active button element
54                 $(elm).addClass("active");
55
56                 // Add or remove the css classes for the group list with regard to the active view mode
57                 if (elm.id === "group-list-small") {
58                         $("#contact-group-list > li").addClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
59                 } else {
60                         $("#contact-group-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
61                 }
62 }
63
64 /**
65  * Filter the group member list for contacts
66  *
67  * @returns {undefined}
68  */
69 function filterList() {
70         // Declare variables
71         var input, filter, ul, li, a, i;
72         input = document.getElementById("contacts-search");
73         filter = input.value.toUpperCase();
74         li = document.querySelectorAll("#contact-group-list>li");
75
76         // Loop through all list items, and hide those who don't match the search query
77         for (i = 0; i < li.length; i++) {
78                 // Get the heading element
79                 var mh = li[i].getElementsByClassName("media-heading")[0];
80                 // The first child of the heading element should contain
81                 // the text which we want to filter
82                 a = mh.firstChild;
83                 if (a.innerHTML.toUpperCase().indexOf(filter) > -1) {
84                         li[i].style.display = "";
85                 } else {
86                         li[i].style.display = "none";
87                 }
88         }
89 }
90 // @license-end