jQuery.fn.evolutionBookmark
This plugin supports rendering a bookmark toggle link, allowing the user to bookmark or unbookmark content.
Usage
$('SELECTOR').evolutionBookmark(options)
where 'SELECTOR' is a span.
Options
contentId
: (string) content IDcontentTypeId
: (string) content type IDtypeId
: (string) bookmark type IDcontentTypeName
: (string) the name of the content type-
initialState
: (boolean) content is bookmarked- default
false
- default
onBookmark
: (function) callback function when a selection is made. The function is passed contentId, contentTypeId, typeId, and a callback function to call when processing is completeonUnbookmark
: (function) callback function when a selection is made. The function is passed contentId, contentTypeId, typeId, and a callback function to call when processing is complete-
deleteBookmarkText
: Label for the unbookmark link.{content_type_name}
is replaced with the content's type name.- default
'Unbookmark {content_type_name}'
- default
-
addBookmarkText
: Label for the bookmark link.{content_type_name}
is replaced with the content's type name.- default
'Bookmark this {content_type_name}'
- default
-
processingText
: Label for the link when it is processing.{content_type_name}
is replaced with the content's type name.- default
'...'
- default
-
addBookmarkCssClass
: CSS class to apply to the bookmark link.- default
'internal-link favorite-off'
- default
-
deleteBookmarkCssClass
: CSS class to apply to the unbookmark link.- default
'internal-link favorite-on'
- default
-
processingCssCLass
: CSS class to apply to the link when processing.- default
'internal-link processing'
- default
Example
Given the following span to contain a bookmark control:
<span id="bookmarkControl"></span>
The following will initialize a bookmark control, using defaults for most options
var bookmarkControl = $('#bookmarkControl');
bookmarkControl.evolutionBookmark({
initialState: true, // content is bookmarked
contentId: 'C512D1A1-ED6C-442D-BC9d-3587CD711D35',
contentTypeId: 'F7D226AB-D59F-475C-9D22-4A79E3F0EC07',
contentTypeName: 'Blog Post',
onBookmark: function(contentId, contentTypeId, typeId, callback) {
alert(contentId + ' bookmarked!');
// ...perform AJAX-based saving of bookmark here...
// After a successful save, callback to notify the bookmark plugin
callback();
},
onUnbookmark: function(contentId, contentTypeId, typeId, callback) {
alert(contentId + ' unbookmarked!');
// ...perform AJAX-based saving of bookmark here...
// After a successful save, callback to notify the bookmark plugin
callback();
}
});