Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
1188c7a8 | 3 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 4 | | | |
1188c7a8 TO |
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 | | |
6a488035 TO |
8 | +--------------------------------------------------------------------+ |
9 | *} | |
10 | ||
7323e0eb | 11 | {* template for a single row *} |
6a488035 | 12 | {if $soInstance} |
d24c529a CW |
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"> | |
7323e0eb CW |
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> | |
6a488035 TO |
20 | |
21 | {else} | |
7323e0eb | 22 | {* this template is used for adding/editing string overrides *} |
de580597 MR |
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> | |
7323e0eb | 26 | <div class="crm-form crm-form-block crm-string_override-form-block"> |
7323e0eb CW |
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> | |
d24c529a CW |
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> | |
6a488035 | 47 | </table> |
13a3d214 | 48 | <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> |
7323e0eb CW |
49 | </td> |
50 | </tr> | |
51 | </table> | |
52 | <div class="crm-submit-buttons"> | |
53 | {include file="CRM/common/formButtons.tpl" location='bottom'} | |
54 | </div> | |
6a488035 | 55 | |
7323e0eb | 56 | </div> |
6a488035 | 57 | {literal} |
7323e0eb CW |
58 | <script type="text/javascript"> |
59 | CRM.$(function($) { | |
60 | {/literal} | |
61 | {if $stringOverrideInstances} | |
d24c529a CW |
62 | {* Rebuild necessary rows in case of form error *} |
63 | {foreach from=$stringOverrideInstances key="index" item="instance"} | |
64 | buildStringOverrideRow( {$instance} ); | |
65 | {/foreach} | |
7323e0eb CW |
66 | {/if} |
67 | {literal} | |
127ec3de | 68 | |
7323e0eb | 69 | function buildStringOverrideRow( curInstance ) { |
d24c529a | 70 | var newRowNum; |
127ec3de | 71 | |
7323e0eb | 72 | if (curInstance) { |
d24c529a CW |
73 | // Don't fetch if already present |
74 | if ($('tr.string-override-row[data-row=' + curInstance + ']').length) { | |
75 | return; | |
76 | } | |
77 | newRowNum = curInstance; | |
7323e0eb | 78 | } else { |
d24c529a | 79 | newRowNum = 1 + $('tr.string-override-row:last').data('row'); |
7323e0eb | 80 | } |
127ec3de | 81 | |
7323e0eb | 82 | var dataUrl = {/literal}"{crmURL q='snippet=4' h=0}"{literal}; |
d24c529a | 83 | dataUrl += "&instance="+newRowNum; |
127ec3de | 84 | |
7323e0eb CW |
85 | $.ajax({ |
86 | url: dataUrl, | |
87 | async: false, | |
88 | success: function(html) { | |
d24c529a CW |
89 | $('.string-override-table tbody').append(html); |
90 | $('tr.string-override-row:last').trigger('crmLoad'); | |
7323e0eb CW |
91 | } |
92 | }); | |
127ec3de | 93 | } |
7323e0eb CW |
94 | |
95 | $('.buildStringOverrideRow').click(function(e) { | |
96 | buildStringOverrideRow(false); | |
97 | e.preventDefault(); | |
98 | }); | |
d24c529a CW |
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 | ||
127ec3de | 110 | }); |
7323e0eb | 111 | </script> |
6a488035 | 112 | {/literal} |
7323e0eb | 113 | {/if} |