jQuery Bookmark

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

The current version is 1.4.0 and is available under the GPL and MIT licences. For more detail see the documentation reference page. Or see a minimal page that you could use as a basis for your own investigations.

Default Settings

The bookmark sharing functionality can easily be added to a div or span with appropriate default settings. The resulting links allow the user to easily post your current page to any number of bookmarking sites.

You can also remove the bookmarking widget if it is no longer required.

Bookmark with everyone:

$('#defaultBookmark').bookmark();

$('#removeBookmark').toggle(function() {
		$(this).text('Re-attach');
		$('#defaultBookmark').bookmark('destroy');
	},
	function() {
		$(this).text('Remove');
		$('#defaultBookmark').bookmark();
	}
);

Note that the jquery.bookmark.ext.js module has been included here to provide the complete list of bookmarking sites.

You can override the defaults globally as shown below:

$.bookmark.setDefaults({icons: 'img/bookmarks.png'});

Processed fields are marked with a class of hasBookmark and are not re-processed if targetted a second time.

Format Appearance

Control the appearance of the widget.

A select few:

$('#selectBookmark').bookmark({sites:
	['delicious', 'digg', 'linkedin', 'stumbleupon']});

A select few plus show all:

$('#showAllBookmark').bookmark({sites:
	['delicious', 'digg', 'linkedin', 'stumbleupon'], addShowAll: true});

By language:

$('#languageBookmark').bookmark({sites: ['lang:pl', 'lang:sk']});

By category:

$('#categoryBookmark').bookmark({sites: ['category:shopping']});

Use an expanded format:

$('#expandedBookmark').bookmark({compact: false,
	sites: ['facebook', 'google', 'hotmail', 'mixx']});

Popup on demand:

$('#popupBookmark').bookmark({popup: true});

Popup from image:

$('#popupImageBookmark').bookmark({popup: true,
	popupText: '<img src="img/bookmarkthis.png" alt="Bookmark this..."/>'});

Popup some, then show all:

$('#popupAllBookmark').bookmark({popup: true, addShowAll: true,
	sites: $.bookmark.commonSites});

Add to favourites:

$('#favouriteBookmark').bookmark({sites: ['blogger'], addFavorite: true});

E-mail a friend:

$('#emailBookmark').bookmark({sites: ['newsvine'], addEmail: true});

Alternate icons:

$('#iconsBookmark').bookmark({iconsStyle: 'bookmark_largeIcons', iconSize: 22,
	sites: ['digg', 'dzone', 'stumbleupon', 'technorati',
	'reddit', 'delicious', 'newsvine', 'blinklist']});
.bookmark_list span.bookmark_largeIcons {
	background: url(img/bookmarks-big.png) no-repeat center; }

Add a description:

$('#descrBookmark').bookmark({
	description: 'A longer description of the page',
	sites: ['designmoo', 'diglog']});

Add a source tag:

$('#sourceBookmark').bookmark({
	sourceTag: 'from', sites: ['care2', 'mindbody']});

Bookmark another page:

$('#otherBookmark').bookmark({
	url: 'http://keith-wood.name/bookmarkRef.html',
	title: 'jQuery Bookmark Reference',
	sites: ['technorati', 'reddit']});

Change on the fly:

$('#changeBookmark').bookmark({sites: ['google', 'linkedin']});

$('#changeButton').toggle(function() {
		$('#changeBookmark').bookmark('change',
			{sites: ['stumbleupon', 'digg']});
	},
	function() {
		$('#changeBookmark').bookmark('change',
			{sites: ['google', 'linkedin']});
});

Selection Callback

If you want more control over the presentation of the bookmarking site you can add a callback to be notified of selection.

Bookmark callback:

$('#callbackBookmark').bookmark({onSelect: customBookmark});

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

Additional Sites

You can add new sites to the list as shown below. Note: this example is not a real bookmarking site.

The parameters are the id, display name, icon URL, language and site URL. Within the site URL use '{u}' to mark the insertion point for the current page's URL, '{t}' for the current page's title, and '{d}' for the page's description.

Add your own:

 

$.bookmark.addSite('example', 'Example', 'img/example.png',
	'en', 'other', 'http://www.example.net/?url={u}&title={t}');
