constructor()

in static/src/javascripts/projects/common/modules/discussion/comment-box.js [49:111]


    constructor(options) {
        super();

        this.useBem = true;
        this.templateName = 'comment-box';
        this.componentClass = 'd-comment-box';
        this.classes = {};
        this.errors = [];
        this.defaultOptions = {
            discussionId: null,
            apiRoot: null,
            maxLength: 5000,
            premod: false,
            newCommenter: false,
            hasUsername: true,
            focus: false,
            state: 'top-level',
            replyTo: null,
            priorToVerificationDate: new Date(1392719401337), // Tue Feb 18 2014 10:30:01 GMT
        };
        this.setOptions(options);

        this.errorMessages = {
            EMPTY_COMMENT_BODY: 'Please write a comment.',
            COMMENT_TOO_LONG:
                'Your comment must be fewer than 5000 characters long.',
            USER_BANNED:
                'Commenting has been disabled for this account (<a href="/community-faqs#321a">why?</a>).',
            IP_THROTTLED:
                'Commenting has been temporarily blocked for this IP address (<a href="/community-faqs">why?</a>).',
            DISCUSSION_CLOSED:
                'Sorry your comment can not be published as the discussion is now closed for comments.',
            PARENT_COMMENT_MODERATED:
                'Sorry the comment can not be published as the comment you replied to has been moderated since.',
            COMMENT_RATE_LIMIT_EXCEEDED:
                'You can only post one comment every minute. Please try again in a moment.',
            INVALID_PROTOCOL:
                'Sorry your comment can not be published as it was not sent over a secure channel. Please report us this issue using the technical issue link in the page footer.',
            AUTH_COOKIE_INVALID:
                'Sorry, your comment was not published as you are no longer signed in. Please sign in and try again.',
            'READ-ONLY-MODE':
                'Sorry your comment can not currently be published as commenting is undergoing maintenance but will be back shortly. Please try again in a moment.',
            USERNAME_MISSING: `You must <a href="${config.get('page.mmaUrl')}/public-settings">set a username</a> before commenting. (<a href="/help/2020/feb/10/why-am-i-unable-to-post-a-comment">Learn more</a>).`,

            /* Custom error codes */
            /* CORS blocked by HTTP/1.0 proxy */

            API_CORS_BLOCKED: `Could not post due to your internet settings, which might be
                 controlled by your provider. Please contact your administrator
                 or disable any proxy servers or VPNs and try again.`,
            API_ERROR: `Sorry, there was a problem posting your comment. Please try
                another browser or network connection.  Reference code `,
            EMAIL_VERIFIED: `<span class="d-comment-box__error-meta">Sent. Please check your
                email to verify your email address. Once verified post your
                comment.</span>`,
            EMAIL_VERIFIED_FAIL: `We are having technical difficulties. Please try again later.`,
            EMAIL_NOT_VALIDATED: `Please confirm your email address to comment by
            <a href="${window.guardian.config.page.idUrl}/reset?returnUrl=${encodeURIComponent(
                `${config.get('page.host')}/${config.get('page.pageId')}`
            )}>
            <strong>resetting your password</strong></a>.`,
        };
    }