jQuery.telligent.evolution.ui.components.bookmark
UI Component which handles presentation of bookmark behavior for content. Transforms the output from $core_v2_ui.Bookmark()
, which is a <span class="ui-bookmark"></span>
stub. The default implementation uses the evolutionBookmark plugin. Overrides can be provided at the theme level to present bookmarks differently.
Options
Data made available to instances of the component:
contenttypeid
: (string) Content Type Id Guidcontentid
: (string) Content Id Guidbookmarktypeid
: (string) Type Id Guidvalue
: (string) If the content is bookmarked or not by the accessing user (true
orfalse
)contenttypename
: (string) Type name for this content
Example
A barebones UI component override which would result in rendering a read-only message of 'Bookmarked? Yes/No' for a given call to $core_v2_ui.Bookmark()
.
$.telligent.evolution.ui.components.rate = {
setup: function() {
},
add: function(elm, options) {
$(elm).html('Bookmarked? ' + (options.value == 'true' ? 'Yes' : 'No'));
console.log('ContentId: ' + options.contentid);
console.log('ContentTypeId: ' + options.contenttypeid);
console.log('TypeId: ' + options.bookmarktypeid);
console.log('Value: ' + options.value);
console.log('ContentTypeName: ' + options.contenttypename);
}
}
Default Implementation
For reference purposes or as the basis for an override:
$.telligent.evolution.ui.components.bookmark = {
setup: function() {
},
add: function(elm, options) {
elm.empty();
var config = {
contentId: options.contentid,
contentTypeId: options.contenttypeid,
typeId: options.bookmarktypeid,
initialState: options.value == 'true',
contentTypeName: options.contenttypename,
onBookmark: function(contentId, contentTypeId, typeId, complete) {
$.telligent.evolution.post({
url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/bookmark.json?ContentId={ContentId}&ContentTypeId={ContentTypeId}' + (typeId ? '&TypeId=' + typeId : ''),
data: {
ContentId: contentId,
ContentTypeId: contentTypeId
},
dataType: 'json',
success: function(response) { complete(); }
});
},
onUnbookmark: function(contentId, contentTypeId, typeId, complete) {
$.telligent.evolution.del({
url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/bookmark.json?ContentId={ContentId}' + (typeId ? '&TypeId=' + typeId : ''),
data: {
ContentId: contentId
},
dataType: 'json',
success: function(response) { complete(); }
});
}
};
if (options.configuration.deleteBookmarkText) { config.deleteBookmarkText = options.configuration.deleteBookmarkText; }
if (options.configuration.addBookmarkText) { config.addBookmarkText = options.configuration.addBookmarkText; }
if (options.configuration.processingText) { config.processingText = options.configuration.processingText; }
if (options.configuration.addBookmarkCssClass) { config.addBookmarkCssClass = options.configuration.addBookmarkCssClass; }
if (options.configuration.deleteBookmarkCssClass) { config.deleteBookmarkCssClass = options.configuration.deleteBookmarkCssClass; }
if (options.configuration.processingCssClass) { config.processingCssClass = options.configuration.processingCssClass; }
$(elm).evolutionBookmark(config);
}
};