$('#addBookmark').bookmark({sites: ['google', 'example']});
$('#add2Bookmark').bookmark({
	sites: ['google', 'example'], compact: false});

The following list shows the current sites with their IDs, optionally filtered by language and/or category.

Language:

Category:

var langs = [];
var categories = [];
$.each($.bookmark.getSites(), function(id, site) {
	if ($.inArray(site.lang, langs) == -1) {
		langs.push(site.lang);
	}
	if ($.inArray(site.category, categories) == -1) {
		categories.push(site.category);
	}
});

langs.sort();
var options = '<option>All</option>';
$.each(langs, function(i, lang) {
	options += '<option>' + lang + '</option>';
});
$('#lang').html(options);
categories.sort();
options = '<option>All</option>';
$.each(categories, function(i, category) {
	options += '<option>' + category + '</option>';
});
$('#category').html(options);

$('#lang,#category').change(function() {
	filterSites();
});
filterSites();

function filterSites() {
	var html = '';
	var lang = $('#lang').val();
	var category = $('#category').val();
	var sites = $.bookmark.getSites();
	var ids = [];
	$.each(sites, function(id, site) {
		ids.push(id);
	});
	ids.sort();
	$.each(ids, function(i, id) {
		var site = sites[id];
		if (id != 'example' && (lang == 'All' || lang == site.lang) &&
				(category == 'All' || category == site.category)) {
			html += '<li><span class="bmkIcon" ' +
				'style="background-position: -' + ((site.icon % 16) * 16) +
				'px -' + (Math.floor(site.icon / 16) * 16) + 'px;"></span>' +
				id + ' - ' + site.display + '</li>';
		}
	});
	$('#siteList').html(html);
}

Styling

You can format the links with a bit of CSS.

Discrete styling: Add to

$('#discreteBookmark').bookmark({
	sites: ['delicious', 'digg', 'stumbleupon', 'technorati']});
#discreteBookmark { float: left; }
#discreteBookmark ul { background: transparent; border: none; }
#discreteBookmark li { padding: 0px 5px; }

Alternate styling:

$('#styleBookmark').bookmark();
#styleBookmark { float: left; width: 388px; }
#styleBookmark ul { float: left;
	background: #81c7fb url(bookmark-bg.jpg) center; border: 1px solid #247; }
#styleBookmark li { margin: 2px; background: transparent; border: none; }

Scrolling columns:

$('#columnsBookmark').bookmark({
	addEmail: true, addFavorite: true, compact: false});
#columnsBookmark ul { width: 340px; height: 210px;
	overflow: auto; padding: 0px 5px; border: 2px solid #888;
	-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; }
#columnsBookmark li { width: 155px; background: transparent; border: none; }

The structure of the links is shown below, where the outermost div is the container you specify in your page:

<div id="defaultBookmark" class="hasBookmark">
	<ul class="bookmark_list"> <!-- May also be bookmark_compact -->
		<li><a href="{Submission URL}">
			<span class="{settings.iconsStyle}"></span> {Display Name}</a></li>
		<!-- or -->
		<li><a href="{Submission URL}">
			<span class="background-image: url({settings.icons});"></span> {Display Name}</a></li>
		<!-- or -->
		<li><a href="{Submission URL}"><img src="{site.icon}"> {Display Name}</a></li>
		:
	</ul>
</div>

If the list is in the compact format then the ul also has the bookmark_compact class assigned to it.

If the bookmark is set to popup then it has the additional structure shown below.

<div id="popupBookmark" class="hasBookmark">
	<a class="bookmark_popup_text" href="#">{Popup text}</a>
	<div class="bookmark_popup">
		<ul class="bookmark_list"> <!-- May also be bookmark_compact -->
			:
		</ul>
	</div>
</div>

In the Wild

This tab highlights examples of this plugin in use "in the wild".

To add another example, please contact me (kbwood{at}iinet.com.au) and provide the plugin name, the URL of your site, its title, and a short description of its purpose and where/how the plugin is used.

Quick Reference

A full list of all possible settings is shown below. Note that not all would apply in all cases. For more detail see the documentation reference page.

