Verint | Telligent Community
Verint | Telligent Community
  • Site
  • User
  • Site
  • Search
  • User
Verint Community 12.x
  • Verint Community
Verint Community 12.x
API Documentation Idea Voting 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

Idea Voting UI Component


jQuery.telligent.evolution.ui.components.vote

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

Options

Data made available to instances of the component:

  • isReadOnly: (boolean) Is the idea in ReadOnly mode, ReadOnly mode would prevent new votes from being added.
  • yesVotes: (integer) The current count of up votes for the idea
  • noVotes: (integer) The current count of down votes for the idea
  • voteCount: (integer) The current total vote count for the idea
  • score: (integer) The current score of the idea
  • allowMultipleVotes: (boolean) Does this idea allow for multiple votes per user
  • userVote: (integer) Number of votes the accessing user has used on this idea
  • canUserUpVote: (boolean) Does accessing user have permission to vote up this idea
  • canUserDownVote: (boolean) Does accessing user have permission to vote down this idea
  • canViewVotes: (boolean) Does accessing user have permission to view votes on this idea
  • isUserRegistered: (boolean) Is the accessing user authenicated on the site
  • isUserGroupMember: (boolean) Is the accessing user a member of the group the idea belongs to
  • loginUrl: (string) Login Url to use for unaunthenicated users
  • voteUrl: (string) Url to for vote callbacks

Example

A barebones UI component override which would result in rendering a read-only message of 'Idea Score: {score}' for a given call to $telligentIdeas_v1_ideas.UpDownVoteUI().

$.telligent.evolution.ui.components.vote = { setup: function() { }, add: function(elm, options) { $(elm).html('Idea Score: ' + options.score);

        console.log('ReadOnly? ' + options.isReadOnly);
        console.log('YesVotes: ' + options.yesVotes);
        console.log('NoVotes: ' + options.noVotes);
        console.log('Vote Count: ' + options.voteCount);
        console.log('Score: ' + options.score);
        console.log('Allow Multiple Votes?: ' + options.allowMultipleVotes);
        console.log('Current User Vote: ' + options.userVote);
        console.log('Up Vote Permission? ' + options.canUserUpVote);
        console.log('Down Vote Permission? ' + options.canUserDownVote);
        console.log('View Votes Permission? ' + options.canViewVotes);
        console.log('User Registered? ' + options.isUserRegistered);
        console.log('Group Member? ' + options.isUserGroupMember);
        console.log('Login Url: ' + options.loginUrl);
        console.log('Vote Url: ' + options.voteUrl);
    }
}

Default Implementation

$.telligent.evolution.ui.components.vote = { setup: function () {

},
add: function (elm, options) {
    var settings = $.extend({}, {
        isReadOnly: (options.readonly === 'true'),
        yesVotes: parseInt(options.initialyesvotes),
        noVotes: parseInt(options.initialnovotes),
        voteCount: parseInt(options.initialvotes),
        score: parseInt(options.initialscore),
        allowMultipleVotes: (options.allowmultiplevotes === 'true'),
        userVote: options.initialuservotetotal,
        canUserUpVote: (options.canuserupvote === 'true'),
        canUserDownVote: (options.canuserdownvote === 'true'),
        canViewVotes: (options.canviewvotes === 'true'),
        isUserRegistered: (options.isuserregistered === 'true'),
        isUserGroupMember: (options.isusergroupmember === 'true'),
        loginUrl: options.loginurl,
        voteUrl: options.voteurl
    });

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

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

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

                if (response && response.Vote && response.Vote.Idea) {
                    $(elm).evolutionUpDownVoting('option', {
                        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('option', {
                        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() + 'api.ashx/v2/ideas/vote.json',
            data: {
                IdeaId: options.contentid
            },
            success: function (response) {

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

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

    $(elm).evolutionUpDownVoting(settings);
}

};


  • 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