<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Idea Voting UI Component</title><link>https://community.telligent.com/community/13/w/api-documentation/75814/idea-voting-ui-component</link><description>&lt;p&gt;&lt;span&gt;Developing on Verint Community? Use the API documentation as a reference for all supported interactions with Verint Community.&lt;/span&gt;&lt;/p&gt;</description><dc:language>en-US</dc:language><generator>14.0.0.586 14</generator><item><title>Idea Voting UI Component</title><link>https://community.telligent.com/community/13/w/api-documentation/75814/idea-voting-ui-component</link><pubDate>Fri, 08 Mar 2024 17:52:03 GMT</pubDate><guid isPermaLink="false">b5edfea9-142c-4f8e-afed-f91a8feee48e</guid><dc:creator>Ben Tiedt</dc:creator><comments>https://community.telligent.com/community/13/w/api-documentation/75814/idea-voting-ui-component#comments</comments><description>Current Revision posted to API Documentation by Ben Tiedt on 03/08/2024 17:52:03&lt;br /&gt;
&lt;hr class="generated-documentation-start" style="border-width:0;" /&gt;&lt;h3&gt;jQuery.telligent.evolution.ui.components.vote&lt;/h3&gt;
&lt;p&gt;[[ui JavaScript API Module|UI Component]] which handles presentation of idea vote behavior for content. Transforms the output from &lt;code&gt;$telligentIdeas_v1_ideas.UpDownVoteUI()&lt;/code&gt;, which is a &lt;code&gt;&amp;lt;span class=&amp;quot;ui-vote&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;/code&gt; stub. The default implementation uses the evolutionVote plugin. [[ui JavaScript API Module|Overrides can be provided]] at the theme level to present idea votes differently.&lt;/p&gt;
&lt;h3&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;isReadOnly&lt;/code&gt;: (boolean) Is the idea in ReadOnly mode, ReadOnly mode would prevent new votes from being added.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;yesVotes&lt;/code&gt;: (integer) The current count of up votes for the idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;noVotes&lt;/code&gt;: (integer) The current count of down votes for the idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;voteCount&lt;/code&gt;: (integer) The current total vote count for the idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;score&lt;/code&gt;: (integer) The current score of the idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;allowMultipleVotes&lt;/code&gt;: (boolean) Does this idea allow for multiple votes per user&lt;/li&gt;
&lt;li&gt;&lt;code&gt;userVote&lt;/code&gt;: (integer)  Number of votes the accessing user has used on this idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;canUserUpVote&lt;/code&gt;: (boolean) Does accessing user have permission to vote up this idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;canUserDownVote&lt;/code&gt;: (boolean) Does accessing user have permission to vote down this idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;canViewVotes&lt;/code&gt;: (boolean) Does accessing user have permission to view votes on this idea&lt;/li&gt;
&lt;li&gt;&lt;code&gt;isUserRegistered&lt;/code&gt;: (boolean) Is the accessing user authenicated on the site&lt;/li&gt;
&lt;li&gt;&lt;code&gt;isUserGroupMember&lt;/code&gt;: (boolean) Is the accessing user a member of the group the idea belongs to&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loginUrl&lt;/code&gt;: (string) Login Url to use for unaunthenicated users&lt;/li&gt;
&lt;li&gt;&lt;code&gt;voteUrl&lt;/code&gt;: (string) Url to for vote callbacks&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&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;Idea Score: {score}&amp;#39; for a given call to &lt;code&gt;$telligentIdeas_v1_ideas.UpDownVoteUI()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;$.telligent.evolution.ui.components.vote = {
    	setup: function() {
    	},
    	add: function(elm, options) {
    		$(elm).html(&amp;#39;Idea Score: &amp;#39; + options.score);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        console.log(&amp;#39;ReadOnly? &amp;#39; + options.isReadOnly);
        console.log(&amp;#39;YesVotes: &amp;#39; + options.yesVotes);
        console.log(&amp;#39;NoVotes: &amp;#39; + options.noVotes);
        console.log(&amp;#39;Vote Count: &amp;#39; + options.voteCount);
        console.log(&amp;#39;Score: &amp;#39; + options.score);
        console.log(&amp;#39;Allow Multiple Votes?: &amp;#39; + options.allowMultipleVotes);
        console.log(&amp;#39;Current User Vote: &amp;#39; + options.userVote);
        console.log(&amp;#39;Up Vote Permission? &amp;#39; + options.canUserUpVote);
        console.log(&amp;#39;Down Vote Permission? &amp;#39; + options.canUserDownVote);
        console.log(&amp;#39;View Votes Permission? &amp;#39; + options.canViewVotes);
        console.log(&amp;#39;User Registered? &amp;#39; + options.isUserRegistered);
        console.log(&amp;#39;Group Member? &amp;#39; + options.isUserGroupMember);
        console.log(&amp;#39;Login Url: &amp;#39; + options.loginUrl);
        console.log(&amp;#39;Vote Url: &amp;#39; + options.voteUrl);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Default Implementation&lt;/h3&gt;
&lt;p&gt;$.telligent.evolution.ui.components.vote = {
	setup: function () {&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;},
add: function (elm, options) {
    var settings = $.extend({}, {
        isReadOnly: (options.readonly === &amp;#39;true&amp;#39;),
        yesVotes: parseInt(options.initialyesvotes),
        noVotes: parseInt(options.initialnovotes),
        voteCount: parseInt(options.initialvotes),
        score: parseInt(options.initialscore),
        allowMultipleVotes: (options.allowmultiplevotes === &amp;#39;true&amp;#39;),
        userVote: options.initialuservotetotal,
        canUserUpVote: (options.canuserupvote === &amp;#39;true&amp;#39;),
        canUserDownVote: (options.canuserdownvote === &amp;#39;true&amp;#39;),
        canViewVotes: (options.canviewvotes === &amp;#39;true&amp;#39;),
        isUserRegistered: (options.isuserregistered === &amp;#39;true&amp;#39;),
        isUserGroupMember: (options.isusergroupmember === &amp;#39;true&amp;#39;),
        loginUrl: options.loginurl,
        voteUrl: options.voteurl
    });

    $.telligent.evolution.messaging.subscribe(&amp;#39;ideaVote.created&amp;#39;, function (data) {
        handleVoteMessage(options, elm, data);
    });
    $.telligent.evolution.messaging.subscribe(&amp;#39;ideaVote.deleted&amp;#39;, function (data) {
        handleVoteMessage(options, elm, data);
    });

    settings.onVote = function (value, totalVotes) {
        if (!options.contentid) {
            return;
        }

        $.telligent.evolution.post({
            url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;api.ashx/v3/ideas/vote.json&amp;#39;,
            data: {
                IdeaId: options.contentid,
                Value: totalVotes
            },
            success: function (response) {

                if (response &amp;amp;&amp;amp; response.Vote &amp;amp;&amp;amp; response.Vote.Idea) {
                    $(elm).evolutionUpDownVoting(&amp;#39;option&amp;#39;, {
                        yesVotes: response.Vote.Idea.YesVotes,
                        noVotes: response.Vote.Idea.NoVotes,
                        voteCount: response.Vote.Idea.TotalVotes,
                        score: response.Vote.Idea.Score,
                        userVote: response.Vote.TotalVotes
                    });
                } else {
                    $(elm).evolutionUpDownVoting(&amp;#39;option&amp;#39;, {
                        yesVotes: 0,
                        noVotes: 0,
                        voteCount: 0,
                        score: 0,
                        userVote: null
                    });
                }
            }
        });
    };

    settings.onDeleteVote = function () {
        if (!options.contentid) {
            return;
        }

        $.telligent.evolution.del({
            url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;api.ashx/v2/ideas/vote.json&amp;#39;,
            data: {
                IdeaId: options.contentid
            },
            success: function (response) {

                $.telligent.evolution.get({
                    url: $.telligent.evolution.site.getBaseUrl() + &amp;#39;api.ashx/v2/ideas/idea.json&amp;#39;,
                    data: {
                        Id: options.contentid
                    },
                    success: function (response) {
                        if (response &amp;amp;&amp;amp; response.Idea) {
                            $(elm).evolutionUpDownVoting(&amp;#39;option&amp;#39;, {
                                yesVotes: response.Idea.YesVotes,
                                noVotes: response.Idea.NoVotes,
                                voteCount: response.Idea.TotalVotes,
                                score: response.Idea.Score,
                                userVote: 0
                            });
                        } else {
                            $(elm).evolutionUpDownVoting(&amp;#39;option&amp;#39;, {
                                yesVotes: 0,
                                noVotes: 0,
                                voteCount: 0,
                                score: 0,
                                userVote: null
                            });
                        }
                    }
                });
            }
        });
    };

    if (settings.voteCount == 0 &amp;amp;&amp;amp; settings.isReadOnly) {
        return;
    }

    $(elm).evolutionUpDownVoting(settings);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;};&lt;/p&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>