Verint | Telligent Community
Verint | Telligent Community
  • Site
  • User
  • Site
  • Search
  • User
Verint Community 12.x
  • Verint Community
Verint Community 12.x
API Documentation moderate UI Component
  • User Documentation
  • Ask the Community
  • API Documentation
  • Manager Training
  • Developer Training
  • Tags
  • More
  • Cancel
  • New
  • API Documentation
  • +In-Process API Documentation
  • +Plugin API Documentation
  • +REST API Documentation
  • -Widget, Theme, and Automation APIs
    • +Automation Events
    • -Client-side APIs
      • +Client Messages
      • +Composer Plugins
      • +JavaScript API Modules
      • +jQuery Events
      • +jQuery Plugins
      • -UI Components
        • bookmark UI Component
        • code UI Component
        • collapseexpand UI Component
        • feature UI Component
        • html UI Component
        • Idea Voting UI Component
        • like UI Component
        • links UI Component
        • loading UI Component
        • masonry UI Component
        • moderate UI Component
        • page UI Component
        • poll UI Component
        • previewhtml UI Component
        • rate UI Component
        • resizedimage UI Component
        • scheduledfile UI Component
        • searchresult UI Component
        • select UI Component
        • squeezetext UI Component
        • tag UI Component
        • theater UI Component
        • tip UI Component
        • tourtip UI Component
        • viewhtml UI Component
        • webpreview UI Component
    • +Dynamic Configuration
    • +LESS Functions
    • +Script API Types
    • +Script APIs

moderate UI Component


jQuery.telligent.evolution.ui.components.moderate

UI Component which handles presentation of moderation behavior for content. Transforms the output from $core_v2_ui.Moderate(), which is a <span class="ui-moderate"></span> stub. The default implementation uses the evolutionModerate plugin. Overrides can be provided at the theme level to present moderation differently.

Options

Data made available to instances of the component:

  • contenttypeid: (string) Content Type Id Guid
  • contentid: (string) Content Id Guid
  • initialstate: (boolean) Reported state, true when already reported by the accessing user
  • supportsabuse: (boolean) Whether this piece of content supports being reported
  • configuration: Object of all other keys and values passed via the options dictionary to $core_v2_ui.Moderate(), regardless of whether they have been pre-defined
    • jQuery.evolutionModerate looks for the following optional configuration:
      • AdditionalLinks: Array of objects with keys href, text, and className to present as additional actions alongside moderation
      • AdditionalLinksUrl: Ajax endpoint which returns a JSON array of objects with keys href, text, and className to present as additional actions alongside moderation, used when the set of links is non-deterministic until needed
      • LinkClassName: CSS class name to apply to extra links

Example

A barebones UI component override which would result in rendering a read-only message of 'You have reported [Content Id]' or 'You have not reported [Content Id]' for a given call to $core_v2_ui.Moderate().

$.telligent.evolution.ui.components.moderate = {
    setup: function() {
    },
    add: function(elm, options) {
        var message;
        if(options.initialstate) {
            message = 'You have reported ' + options.contentid;
        } else {
            message = 'You have not reported ' + options.contentid;
        }

        $(elm).html(message);
    }
}

Default Implementation

For reference purposes or as the basis for an override:

(function($){

var reportAbuse = function(contentId, contentTypeId, complete) {
    $.telligent.evolution.post({
        url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/abusereports.json',
        data: {
            ContentId: contentId,
            ContentTypeId: contentTypeId
        },
        cache: false,
        dataType: 'json',
        success: function(response) {
            complete(response);
        }
    });
};

$.telligent.evolution.ui.components.moderate = {
    setup: function() { },
    add: function(elm, options) {
        elm = $(elm);
        var moderationOptions = {
            contentId: options.contentid,
            contentTypeId: options.contenttypeid,
            supportsAbuse: options.supportsabuse === 'true',
            initialState: options.initialstate === 'true',
            onReport: reportAbuse
        };
        if(options.configuration && options.configuration.AdditionalLinks) {
            var links = JSON.parse(options.configuration.AdditionalLinks);
            // don't render if no links
            if(!moderationOptions.supportsAbuse && links.length === 0)
                return;
            // if given an explicit set of links at init-time, create a wrapper
            // callback which always returns them as aditional inks
            moderationOptions.onGetAdditionalLinks = function(complete) {
                complete(links);
            };
        }
        else if(options.configuration && options.configuration.AdditionalLinksUrl) {
            // don't render if no links
            if(!moderationOptions.supportsAbuse && options.configuration.AdditionalLinksUrl.length === 0)
                return;
            // otherwise, if given a url for additional links, create a wrapper
            // callback which makes an ajax request to get the extra links
            moderationOptions.onGetAdditionalLinks = function(complete) {
                $.telligent.evolution.get({
                    url: options.configuration.AdditionalLinksUrl,
                    cache: false,
                    dataType: 'json',
                    success: function(response) {
                        complete(response.links || []);
                    }
                });
            };
        }
        // don't render if no additional links
        if(!moderationOptions.supportsAbuse && !moderationOptions.onGetAdditionalLinks)
            return;
        if(options.configuration && options.configuration.LinkClassName) {
            moderationOptions.linkClassName = options.configuration.LinkClassName;
        }
        elm.evolutionModerate(moderationOptions);
    }
};

}(jQuery));

  • Share
  • History
  • More
  • Cancel
Related
Recommended
  • Telligent
  • Professional Services
  • Submit a Support Ticket
  • Become a Partner
  • Request a Demo
  • Contact Us

About
Privacy Policy
Terms of use
Copyright 2024 Verint, Inc.
Powered by Verint Community