commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / templates / CRM / Admin / Form / WordReplacements.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
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
27 {* template for a single row *}
28 {if $soInstance}
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">
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>
36
37 {else}
38 {* this template is used for adding/editing string overrides *}
39 <div class="crm-form crm-form-block crm-string_override-form-block">
40 <div id="help">
41 {ts}Use <strong>Word Replacements</strong> to change all occurrences of a word or phrase in CiviCRM screens (e.g. replace all occurences of 'Contribution' with 'Donation').{/ts} {help id="id-word_replace"}
42 </div>
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>
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>
63 </table>
64 &nbsp;&nbsp;&nbsp;<a class="action-item crm-hover-button buildStringOverrideRow" href="#"><span class="icon ui-icon-circle-plus"></span> {ts}Add row{/ts}</a>
65 </td>
66 </tr>
67 </table>
68 <div class="crm-submit-buttons">
69 {include file="CRM/common/formButtons.tpl" location='bottom'}
70 </div>
71
72 </div>
73 {literal}
74 <script type="text/javascript">
75 CRM.$(function($) {
76 {/literal}
77 {if $stringOverrideInstances}
78 {* Rebuild necessary rows in case of form error *}
79 {foreach from=$stringOverrideInstances key="index" item="instance"}
80 buildStringOverrideRow( {$instance} );
81 {/foreach}
82 {/if}
83 {literal}
84
85 function buildStringOverrideRow( curInstance ) {
86 var newRowNum;
87
88 if (curInstance) {
89 // Don't fetch if already present
90 if ($('tr.string-override-row[data-row=' + curInstance + ']').length) {
91 return;
92 }
93 newRowNum = curInstance;
94 } else {
95 newRowNum = 1 + $('tr.string-override-row:last').data('row');
96 }
97
98 var dataUrl = {/literal}"{crmURL q='snippet=4' h=0}"{literal};
99 dataUrl += "&instance="+newRowNum;
100
101 $.ajax({
102 url: dataUrl,
103 async: false,
104 success: function(html) {
105 $('.string-override-table tbody').append(html);
106 $('tr.string-override-row:last').trigger('crmLoad');
107 }
108 });
109 }
110
111 $('.buildStringOverrideRow').click(function(e) {
112 buildStringOverrideRow(false);
113 e.preventDefault();
114 });
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
126 });
127 </script>
128 {/literal}
129 {/if}