2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
10 {if $pager and $pager->_response}
11 {if $pager->_response.numPages > 1}
12 <div class="crm-pager">
13 <span class="element-right">
14 {if $location eq 'top'}
15 {$pager->_response.titleTop}
17 {$pager->_response.titleBottom}
21 <span class="crm-pager-nav">
22 {$pager->_response.first}
23 {$pager->_response.back}
24 {$pager->_response.next}
25 {$pager->_response.last}
26 {$pager->_response.status}
32 {* Controller for 'Rows Per Page' *}
33 {if $location eq 'bottom' and $pager->_totalItems > 25}
34 <div class="form-item float-right">
35 <label for="{$form.formClass}-rows-per-page-select">{ts}Rows per page:{/ts}</label>
36 <input class="crm-rows-per-page-select" id="{$form.formClass}-rows-per-page-select" type="text" size="3" value="{$pager->_perPage}"/>
38 <div class="clear"></div>
41 {if $location neq 'top'}
42 <script type="text/javascript">
47 $form = $({if empty($form.formClass)}'#crm-main-content-wrapper'{else}'form.{$form.formClass}'{/if}),
48 numPages = {$pager->_response.numPages},
49 currentPage = {$pager->_response.currentPage},
50 perPageCount = {$pager->_perPage},
51 currentLocation = {$pager->_response.currentLocation|json_encode},
55 function refresh(url) {
58 var options = url ? {url: url} : {};
59 $form.off('.crm-pager').closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet(options).crmSnippet('refresh');
63 num = parseInt(num, 10);
64 if (isNaN(num) || num < 1 || num > numPages || num === currentPage) {
67 refresh(currentLocation.replace(/crmPID=\d+/, 'crmPID=' + num));
69 function changeCount(num) {
70 num = parseInt(num, 10);
71 if (isNaN(num) || num < 1 || num === perPageCount) {
74 refresh(currentLocation.replace(/&crmRowCount=\d+/, '') + '&crmRowCount=' + num);
76 function preventSubmit(e) {
77 if (e.keyCode == 13) {
79 $(this).trigger('change');
83 $('input[name^=crmPID]', $form)
88 .on('change', function() {
89 page($(this).spinner('value'));
91 .on('keyup keydown keypress', preventSubmit);
92 $('input.crm-rows-per-page-select', $form)
97 .on('change', function() {
98 changeCount($(this).spinner('value'));
100 .on('keyup keydown keypress', preventSubmit);
102 .on('click.crm-pager', 'a.ui-spinner-button', function(e) {
104 // Update after a short delay to allow multiple clicks
105 spinning !== null && window.clearTimeout(spinning);
106 spinning = window.setTimeout(function() {
107 if ($el.is('.crm-pager a')) {
108 page($el.siblings('input[name^=crmPID]').spinner('value'));
110 changeCount($el.siblings('input.crm-rows-per-page-select').spinner('value'));
114 // Handle sorting, paging and alpha filtering links
115 .on('click.crm-pager', 'a.crm-pager-link, #alpha-filter a, th a.sorting, th a.sorting_desc, th a.sorting_asc', function(e) {
116 refresh($(this).attr('href'));