$(selector).bookmark({
	url: '',  // The URL to bookmark, leave blank for the current page
	sourceTag: '', // Extra tag to add to URL to indicate source when it returns
	title: '',  // The title to bookmark, leave blank for the current one
	description: '',  // A longer description of the site
	sites: [],  // List of site IDs or language selectors (lang:xx) or
		// category selectors (category:xx) to use, empty for all
	iconsStyle: 'bookmark_icons', // CSS class for site icons
	icons: 'bookmarks.png', // Horizontal amalgamation of all site icons
	iconSize: 16,  // The size of the individual icons
	iconCols: 16,  // The number of icons across the combined image
	target: '_blank',  // The name of the target window for the bookmarking links
	compact: true,  // True if a compact presentation should be used, false for full
	hint: 'Send to {s}',  // Popup hint for links, {s} is replaced by display name
	popup: false, // True to have it popup on demand, false to show always
	popupText: 'Bookmark this site...', // Text for the popup trigger
	addFavorite: false,  // True to add a 'add to favourites' link, false for none
	favoriteText: 'Favorite',  // Display name for the favourites link
	favoriteIcon: 0,  // Icon for the favourites link
	addEmail: false,  // True to add a 'e-mail a friend' link, false for none
	emailText: 'E-mail',  // Display name for the e-mail link
	emailIcon: 1,  // Icon for the e-mail link
	emailSubject: 'Interesting page',  // The subject for the e-mail
	emailBody: 'I thought you might find this page interesting:\n{t} ({u})', // The body of the e-mail,
		// use '{t}' for the position of the page title, '{u}' for the page URL,
		// '{d}' for the description, and '\n' for new lines
	manualBookmark: 'Please close this dialog and\npress Ctrl-D to bookmark this page.',
		// Instructions for manually bookmarking the page
	addShowAll: false, // True to show listed sites first, then all on demand
	showAllText: 'Show all ({n})', // Display name for show all link, use '{n}' for the number of sites
	showAllIcon: 2, // Icon for show all link
	showAllTitle: 'All bookmarking sites', // Title for show all popup
	onSelect: null, // Callback on selection
	addAnalytics: false, // True to include Google Analytics for links
	analyticsName: '/share/{r}/{s}' // The "URL" that is passed to the Google Analytics,
		// use '{s}' for the site code, '{n}' for the site name,
		// '{u}' for the current full URL, '{r}' for the current relative URL,
		// or '{t}' for the current title
});

$.bookmark.setDefaults(settings);  // Change default settings

$.bookmark.commonSites // IDs of the common sites in the basic module

$.bookmark.addSite(id, display, icon, lang, category, url);  // Add a new bookmarking site

$.bookmark.getSites();  // Retrieve all the site details

$(selector).bookmark('change', settings);  // Update the bookmark settings
$(selector).bookmark('change', name, value);  // Update a single bookmark setting

$(selector).bookmark('destroy');  // Remove the bookmarks

Usage

  1. Include the jQuery library in the head section of your page.
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  2. Download and include the jQuery Bookmark CSS and JavaScript in the head section of your page.
    <style type="text/css">@import "jquery.bookmark.css";</style>
    <script type="text/javascript" src="jquery.bookmark.js"></script>
    Alternately, you can use the packed version jquery.bookmark.pack.js (9.2K vs 20.7K), or the minified version jquery.bookmark.min.js (10.6K, 3.7K when zipped).
  3. Add additional bookmarking sites by including the ext module (optional).
    <script type="text/javascript" src="jquery.bookmark.ext.js"></script>
  4. Connect the bookmarking functionality to your div.
    $(selector).bookmark();
    You can include custom settings as part of this process.
    $(selector).bookmark({sites: ['delicious', 'digg']});

For more detail see the documentation reference page. Or see a minimal page that you could use as a basis for your own investigations.

Comments

Just wanted to thank you for the fantastic bookmark plug-in.

Josh Berman

Been trying out your social bookmark plugin for jquery and like it a lot. I was using jsocialize but it is no where near as efficient as yours.

Dean Welch

I was looking for some good bookmarking techniques and yours is perfect.

Matthew McLemore

Excellent scipt, amazing piece of art.

José Pablo Orozco Marín

So I love this thing, thank you so much for making it. It's extremely well done, and I use in on several sites with a ton of success.

Robert Conner

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

Change History

