(function($) { // Hide scope, no $ conflict var PROP_NAME = 'bookmark'; /* Bookmark sharing manager. */ function Bookmark() { this._defaults = { url: '', // The URL to bookmark, leave blank for the current page title: '', // The title to bookmark, leave blank for the current one sites: [], // List of site IDs to use, empty for all icons: 'http://www.ojezu.pl/img/skin/bookmarks.png', // Horizontal amalgamation of all site icons iconSize: 16, // The size of the individual icons 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, and '\n' for new lines manualBookmark: 'Please close this dialog and\npress Ctrl-D to bookmark this page.' // Instructions for manually bookmarking the page }; this._sites = { // The definitions of the available bookmarking sites 'wykop': {display: 'wykop ', icon: 'http://www.ojezu.pl/img/skin/wykop.gif', url: 'http://www.wykop.pl/dodaj?url={u}&title={t}'}, 'flaker': {display: 'flaker ', icon: 'http://www.ojezu.pl/img/skin/flaker.png', url: 'http://flaker.pl/add2flaker.php?title={t}&url={u}'}, 'blip': {display: 'blip ', icon: 'http://www.ojezu.pl/img/skin/blip.png', url: 'http://blip.pl/dashboard?body={t}+{u}'}, 'facebook': {display: 'facebook ', icon: 'http://www.ojezu.pl/img/skin/facebook.gif', url: 'http://www.facebook.com/share.php?u={u}&t={t}'} }; } $.extend(Bookmark.prototype, { /* Class name added to elements to indicate already configured with bookmarking. */ markerClassName: 'hasBookmark', /* Override the default settings for all bookmarking instances. @param settings object - the new settings to use as defaults @return void */ setDefaults: function(settings) { extendRemove(this._defaults, settings || {}); return this; }, /* Add a new bookmarking site to the list. @param id string - the ID of the new site @param display string - the display name for this site @param icon url - the location of an icon for this site (16x16), or number - the index of the icon within the combined image @param url url - the submission URL for this site, with {u} marking where the current page's URL should be inserted, and {t} indicating the title insertion point @return void */ addSite: function(id, display, icon, url) { this._sites[id] = {display: display, icon: icon, url: url}; return this; }, /* Return the list of defined sites. @return object[] - indexed by site id (string), each object contains display (string) - the display name, icon (string) - the location of the icon,, or (number) the icon's index in the combined image url (string) - the submission URL for the site */ getSites: function() { return this._sites; }, /* Attach the bookmarking widget to a div. */ _attachBookmark: function(target, settings) { target = $(target); if (target.hasClass(this.markerClassName)) { return; } target.addClass(this.markerClassName); this._updateBookmark(target, settings); }, /* Reconfigure the settings for a bookmarking div. */ _changeBookmark: function(target, settings) { target = $(target); if (!target.hasClass(this.markerClassName)) { return; } this._updateBookmark(target, settings); }, /* Construct the requested bookmarking links. */ _updateBookmark: function(target, settings) { var oldSettings = $.data(target[0], PROP_NAME) || $.extend({}, this._defaults); settings = extendRemove(oldSettings, settings || {}); $.data(target[0], PROP_NAME, settings); var sites = settings.sites; if (sites.length == 0) { $.each(this._sites, function(id) { sites.push(id); }); } var hint = settings.hint || '{s}'; var html = (settings.popup ? '' + settings.popupText + '