jQuery Bookmark Reference

A jQuery plugin that sets a div or span to allow sharing of your page on various bookmarking sites. If you find this plugin useful please vote for it on the jQuery site.

This page provides a documentation reference for working with the plugin v1.3.1. See a demonstration of the bookmark plugin and download the code from there. Or see a minimal page that you could use as a basis for your own investigations.

Instance Settings

Customise each targetted div or span with the settings below (all are optional):
$(selector).bookmark({sites: ['delicious', 'reddit']});.

addEmail | addFavorite | compact | description | emailBody | emailIcon | emailSubject | emailText | favoriteIcon | favoriteText | hint | iconCols | icons | iconSize | iconsStyle | manualBookmark | onSelect | popup | popupText | sites | sourceTag | target | title | url

NameTypeDefaultComments
urlstring'' The URL for the page to be bookmarked. Leave blank for the URL of the current page.

Since 1.1.2.
sourceTagstring'' The name of an additional tag to be appended to the URL so that traffic from that source can be tracked. For example, a value of 'from' would add from=siteID to the URL being bookmarked as a query parameter, where siteID is the ID of the selected site. Leave blank to not add anything.

Since 1.3.0.
titlestring'' The title of the page to be bookmarked. Leave blank for the title of the current page.

Since 1.1.2.
descriptionstring'' A longer description of the page. Not all sites accept this value.

Since 1.3.0.
sitesstring[][] List the IDs or language selectors of the bookmarking sites to include. Language selectors are of the form 'lang:xx', where 'xx' is the standard ISO 639-1 language code. If none are specified, all sites are shown.

$(selector).bookmark({sites: ['digg', 'furl']});
$(selector).bookmark({sites: ['lang:ja', 'lang:ko']});

Since 1.3.1 - language selectors.
iconsStylestring'bookmark_icons' The CSS class to apply to the icon containers for the standard bookmarking sites. The style should apply a background image of an amalgamation of all the individual icons - counting from zero at the top/left, with iconCols icons across. The default style assumes that the CSS resides in a css directory with the images in an img directory at the same level.
.bookmark_list span.bookmark_icons {
	background: url(../img/bookmarks.gif)
		no-repeat center;
}
This setting was added for performance reasons - some browsers load the icons image multiple times, once for each site shown.

Since 1.2.0.
iconsstring'bookmarks.gif' The location (URL) of the icons for the standard bookmark sites. This image is an amalgamation of all the individual icons - counting from zero at the top/left, with iconCols icons across. This value is only used if iconsStyle is blank. The latter should be used in preference to this setting for performance reasons.
iconSizenumber16 The pixel size of the individual icons in the iconsStyle or icons images.

Since 1.0.1.
iconColsnumber16 The number of individual icons across the iconsStyle or icons images. This allows for a more compact image.

Since 1.1.3.
targetstring'_blank' The name of the window in which the bookmark links are opened. The default opens in a new tab/window. Set to '' to replace the current window.
compactbooleantrue Set to true to display the links in a compact format using only the icons. When false, the icon and display name are shown in separate 'buttons'.

Since 1.1.0 - default is true, previously it was false.
hintstring'Send to {s}' A template for popup hints on the site icons. '{s}' is replaced by the site's display name.

Since 1.1.2.
popupbooleanfalse Indicate whether or not the bookmarks should appear on demand (true) or should always be shown (false).

Since 1.1.0.
popupTextstring'Bookmark this site...' The display text for the popup trigger. You can include HTML markup here - even inserting an image instead of text.
$(selector).bookmark({popup: true,
	popupText: '<img src="bookmarkthis.png" ' +
		'alt="Bookmark this..."/>'});
Since 1.1.0.
addFavoritebooleanfalse Indicate whether or not an 'Add to favourites' link should be included. This adds the current page to the browser's bookmarks when clicked in Internet Explorer, and provides manual instructions on how to do this for other browsers.
favoriteTextstring'Favorite' The display text for the 'Add to favourites' link.
favoriteIconstring or number0 The URL of the icon to use for the 'Add to favourites' link, or the index of the 'Favorite' icon within the iconsStyle or icons images.
addEmailbooleanfalse Indicate whether or not an 'E-mail to a friend' link should be included. This prepares an e-mail about the current page when clicked.
emailTextstring'E-mail' The display text for the 'E-mail to a friend' link.
emailIconstring or number1 The URL of the icon to use for the 'E-mail to a friend' link, or the index of the 'E-mail' icon within the iconsStyle or icons images.
emailSubjectstring'Interesting page' The subject for the e-mail to be sent out.
emailBodystring 'I thought you might find this page interesting:\n{t} ({u})' The body for the e-mail to be sent out. Use '{t}' to mark the position where the title of the current page is inserted, '{u}' to mark where the current page's URL should appear, '{d}' to mark the location of the description, and '\n' to mark new lines.
manualBookmarkstring 'Please close this dialog and\npress Ctrl-D to bookmark this page.' The text to display for manually bookmarking a page within the browser. Used for browsers other than Internet Explorer. Use '\n' to mark new lines.
onSelectfunctionnull A callback function upon selection of a bookmarking site. The site ID, display name, and URL are passed in as parameters while this refers to the bookmarks container. The callback is not triggered for favourites or e-mail links.
$(selector).bookmark({onSelect: customBookmark});

function customBookmark(id, display, url) {
	window.open(url, '_blank',
		'width=600,height=400,menubar=no,toolbar=no,scrollbars=yes');
}
Since 1.3.0.

Functions

addSite | change | destroy | getSites | setDefaults

SignatureReturnsComments
$.bookmark.setDefaults(settings)Bookmark object Update the default instance settings to use with all bookmark instances.

settings (object) is the collection of new settings to apply.
$.bookmark.addSite(id, display, icon, lang, url)Bookmark object Add a definition for a new bookmarking site (or overwrite an existing one). The parameters are:

id (string) the identifier for this site;

display (string) the display text for this site;

icon (string) the location (URL) of an icon for this site (size as specified by iconSize setting), or (number) the index into the iconsStyle or icons images (both starting at zero);

lang (string) the ISO 639-1 language code for this site;

url (string) the submission URL for this site. Within the URL use '{u}' to mark the insertion point for the URL of the current page, '{t}' for the current page's title, and '{d}' for the page's description.

$.bookmark.addSite(
	'delicious', 'del.icio.us', 'delicious.png',
	'http://del.icio.us/post?url={u}&title={t}');

Since 1.3.1 - added lang.
$.bookmark.getSites()object[] Return details about all the known sites. The array is indexed by the site ID (string). Each object in the array has the following attributes:

display (string) the display text for this site;

icon (string) the location (URL) of an icon for this site (size as specified by iconSize setting), or (number) its index into the iconsStyle or icons images (starting at zero);

lang (string) the ISO 639-1 language code for this site;

url (string) the submission URL for this site.

$.each($.bookmark.getSites(), function(id, site) {
	// Process each site here
});

Since 1.3.1 - added lang.
$(selector).bookmark('change', settings)jQuery object Update the settings for the bookmarking instance attached to the given div(s) or span(s).

settings (object) is the collection of new settings to apply.
$(selector).bookmark('change', name, value)jQuery object Update a single setting for the bookmarking instance attached to the given div(s) or span(s).

name (string) is the name of the setting;

value (any) is the setting value.

Since 1.3.0.
$(selector).bookmark('destroy')jQuery object Remove the bookmarking functionality from the given div(s) or span(s).

Contact Keith Wood at kbwood{at}iinet.com.au with comments or suggestions.


Valid HTML 4.01 Strict