2020-09-27 18:36:33 +02:00
|
|
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
|
2017-04-21 16:04:29 +02:00
|
|
|
|
|
|
|
/**
|
2023-05-14 01:54:35 +02:00
|
|
|
* @file view/theme/frio/js/mod_circle.js
|
|
|
|
* The javascript for the circle module
|
2017-04-21 16:04:29 +02:00
|
|
|
*/
|
|
|
|
|
2021-01-22 14:38:44 +01:00
|
|
|
$(document).ready(function () {
|
2017-04-21 16:04:29 +02:00
|
|
|
// Add an event listeners on buttons for switching the contact list view
|
2023-05-14 01:54:35 +02:00
|
|
|
$("body").on("click", ".circle-list-switcher", function () {
|
|
|
|
switchCircleViewMode(this);
|
2017-04-21 16:04:29 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2023-05-14 01:54:35 +02:00
|
|
|
* Change the circle membership of the contacts and fetch the new grup list
|
2017-04-21 16:04:29 +02:00
|
|
|
* as html
|
2017-05-11 14:54:26 +02:00
|
|
|
*
|
2023-05-14 01:54:35 +02:00
|
|
|
* @param {int} gid The circle ID
|
2017-04-21 16:04:29 +02:00
|
|
|
* @param {int} cid The contact ID
|
|
|
|
* @param {string} sec_token The security token
|
2017-05-11 14:54:26 +02:00
|
|
|
*
|
2017-04-21 16:04:29 +02:00
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
2023-05-14 01:54:35 +02:00
|
|
|
function circleChangeMember(gid, cid, sec_token) {
|
2017-04-23 15:26:26 +02:00
|
|
|
$("#contact-entry-wrapper-" + cid).fadeTo("fast", 0.33);
|
2017-04-21 16:04:29 +02:00
|
|
|
$(".tooltip").tooltip("hide");
|
|
|
|
$("body").css("cursor", "wait");
|
2017-04-23 15:26:26 +02:00
|
|
|
|
2023-05-14 01:54:35 +02:00
|
|
|
$.get("circle/" + gid + "/" + cid + "?t=" + sec_token, function (data) {
|
|
|
|
// Insert the new circle member list
|
|
|
|
$("#circle-update-wrapper").html(data);
|
2017-04-21 16:04:29 +02:00
|
|
|
|
2023-05-14 01:54:35 +02:00
|
|
|
// Apply the actual circle list view mode to the new
|
|
|
|
// circle list html
|
|
|
|
var activeMode = $(".circle-list-switcher.active");
|
|
|
|
switchCircleViewMode(activeMode[0]);
|
2017-04-21 16:04:29 +02:00
|
|
|
|
2021-01-22 14:38:44 +01:00
|
|
|
$("body").css("cursor", "auto");
|
2017-04-21 16:04:29 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-05-14 01:54:35 +02:00
|
|
|
* Change the circle list view mode
|
2017-05-11 14:54:26 +02:00
|
|
|
*
|
2017-04-21 16:04:29 +02:00
|
|
|
* @param {object} elm The button element of the view mode switcher
|
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
2023-05-14 01:54:35 +02:00
|
|
|
function switchCircleViewMode(elm) {
|
|
|
|
// Remove the active class from circle list switcher buttons
|
|
|
|
$(".circle-list-switcher").removeClass("active");
|
2021-01-22 14:38:44 +01:00
|
|
|
// And add it to the active button element
|
|
|
|
$(elm).addClass("active");
|
2017-04-21 16:04:29 +02:00
|
|
|
|
2023-05-14 01:54:35 +02:00
|
|
|
// Add or remove the css classes for the circle list with regard to the active view mode
|
|
|
|
if (elm.id === "circle-list-small") {
|
|
|
|
$("#contact-circle-list > li").addClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
|
2021-01-22 14:38:44 +01:00
|
|
|
} else {
|
2023-05-14 01:54:35 +02:00
|
|
|
$("#contact-circle-list > li").removeClass("shortmode col-lg-6 col-md-6 col-sm-6 col-xs-12");
|
2021-01-22 14:38:44 +01:00
|
|
|
}
|
2017-04-21 16:04:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-05-14 01:54:35 +02:00
|
|
|
* Filter the circle member list for contacts
|
2017-05-11 14:54:26 +02:00
|
|
|
*
|
2017-04-21 16:04:29 +02:00
|
|
|
* @returns {undefined}
|
|
|
|
*/
|
|
|
|
function filterList() {
|
2023-10-15 06:48:44 +02:00
|
|
|
const search = document.getElementById("contacts-search").value.toUpperCase();
|
|
|
|
const li = document.querySelectorAll("#contact-circle-list>li");
|
2017-04-21 16:04:29 +02:00
|
|
|
|
2023-10-15 06:48:44 +02:00
|
|
|
for (let i = 0; i < li.length; i++) {
|
|
|
|
let foundInDisplayName = li[i].getElementsByClassName("media-heading")[0].firstChild.textContent.toUpperCase().indexOf(search) > -1;
|
|
|
|
let foundInAddr = li[i].getElementsByClassName("contact-entry-url")[0].textContent.toUpperCase().indexOf(search) > -1;
|
|
|
|
|
|
|
|
if (foundInDisplayName || foundInAddr) {
|
2017-04-21 16:04:29 +02:00
|
|
|
li[i].style.display = "";
|
|
|
|
} else {
|
|
|
|
li[i].style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-27 18:36:33 +02:00
|
|
|
// @license-end
|