Origami Frontend Components & Services

Readme: o-comment-ui

📢 The commenting platform for ft.com, the app, interactive graphics & alphaville is currently being replaced. Please speak to the Comments team if you intend to start using this component or which to make any changes to it.

JavaScript module which incorporates common UI elements of the FT commenting system like dialogs, forms, common parts of a commenting widget with DOM manipulation and a unified way to load it.


JavaScript API


Widget is responsible to coordinate getting initialization data, initializing the Ui. While this class implements some of the basic functionality (handling errors, loading timeout), it should be extended by providing an implementation for getting the initialization data.


new oCommentUi.Widget(config);

To create an instance, you need to provide a configuration object. This should have the following structure:

Mandatory fields:
Optional fields:


new oCommentUi.Widget(el, {
    articleId: 'e113c91c-10d9-11e4-812b-00144feabdc0',
    url: 'http://www.ft.com/cms/s/0/e113c91c-10d9-11e4-812b-00144feabdc0.html',
    title: 'Rolls-Royce seeks to catch-up with rivals on margins - FT.com'

Final methods


This method will initiate the process of loading the initialization data that are needed to render the widget and the rendering of the UI. This method uses hook methods which are not implemented in this module, but should be implemented in the module that extends it.
init will handle errors of the process of loading the widget, also timeout if an error is not available.

This method can be called once on an instance (calling it multiple types will have no effect).

Abstract methods (not implemented in this module)


This method is responsible for gathering data that is needed to initialize the widget (e.g. metadata, site ID, comments, etc.).


This method is responsible for rendering the UI of the widget on the page. Render is called when the initialization process is done.
This method is called using the data gathered during the init process:


Methods that can be overriden (they have default implementation)


This method is responsible to handle any error that appears during the initialization.


The default implementation clears out the container of the widget and shows the unavailable message template (available using the template object).


This method is responsible to handle the case when within a given time the loading isn't finished and no error appeared.

The default implementation clears out the container of the widget and shows the unavailable message template (available using the template object).


Extending of the Widget can be done in the following way:

var WidgetExtend = function () {
    oCommentUi.Widget.apply(this, arguments);
oCommentUi.Widget.__extend(WidgetExtend, {eventNamespace}, {classNamespace});

Example from o-comments:

var Widget = function () {
    oCommentUi.Widget.apply(this, arguments);
oCommentUi.Widget.__extend(Widget, 'oComments', 'o-comments');

Widget UI

This class is responsible to handle the UI part of a commenting widget. An instance of this is created within an instance of the Widget.
While this implementation has predefined methods, it can be extended with particular UI methods.


new oCommentUi.WidgetUi(widgetContainer);

Where widgetContainer should be a DOM element in which the widget is loaded.



Scrolls the page to the widget. A callback function is called when the scroll finished (optional).


Inserts message when comments is not available, either because of the web services or Livefyre.


Clears the container's content.


Extending of Widget can be done in the following way:

var WidgetUiExtend = function () {
    oCommentUi.WidgetUi.apply(this, arguments);


Generic Ui functionality which is common across all istances of the comments. These are mostly dialogs which show on the page and are unrelated to the Widget's container or widget instance.

The features are available on the following object:




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

    submit: function (formData, callback) {
        // called when the form is submitted
    close: function () {
        // called when the dialog is closed by a user action

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

        displayName: 'currentPseudonym',
        settings: {
            emaillikes: 'never'
        submit: function (formData, callback) {
            // called when the form is submitted
        close: function () {
            // called when the dialog is closed by a user action

Shows a dialog which reminds the user to save its email preferences if he/she didn't do so.

    submit: function (formData, callback) {
        // called when the form is submitted
    close: function () {
        // called when the dialog is closed by a user action

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

    submit: function (formData, callback) {
        // called when the form is submitted
    close: function () {
        // called when the dialog is closed by a user action


All functions of userDialogs has the same callback parameter structure, which should be an object with the following fields:


Required. Function that is called when the form is submitted. As parameters the form data is provided (serialized into an object of key-value pairs), and a callback which should be called with either an error message (if an error occurred) or without parameters if submission is successful.

    formKey: 'formValue'
}, function (err) {
    if (err) {
        // show the error message, leave the dialog open

    // success, close the dialog

Optional. Function that is called when the dialog is closed.


This contains common Mustache templates which are compiled and can be rendered with custom data.

The templates are available on the following object:


Templates that are available:


Message that appears when an error occured or loading the widget takes longer than the timeout period. It has a default style added.



Terms and guidelines message with default style.
Requires no parameters to render.

Link that is used for changing user settings.



Clearfix. Separates rows horizontally that have float.

These templates can be overriden on a global level.


Internationalization is responsible to provide common messages/texts that are used within the commenting application.

The strings are available on the following object:


It exposes the following:


Contains generic messages:


Some error messages that come from the web services are not very user friendly. These messages are mapped to more user friendly versions that can be shown to the user.


Logging can be enabled for debugging purposes. It logs using the global 'console' if available (if not, nothing happens and it degrades gracefully).
By default logging is disabled.


This method enables logging of the module.


This method disables logging of the module.


This method sets the logging level. This could be a number from 0 to 4 (where 0 is debug, 4 is error), or a string from the available methods of 'console' (debug, log, info, warn, error).
Default is 3 (warn).

Sass API


There is a default font-family set for o-comment-ui: MetricWeb, serif
Please note that the font itself is not loaded by this module, this should be done by the product.

In order to override the default font, set a value for the following variable:

$o-comment-ui-font-family: font1, font2;

In order to suppress downloading the web fonts set the following variable

$o-comment-ui-include-fonts: false;

Browser support

Works in accordance with our support policy

Core/Enhanced Experience

Only the enhanced experience offers any kind of commenting functionality. Core functionality will be added in due course.

Support Status
Switch component view

GitHub Repository

Install o-comment-ui

If using the Build Service, add o-comment-ui@^5.0.0 to your script and link tags.

If running a Manual Build, run bower install --save "o-comment-ui@^5.0.0".

Help & Support

o-comment-ui is maintained directly by the Origami team. If you have any questions about o-comment-ui or Origami in general, we are happy to help. 😊

Slack: #ft-origami
Email: origami.support@ft.com

Feedback / Issues

To report a bug or request features please create an issue on Github. For support or general feedback please get in touch 😊

Slack: #ft-origami
Email: origami.support@ft.com