]> git.mxchange.org Git - friendica.git/blob - view/templates/acl/message_recipient.tpl
Update translation fie after adding a string
[friendica.git] / view / templates / acl / message_recipient.tpl
1 <select name="recipient" class="form-control input-lg" id="recipient">
2         {{foreach $contacts as $contact}}
3                 <option value="{{$contact.id}}"{{if $contact.id == $selected}} selected{{/if}}>{{$contact.name}}</option>
4         {{/foreach}}
5 </select>
6 <script type="text/javascript">
7         $(function() {
8                 let $recipient_input = $('[name="recipient"]');
9
10                 let acl = new Bloodhound({
11                         local: {{$contacts|@json_encode nofilter}},
12                         identify: function(obj) { return obj.id.toString(); },
13                         datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
14                         queryTokenizer: Bloodhound.tokenizers.whitespace,
15                         sorter: function (itemA, itemB) {
16                                 if (itemA.name === itemB.name) {
17                                         return 0;
18                                 } else if (itemA.name > itemB.name) {
19                                         return 1;
20                                 } else {
21                                         return -1;
22                                 }
23                         },
24                 });
25                 acl.initialize();
26
27                 let suggestionTemplate = function (item) {
28                         return '<div><img src="' + item.micro + '" alt="" style="float: left; width: auto; height: 2.8em; margin-right: 0.5em;"><p style="margin-left: 3.3em;"><strong>' + item.name + '</strong><br /><em>' + item.addr + '</em></p></div>';
29                 };
30
31                 $recipient_input.tagsinput({
32                         confirmKeys: [13, 44],
33                         freeInput: false,
34                         tagClass: 'label label-info',
35                         itemValue: function (item) { return item.id.toString(); },
36                         itemText: 'name',
37                         itemThumb: 'micro',
38                         itemTitle: function(item) {
39                                 return item.addr;
40                         },
41                         typeaheadjs: {
42                                 name: 'contacts',
43                                 displayKey: 'name',
44                                 templates: {
45                                         suggestion: suggestionTemplate
46                                 },
47                                 source: acl.ttAdapter()
48                         }
49                 });
50
51                 // Import existing ACL into the tags input fields.
52                 $recipient_input.tagsinput('add', acl.get({{$selected}})[0]);
53         });
54 </script>