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