From 85f558d8fb537f0a97111e20f00206ac19cbc054 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 15 Dec 2017 18:09:04 +0100 Subject: [PATCH] frio: fix some contact list issues --- view/theme/frio/js/mod_contacts.js | 60 +++++++++++++++++++ view/theme/frio/js/theme.js | 19 ++++-- .../theme/frio/templates/contact_template.tpl | 42 ++++++------- view/theme/frio/templates/contacts-head.tpl | 25 +------- .../frio/templates/contacts-template.tpl | 53 ++-------------- .../theme/frio/templates/directory_header.tpl | 6 +- 6 files changed, 98 insertions(+), 107 deletions(-) create mode 100644 view/theme/frio/js/mod_contacts.js diff --git a/view/theme/frio/js/mod_contacts.js b/view/theme/frio/js/mod_contacts.js new file mode 100644 index 0000000000..ab57218100 --- /dev/null +++ b/view/theme/frio/js/mod_contacts.js @@ -0,0 +1,60 @@ + +var batchConfirmed = false; + +$(document).ready(function() { + // Add contact_filter autocompletion to the search field. + $("#contacts-search").contact_filter(baseurl + '/acl', 'r', true); + + // Hide the viewcontact_wrapper if there is an input in the search field + // We are doing this to let the the contact_filter replace the original + // shown contacts. + $("#contacts-search").keyup(function(){ + var elText = $(this).val(); + if (elText.length !== 0) { + $("#viewcontact_wrapper").hide(); + $("ul.textcomplete-dropdown").addClass("show media-list"); + } else { + $("#viewcontact_wrapper").show(); + $("ul.textcomplete-dropdown").removeClass("show"); + } + }); + // Initiale autosize for the textareas. + autosize($("textarea.text-autosize")); + + + // Replace the drop contact link of the photo menu + // with a confirmation modal. + $("body").on("click", ".contact-photo-menu a", function(e) { + var photoMenuLink = $(this).attr('href'); + if (typeof photoMenuLink !== "undefined" && photoMenuLink.indexOf("/drop?confirm=1") !== -1) { + e.preventDefault(); + addToModal(photoMenuLink); + return false; + } + }); + +}); + +/** + * @brief This function submits the form with the batch action values. + * + * @param {string} name The name of the batch action. + * @param {string} value If it isn't empty the action will be posted. + * + * @return {void} + */ +function batch_submit_handler(name, value) { + if (confirm(value + " ?")) { + // Set the value of the hidden input element with the name batch_submit. + document.batch_actions_submit.batch_submit.value = value; + // Change the name of the input element from batch_submit according to the + // name which is transmitted to this function. + document.batch_actions_submit.batch_submit.name = name; + // Transmit the form. + document.batch_actions_submit.submit(); + + return true; + } else { + return false; + } +} diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 82cbace5cb..819a7c75c3 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -520,24 +520,31 @@ function filter_replace(item) { return item.name; } -(function( $ ) { +(function($) { $.fn.contact_filter = function(backend_url, typ, autosubmit, onselect) { - if(typeof typ === 'undefined') typ = ''; - if(typeof autosubmit === 'undefined') autosubmit = false; + if (typeof typ === 'undefined') { + typ = ''; + } + + if (typeof autosubmit === 'undefined') { + autosubmit = false; + } // Autocomplete contacts contacts = { match: /(^)([^\n]+)$/, index: 2, - search: function(term, callback) { contact_search(term, callback, backend_url, typ); }, + search: function(term, callback) {contact_search(term, callback, backend_url, typ);}, replace: filter_replace, - template: contact_filter, + template: contact_filter }; this.attr('autocomplete','off'); var a = this.textcomplete([contacts], {className:'accontacts', appendTo: '#contact-list'}); - a.on('textComplete:select', function(e, value, strategy) { $(".dropdown-menu.textcomplete-dropdown.media-list").show(); }); + a.on('textComplete:select', function(e, value, strategy) { + $(".dropdown-menu.textcomplete-dropdown.media-list").show(); + }); }; })( jQuery ); diff --git a/view/theme/frio/templates/contact_template.tpl b/view/theme/frio/templates/contact_template.tpl index 2824ff22b9..b26e4fcbd0 100644 --- a/view/theme/frio/templates/contact_template.tpl +++ b/view/theme/frio/templates/contact_template.tpl @@ -1,24 +1,20 @@
- {{* This is a wrapper for the contact picture and the dropdown menu with contact relating actions *}} + {{* This is a wrapper for the contact picture *}} - - - diff --git a/view/theme/frio/templates/directory_header.tpl b/view/theme/frio/templates/directory_header.tpl index 2bdd07a69c..4bb739e78c 100644 --- a/view/theme/frio/templates/directory_header.tpl +++ b/view/theme/frio/templates/directory_header.tpl @@ -8,10 +8,6 @@ {{include file="section_title.tpl"}} -{{if $findterm}} -

{{$finding}} {{$findterm}}

-{{/if}} - {{* The search input field to search for contacts *}}