userSession

Global Property

Set user's session data if it's available.

Links

storageBaseName

Global Property

Type

  • String

Base name for the message queue session storage container, which is completed with the collectionId.

Links

collectionId

Global Property

Type

  • Number

Collection ID.

Links

messageQueue

Global Property

Message queue which is responsible to save comments when a page reload is needed to authenticate (when posting a comment).

Links

ui

Global Property

Type

  • WidgetUi

Instance of WidgetUi. This can handle the UI part of the widget.

Links

pseudonymMissing

Global Property

Type

  • Boolean

Pseudonym is still missing.

Links

errors

Global Property

Type

  • Object

Error message override.

Links

showInactivityMessage

Global Property

Shows a dialog with a sign in link to re-login after a session expire.

Links

setConfig(keyOrObject, value)

Global Function

Adds or overrides configuration options.

parameter type default description
keyOrObject string | object Key or actually an object with key-value pairs.
value anything Optional. Should be specified only if keyOrObject is actually a key (string).

Returns

  • undefined

Links

enableLogging

Global Function

Enables logging.

Returns

  • undefined

Links

disableLogging

Global Function

Disables logging.

Returns

  • undefined

Links

setLoggingLevel

Global Function

Sets logging level.

Returns

  • undefined

Links

MessageQueue(collectionId)

Global Function

MessageQueue saves a message to the session storage to preserve it after a page reload.

parameter type default description
collectionId Number | String Collection ID.

Returns

  • undefined

Links

save(commentBody)

Global Function

Saves a comment to the session storage.

parameter type default description
commentBody String Body of the comment

Returns

  • undefined

Links

hasComment

Global Function

Verifies if there are comments for the provided collection id.

Returns

  • Boolean - If there are comments saved

Links

getComment

Global Function

Returns the comment saved in the storage.

Returns

  • String - The saved comment.

Links

clear

Global Function

Clears the storage attached to the provided collectionId.

Returns

Links

Widget(rootEl, config)

Global Function

Incorporates the communication with the content creation service, Livefyre authentication, live streaming, and creation of the markup of the commenting widget.

The Widget is configurable and customizable.

Configuration:

Mandatory fields:
  • articleId: ID of the article, any string
  • url: canonical URL of the page
  • title: Title of the page
Optional fields:
  • order: This specifies how the widget is built. It can have two values:
    • normal: the commenting box is placed on top of the comment stream, and the comments are ordered as newest on top.
    • inverted: the commenting box is placed at the bottom of the comment stream, and the comments are ordered newest on bottom. <br/>Default value is 'normal'.
  • layout: Specifies the layout style of the widget. It can have two values:
    • normal: When placed in the main area of the page.
    • side: When placed in the side area of the page. <br/>Default value is 'normal'.
  • datetimeFormat: How to format the timestamps. This is an object and has two fields:
    • minutesUntilAbsoluteTime: specifies after how many minutes to switch from relative time to absolute. If -1 is specified, the timestamps will be in the absolute format immediately. By default it is set to 14 days.
    • absoluteFormat: specifies the format with which the absolute timestamp is rendered. For more information about the possible values please visit: https://github.com/Financial-Times/o-date#o-dateformatdate-tpl
  • section: Override the default mapping based on URL or CAPI with an explicit mapping. Section parameter should be a valid FT metadata term (Primary section)
  • tags: Tags which will be added to the collection in Livefyre
parameter type default description
rootEl object | string Root element in which the widget should be loaded.
config object Configuration object. See in the description the fields that are mandatory.

Returns

  • undefined

Links

loadInitData(callback)

Global Function

Override of oCommentUi.Widget.init function. This is responsible to load the comments and the article related data. This function also initiates live stream from Livefyre.

parameter type default description
callback function function(err, data), where data contains collectionId and comments. See o-comment-api.api.getComments

Returns

  • undefined

Links

onError(err)

Global Function

Decides what happens when an error occurs. It clears the container. If the article is flagged as unclassified, no message appears. If any other error occurs, show a generic not available message.

parameter type default description
err Object | String Error object or string.

Returns

  • undefined

Links

render(commentsData, callback)

Global Function

Handle the comments, render them, and initiate the login process as well.

parameter type default description
commentsData Object Object with collectionId and comments.
callback function Called when the initial rendering completed.

Returns

  • undefined

Links

adaptToHeight(height)

Global Function

Calling this method with a height in pixels as parameter will adapt the UI to shrink within that height. If the current UI is smaller, it will fill the space to occupy the full height, or if the current UI is taller, a scroll will appear on the comments.

parameter type default description
height Number Desired height in pixels.

Returns

  • undefined

Links

addAuthNotAvailableMessage

