library: split count/load into two functions

- When the year or page length is changed, we no longer make an
unnecessary call to the years API method; we just use previously stored
document counts to rebuild the pager.
- Renamed loadDocuments to loadDocumentPage; it now takes a page
argument instead of reading a data variable.
- Added an extra boolean parameter to the setFilter public method which
can trigger a refetch.
- Also, the onFilterUpdate event callback now fires before the actual
filter gets updated.