{*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
<td class="label">{$form.weight.label}</td>
<td>{$form.weight.html} {help id="id-weight"}</td>
</tr>
- <tr id="is_multiple" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *}
+ <tr id="is_multiple_row" class="hiddenElement"> {* This section shown only when Used For = Contact, Individ, Org or Household. *}
<td></td>
<td class="html-adjust">{$form.is_multiple.html} {$form.is_multiple.label} {help id="id-is_multiple"}</td>
</tr>
- <tr id="multiple" class="hiddenElement">
- {*<dt>{$form.min_multiple.label}</dt><dd>{$form.min_multiple.html}</dd>*}
+ <tr id="multiple_row" class="hiddenElement">
<td class="label">{$form.max_multiple.label}</td>
<td>{$form.max_multiple.html} {help id="id-max_multiple"}</td>
</tr>
- <tr id="style" class="hiddenElement">
+ <tr id="style_row" class="hiddenElement">
<td class="label">{$form.style.label}</td>
<td>{$form.style.html} {help id="id-display_style"}</td>
</tr>
{if $action eq 2 or $action eq 4} {* Update or View*}
<p></p>
<div class="action-link">
- <a href="{crmURL p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid"}" class="button"><span>{ts}Custom Fields for this Set{/ts}</span></a>
+ {crmButton p='civicrm/admin/custom/group/field' q="action=browse&reset=1&gid=$gid"}{ts}Custom Fields for this Set{/ts}{/crmButton}
</div>
{/if}
{$initHideBlocks}
{literal}
<script type="text/Javascript">
CRM.$(function($) {
+ var tabWithTableOption;
- showHideStyle();
- $('#extends_0').change(function() {
- showHideStyle();
- });
+ $('#extends_0').each(showHideStyle).change(showHideStyle);
- var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}";
+ var isGroupEmpty = "{/literal}{$isGroupEmpty}{literal}";
if (isGroupEmpty) {
showRange(true);
}
- $('#is_multiple').click(function() {
- showRange();
+ $('input#is_multiple').change(showRange);
+
+ // "Collapse" is a bad default for "Tab" display
+ $("select#style").change(function() {
+ if ($(this).val() == 'Tab') {
+ $('#collapse_display').prop('checked', false);
+ }
});
+ /**
+ * Check if this is a contact-related set and show/hide other options accordingly
+ */
function showHideStyle() {
- var isShow = false;
- var extend = $('#extends_0').val();
-
- var contactTypes = {/literal}{$contactTypes}{literal};
- var showStyle = "{/literal}{$showStyle}{literal}";
- var showMultiple = "{/literal}{$showMultiple}{literal}";
- var showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}";
+ var
+ extend = $(this).val(),
+ contactTypes = {/literal}{$contactTypes}{literal},
+ showStyle = "{/literal}{$showStyle}{literal}",
+ showMultiple = "{/literal}{$showMultiple}{literal}",
+ showMaxMultiple = "{/literal}{$showMaxMultiple}{literal}",
+ isContact = ($.inArray(extend, contactTypes) >= 0);
- if ($.inArray(extend, contactTypes) >= 0) {
- isShow = true;
- }
-
- if (isShow) {
- $("tr#style").show();
- $("tr#is_multiple").show();
+ if (isContact) {
+ $("tr#style_row, tr#is_multiple_row").show();
if ($('#is_multiple :checked').length) {
- $("tr#multiple").show();
+ $("tr#multiple_row").show();
}
}
else {
- $("tr#style").hide();
- $("tr#is_multiple").hide();
- $("tr#multiple").hide();
+ $("tr#style_row, tr#is_multiple_row, tr#multiple_row").hide();
}
if (showStyle) {
- $("tr#style").show();
+ $("tr#style_row").show();
}
if (showMultiple) {
- $("tr#style").show();
- $("tr#is_multiple").show();
+ $("tr#style_row, tr#is_multiple_row").show();
}
if (!showMaxMultiple) {
- $("tr#multiple").hide();
+ $("tr#multiple_row").hide();
}
- else if($( '#is_multiple').prop('checked')) {
- $("tr#multiple").show();
+ else if ($('#is_multiple').prop('checked')) {
+ $("tr#multiple_row").show();
}
}
+ /**
+ * Check if this set supports multiple records and adjust other options accordingly
+ *
+ * @param onFormLoad
+ */
function showRange(onFormLoad) {
- if($("#is_multiple :checked").length) {
- $("tr#multiple").show();
- $('#collapse_display').prop('checked', '');
- $("select#style option[value='Tab with table']").prop("selected", true);
+ if($("#is_multiple").is(':checked')) {
+ $("tr#multiple_row").show();
+ if (onFormLoad !== true) {
+ $('#collapse_display').prop('checked', false);
+ $("select#style").append(tabWithTableOption);
+ $("select#style").val('Tab with table');
+ }
}
else {
- $('#collapse_display').prop('checked', 'checked');
- $("tr#multiple").hide();
- if (!onFormLoad) {
- $("select#style option[value='Inline']").prop("selected", true);
+ $("tr#multiple_row").hide();
+ if ($("select#style").val() === 'Tab with table') {
+ $("select#style").val('Inline');
}
+ tabWithTableOption = $("select#style option[value='Tab with table']").detach();
}
}
// In update mode, when 'extends' is set to an option which doesn't have
- // any options in 2nd selector (for subtypes) -
+ // any options in 2nd selector (for subtypes)
var subtypes = document.getElementById('extends_1');
if (subtypes) {
if (subtypes.options.length <= 0) {
subtypes.style.display = 'inline';
}
}
-});
-function warnDataLoss() {
- var submittedSubtypes = cj('#extends_1').val();
- var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
+ // When removing sub-types
+ $('.crm-warnDataLoss').on('click', function() {
+ var submittedSubtypes = $('#extends_1').val();
+ var defaultSubtypes = {/literal}{$defaultSubtypes}{literal};
+
+ var warning = false;
+ $.each(defaultSubtypes, function(index, subtype) {
+ if ($.inArray(subtype, submittedSubtypes) < 0) {
+ warning = true;
+ }
+ });
- var warning = false;
- cj.each(defaultSubtypes, function(index, subtype) {
- if (cj.inArray(subtype, submittedSubtypes) < 0) {
- warning = true;
+ if (warning) {
+ return confirm({/literal}'{ts escape='js'}Warning: You have chosen to remove one or more subtypes. This will cause any custom data records associated with those subtypes to be removed.{/ts}'{literal});
}
+ return true;
});
-
- if (warning) {
- return confirm( 'One or more subtypes has been un-selected from the list. Any custom data associated with un-selected subtype would be removed. Click OK to proceed.' );
- }
- return true;
-}
+});
</script>
{/literal}