source: extensions/ContactForm/admin/template/emails.tpl @ 17945

Last change on this file since 17945 was 17945, checked in by mistic100, 12 years ago
  • stores emails in database (/!\ update only from published version, not from trunk)
  • allow emails to be categorized
File size: 3.9 KB
Line 
1{combine_css path=$CONTACT_FORM_PATH|@cat:"admin/template/style.css"}
2
3
4<div class="titrePage">
5        <h2>Contact Form</h2>
6</div>
7
8
9<form method="post" action="{$CONTACT_FORM_ADMIN}-emails" class="properties">
10  <table class="table2" id="emails">
11    <tr class="throw">
12      <th>{'Name'|@translate}</th>
13      <th>{'Email address'|@translate}</th>
14      <th>{'Category'|@translate}</th>
15      <th>{'Active'|@translate}</th>
16      <th>{'Delete'|@translate}</th>
17    </tr>
18  {counter start=0 assign=i}
19  {foreach from=$EMAILS item=entry}
20    <tr class="{if $i is odd}row1{else}row2{/if}">
21      <td>
22        <input type="text" name="emails[{$i}][name]" value="{$entry.name|escape:html}" size="20">
23      </td>
24      <td>
25        <input type="text" name="emails[{$i}][email]" value="{$entry.email}" size="30">
26      </td>
27      <td>
28        <select name="emails[{$i}][group_name]" class="groups">
29          <option value="-1">------------</option>
30          {html_options values=$GROUPS output=$GROUPS selected=$entry.group_name}
31        </select>
32      </td>
33      <td style="text-align:center;">
34        <input type="checkbox" name="emails[{$i}][active]" value="1" {if $entry.active}checked="checked"{/if}>
35      </td>
36      <td style="text-align:center;">
37        <input type="checkbox" name="emails[{$i}][delete]" value="1" class="delete">
38      </td>
39    </tr>
40    {counter}
41  {/foreach}
42    <tr class="{if $i is odd}row1{else}row2{/if}" id="addEntryContainer">
43      <td colspan="2" style="text-align:center;">
44        <a id="addEntry">{'+ Add an email'|@translate}</a>
45      </td>
46      <td>
47        <a id="addGroup">{'+ Add a category'|@translate}</a>
48      </td>
49      <td colspan="2"  style="text-align:center;">
50        <input type="submit" name="save_emails" value="{'Submit'|@translate}" class="submit">
51      </td>
52    </tr>
53  </table>
54  {footer_script}var entry = {$i};{/footer_script}
55</form>
56
57
58
59{footer_script}
60var group_options = new Array;
61{foreach from=$GROUPS item=entry}
62group_options[group_options.length] = '<option value="{$entry|escape:javascript}">{$entry|escape:javascript}</option>';
63{/foreach}
64
65{literal}
66var doBlink = function(obj,start,finish) { jQuery(obj).fadeOut(300).fadeIn(300); if(start!=finish) { start=start+1; doBlink(obj,start,finish); } };
67jQuery.fn.blink = function(start,finish) { return this.each(function() { doBlink(this,start,finish) }); };
68
69jQuery(document).on('change', '.delete', function() {
70  if ($(this).is(':checked')) {
71    $(this).parents('tr').addClass('delete');
72  } else {
73    $(this).parents('tr').removeClass('delete');
74  }
75});
76
77jQuery('#addEntry').click(function() {
78  entry++;
79  i = entry;
80 
81  content =
82    '<tr class="row'+ (i%2+1) +'">'+
83      '<td>'+
84        '<input type="text" name="emails['+ i +'][name]" size="20">'+
85      '</td>'+
86      '<td>'+
87        '<input type="text" name="emails['+ i +'][email]" size="30">'+
88      '</td>'+
89      '<td>'+
90        '<select name="emails['+ i +'][group_name]" class="groups">'+
91          '<option value="-1">------------</option>';
92          for (var j in group_options) {
93            content+= group_options[j];
94          }
95        content+= '</select>'+
96      '</td>'+
97      '<td style="text-align:center;">'+
98        '<input type="checkbox" name="emails['+ i +'][active]" value="1" checked="checked">'+
99      '</td>'+
100      '<td style="text-align:center;">'+
101        '<input type="checkbox" name="emails['+ i +'][delete]" value="1" class="delete">'+
102      '</td>'+
103    '</tr>'
104  $('#emails').append(content);
105   
106  $('#addEntryContainer')
107    .removeClass('row1 row2')
108    .addClass('row'+ Math.abs(i%2-2))
109    .appendTo($('#emails'));
110});
111
112jQuery('#addGroup').click(function() {
113  name = prompt("{/literal}{'Name'|@translate}{literal}:");
114  if (name != null && name != "") {
115    name = name.replace(new RegExp('"','g'),"'");
116    content = '<option value="'+ name +'">'+ name +'</option>';
117    group_options[group_options.length] = content;
118    $("select.groups").append(content).blink(1,2);
119  }
120});
121{/literal}{/footer_script}
Note: See TracBrowser for help on using the repository browser.