commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / templates / CRM / Contact / Form / Task / LatexPDFLatexCommon.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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 {*common template for compose PDF letters*}
27 {if $form.template.html}
28 <table class="form-layout-compressed">
29 <tr>
30 <td class="label-left">{$form.template.label}</td>
31 <td>{$form.template.html}</td>
32 </tr>
33 </table>
34 {/if}
35
36 <div class="crm-accordion-wrapper collapsed">
37 <div class="crm-accordion-header">
38 {$form.pdf_format_header.html}
39 </div>
40 <div class="crm-accordion-body">
41 <div class="crm-block crm-form-block crm-pdf-format-form-block">
42 <table class="form-layout-compressed">
43 <tr>
44 <td class="label-left">{$form.format_id.label}</td><td>{$form.format_id.html}{help id="id-pdf-format" file="CRM/Contact/Form/Task/PDFLetterCommon.hlp"}</td>
45 <td colspan="2">&nbsp;</td>
46 </tr>
47 <tr>
48 <td class="label-left">{$form.paper_size.label}</td><td>{$form.paper_size.html}</td>
49 <td class="label-left">{$form.orientation.label}</td><td>{$form.orientation.html}</td>
50 </tr>
51 <tr>
52 <td class="label-left">{$form.metric.label}</td><td>{$form.metric.html}</td>
53 <td colspan="2">&nbsp;</td>
54 </tr>
55 <tr>
56 <td>{$form.paper_dimensions.html}</td><td id="paper_dimensions">&nbsp;</td>
57 <td colspan="2">&nbsp;</td>
58 </tr>
59 <tr>
60 <td class="label-left">{$form.margin_top.label}</td><td>{$form.margin_top.html}</td>
61 <td class="label-left">{$form.margin_bottom.label}</td><td>{$form.margin_bottom.html}</td>
62 </tr>
63 <tr>
64 <td class="label-left">{$form.margin_left.label}</td><td>{$form.margin_left.html}</td>
65 <td class="label-left">{$form.margin_right.label}</td><td>{$form.margin_right.html}</td>
66 </tr>
67 </table>
68 <div id="bindFormat">{$form.bind_format.html}&nbsp;{$form.bind_format.label}</div>
69 <div id="updateFormat" style="display: none">{$form.update_format.html}&nbsp;{$form.update_format.label}</div>
70 </div>
71 </div>
72 </div>
73
74 <div class="crm-accordion-wrapper crm-html_email-accordion ">
75 <div class="crm-accordion-header">
76 {$form.html_message.label}
77 </div><!-- /.crm-accordion-header -->
78 <div class="crm-accordion-body">
79 {if $action neq 4}
80 <span class="helpIcon" id="helphtml">
81 <a href="#" onClick="return showToken('Html', 1);">{$form.token1.label}</a>
82 {help id="id-token-html" file="CRM/Contact/Form/Task/Email.hlp" tplFile=$tplFile isAdmin=$isAdmin editor=$editor}
83 <div id="tokenHtml" style="display:none;">
84 <input style="border:1px solid #999999;" type="text" id="filter1" size="20" name="filter1" onkeyup="filter(this, 1)"/><br />
85 <span class="description">{ts}Begin typing to filter list of tokens{/ts}</span><br/>
86 {$form.token1.html}
87 </div>
88 </span>
89 {/if}
90 <div class="clear"></div>
91 <div class='html'>
92 {if $editor EQ 'textarea'}
93 <div class="help description">{ts}The content of this page should be LaTeX.{/ts}</div>
94 {/if}
95 {$form.html_message.html}<br />
96 </div>
97
98 <div id="editMessageDetails">
99 <div id="updateDetails" >
100 {$form.updateTemplate.html}&nbsp;{$form.updateTemplate.label}
101 </div>
102 <div>
103 {$form.saveTemplate.html}&nbsp;{$form.saveTemplate.label}
104 </div>
105 </div>
106
107 <div id="saveDetails" class="section">
108 <div class="label">{$form.saveTemplateName.label}</div>
109 <div class="content">{$form.saveTemplateName.html|crmAddClass:huge}</div>
110 </div>
111
112 </div><!-- /.crm-accordion-body -->
113 </div><!-- /.crm-accordion-wrapper -->
114
115 {include file="CRM/Mailing/Form/InsertTokens.tpl"}
116
117 {literal}
118 <script type="text/javascript">
119 cj(function() {
120 cj().crmAccordions();
121 });
122
123 var currentWidth;
124 var currentHeight;
125 var currentMetric = document.getElementById('metric').value;
126 showBindFormatChkBox();
127 selectPaper( document.getElementById('paper_size').value );
128
129 function tokenReplHtml ( )
130 {
131 var token1 = cj("#token1").val( )[0];
132 var editor = {/literal}"{$editor}"{literal};
133 if ( editor == "tinymce" ) {
134 var content= tinyMCE.get('html_message').getContent() +token1;
135 tinyMCE.get('html_message').setContent(content);
136 } else if ( editor == "joomlaeditor" ) {
137 tinyMCE.execCommand('mceInsertContent',false, token1);
138 var msg = document.getElementById(html_message).value;
139 var cursorlen = document.getElementById(html_message).selectionStart;
140 var textlen = msg.length;
141 document.getElementById(html_message).value = msg.substring(0, cursorlen) + token1 + msg.substring(cursorlen, textlen);
142 var cursorPos = (cursorlen + token1.length);
143 document.getElementById(html_message).selectionStart = cursorPos;
144 document.getElementById(html_message).selectionEnd = cursorPos;
145 document.getElementById(html_message).focus();
146 } else if ( editor == "ckeditor" ) {
147 oEditor = CKEDITOR.instances[html_message];
148 oEditor.insertHtml(token1.toString() );
149 } else if ( editor == "drupalwysiwyg" ) {
150 Drupal.wysiwyg.instances[html_message].insert(token1.toString());
151 } else {
152 var msg = document.getElementById(html_message).value;
153 var cursorlen = document.getElementById(html_message).selectionStart;
154 var textlen = msg.length;
155 document.getElementById(html_message).value = msg.substring(0, cursorlen) + token1 + msg.substring(cursorlen, textlen);
156 var cursorPos = (cursorlen + token1.length);
157 document.getElementById(html_message).selectionStart = cursorPos;
158 document.getElementById(html_message).selectionEnd = cursorPos;
159 document.getElementById(html_message).focus();
160 }
161 verify();
162 }
163
164 function showBindFormatChkBox()
165 {
166 var templateExists = true;
167 if ( document.getElementById('template') == null || document.getElementById('template').value == '' ) {
168 templateExists = false;
169 }
170 var formatExists = true;
171 if ( document.getElementById('format_id').value == 0 ) {
172 formatExists = false;
173 }
174 if ( templateExists && formatExists ) {
175 document.getElementById("bindFormat").style.display = "block";
176 } else if ( formatExists && document.getElementById("saveTemplate") != null && document.getElementById("saveTemplate").checked ) {
177 document.getElementById("bindFormat").style.display = "block";
178 var yes = confirm( '{/literal}{$useThisPageFormat}{literal}' );
179 if ( yes ) {
180 document.getElementById("bind_format").checked = true;
181 }
182 } else {
183 document.getElementById("bindFormat").style.display = "none";
184 document.getElementById("bind_format").checked = false;
185 }
186 }
187
188 function showUpdateFormatChkBox()
189 {
190 if ( document.getElementById('format_id').value != 0 ) {
191 document.getElementById("updateFormat").style.display = "block";
192 }
193 }
194
195 function hideUpdateFormatChkBox()
196 {
197 document.getElementById("update_format").checked = false;
198 document.getElementById("updateFormat").style.display = "none";
199 }
200
201 function selectFormat( val, bind )
202 {
203 if ( val == null || val == 0 ) {
204 val = 0;
205 bind = false;
206 }
207 var dataUrl = {/literal}"{crmURL p='civicrm/ajax/pdfFormat' h=0 }"{literal};
208 cj.post( dataUrl, {formatId: val}, function( data ) {
209 cj("#format_id").val( data.id );
210 cj("#paper_size").val( data.paper_size );
211 cj("#orientation").val( data.orientation );
212 cj("#metric").val( data.metric );
213 cj("#margin_top").val( data.margin_top );
214 cj("#margin_bottom").val( data.margin_bottom );
215 cj("#margin_left").val( data.margin_left );
216 cj("#margin_right").val( data.margin_right );
217 selectPaper( data.paper_size );
218 hideUpdateFormatChkBox();
219 document.getElementById('bind_format').checked = bind;
220 showBindFormatChkBox();
221 }, 'json');
222 }
223
224 function selectPaper( val )
225 {
226 dataUrl = {/literal}"{crmURL p='civicrm/ajax/paperSize' h=0 }"{literal};
227 cj.post( dataUrl, {paperSizeName: val}, function( data ) {
228 cj("#paper_size").val( data.name );
229 metric = document.getElementById('metric').value;
230 currentWidth = convertMetric( data.width, data.metric, metric );
231 currentHeight = convertMetric( data.height, data.metric, metric );
232 updatePaperDimensions( );
233 }, 'json');
234 }
235
236 function selectMetric( metric )
237 {
238 convertField( 'margin_top', currentMetric, metric );
239 convertField( 'margin_bottom', currentMetric, metric );
240 convertField( 'margin_left', currentMetric, metric );
241 convertField( 'margin_right', currentMetric, metric );
242 currentWidth = convertMetric( currentWidth, currentMetric, metric );
243 currentHeight = convertMetric( currentHeight, currentMetric, metric );
244 updatePaperDimensions( );
245 }
246
247 function updatePaperDimensions( )
248 {
249 metric = document.getElementById('metric').value;
250 width = new String( currentWidth.toFixed( 2 ) );
251 height = new String( currentHeight.toFixed( 2 ) );
252 if ( document.getElementById('orientation').value == 'landscape' ) {
253 width = new String( currentHeight.toFixed( 2 ) );
254 height = new String( currentWidth.toFixed( 2 ) );
255 }
256 document.getElementById('paper_dimensions').innerHTML = parseFloat( width ) + ' ' + metric + ' x ' + parseFloat( height ) + ' ' + metric;
257 currentMetric = metric;
258 }
259
260 function convertField( id, from, to )
261 {
262 val = document.getElementById( id ).value;
263 if ( val == '' || isNaN( val ) ) return;
264 val = convertMetric( val, from, to );
265 val = new String( val.toFixed( 3 ) );
266 document.getElementById( id ).value = parseFloat( val );
267 }
268
269 function convertMetric( value, from, to ) {
270 switch( from + to ) {
271 case 'incm': return value * 2.54;
272 case 'inmm': return value * 25.4;
273 case 'inpt': return value * 72;
274 case 'cmin': return value / 2.54;
275 case 'cmmm': return value * 10;
276 case 'cmpt': return value * 72 / 2.54;
277 case 'mmin': return value / 25.4;
278 case 'mmcm': return value / 10;
279 case 'mmpt': return value * 72 / 25.4;
280 case 'ptin': return value / 72;
281 case 'ptcm': return value * 2.54 / 72;
282 case 'ptmm': return value * 25.4 / 72;
283 }
284 return value;
285 }
286
287 function showSaveDetails(chkbox) {
288 var formatSelected = ( document.getElementById('format_id').value > 0 );
289 var templateSelected = ( document.getElementById('template') != null && document.getElementById('template').value > 0 );
290 if (chkbox.checked) {
291 document.getElementById("saveDetails").style.display = "block";
292 document.getElementById("saveTemplateName").disabled = false;
293 if ( formatSelected && ! templateSelected ) {
294 document.getElementById("bindFormat").style.display = "block";
295 var yes = confirm( '{/literal}{$useSelectedPageFormat}{literal}' );
296 if ( yes ) {
297 document.getElementById("bind_format").checked = true;
298 }
299 }
300 } else {
301 document.getElementById("saveDetails").style.display = "none";
302 document.getElementById("saveTemplateName").disabled = true;
303 if ( ! templateSelected ) {
304 document.getElementById("bindFormat").style.display = "none";
305 document.getElementById("bind_format").checked = false;
306 }
307 }
308 }
309
310 </script>
311 {/literal}
312