Class: CitationView

CitationView()

The CitationView shows a formatted citation for a package, including title, authors, year, UUID/DOI, etc.

Screenshot

Constructor

new CitationView()

Source:

Extends

  • Backbone.View

Members

citationMetadataClass :string

The HTML classes to use for the element that will contain the citation metadata. The citation metadata are the citations that cite the main citation. This class will be passed to the template and will be used to identify the container element.
Type:
  • string
Since:
  • 2.23.0
Source:

className :string

The HTML classes to use for this view's element
Type:
  • string
Source:

context :string

The context to use when rendering the citation. This can be either "inText" or "full". Configure this in the CitationView#styles property.
Type:
  • string
Since:
  • 2.23.0
Source:
Set this to true to create a link to the object's landing page around the entire citation. This will override the createTitleLink option.
Type:
  • boolean
Source:
Set this to true to create a link to the object's landing page around the title. This will be ignored if the createLink option is set to true.
Type:
  • boolean
Source:

defaultTitle :string

A default title for when the Citation Model does not have a title.
Type:
  • string
Since:
  • 2.23.0
Source:

model :CitationModel

The CitationModel that this view is displaying. The view can be instantiated by passing in a CitationModel, or a SolrResult, DataONEObject, or an extension of those, and the view will create a CitationModel from it. To change the model after the view has been instantiated, use the CitationView#setModel method.
Type:
Source:

openLinkInNewTab :boolean

When links are created as part of this view, whether to open them in a new tab or not. If the URL begins with "http" then it will always open in a new tab. When this option is true, then relative URLs will also open in a new tab.
Type:
  • boolean
Since:
  • 2.23.0
Source:

style :string

The citation style to use. Any style that is defined in the CitationView#styles property can be used. If the style is not defined then the view will not render.
Type:
  • string
Since:
  • 2.23.0
Source:

styles :Object

The format and layout options that are available for this view.
Type:
  • Object
Properties:
Name Type Description
styleName CitationView#StyleDefinition Each property in the styles object maps a style name to a StyleOption object.
Since:
  • 2.23.0
Source:

tagName :string

The HTML tag name for this view's element
Type:
  • string
Source:

titleClass :string

The HTML classes to use for the title element. This will be passed to the template and will be used to identify the title element if the createTitleLink option is set to true.
Type:
  • string
Since:
  • 2.23.0
Source:

type :string

The name of this type of view
Type:
  • string
Source:

Methods

CSLNameToAPA(cslJSON)

Given one name object in CSL-JSON format, return the author's name in the format required for a full APA citation: Last name first, followed by author initials with a period after each initial. See EMLParty#toCSLJSON
Parameters:
Name Type Description
cslJSON object A CSL-JSON name object
Since:
  • 2.23.0
Source:

CSLNameToFullNameStr(authors) → {string}

Given a list of authors in CSL JSON, merge them all into a single string where authors full names are separated by commas.
Parameters:
Name Type Description
authors Array.<object> An array of CSL JSON name objects
Since:
  • 2.23.0
Source:
Returns:
The formatted author string or an empty string if there are no authors
Type
string

CSLNamesToAPA(authors, maxAuthorsopt) → {string}

Given a list of authors in CSL JSON, merge them all into a single string for display in an APA citation.
Parameters:
Name Type Attributes Default Description
authors Array.<object> An array of CSL JSON name objects
maxAuthors number <optional>
20 The maximum number of authors to display. If there are more than this number of authors, then the remaining authors will be replaced with an ellipsis. The default is 20 since that is the maximum that APA allows. Set to a falsy value to display all authors.
Since:
  • 2.23.0
Source:
Returns:
The formatted author string or an empty string if there are no authors
Type
string

CSLNamesToAPAInText(authors) → {string}

Given a list of authors in CSL JSON, merge them all into a single string for display in an In-Text APA citation.
Parameters:
Name Type Description
authors Array.<object> An array of CSL JSON name objects
Since:
  • 2.23.0
Source:
Returns:
The formatted author string or an empty string if there are no authors
Type
string

addCitationMetadata(citationMetadata)

Render the list of in-text citations that cite the main citation. This function will find the element in the template that is designated as the container for the in-text citations and will render any citations from the model's citationMetadata attribute.
Parameters:
Name Type Description
citationMetadata Array.<Object> The citationMetadata to render. See CitationModel#defaults.
Since:
  • 2.23.0
Source:
Make the entire citation a link to the view page or the source URL.
Since:
  • 2.23.0
Source:
Make the title a link to the view page or the source URL.
Since:
  • 2.23.0
Source:

clear() → {CitationView}

Remove all HTML from the view.
Since:
  • 2.23.0
Source:
Returns:
Returns the view.
Type
CitationView

initialize(options)

Executed when a new CitationView is created. Options that are available but which are not defined as properties of this view are defined below.
Parameters:
Name Type Description
options Object A literal object with options to pass to the view.
Properties
Name Type Attributes Description
metadata Backbone.Model <optional>
This option is allowed for backwards compatibility, but it is recommended to use the model option instead. This will be ignored if a model is set. A model passed in this option will be used to populate a CitationModel.
title string <optional>
Allowed for backwards compatibility. Setting this option will set the default title for this view, on the CitationView#defaultTitle property.
id string <optional>
When no model and no metadata are provided, this option can be used to query for an object to cite. If a model or metadata model is provided, then the ID will be ignored.
Source:

render() → {CitationView}

Renders the view.
Source:
Returns:
Returns the view.
Type
CitationView

renderAPA(options, template, maxAuthorsopt)

Render a complete APA style citation.
Parameters:
Name Type Attributes Default Description
options Object The options to pass to the template.
template function The template associated with this style, or it's archive template if the object is archived and not indexed.
maxAuthors number <optional>
20 The maximum number of authors to display. If there are more than this number of authors, then the remaining authors will be replaced with an ellipsis. The default is 20 since that is the maximum that APA allows. Set to a falsy value to display all authors.
Since:
  • 2.23.0
Source:

renderAPAAllAuthors(options, template)

Render a complete APA style citation with all authors listed.
Parameters:
Name Type Description
options Object The options to pass to the template.
template function The template associated with this style, or it's archive template if the object is archived and not indexed.
Since:
  • 2.26.0
Source:

renderAPAInText(options, template)

Render an in-text APA style citation.
Parameters:
Name Type Description
options Object The options to pass to the template.
template function The template associated with this style, or it's archive template if the object is archived and not indexed.
Since:
  • 2.23.0
Source:

setModel(newModelopt, metadataopt, idopt, renderopt)

Use this method to set or change the model for this view, and re-render. If a CitationModel is provided, then it will be used. If a SolrResult, DataONEObject, or an extension of those is provided as either the first or second argument, then a CitationModel will be created from it. Otherwise, if there is an ID provided, then a CitationModel will be created from a SolrResult with that ID. If none of those are provided, then a new, empty CitationModel will be created.
Parameters:
Name Type Attributes Default Description
newModel CitationModel <optional>
The new model to set on this view.
metadata Backbone.Model <optional>
This option is allowed for backwards compatibility, but it is recommended to use the model option instead. This will be ignored if a model is set. A model passed in this option will be used to populate a CitationModel.
id string <optional>
When no model and no metadata are provided, this option can be used to query for an object to cite.
render boolean <optional>
true Whether to re-render the view after setting the model.
Since:
  • 2.23.0
Source: