Q4Widgets API Documentation

q4.library

A collection of many different document types in the same widget. Documents can be filtered by title, tag, or date.
Script link
q4.library.1.0.1.min.js
Source file
q4.library.js, line 2
Requires

Options

feedUrl string
The base URL for the Q4 website.
perPage number
The number of items to display per page, or 0 for unlimited.
Default value
0
sortByYear boolean
Whether to divide the documents by year, or show all at once.
Default value
true
allowAllYears boolean
If using a years filter, whether to show an "all years" option.
Default value
true
allYearsText string
The label for the "all years" option.
Default value
All
startYear number
The year to display first. Default is "all", or most recent.
Example
`new Date().getFullYear()`
dateFormat string
A Moment.js date format string.
Default value
MM/DD/YYYY
template string
An overall template for the timeline.
Example
'<ul class="content-types"></ul>' +
 '<ul class="tags"></ul>' +
 '<p>' +
     '<input type="text" class="search">' +
     'Year: <select class="years"></select>' +
     'Documents per page: <select class="perpage"></select>' +
 '</p>' +
 '<p class="docsfound"></p>' +
 '<ul class="documents"></ul>' +
 '<ul class="pager"></ul>'
loadingTemplate string
An HTML string to display while loading.
Default value
Loading...
docsFoundContainer string
A selector for a message about the number of documents found.
Default value
.docsfound
docsFoundTemplate string
A Mustache template to display the number of documents found. - `{{docCount}}`: The number of documents on this page. - `{{docTotal}}`: The total number of documents. - `{{docFirst}}`: The index of the first document displayed. - `{{docLast}}`: The index of the last document displayed. - `{{page}}`: The page number. - `{{pageCount}}`: The total number of pages.
Default value
Showing {{docFirst}}–{{docLast}} of {{docTotal}} documents.
noDocsMessage string
An HTML string to display when no documents are found.
Default value
No documents found. Please try broadening your search.
docContainer string
A selector for the document list.
Default value
.documents
singleDocTemplate string
A template for a list of single documents.
Example
'<h3 class="docheader single">' +
    '<span class="title">Title</span>' +
    '<span class="date">Date</span>' +
    '<span class="type">Type</span>' +
    '<span class="size">Size</span>' +
'</h3>' +
'<ul class="doclist">' +
    '{{#docs}}' +
    '<li class="single"><a href="{{url}}" target="_blank">' +
        '<span class="title">{{title}}</span>' +
        '<span class="date">{{date}}</span>' +
        '<span class="type">{{type}}</span>' +
        '<span class="size">{{size}}</span>' +
    '</a></li>' +
    '{{/docs}}' +
'</ul>'
multiDocTemplate string
A template for a list of documents with sub-documents.
Example
'<h3 class="docheader multi">' +
    '<span class="title">Title</span>' +
    '<span class="date">Date</span>' +
    '<span class="type">Type</span>' +
    '<span class="size">Size</span>' +
'</h3>' +
'<ul class="doclist">' +
    '{{#docs}}' +
    '<li class="multi">' +
        '<div class="trigger">' +
            '<span class="title">{{title}}</span>' +
            '<span class="date">{{date}}</span>' +
        '</div>' +
        '<ul class="docs">' +
            '{{#subdocs}}' +
            '<li><a href="{{url}}" target="_blank">' +
                '<span class="title">{{title}}</span>' +
                '<span class="date"></span>' +
                '<span class="type">{{type}}</span>' +
                '<span class="size">{{size}}</span>' +
            '</a></li>' +
            '{{/subdocs}}' +
        '</ul>' +
    '</li>' +
    '{{/docs}}' +
'</ul>'
accordionContainer string
A selector for the overall container for multiple-document items. Used to add an accordion effect.
Default value
.multi
accordionTrigger string
A selector for the trigger for the multi-doc accordion effect.
Default value
.trigger
accordionDocContainer string
A selector for the list of documents that will be shown/hidden by the multi-doc accordion.
Default value
.docs
pagerContainer string
A selector for the pager.
Default value
.pager
pagerTrigger string
A selector for each pager link.
Default value
> *
pagerTemplate string
A template for individual pager links.
Default value
<li>{{page}}</li>
pagerLabels Object
An object with labels for pager navigation items.
perPageOptions Object
Options for the "documents per page" control.
Default value
{"container":".perpage","input":"select","template":"<option>{{number}}</option>","trigger":"> *","allowMulti":false,"allowNone":false}
searchSelector string
A selector for the search box.
Default value
.search
categories
An array of categories to display. These can be either contentType strings, or objects with these properties: - `name`: The display name. - `contentType`: One of the types defined in this.contentTypes. - `cssClass`: An optional class to apply to the widget. - `options`: An optional object of parameters to pass to the API: - `tag`: Tag(s) to filter by. Can be a string or an array. - `year`: Year(s) to filter by. String or array. - `type`: For contentAssets only, the download list(s) to use.
catOptions Object
Options for the category control.
Default value
{"container":".content-types","input":"trigger","template":"<li>{{name}}</li>","trigger":"> *","allowMulti":false,"allowNone":false}
tags Array.<string>Array.<object>
If `tagOptions.input` is `trigger` or `select`, an array of preset tags to offer as filter options. Tags can be either strings or {name, value} objects.
tagOptions Object
Options for the tag filter control.
Default value
{"container":".tags","input":"trigger","template":"<li>{{name}}</li>","trigger":"> *","allowMulti":true,"allowNone":true}
yearOptions Object
Options for the year filter control.
Default value
{"container":".years","input":"select","template":"<option value=\"{{value}}\">{{year}}</option>","trigger":"> *","allowMulti":false,"allowNone":false}
onFilterUpdate function
A callback fired after a filter control is updated, but before matching documents are loaded. Use event.preventDefault() to cancel loading documents.
Parameters
event Event
The triggering event.
pageComplete function
A callback fired after loading a new page of documents.
Parameters
event Event
The triggering event.

Methods

setFilter
Set the value of one of the filters.
Parameters
filter string
The filter to update.
value number/string
The value to assign to the filter.
reload boolean
Whether to fetch fresh documents.