Verint | Telligent Community
Verint | Telligent Community
  • Site
  • User
  • Site
  • Search
  • User
Verint Community 11.x
  • Verint Community
Verint Community 11.x
API Documentation rate 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
        • 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
        • theater UI Component
        • tip UI Component
        • tourtip UI Component
        • UI Component tag
        • viewhtml UI Component
        • webpreview UI Component
    • +Dynamic Configuration
    • +LESS Functions
    • +Script API Types
    • +Script APIs

rate UI Component


jQuery.telligent.evolution.ui.components.rate

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

Options

Data made available to instances of the component:

  • contenttypeid: (string) Content Type Id Guid
  • contentid: (string) Content Id Guid
  • ratingtypeid: (string) Type Id Guid
  • initialvalue: (number) Current value
  • initialcount: (number) Requested max count to allow

Example

A barebones UI component override which would result in rendering a read-only message of 'Current Rating: X' for a given call to $core_v2_ui.Rate().

$.telligent.evolution.ui.components.rate = {
    setup: function() {
    },
    add: function(elm, options) {
        $(elm).html('Current Rating: ' + options.initialvalue * options.initialcount);

        console.log('ContentId: ' + options.contentid);
        console.log('ContentTypeId: ' + options.contenttypeid);
        console.log('TypeId: ' + options.ratingtypeid);
        console.log('Value: ' + options.initialvalue);
        console.log('Count: ' + options.initialcount);
    }
}

Default Implementation

For reference purposes or as the basis for an override:

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

    },
    add: function(elm, options) {
        var settings = $.extend({}, {
            isReadOnly: (options.readonly === 'true'),
            value: parseFloat(options.initialvalue),
            ratingCount: parseFloat(options.initialcount)
        });

        settings.value = settings.value * $.fn.evolutionStarRating.defaults.maxRating;
        settings.onRate = function(value) {
            if (!options.contentid || !options.contenttypeid) {
                return;
            }

            value = value / $.fn.evolutionStarRating.defaults.maxRating;

            var data = {
                ContentId: options.contentid,
                ContentTypeId: options.contenttypeid,
                Value: value
            };
            if (options.ratingtypeid) {
                data.TypeId = options.ratingtypeid;
            }

            $.telligent.evolution.post({
                url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/ratings.json',
                data: data,
                success: function(response) {
                    var data = {
                        ContentId: options.contentid
                    };
                    if (options.ratingtypeid) {
                        data.TypeId = options.ratingtypeid;
                    }

                    $.telligent.evolution.get({
                        url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/rateditem.json',
                        data: data,
                        success: function(response) {
                            if (response && response.RatedItem && response.RatedItem.AverageValue) {
                                $(elm).evolutionStarRating('option', {
                                    value: response.RatedItem.AverageValue * $.fn.evolutionStarRating.defaults.maxRating,
                                    ratingCount: response.RatedItem.Count
                                });
                            } else {
                                $(elm).evolutionStarRating('option', {
                                    value: 0,
                                    ratingCount: 0
                                });
                            }
                        }
                    });
                }
            });
        };

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

        $(elm).evolutionStarRating(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