Ignore:
Timestamp:
09/16/12 17:20:39 (7 years ago)
Author:
mistic100
Message:
  • stores emails in database (/!\ update only from published version, not from trunk)
  • allow emails to be categorized
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContactForm/admin/template/emails.tpl

    r17483 r17945  
    11{combine_css path=$CONTACT_FORM_PATH|@cat:"admin/template/style.css"} 
    22 
    3 {footer_script}{literal} 
    4 jQuery(document).on('change', '.delete', function() { 
    5   if ($(this).is(':checked')) { 
    6     $(this).parents('tr').addClass('delete'); 
    7   } else { 
    8     $(this).parents('tr').removeClass('delete'); 
    9   } 
    10 }); 
    11 {/literal}{/footer_script} 
    123 
    134<div class="titrePage"> 
    145        <h2>Contact Form</h2> 
    156</div> 
     7 
    168 
    179<form method="post" action="{$CONTACT_FORM_ADMIN}-emails" class="properties"> 
     
    2012      <th>{'Name'|@translate}</th> 
    2113      <th>{'Email address'|@translate}</th> 
     14      <th>{'Category'|@translate}</th> 
    2215      <th>{'Active'|@translate}</th> 
    2316      <th>{'Delete'|@translate}</th> 
     
    2720    <tr class="{if $i is odd}row1{else}row2{/if}"> 
    2821      <td> 
    29         <input type="text" name="emails[{$i}][name]" value="{$entry.name}" size="20"> 
     22        <input type="text" name="emails[{$i}][name]" value="{$entry.name|escape:html}" size="20"> 
    3023      </td> 
    3124      <td> 
    3225        <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> 
    3332      </td> 
    3433      <td style="text-align:center;"> 
     
    4241  {/foreach} 
    4342    <tr class="{if $i is odd}row1{else}row2{/if}" id="addEntryContainer"> 
    44       <td colspan="4"> 
     43      <td colspan="2" style="text-align:center;"> 
    4544        <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"> 
    4651      </td> 
    4752    </tr> 
    4853  </table> 
    4954  {footer_script}var entry = {$i};{/footer_script} 
    50  
    51   <p><input type="submit" name="save_emails" value="{'Submit'|@translate}" class="submit"></p> 
    5255</form> 
    5356 
    54 {footer_script}{literal} 
     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 
    5577jQuery('#addEntry').click(function() { 
    5678  entry++; 
    5779  i = entry; 
    5880   
    59   $('#emails').append( 
     81  content = 
    6082    '<tr class="row'+ (i%2+1) +'">'+ 
    6183      '<td>'+ 
     
    6486      '<td>'+ 
    6587        '<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>'+ 
    6696      '</td>'+ 
    6797      '<td style="text-align:center;">'+ 
     
    72102      '</td>'+ 
    73103    '</tr>' 
    74     ); 
     104  $('#emails').append(content); 
    75105     
    76106  $('#addEntryContainer') 
     
    79109    .appendTo($('#emails')); 
    80110}); 
     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}); 
    81121{/literal}{/footer_script} 
Note: See TracChangeset for help on using the changeset viewer.