]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/mod_circle.js
Some more settings moved to the admin frontend
[friendica.git] / view / theme / frio / js / mod_circle.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_circle.js
5  * The javascript for the circle module
6  */
7
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);
12         });
13 });
14
15 /**
16  * Change the circle membership of the contacts and fetch the new grup list
17  * as html
18  *
19  * @param {int} gid The circle ID
20  * @param {int} cid The contact ID
21  * @param {string} sec_token The security token
22  *
23  * @returns {undefined}
24  */
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");
29
30         $.get("circle/" + gid + "/" + cid + "?t=" + sec_token, function (data) {
31                 // Insert the new circle member list
32                 $("#circle-update-wrapper").html(data);
33
34                 // Apply the actual circle list view mode to the new
35                 // circle list html
36                 var activeMode = $(".circle-list-switcher.active");
37                 switchCircleViewMode(activeMode[0]);
38
39                 $("body").css("cursor", "auto");
40         });
41 }
42
43 /**
44  * Change the circle list view mode
45  *
46  * @param {object} elm The button element of the view mode switcher
47  * @returns {undefined}
48  */
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");
54
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");
58         } else {
59                 $("#contact-circle-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
60         }
61 }
62
63 /**
64  * Filter the circle member list for contacts
65  *
66  * @returns {undefined}
67  */
68 function filterList() {
69         const search = document.getElementById("contacts-search").value.toUpperCase();
70         const li     = document.querySelectorAll("#contact-circle-list>li");
71
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;
75
76                 if (foundInDisplayName || foundInAddr) {
77                         li[i].style.display = "";
78                 } else {
79                         li[i].style.display = "none";
80                 }
81         }
82 }
83 // @license-end