]> git.mxchange.org Git - friendica.git/blob - templates/contacts-template.tpl
contacts page: batch actions are now links in a dropdown menu -
[friendica.git] / templates / contacts-template.tpl
1
2 <div id="contacts" class="standard-page">
3
4         {{$tabs}}
5
6         {{* The page headding with it's contacts counter *}}
7         <h2 class="headding">{{$header}} {{if $total}} ({{$total}}) {{/if}}</h2>
8
9         {{if $finding}}<h4>{{$finding}}</h4>{{/if}}
10
11         {{* The search input field to search for contacts *}}
12         <div id="contacts-search-wrapper">
13                 <form id="contacts-search-form" class="navbar-form" action="{{$cmd}}" method="get" >
14                         <label for="contacts-search" class="contacts-search-desc">{{$desc}}</label><br/>
15                         <div class="input-group">
16                                 <input type="text" name="search" id="contacts-search" class="search-input form-control" onfocus="this.select();" value="{{$search|escape:'html'}}" />
17                                 <div class="input-group-btn">
18                                         <button class="btn btn-default" type="submit" name="submit" id="contacts-search-submit" value="{{$submit|escape:'html'}}"><i class="fa fa-search"></i></button>
19                                 </div>
20                         </div>
21                 </form>
22         </div>
23
24         <hr>
25         <div id="contacts-search-end"></div>
26
27         {{* we need the form container to make batch actions work *}}
28         <form name="batch_actions_submit" action="{{$baseurl}}/contacts/batch/" method="POST">
29
30                 {{* we put here a hidden input element. This is needed to transmit the batch actions with javascript*}}
31                 <input type="hidden" class="batch-action no-input fakelist" name="batch_submit" value="{{$l|escape:'html'}}">
32
33                 {{* We put the contact batch actions in a dropdown menu *}}
34                 <ul class="nav nav-pills preferences">
35                         <li class="dropdown pull-right">
36                                 <a class="btn btn-link dropdown-toggle" type="button" id="BatchActionDropdownMenuTools" data-toggle="dropdown" aria-expanded="true">
37                                         <i class="fa fa-angle-down"></i>
38                                 </a>
39                                 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="BatchActionDropdownMenuTools">
40                                 {{foreach $batch_actions as $n=>$l}}
41                                         <li role="menuitem">
42                                                 {{* call the js batch_submit_handler. Have a look at the buttom of this file *}}
43                                                 <a onclick="batch_submit_handler('{{$n}}', '{{$l}}')">{{$l}}</a>
44                                         </li>
45                                 {{/foreach}}
46                                 </ul>
47                         </li>
48                 </ul>
49                 <div class="clear">
50
51                 {{* format each contact with the contact_template.tpl *}}
52                 <ul id="viewcontact_wrapper" class="viewcontact_wrapper media-list">
53                 {{foreach $contacts as $contact}}
54                         <li>{{include file="contact_template.tpl"}}</li>
55                 {{/foreach}}
56                 </ul>
57                 <div id="contact-edit-end"></div>
58         </form>
59
60         {{$paginate}}
61 </div>
62
63 <script>
64  $(document).ready(function() {
65   // javascript dialog to batch actions
66   $(".batch-action").click(function(e){
67     if (confirm($(this).attr('value')+" ?")) {
68      return true;
69     } else {
70      e.preventDefault();
71      return false;
72     }
73   });
74  
75   // add javascript confirm dialog to "drop" links. Plain html url have "?confirm=1" to show confirmation form, we need to remove it
76   $(".drop").each(function() {
77    $(this).attr('href', $(this).attr('href').replace("confirm=1","") );
78    $(this).click(function(e){
79     if (confirm("{{$contact_drop_confirm}}")) {
80      return true;
81     } else {
82      e.preventDefault();
83      return false;
84     }
85    });
86    
87   });
88  });
89
90 /**
91  * @brief This function submits the form with the batch action values
92  *
93  * @param string name The name of the batch action
94  * @param string value If it isn't empty the action will be posted
95  */
96 function batch_submit_handler(name, value) {
97     // set the value of the hidden input element with the name batch_submit
98     document.batch_actions_submit.batch_submit.value=value;
99     // change the name of the input element from batch_submit according to the
100     // name which is transmitted to this function
101     document.batch_actions_submit.batch_submit.name=name;
102     // transmit the form
103     document.batch_actions_submit.submit() ;
104 }
105  </script>
106