Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | ||
27 | <tr> | |
28 | <td class="label">{$form.option_type.label}</td> | |
29 | <td class="html-adjust">{$form.option_type.html}<br /> | |
30 | <span class="description">{ts}You can create new result options for this survey, or select an existing survey result set which you've already created for another survey.{/ts}</span> | |
31 | </td> | |
32 | </tr> | |
33 | ||
34 | <tr id="option_group" {if !$form.option_group_id}class="hiddenElement"{/if}> | |
35 | <td class="label">{$form.option_group_id.label}</td> | |
36 | <td class="html-adjust">{$form.option_group_id.html}</td> | |
37 | </tr> | |
38 | ||
39 | <tr id="multiple"> | |
40 | <td colspan="2" class="html-adjust"> | |
41 | <fieldset><legend>{ts}Result Options{/ts}</legend> | |
42 | <span class="description"> | |
43 | {ts}Enter up to ten (10) multiple choice options in this table (click 'another choice' for each additional choice).You can use existing result set options by selecting survey result set.{/ts} | |
44 | </span> | |
45 | <br /> | |
46 | {strip} | |
47 | <table id="optionField"> | |
48 | <tr> | |
49 | <th> </th> | |
50 | <th> {ts}Default{/ts}</th> | |
51 | <th> {ts}Label{/ts}</th> | |
52 | <th> {ts}Value{/ts}</th> | |
53 | <th> {ts}Recontact Interval{/ts}</th> | |
54 | <th> {ts}Weight{/ts}</th> | |
55 | </tr> | |
56 | ||
57 | {section name=rowLoop start=1 loop=12} | |
58 | {assign var=index value=$smarty.section.rowLoop.index} | |
59 | <tr id="optionField_{$index}" class="form-item {cycle values="odd-row,even-row"}"> | |
60 | <td> | |
61 | {if $index GT 1} | |
b7054e52 | 62 | <a onclick="showHideRow({$index}); return false;" name="optionField_{$index}" href="#" class="form-link"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="{ts}hide field or section{/ts}"/></a> |
6a488035 TO |
63 | {/if} |
64 | </td> | |
65 | <td> | |
66 | <div id="radio{$index}"> | |
67 | {$form.default_option[$index].html} | |
68 | </div> | |
69 | ||
70 | </td> | |
71 | <td> {$form.option_label.$index.html}</td> | |
72 | <td> {$form.option_value.$index.html}</td> | |
73 | <td> {$form.option_interval.$index.html}</td> | |
74 | <td> {$form.option_weight.$index.html}</td> | |
75 | </tr> | |
76 | {/section} | |
77 | </table> | |
78 | <div id="optionFieldLink" class="add-remove-link"> | |
b7054e52 | 79 | <a onclick="showHideRow(); return false;" name="optionFieldLink" href="#" class="form-link"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="{ts}show field or section{/ts}"/>{ts}another choice{/ts}</a> |
6a488035 TO |
80 | </div> |
81 | <span id="additionalOption" class="description"> | |
82 | {ts}If you need additional options - you can add them after you Save your current entries.{/ts} | |
83 | </span> | |
84 | {/strip} | |
85 | ||
86 | </fieldset> | |
87 | </td> | |
88 | </tr> | |
89 | ||
90 | <script type="text/javascript"> | |
ae8f569f CW |
91 | var showRows = [{$showBlocks}]; |
92 | var hideBlocks = [{$hideBlocks}]; | |
6a488035 TO |
93 | var rowcounter = 0; |
94 | var surveyId = {if $surveyId}{$surveyId}{else}''{/if}; | |
95 | ||
96 | {literal} | |
97 | if (navigator.appName == "Microsoft Internet Explorer") { | |
98 | for ( var count = 0; count < hideBlocks.length; count++ ) { | |
99 | var r = document.getElementById(hideBlocks[count]); | |
100 | r.style.display = 'none'; | |
101 | } | |
102 | } | |
103 | ||
104 | function showOptionSelect( ) { | |
105 | if ( document.getElementsByName("option_type")[0].checked ) { | |
106 | cj('#option_group').hide(); | |
107 | cj('#default_option').val(''); | |
108 | } else { | |
109 | cj('#option_group').show(); | |
110 | loadOptionGroup( ); | |
111 | } | |
112 | } | |
113 | ||
114 | function resetResultSet( ) { | |
115 | for( i=1; i<=11; i++ ) { | |
116 | cj('#option_label_'+ i).val(''); | |
117 | cj('#option_value_'+ i).val(''); | |
118 | cj('#option_weight_'+ i).val(''); | |
119 | cj('#option_interval_'+ i).val(''); | |
120 | if ( i > 2 ) { | |
121 | showHideRow(i); | |
122 | } | |
123 | } | |
124 | } | |
125 | ||
126 | function loadOptionGroup( ) { | |
127 | var data = new Object; | |
128 | ||
129 | resetResultSet( ); | |
130 | if ( cj('#option_group_id').val() ) { | |
131 | data['option_group_id'] = cj('#option_group_id').val(); | |
132 | data['survey_id'] = surveyId; | |
133 | } else { | |
134 | return false; | |
135 | } | |
136 | ||
137 | var dataUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='className=CRM_Campaign_Page_AJAX&fnName=loadOptionGroupDetails' }"{literal} | |
138 | ||
139 | // build new options | |
140 | cj.post( dataUrl, data, function( opGroup ) { | |
141 | if ( opGroup.status == 'success' ) { | |
142 | var result = opGroup.result; | |
143 | var countRows = 1; | |
144 | for( key in result ) { | |
145 | cj('#option_label_'+ countRows).val( result[key].label); | |
146 | cj('#option_value_'+ countRows).val( result[key].value); | |
147 | cj('#option_weight_'+ countRows).val( result[key].weight); | |
148 | ||
149 | if ( surveyId && result[key].interval ) { | |
150 | cj('#option_interval_'+ countRows).val( result[key].interval); | |
151 | } | |
152 | ||
153 | if ( result[key].is_default == 1 ) { | |
8539f25d | 154 | cj('#radio'+countRows+' input').prop('checked', true); |
6a488035 TO |
155 | } |
156 | ||
157 | if ( countRows > 1 ) { | |
158 | showHideRow( ); | |
159 | } | |
160 | countRows +=1; | |
161 | } | |
162 | } | |
163 | }, "json" ); | |
164 | } | |
165 | ||
32678ccb | 166 | CRM.$(function($) { |
6a488035 TO |
167 | showOptionSelect( ); |
168 | }); | |
169 | ||
170 | {/literal} | |
171 | on_load_init_blocks( showRows, hideBlocks, '' ); | |
172 | </script> | |
173 |