Plugin Directory

Changeset 1967449


Ignore:
Timestamp:
11/01/2018 09:34:38 PM (7 years ago)
Author:
commentbox
Message:

Made initCommentBoxIo a callable function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • commentbox-io/trunk/public/js/initCommentBoxIo.js

    r1965305 r1967449  
    1 jQuery(document).ready(function() {
     1function initCommentBoxIo() {
    22
    3     if (!commentBoxIoOptions) {
    4         commentBoxIoOptions = {};
    5     }
     3    jQuery(document).ready(function() {
    64
    7     commentBox(commentBoxIoOptions['project-id'], {
    8         className: commentBoxIoOptions['class-name'], // the class of divs to look for
    9         defaultBoxId: commentBoxIoOptions['box-id'], // the default ID to associate to the div
    10         tlcParam: commentBoxIoOptions['comment-link-param'], // used for identifying links to comments on your page
    11         backgroundColor: commentBoxIoOptions['background-color'], // default transparent
    12         textColor: commentBoxIoOptions['text-color'], // default black
    13         subtextColor: commentBoxIoOptions['subtext-color'], // default grey
    14         /**
    15          * Creates a unique URL to each box on your page.
    16          *
    17          * @param {string} boxId
    18          * @param {Location} pageLocation - a copy of the current window.location
    19          * @returns {string}
    20          */
    21         createBoxUrl(boxId, pageLocation) {
     5        if (!commentBoxIoOptions) {
     6            commentBoxIoOptions = {};
     7        }
    228
    23             pageLocation.href = commentBoxIoOptions['permalink'];
    24             //pageLocation.search = ''; // removes query string!
    25             pageLocation.hash = boxId; // creates link to this specific Comment Box on your page
    26             return pageLocation.href; // return url string
    27         },
    28         /**
    29          * Fires once the plugin loads its comments.
    30          * May fire multiple times in its lifetime.
    31          *
    32          * @param {number} count
    33          */
    34         onCommentCount(count) {
     9        commentBox(commentBoxIoOptions['project-id'], {
     10            className: commentBoxIoOptions['class-name'], // the class of divs to look for
     11            defaultBoxId: commentBoxIoOptions['box-id'], // the default ID to associate to the div
     12            tlcParam: commentBoxIoOptions['comment-link-param'], // used for identifying links to comments on your page
     13            backgroundColor: commentBoxIoOptions['background-color'], // default transparent
     14            textColor: commentBoxIoOptions['text-color'], // default black
     15            subtextColor: commentBoxIoOptions['subtext-color'], // default grey
     16            /**
     17             * Creates a unique URL to each box on your page.
     18             *
     19             * @param {string} boxId
     20             * @param {Location} pageLocation - a copy of the current window.location
     21             * @returns {string}
     22             */
     23            createBoxUrl(boxId, pageLocation) {
    3524
    36             if (commentBoxIoOptions['comment-count-selector']) {
    37                 jQuery(commentBoxIoOptions['comment-count-selector']).text(count);
     25                pageLocation.href = commentBoxIoOptions['permalink'];
     26                //pageLocation.search = ''; // removes query string!
     27                pageLocation.hash = boxId; // creates link to this specific Comment Box on your page
     28                return pageLocation.href; // return url string
     29            },
     30            /**
     31             * Fires once the plugin loads its comments.
     32             * May fire multiple times in its lifetime.
     33             *
     34             * @param {number} count
     35             */
     36            onCommentCount(count) {
     37
     38                if (commentBoxIoOptions['comment-count-selector']) {
     39                    jQuery(commentBoxIoOptions['comment-count-selector']).text(count);
     40                }
    3841            }
    39         }
     42        });
    4043    });
    41 });
     44}
     45
     46initCommentBoxIo();
Note: See TracChangeset for help on using the changeset viewer.