<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>moderate UI Component</title><link>https://community.telligent.com/community/11/w/api-documentation/67184/moderate-ui-component</link><description /><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>moderate UI Component</title><link>https://community.telligent.com/community/11/w/api-documentation/67184/moderate-ui-component</link><pubDate>Tue, 19 Nov 2019 20:29:50 GMT</pubDate><guid isPermaLink="false">45065c07-00d4-4465-aa0b-694a7f11c7b3</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/11/w/api-documentation/67184/moderate-ui-component#comments</comments><description>Current Revision posted to API Documentation by Ben Tiedt on 11/19/2019 20:29:50&lt;br /&gt;
&lt;hr class="generated-documentation-start" style="border-width:0;" /&gt;&lt;h3&gt;&lt;a id="jQuery_telligent_evolution_ui_components_moderate" name="jQuery_telligent_evolution_ui_components_moderate"&gt;&lt;/a&gt;jQuery.telligent.evolution.ui.components.moderate&lt;/h3&gt;
&lt;p&gt;[[ui JavaScript API Module|UI Component]] which handles presentation of moderation behavior for content. Transforms the output from &lt;code&gt;$core_v2_ui.Moderate()&lt;/code&gt;, which is a &lt;code&gt;&amp;lt;span class=&amp;quot;ui-moderate&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;/code&gt; stub. The default implementation uses the [[evolutionModerate jQuery Plugin|evolutionModerate plugin]]. [[ui JavaScript API Module|Overrides can be provided]] at the theme level to present moderation differently.&lt;/p&gt;
&lt;h3&gt;&lt;a id="Options" name="Options"&gt;&lt;/a&gt;Options&lt;/h3&gt;
&lt;p&gt;Data made available to instances of the component:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;contenttypeid&lt;/code&gt;: (string) Content Type Id Guid&lt;/li&gt;
&lt;li&gt;&lt;code&gt;contentid&lt;/code&gt;: (string) Content Id Guid&lt;/li&gt;
&lt;li&gt;&lt;code&gt;initialstate&lt;/code&gt;: (boolean) Reported state, true when already reported by the accessing user&lt;/li&gt;
&lt;li&gt;&lt;code&gt;supportsabuse&lt;/code&gt;: (boolean) Whether this piece of content supports being reported&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;configuration&lt;/code&gt;: Object of all other keys and values passed via the options dictionary to &lt;code&gt;$core_v2_ui.Moderate()&lt;/code&gt;, regardless of whether they have been pre-defined
&lt;ul&gt;
&lt;li&gt;
[[evolutionModerate jQuery Plugin|jQuery.evolutionModerate]] looks for the following optional configuration:
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;AdditionalLinks&lt;/code&gt;: Array of objects with keys &lt;code&gt;href&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt;, and &lt;code&gt;className&lt;/code&gt; to present as additional actions alongside moderation&lt;/li&gt;
&lt;li&gt;&lt;code&gt;AdditionalLinksUrl&lt;/code&gt;: Ajax endpoint which returns a JSON array of objects with keys &lt;code&gt;href&lt;/code&gt;, &lt;code&gt;text&lt;/code&gt;, and &lt;code&gt;className&lt;/code&gt; to present as additional actions alongside moderation, used when the set of links is non-deterministic until needed&lt;/li&gt;
&lt;li&gt;&lt;code&gt;LinkClassName&lt;/code&gt;: CSS class name to apply to extra links&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;a id="Example" name="Example"&gt;&lt;/a&gt;Example&lt;/h3&gt;
&lt;p&gt;A barebones UI component override which would result in rendering a read-only message of &amp;#39;You have reported [Content Id]&amp;#39; or &amp;#39;You have not reported [Content Id]&amp;#39; for a given call to &lt;code&gt;$core_v2_ui.Moderate()&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$.telligent.evolution.ui.components.moderate = {
    setup: function() {
    },
    add: function(elm, options) {
        var message;
        if(options.initialstate) {
            message = &amp;#39;You have reported &amp;#39; + options.contentid;
        } else {
            message = &amp;#39;You have not reported &amp;#39; + options.contentid;
        }

        $(elm).html(message);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;&lt;a id="Default_Implementation" name="Default_Implementation"&gt;&lt;/a&gt;Default Implementation&lt;/h3&gt;
&lt;p&gt;For reference purposes or as the basis for an override:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(function($){

var reportAbuse = function(contentId, contentTypeId, complete) {
    $.telligent.evolution.post({
        url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;api.ashx/v2/abusereports.json&amp;#39;,
        data: {
            ContentId: contentId,
            ContentTypeId: contentTypeId
        },
        cache: false,
        dataType: &amp;#39;json&amp;#39;,
        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 === &amp;#39;true&amp;#39;,
            initialState: options.initialstate === &amp;#39;true&amp;#39;,
            onReport: reportAbuse
        };
        if(options.configuration &amp;amp;&amp;amp; options.configuration.AdditionalLinks) {
            var links = JSON.parse(options.configuration.AdditionalLinks);
            // don&amp;#39;t render if no links
            if(!moderationOptions.supportsAbuse &amp;amp;&amp;amp; 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 &amp;amp;&amp;amp; options.configuration.AdditionalLinksUrl) {
            // don&amp;#39;t render if no links
            if(!moderationOptions.supportsAbuse &amp;amp;&amp;amp; 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: &amp;#39;json&amp;#39;,
                    success: function(response) {
                        complete(response.links || []);
                    }
                });
            };
        }
        // don&amp;#39;t render if no additional links
        if(!moderationOptions.supportsAbuse &amp;amp;&amp;amp; !moderationOptions.onGetAdditionalLinks)
            return;
        if(options.configuration &amp;amp;&amp;amp; options.configuration.LinkClassName) {
            moderationOptions.linkClassName = options.configuration.LinkClassName;
        }
        elm.evolutionModerate(moderationOptions);
    }
};

}(jQuery));
&lt;/code&gt;&lt;/pre&gt;

&lt;hr class="generated-documentation-end" style="border-width:0;" /&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>