Global Function

Inserts message when SUDS reports as authentication is not available.

Returns

  • undefined

Links

login(callback)

Global Function

Tries to obtain the user's login data. Calls a callback with the resulted status, and also fires an event if the user can be logged in.

parameter type default description
callback function Called with two parameters: loginStatus, authData.

Returns

  • undefined

Links

logout

Global Function

Broadcasts a logout event.

Returns

  • undefined

Links

loginRequiredPseudonymMissing(callback)

Global Function

Login required and pseudonym is missing

parameter type default description
callback function function (err, authData)

Returns

  • undefined

Links

loginRequiredAfterASuccess(callback)

Global Function

Login required, first attempt of the login process is successful. If the user is still not logged in, then fail. If the user has no pseudonym, ask for a pseudonym.

parameter type default description
callback function function (err, authData)

Returns

  • undefined

Links

loginRequired(callback, force)

Global Function

Login is required. If pseudonym is missing, ask for a pseudonym. If there is no known method to login the user, generate a loginRequired.authAction event that can be handled at the integration level. If successful, check if the user is logged in.

parameter type default description
callback function function (err, authData)
force Boolean Forces checking the login status of the user by a call to SUDS

Returns

  • undefined

Links

trackPost(collectionId)

Global Function

Tracks a comment post.

parameter type default description
collectionId number Livefyre collection ID.

Returns

  • undefined

Links

trackCcsDown

Global Function

Tracks when CCS is down.

Returns

  • undefined

Links

trackSuccessLoad

Global Function

Tracks when the widget is successfully loaded.

Returns

  • undefined

Links

showSetPseudonymDialog(callback)

Global Function

Shows a dialog for setting the initial pseudonym (shown when the user doesn't have a pseudonym set).

parameter type default description
callback function Optional. function (err, authData)

Returns

  • undefined

Links

showChangePseudonymDialog(currentPseudonym, callback)

Global Function

Settings dialog where the user can change its pseudonym or email preferences.

parameter type default description
currentPseudonym Object Required. Current pseudonym of the user.
callback function Optional. function (err, authData)

Returns

  • undefined

Links

showMessage(title, message)

Global Function

Shows a message to the user in a dialog (not modal).

parameter type default description
title String Title of the dialog
message String The content of the dialog (the message).

Returns

  • undefined

Links

module.exports

Static Property

Type

  • object

Widget.js exposed as main constructor

Links

Widget~hasCommentId(id)

Inner Function

Comment IDs are saved to avoid duplicates. This returns if an ID already exists.

parameter type default description
id Number ID of a comment.

Returns

  • Boolean - If the comment ID was already processed or not.

Links

Widget~removeCommentId(id)

Inner Function

Removes a comment ID from the list of existing comments IDs.

parameter type default description
id Number ID of a comment.

Returns

  • Boolean - If the ID was already saved or not.

Links

Widget~processOneComment(aComment)

Inner Function

Adds the following parameters to an existing comment object:

  • dateToShow: date in the format that is rendered in the UI
  • datetime: date in ISO format
  • relativeTime: if dateToShow is in relative time format
  • timestamp: normalized timestamp (in milliseconds)
  • author.displayName truncated to 50 characters
parameter type default description
aComment Object A comment object, which respects the format the oCommentApi.api.getComments returns.

Returns

  • Object - Processed comment

Links

Widget~preprocessCommentData(comments)

Inner Function

Iterates over an array of comments and applies the modifications made by the processOneComment function.

parameter type default description
comments Array Array with comments objects, which respects the format the oCommentApi.api.getComments returns.

Returns

  • Array - Processed comment array

Links

Widget~newCommentReceived(commentData)

Inner Function

New comment received over the stream, this function handles it.

parameter type default description
commentData Object A comment object, in Livefyre format.

Returns

  • undefined

Links

Widget~postComment(commentBody, retryingToPostAfterReLogin)

Inner Function

Post a comment. Known fact is that the user is logged in and the comment body is not blank.

Insert the comment in the DOM instantly, and try to post the comment with the API. If successful, leave the comment in the DOM and change the ID with the real comment ID. If unsuccessful, remove the comment from the DOM, repopulate the comment area with the comment and show the error message.

parameter type default description
commentBody String Text of the comment
retryingToPostAfterReLogin Boolean Second trial

Returns

  • undefined

Links

module.exports

Static Property

Type

  • EnvConfig

Export a single instance of the config container.

Links

module.exports

Static Property

Type

  • Object

List of the templates available.

Links

strings.trim(string)

Static Method

Shim of String.trim for older browsers. Trims a string.

parameter type default description
string String String to be trimmed.

Returns

  • String - Trimmed string

Links