VersionDateChanges
1.4.020 Aug 2011
  • Split less common bookmarking sites into a separate module
  • Added addShowAll, showAllText, showAllIcon, and showAllTitle settings
  • Default to PNG icons for better quality
1.3.416 Apr 2011
  • Added addAnalytics and analyticsName settings to integrate with Google Analytics
  • Corrected description in add e-mail
  • Added 62 bookmarking sites: 2Tag, a97abi, adfty, Armenix, Blogger, cOOtopia, curate.us, DigaCultura, Dig This Webhost, digzign, DotShare, draugiem.lv, EFactor, Fashiolista, Fashion BURNER, favoriten.de, Free Dictionary, Frype, Good Noows, historious, index4, Indexor, iOrbix, joliprint, La Tafanera, Links Gutter, Logger 24, Mail.ru, Mark Me, MeFeedia, mototagz, mRcNEtwORK, Nasza Klasa, News me back, packg, pafnet.de, Pochval, Print friendly, QZone, RideFix, Select2gether, Shir.Intar.In, Sina Weibo, Spinsnap, tazza, tarpipe, Technerd, throwpile, topsiteler, Translate, tuenti, tvinx, up news, urlaubswerk, ВКонтакте, vybrali SME, Xing, Yemle, Youblr, Yuuby, ziczac, Zootool
  • Removed bookmarking sites: Ask, BallHype, euCliquei, Followtags, fooxweb, GamesNetWorks, GluvSnap, Grono, Hazarkor, hipstr, hitmarks, HOTWeb.lt, Hugg, Jisko, Khabbr, Koolontheweb, koornk, kudos, Livefavoris, Lynki, Maple, PimpThisBlog, Polladium, Popedition, Propeller, receeve.it, Simpy, Slashdot, SmakNews, Spruzer, SurfPeople, Wovre, yazzem, ZooLoo
  • Changed HealthRanker to HealthBubble
1.3.311 Dec 2010
  • Also get title from first h1 text for onSelect callback
  • Also get description from meta description text for onSelect callback
  • Don't pass ampersands as entities to onSelect callback
1.3.214 Aug 2010
  • title now uses first h1 text if not otherwise specified
  • description now uses meta description text if not otherwise specified
  • Added category field to site information
  • Added selection by category in sites option
  • Added 36 bookmarking sites: 2linkme, 7live7, add.io, aero, All My Faves, bentio, BiggerPockets, Blogtrottr, boardlite, Bookmarked By us, Bookmerken, Buzzzy, Chiq, douban, Dwellicious, FAVable, Followtags, はてな, ideaREF!, Kipup, KOMMENTing, Lifestream, LockerBlogger, mashbord, מקושרים, Popedition, receeve.it, rediff, RedKum, springpad, TagMarks, The Web Blend, Thinkfinity, VK.com, закладок, Zanatic
1.3.117 Apr 2010
  • Added language field to site information
  • Added selection by language in sites option
  • Added 87 bookmarking sites: Сто Закладок, أضفني, Aviary, بانگ, blip, blurpalicious, BonzoBox, bookmarky, Box.net, camyoo, Cirip, Classical Place, Clickazoo, 中国顶客, Colivia, COSMiQ, designbump, diggita, Dipdive, .net Shoutout, drimio, Dropjack, elefanta, eLert Gadget, extraplay, EzySpot, Farkinda, favlog, Flaker, FLOSS.pro, fooxweb, Force Indya, Friendster, fwisp, gamekicker, gamesnetworks, givealink, Google Reader, GreaterDebater, Grono, Hazarkor, Hedgehogs, Hot Bookmark, Hotmail, HOTWeb.lt, ihavegot, informazione, iSociety, iwiw, Jisko, koornk, kudos, ladenzeile, LinkShares, Linkuj, Livefavoris, Mawindo, Meccho, MeinVZ, МоеМесто, Posteezy, Prati.ba, quantcast, Read it Later, Scoop.at, Sekoman, Shaveh, СМИ2, Social Bookmarking, speedtile, spoken to you, Sportpost, Spruzer, startlap, StoryFollower, Stuffpit, SurfPeople, Tagvn, tweetmeme, twitter, Visitez mon Site, vyoom, Windy Citizen, WireFan, yazzem, YouBookmarks, ZooLoo
  • Removed bookmarking sites: Doower, FoxieWire, Netscape
