Merge pull request #17487 from eileenmcnaughton/date
[civicrm-core.git] / templates / CRM / Admin / Form / WordReplacements.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10
11 {* template for a single row *}
12 {if $soInstance}
13 <tr class="string-override-row {if $soInstance % 2}odd{else}even{/if}-row" data-row="{$soInstance}"
14 xmlns="http://www.w3.org/1999/html">
15 <td>{$form.enabled.$soInstance.html}</td>
16 <td>{$form.old.$soInstance.html}</td>
17 <td>{$form.new.$soInstance.html}</td>
18 <td>{$form.cb.$soInstance.html}</td>
19 </tr>
20
21 {else}
22 {* this template is used for adding/editing string overrides *}
23 <div class="help">
24 {ts}Use <strong>Word Replacements</strong> to change all occurrences of a word or phrase in CiviCRM screens (e.g. replace all occurrences of 'Contribution' with 'Donation').{/ts} {help id="id-word_replace"}
25 </div>
26 <div class="crm-form crm-form-block crm-string_override-form-block">
27 <div class="crm-submit-buttons">
28 {include file="CRM/common/formButtons.tpl" location='top'}
29 </div>
30 <table class="form-layout-compressed">
31 <tr>
32 <td>
33 <table class="string-override-table row-highlight">
34 <thead>
35 <tr class="columnheader">
36 <th>{ts}Enabled{/ts}</th>
37 <th>{ts}Original{/ts}</th>
38 <th>{ts}Replacement{/ts}</th>
39 <th>{ts}Exact Match{/ts}</th>
40 </tr>
41 </thead>
42 <tbody>
43 {section name="numStrings" start=1 step=1 loop=$numStrings+1}
44 {include file="CRM/Admin/Form/WordReplacements.tpl" soInstance=$smarty.section.numStrings.index}
45 {/section}
46 </tbody>
47 </table>
48 &nbsp;&nbsp;&nbsp;<a class="action-item crm-hover-button buildStringOverrideRow" href="#"><i class="crm-i fa-plus-circle" aria-hidden="true"></i> {ts}Add row{/ts}</a>
49 </td>
50 </tr>
51 </table>
52 <div class="crm-submit-buttons">
53 {include file="CRM/common/formButtons.tpl" location='bottom'}
54 </div>
55
56 </div>
57 {literal}
58 <script type="text/javascript">
59 CRM.$(function($) {
60 {/literal}
61 {if $stringOverrideInstances}
62 {* Rebuild necessary rows in case of form error *}
63 {foreach from=$stringOverrideInstances key="index" item="instance"}
64 buildStringOverrideRow( {$instance} );
65 {/foreach}
66 {/if}
67 {literal}
68
69 function buildStringOverrideRow( curInstance ) {
70 var newRowNum;
71
72 if (curInstance) {
73 // Don't fetch if already present
74 if ($('tr.string-override-row[data-row=' + curInstance + ']').length) {
75 return;
76 }
77 newRowNum = curInstance;
78 } else {
79 newRowNum = 1 + $('tr.string-override-row:last').data('row');
80 }
81
82 var dataUrl = {/literal}"{crmURL q='snippet=4' h=0}"{literal};
83 dataUrl += "&instance="+newRowNum;
84
85 $.ajax({
86 url: dataUrl,
87 async: false,
88 success: function(html) {
89 $('.string-override-table tbody').append(html);
90 $('tr.string-override-row:last').trigger('crmLoad');
91 }
92 });
93 }
94
95 $('.buildStringOverrideRow').click(function(e) {
96 buildStringOverrideRow(false);
97 e.preventDefault();
98 });
99
100 // Auto-check new items
101 $('.string-override-table').on('keyup', 'textarea', function() {
102 if (!$(this).data('crm-initial-value')) {
103 var otherValue = $(this).closest('tr').find('textarea').not(this).val();
104 if ($(this).val() && otherValue) {
105 $(this).closest('tr').find('input[type=checkbox]').first().prop('checked', true);
106 }
107 }
108 });
109
110 });
111 </script>
112 {/literal}
113 {/if}