CRM-17620 - Convert pledges to use expandRow.js
authorColeman Watts <coleman@civicrm.org>
Thu, 3 Dec 2015 03:43:00 +0000 (22:43 -0500)
committerColeman Watts <coleman@civicrm.org>
Thu, 3 Dec 2015 03:43:00 +0000 (22:43 -0500)
templates/CRM/Pledge/Form/Selector.tpl
templates/CRM/Pledge/Page/UserDashboard.tpl

index a4a38b33b208a206b57a28e283b98cfec4c617b5..248f8e8c5a8f13c5f72a6f247e8895f9e03d74d4 100644 (file)
                 <td>{$form.$cbName.html}</td>
             {/if}
             <td>
-                {if ! $single }
-                    &nbsp;{$row.contact_type}<br/>
-                {/if}
-                <span id="{$row.pledge_id}_show" title="{ts}Show payments{/ts}">
-                    <a href="#" onclick="cj('#paymentDetails{$row.pledge_id},#minus{$row.pledge_id}_hide,#{$row.pledge_id}_hide').show();
-                        buildPaymentDetails('{$row.pledge_id}','{$row.contact_id}');
-                        cj('#{$row.pledge_id}_show').hide();
-                        return false;"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="&gt;"/></a>
-                </span>
-                <span id="minus{$row.pledge_id}_hide" title="{ts}Hide payments{/ts}">
-                    <a href="#" onclick="cj('#paymentDetails{$row.pledge_id},#{$row.pledge_id}_hide,#minus{$row.pledge_id}_hide').hide();
-                            cj('#{$row.pledge_id}_show').show();
-                            return false;"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="^"/></a>
-                </span>
+                <a class="crm-expand-row" href="{crmURL p='civicrm/pledge/payment' q="action=browse&context=`$context`&pledgeId=`$row.pledge_id`&cid=`$row.contact_id`"}"></a>
             </td>
             {if ! $single }
-                <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
+                <td>
+                    {$row.contact_type} &nbsp;
+                    <a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a>
+                </td>
             {/if}
             <td class="right">{$row.pledge_amount|crmMoney:$row.pledge_currency}</td>
             <td class="right">{$row.pledge_total_paid|crmMoney:$row.pledge_currency}</td>
             <td>{$row.pledge_status}</td>
             <td>{$row.action|replace:'xx':$row.pledge_id}</td>
         </tr>
-        <tr id="{$row.pledge_id}_hide" class='{$rowClass}'>
-            <td style="border-right: none;"></td>
-            <td colspan= {if $context EQ 'Search'} "10" {else} "8" {/if} class="enclosingNested" id="paymentDetails{$row.pledge_id}">&nbsp;</td>
-        </tr>
-        <script type="text/javascript">
-            cj('#{$row.pledge_id}_hide').hide();
-            cj('#minus{$row.pledge_id}_hide').hide();
-        </script>
     {/foreach}
 
     {* Dashboard only lists 10 most recent pledges. *}
 
     {include file="CRM/common/pager.tpl" location="bottom"}
 
-{* Build pledge payment details*}
-{literal}
-<script type="text/javascript">
-  (function($) {
-    // FIXME global function
-    window.buildPaymentDetails = function(pledgeId, contactId) {
-      var dataUrl = {/literal}"{crmURL p='civicrm/pledge/payment' h=0 q="action=browse&snippet=4&context=`$context`&pledgeId="}"{literal} + pledgeId + '&cid=' + contactId;
-      $('#paymentDetails' + pledgeId).load(dataUrl, function() {
-        $(this).trigger('crmLoad');
-      });
-    };
-  })(CRM.$);
-</script>
-{/literal}
+{crmScript file='js/crm.expandRow.js'}
index b1f861418d2113b5b0566d242825256daa0a6984..afb4755e10ade1077f3c68588d08611ee8e16804 100644 (file)
     <td class="crm-pledge-pledge_next_pay_date">{$row.pledge_next_pay_date|truncate:10:''|crmDate}</td>
     <td class="crm-pledge-pledge_next_pay_amount">{$row.pledge_next_pay_amount|crmMoney:$row.pledge_currency}</td>
     <td class="crm-pledge-pledge_status crm-pledge-pledge_status_{$row.pledge_status}">{$row.pledge_status}</td>
-    <td>{if $row.pledge_contribution_page_id and ($row.pledge_status_name neq 'Completed') and ( $row.contact_id eq $loggedUserID ) }<a href="{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$row.pledge_contribution_page_id`&pledgeId=`$row.pledge_id`"}">{ts}Make Payment{/ts}</a><br/>{/if}
-  <div id="{$row.pledge_id}_show">
-      <a href="#" onclick="cj('#paymentDetails{$row.pledge_id}').show(); buildPaymentDetails('{$row.pledge_id}','{$row.contact_id}'); cj('#{$row.pledge_id}_show').hide();cj('#{$row.pledge_id}_hide').show();return false;"><img src="{$config->resourceBase}i/TreePlus.gif" class="action-icon" alt="{ts}open section{/ts}"/>{ts}Payments{/ts}</a>
-  </div>
+    <td>
+      {if $row.pledge_contribution_page_id and ($row.pledge_status_name neq 'Completed') and ( $row.contact_id eq $loggedUserID ) }
+        <a href="{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$row.pledge_contribution_page_id`&pledgeId=`$row.pledge_id`"}">{ts}Make Payment{/ts}</a><br/>
+      {/if}
+      <a class="crm-expand-row" href="{crmURL p='civicrm/pledge/payment' q="action=browse&context=`$context`&pledgeId=`$row.pledge_id`&cid=`$row.contact_id`"}">{ts}Payments{/ts}</a>
     </td>
    </tr>
-   <tr id="{$row.pledge_id}_hide">
-     <td colspan="11">
-         <a href="#" onclick="cj('#{$row.pledge_id}_show').show();cj('#{$row.pledge_id}_hide').hide();return false;"><img src="{$config->resourceBase}i/TreeMinus.gif" class="action-icon" alt="{ts}open section{/ts}"/>{ts}Payments{/ts}</a>
-       <br/>
-       <div id="paymentDetails{$row.pledge_id}"></div>
-     </td>
-  </tr>
- <script type="text/javascript">
-     cj('#{$row.pledge_id}_hide').hide();
- </script>
   {/foreach}
 </table>
 {/strip}
+{crmScript file='js/crm.expandRow.js'}
 {else}
 <div class="messages status no-popup">
          <div class="icon inform-icon"></div>
 </div>
 {* main if close*}
 {/if}
-
-{* Build pledge payment details*}
-{literal}
-<script type="text/javascript">
-
-function buildPaymentDetails( pledgeId, contactId )
-{
-    var dataUrl = {/literal}"{crmURL p='civicrm/pledge/payment' h=0 q="action=browse&context=`$context`&snippet=4&pledgeId="}"{literal} + pledgeId + '&cid=' + contactId;
-
-     cj.ajax({
-               url     : dataUrl,
-               dataType: "html",
-               timeout : 5000, //Time in milliseconds
-               success : function( data ){
-                              cj( '#paymentDetails' + pledgeId ).html( data ).trigger('crmLoad');
-                         },
-               error   : function( XMLHttpRequest, textStatus, errorThrown ) {
-                                 CRM.console('error', 'Error: ', textStatus);
-                        }
-         });
-}
-</script>
-{/literal}