From 3154780cb18b187d51cb2a8ea0e6ce10d14110db Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 2 Dec 2015 20:34:21 -0500 Subject: [PATCH] CRM-17620 - Cleanup and abstract expandRow js --- css/civicrm.css | 10 +++- js/crm.expandRow.js | 18 ++++++++ templates/CRM/Contribute/Form/Selector.tpl | 10 ++-- templates/CRM/common/expandRow.tpl | 54 ---------------------- 4 files changed, 31 insertions(+), 61 deletions(-) create mode 100644 js/crm.expandRow.js delete mode 100644 templates/CRM/common/expandRow.tpl diff --git a/css/civicrm.css b/css/civicrm.css index 98389b4af7..3b2e1b254b 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2245,9 +2245,17 @@ div.crm-master-accordion-header a.helpicon { display: none; } +.crm-container .crm-expand-row { + width: 16px; + height: 16px; + display: inline-block; + background-image: url("../i/TreePlus.gif"); +} + .crm-container .crm-accordion-inner .crm-accordion-header, .crm-container .crm-accordion-wrapper .crm-master-accordion-header, -.crm-container .crm-collapsible .collapsible-title { +.crm-container .crm-collapsible .collapsible-title, +.crm-container .crm-expand-row.expanded { background-image: url("../i/TreeMinus.gif"); background-color: transparent; color: #3E3E3E; diff --git a/js/crm.expandRow.js b/js/crm.expandRow.js new file mode 100644 index 0000000000..de0f41051d --- /dev/null +++ b/js/crm.expandRow.js @@ -0,0 +1,18 @@ +// http://civicrm.org/licensing +CRM.$(function($) { + $('body') + .off('.crmExpandRow') + .on('click.crmExpandRow', 'a.crm-expand-row', function(e) { + var $row = $(this).closest('tr'); + if ($(this).hasClass('expanded')) { + $row.next('.crm-child-row').remove(); + } else { + var count = $('td', $row).length, + $newRow = $('') + .insertAfter($row); + CRM.loadPage(this.href, {target: $('td', $newRow.animate({height: '3em'}, 'fast'))}); + } + $(this).toggleClass('expanded'); + e.preventDefault(); + }); +}); diff --git a/templates/CRM/Contribute/Form/Selector.tpl b/templates/CRM/Contribute/Form/Selector.tpl index f7dddb6c18..0264241504 100644 --- a/templates/CRM/Contribute/Form/Selector.tpl +++ b/templates/CRM/Contribute/Form/Selector.tpl @@ -65,8 +65,9 @@ {$row.contact_type} {$row.sort_name} {/if} - {assign var="targetRowID" value="paymentDetails"|cat:$row.contribution_id} - {include file='CRM/common/expandRow.tpl' rowEntityID=$row.contribution_id rowEntity='contribution' targetRowID=$targetRowID baseUrl='payment'} + + + {if $row.contribution_soft_credit_amount}   {else} @@ -96,14 +97,11 @@ {/if} {$row.action|replace:'xx':$row.contribution_id} - - -   - {/foreach} {/strip} {include file="CRM/common/pager.tpl" location="bottom"} +{crmScript ext='civicrm' file='js/crm.expandRow.js'} diff --git a/templates/CRM/common/expandRow.tpl b/templates/CRM/common/expandRow.tpl deleted file mode 100644 index e352bfc4de..0000000000 --- a/templates/CRM/common/expandRow.tpl +++ /dev/null @@ -1,54 +0,0 @@ - - - - {ts}open section{/ts} - - - - {ts}open section{/ts} - - - - - {literal} - -{/literal} -- 2.25.1