]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/mod_contacts.js
Avoid memory issue in exception
[friendica.git] / view / theme / frio / js / mod_contacts.js
1
2 var batchConfirmed = false;
3
4 $(document).ready(function() {
5         // Add contact_filter autocompletion to the search field.
6         $("#contacts-search").contact_filter(baseurl + '/acl', 'r', true);
7
8         // Hide the viewcontact_wrapper if there is an input in the search field
9         // We are doing this to let the the contact_filter replace the original
10         // shown contacts.
11         $("#contacts-search").keyup(function(){
12                 var elText = $(this).val();
13                 if (elText.length !== 0) {
14                         $("#viewcontact_wrapper").hide();
15                         $("ul.textcomplete-dropdown").addClass("show media-list");
16                 } else {
17                         $("#viewcontact_wrapper").show();
18                         $("ul.textcomplete-dropdown").removeClass("show");
19                 }
20         });
21         // Initiale autosize for the textareas.
22         autosize($("textarea.text-autosize"));
23
24
25         // Replace the drop contact link of the photo menu
26         // with a confirmation modal.
27         $("body").on("click", ".contact-photo-menu a", function(e) {
28                 var photoMenuLink = $(this).attr('href');
29                 if (typeof photoMenuLink !== "undefined" && photoMenuLink.indexOf("/drop?confirm=1") !== -1) {
30                         e.preventDefault();
31                         addToModal(photoMenuLink);
32                         return false;
33                 }
34         });
35
36 });
37
38 /**
39  * @brief This function submits the form with the batch action values.
40  *
41  * @param {string} name The name of the batch action.
42  * @param {string} value If it isn't empty the action will be posted.
43  * 
44  * @return {void}
45  */
46 function batch_submit_handler(name, value) {
47         if (confirm(value + " ?")) {
48                 // Set the value of the hidden input element with the name batch_submit.
49                 document.batch_actions_submit.batch_submit.value = value;
50                 // Change the name of the input element from batch_submit according to the
51                 // name which is transmitted to this function.
52                 document.batch_actions_submit.batch_submit.name = name;
53                 // Transmit the form.
54                 document.batch_actions_submit.submit();
55
56                 return true;
57         } else {
58                 return false;
59         }
60 }