1.3.019 Dec 2009
  • Added description setting
  • Added sourceTag setting to track source of returns
  • Added onSelect setting for selection callback
  • Added name and value parameters for change command
  • Added 21 bookmarking sites: A1 webmarks, bleetbox, Bordom, Bukmark, Do Melhor, Embarkons, fnews, GluvSnap, HackerNews, hitmarks, Kaevur, laaik.it, Librerio, memori.ru, Orkut, Osmosus, studiVZ, Stylehive, Transferr, tulinq, tusul.com
  • Converted icons to GIF to reduce size
1.2.010 Oct 2009
  • Added iconsStyle setting to use existing CSS for site icons - for performance reasons
  • Added 52 bookmarking sites: AmenMe, Baidu, bit.ly, bizSugar, Bloggy, Bobrdobr, Brainify, Bryderi, DesignMoo, Diglog, Doower, Dosti, DotNetKicks, edelight, eKudos, euCliquei, Fabulously40, FavoritUs, forgetfoo, Gacetilla, Grumper, haber.gen.tr, Hadash Hot, hellotxt, hipstr, hotklix, Hyves, InvestorLinks, Kwoff, LinkNinja, Lunch, Lynki, Nujij, Oyyla, PhoneFavs, PimpThisBlog, Planypus, Plurk, Polladium, posterous, She Told Me, SodaHead, Sonico, Svejo, TellMyPolitician, Virb, Worio, Wovre, Wykop, Yammer, Yorumcuyum, YouMob
  • Removed bookmarking sites: Expression, TechNet, Yahoo MyWeb, YardBarker
1.1.422 Aug 2009
  • Corrected my AOL link
  • Removed bookmarking sites: Bloglines, Feed Me links, Furl, Ma.gnolia, Smarking, Symbaloo, Tailrank
1.1.316 May 2009
  • Added iconCols setting
  • Changed popup text to an anchor for keyboard navigation
  • Popup panel hidden on external click
  • Added 54 bookmarking sites: Allvoices, Arto, BibSonomy, bookmarks.fr, BuddyMarks, Business Exchange, Bzzster, citeulike, Connotea, deals plus, Evernote, Expression, Folkd, FoxieWire, Gabbr, Global Grind, Gravee, HealthRanker, HEMiDEMi, identi.ca, Imera, Instapaper, Jamespot, Jumptags, Khabbr, Kledy, Maple, MyLinkVault, NetLog, Netvibes, NewsTrust, Ping, Plaxo Pulse, Protopage, Pusha, ShoutWire, Sitejot, SmakNews, StartAid, Strands, Stumpedia, Symbaloo, Tagza, TechNet, Technotizie, Tip'd, tumblr, Viadeo, Vodpod, WebNews, Amazon WishList, Wists, Xerpi, and yoolink
1.1.207 Mar 2009
  • Added url and title settings to bookmark alternate pages
  • Added hint setting
  • Added 2 bookmarking sites: bookmark.it and oneview
1.1.131 Jan 2009
  • Save instance settings for simpler later changes
  • Added Google Chrome support
  • Added 3 bookmarking sites: alltagz, Design Float, and LinkArena
1.1.027 Dec 2008
  • compact now defaults to true
  • Added popup and popupText settings for display on demand
  • Added 22 bookmarking sites: Backflip, BallHype, Bebo, Bloglines, Current, Fresqui, FriendFeed, funP, Kaboodle, Kirtsy, LinkedIn, menéame, N4G, OKNOtizie, Propeller, Scoopeo, Wikio, Xanga, Yahoo Bookmarks, Yahoo Buzz, Yardbarker, and Yigg
1.0.329 Nov 2008
  • Added check for non-existent sites
  • Added 2 bookmarking sites: Sphinn and TwitThis
1.0.230 Aug 2008
  • Remove FF CSS patch for v3
  • Added 2 bookmarking sites: Koolontheweb and Squidoo
1.0.103 May 2008
  • Included 'Favorite' and 'E-mail' in icons image
  • Added 10 bookmarking sites
1.0.022 Mar 2008
  • Initial release

Valid HTML 4.01 Strict