Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
fee14197 | 3 | | CiviCRM version 5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
6b83d5bd | 5 | | Copyright CiviCRM LLC (c) 2004-2019 | |
6a488035 TO |
6 | +--------------------------------------------------------------------+ |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
9 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
10 | | under the terms of the GNU Affero General Public License | | |
11 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
12 | | | | |
13 | | CiviCRM is distributed in the hope that it will be useful, but | | |
14 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
16 | | See the GNU Affero General Public License for more details. | | |
17 | | | | |
18 | | You should have received a copy of the GNU Affero General Public | | |
19 | | License and the CiviCRM Licensing Exception along | | |
20 | | with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | ||
7323e0eb | 27 | {* template for a single row *} |
6a488035 | 28 | {if $soInstance} |
d24c529a CW |
29 | <tr class="string-override-row {if $soInstance % 2}odd{else}even{/if}-row" data-row="{$soInstance}" |
30 | xmlns="http://www.w3.org/1999/html"> | |
7323e0eb CW |
31 | <td>{$form.enabled.$soInstance.html}</td> |
32 | <td>{$form.old.$soInstance.html}</td> | |
33 | <td>{$form.new.$soInstance.html}</td> | |
34 | <td>{$form.cb.$soInstance.html}</td> | |
35 | </tr> | |
6a488035 TO |
36 | |
37 | {else} | |
7323e0eb | 38 | {* this template is used for adding/editing string overrides *} |
de580597 MR |
39 | <div class="help"> |
40 | {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"} | |
41 | </div> | |
7323e0eb | 42 | <div class="crm-form crm-form-block crm-string_override-form-block"> |
7323e0eb CW |
43 | <div class="crm-submit-buttons"> |
44 | {include file="CRM/common/formButtons.tpl" location='top'} | |
45 | </div> | |
46 | <table class="form-layout-compressed"> | |
47 | <tr> | |
48 | <td> | |
d24c529a CW |
49 | <table class="string-override-table row-highlight"> |
50 | <thead> | |
51 | <tr class="columnheader"> | |
52 | <th>{ts}Enabled{/ts}</th> | |
53 | <th>{ts}Original{/ts}</th> | |
54 | <th>{ts}Replacement{/ts}</th> | |
55 | <th>{ts}Exact Match{/ts}</th> | |
56 | </tr> | |
57 | </thead> | |
58 | <tbody> | |
59 | {section name="numStrings" start=1 step=1 loop=$numStrings+1} | |
60 | {include file="CRM/Admin/Form/WordReplacements.tpl" soInstance=$smarty.section.numStrings.index} | |
61 | {/section} | |
62 | </tbody> | |
6a488035 | 63 | </table> |
a2c70872 | 64 | <a class="action-item crm-hover-button buildStringOverrideRow" href="#"><i class="crm-i fa-plus-circle"></i> {ts}Add row{/ts}</a> |
7323e0eb CW |
65 | </td> |
66 | </tr> | |
67 | </table> | |
68 | <div class="crm-submit-buttons"> | |
69 | {include file="CRM/common/formButtons.tpl" location='bottom'} | |
70 | </div> | |
6a488035 | 71 | |
7323e0eb | 72 | </div> |
6a488035 | 73 | {literal} |
7323e0eb CW |
74 | <script type="text/javascript"> |
75 | CRM.$(function($) { | |
76 | {/literal} | |
77 | {if $stringOverrideInstances} | |
d24c529a CW |
78 | {* Rebuild necessary rows in case of form error *} |
79 | {foreach from=$stringOverrideInstances key="index" item="instance"} | |
80 | buildStringOverrideRow( {$instance} ); | |
81 | {/foreach} | |
7323e0eb CW |
82 | {/if} |
83 | {literal} | |
127ec3de | 84 | |
7323e0eb | 85 | function buildStringOverrideRow( curInstance ) { |
d24c529a | 86 | var newRowNum; |
127ec3de | 87 | |
7323e0eb | 88 | if (curInstance) { |
d24c529a CW |
89 | // Don't fetch if already present |
90 | if ($('tr.string-override-row[data-row=' + curInstance + ']').length) { | |
91 | return; | |
92 | } | |
93 | newRowNum = curInstance; | |
7323e0eb | 94 | } else { |
d24c529a | 95 | newRowNum = 1 + $('tr.string-override-row:last').data('row'); |
7323e0eb | 96 | } |
127ec3de | 97 | |
7323e0eb | 98 | var dataUrl = {/literal}"{crmURL q='snippet=4' h=0}"{literal}; |
d24c529a | 99 | dataUrl += "&instance="+newRowNum; |
127ec3de | 100 | |
7323e0eb CW |
101 | $.ajax({ |
102 | url: dataUrl, | |
103 | async: false, | |
104 | success: function(html) { | |
d24c529a CW |
105 | $('.string-override-table tbody').append(html); |
106 | $('tr.string-override-row:last').trigger('crmLoad'); | |
7323e0eb CW |
107 | } |
108 | }); | |
127ec3de | 109 | } |
7323e0eb CW |
110 | |
111 | $('.buildStringOverrideRow').click(function(e) { | |
112 | buildStringOverrideRow(false); | |
113 | e.preventDefault(); | |
114 | }); | |
d24c529a CW |
115 | |
116 | // Auto-check new items | |
117 | $('.string-override-table').on('keyup', 'textarea', function() { | |
118 | if (!$(this).data('crm-initial-value')) { | |
119 | var otherValue = $(this).closest('tr').find('textarea').not(this).val(); | |
120 | if ($(this).val() && otherValue) { | |
121 | $(this).closest('tr').find('input[type=checkbox]').first().prop('checked', true); | |
122 | } | |
123 | } | |
124 | }); | |
125 | ||
127ec3de | 126 | }); |
7323e0eb | 127 | </script> |
6a488035 | 128 | {/literal} |
7323e0eb | 129 | {/if} |