2 var batchConfirmed = false;
4 $(document).ready(function() {
5 // Add contact_filter autocompletion to the search field.
6 $("#contacts-search").contact_filter(baseurl + '/acl', 'r', true);
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
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");
17 $("#viewcontact_wrapper").show();
18 $("ul.textcomplete-dropdown").removeClass("show");
21 // Initiale autosize for the textareas.
22 autosize($("textarea.text-autosize"));
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) {
31 addToModal(photoMenuLink);
39 * @brief This function submits the form with the batch action values.
41 * @param {string} name The name of the batch action.
42 * @param {string} value If it isn't empty the action will be posted.
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;
54 document.batch_actions_submit.submit();