'status' => CRM_Utils_Array::value('status', $params),
'buttonTop' => CRM_Utils_Array::value('buttonTop', $params),
'buttonBottom' => CRM_Utils_Array::value('buttonBottom', $params),
- 'twentyfive' => $this->getPerPageLink(25),
- 'fifty' => $this->getPerPageLink(50),
- 'onehundred' => $this->getPerPageLink(100),
+ 'currentLocation' => $this->getCurrentLocation(),
);
/**
return array($offset, $this->_perPage);
}
- /**
- * given a number create a link that will display the number of
- * rows as specified by that link
- *
- * @param int $perPage the number of rows
- *
- * @return string the link
- * @access void
- */
- function getPerPageLink($perPage) {
- if ($perPage != $this->_perPage) {
- $href = $this->makeURL(self::PAGE_ROWCOUNT, $perPage);
- $link = sprintf('<a href="%s" %s>%s</a>',
- $href,
- $this->_classString,
- $perPage
- ) . $this->_spacesBefore . $this->_spacesAfter;
- }
- else {
- $link = $this->_spacesBefore . $perPage . $this->_spacesAfter;
- }
-
- return $link;
+ function getCurrentLocation() {
+ $config = CRM_Core_Config::singleton();
+ $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET);
+ return CRM_Utils_System::url($path, CRM_Utils_System::getLinksUrl(self::PAGE_ID, FALSE, TRUE), FALSE, NULL, FALSE) . $this->getCurrentPageID();
}
function getFirstPageLink() {
}
$querystring = array_merge($querystring, array_unique($arrays));
- $querystring = array_map('htmlentities', $querystring);
- $url = implode('&', $querystring);
+ $url = implode('&', $querystring);
if ($urlVar) {
- $url .= (!empty($querystring) ? '&' : '') . $urlVar . '=';
+ $url .= (!empty($querystring) ? '&' : '') . $urlVar . '=';
}
return $url;
* RSS feed.
* @param $fragment string A fragment identifier (named anchor) to append to the link.
*
+ * @param bool $htmlize
+ * @param bool $frontend
+ * @param bool $forceBackend
* @return string an HTML string containing a link to the given path.
* @access public
* @static
{* Controller for 'Rows Per Page' *}
{if $location eq 'bottom' and $pager->_totalItems > 25}
<div class="form-item float-right">
- <label>{ts}Rows per page:{/ts}</label>
- {$pager->_response.twentyfive} |
- {$pager->_response.fifty} |
- {$pager->_response.onehundred}
+ <label for="{$form.formName}-rows-per-page-select">{ts}Rows per page:{/ts}</label>
+ <input class="crm-rows-per-page-select" id="{$form.formName}-rows-per-page-select" type="text" size="3" value="{$pager->_perPage}"/>
</div>
<div class="clear"></div>
{/if}
{literal}
cj(function($) {
{/literal}
- var $form = $('#{$form.formName}');
- var numPages = {$pager->_response.numPages};
- var currentPage = {$pager->_response.currentPage};
+ var
+ $form = $('#{$form.formName}'),
+ numPages = {$pager->_response.numPages},
+ currentPage = {$pager->_response.currentPage},
+ perPageCount = {$pager->_perPage},
+ currentLocation = {$pager->_response.currentLocation|json_encode};
{literal}
function refresh(url) {
var options = url ? {url: url} : {};
if (isNaN(num) || num < 1 || num > numPages || num === currentPage) {
return;
}
- var url = $('a.crm-pager-link', $form).attr('href');
- refresh(url.replace(/crmPID=\d/, 'crmPID=' + num));
+ refresh(currentLocation.replace(/crmPID=\d+/, 'crmPID=' + num));
}
- $('input[name^=crmPID]', $form).spinner({
- min: 1,
- max: numPages
- })
+ function changeCount(num) {
+ num = parseInt(num, 10);
+ if (isNaN(num) || num < 1 || num === perPageCount) {
+ return;
+ }
+ refresh(currentLocation.replace(/&crmRowCount=\d+/, '') + '&crmRowCount=' + num);
+ }
+ function preventSubmit(e) {
+ if (e.keyCode == 13) {
+ e.preventDefault();
+ $(this).trigger('change');
+ return false;
+ }
+ }
+ $('input[name^=crmPID]', $form)
+ .spinner({
+ min: 1,
+ max: numPages
+ })
.on('change', function() {
page($(this).spinner('value'));
- });
+ return false;
+ })
+ .on('keyup keydown keypress', preventSubmit);
+ $('input.crm-rows-per-page-select', $form)
+ .spinner({
+ min: 25,
+ step: 25
+ })
+ .on('change', function() {
+ changeCount($(this).spinner('value'));
+ return false;
+ })
+ .on('keyup keydown keypress', preventSubmit);
$form
.on('click', 'a.ui-spinner-button', function(e) {
- page($(this).siblings('input[name^=crmPID]').spinner('value'));
+ if ($(this).is('.crm-pager a')) {
+ page($(this).siblings('input[name^=crmPID]').spinner('value'));
+ } else {
+ changeCount($(this).siblings('input.crm-rows-per-page-select').spinner('value'));
+ }
})
.on('click', 'a.crm-pager-link, #alpha-filter a', function() {
- refresh($(this).attr('href'));
- return false;
- });
+ refresh($(this).attr('href'));
+ return false;
+ });
});
{/literal}
</script>