/* * Performs the bookmarking functions of the site * Copyright (c) 2008 Radley Yeldar */ var bookmarksContainer; var loadingIndicatorHtml; function setupBookmarks(container, bookmarksUrl, loadingHtml) { bookmarksContainer = container; loadingIndicatorHtml = loadingHtml; bookmarksContainer.load(bookmarksUrl, {fragment:true}, processLoadedBookmarks); // Add bookmark event $("a.addBookmark").click(function (){ $("a.showBookmarks" ).triggerHandler("click"); //Simulate clicking on bookmarks tab showLoadingIndicator(); bookmarksContainer.loadWithIndicator($(this).attr("href"), {fragment:true}, processLoadedBookmarks, $('.bookmarksLoadingIndicator')); trackLink("/script/bookmarks/add"); return false; }); } function processLoadedBookmarks(){ // Delete bookmark event $("a.deleteBookmark", bookmarksContainer).click(function (){ showLoadingIndicator(); bookmarksContainer.loadWithIndicator($(this).attr("href"), {fragment:true}, processLoadedBookmarks, $('.bookmarksLoadingIndicator')); trackLink("/script/bookmarks/delete"); return false; }); // Print bookmarks event $(".printBookmarks", bookmarksContainer).click(openPrintBookmarksWindow); } function showLoadingIndicator(){ bookmarksContainer.html(loadingIndicatorHtml); } /* * Open the print bookmarks page in a new window */ function openPrintBookmarksWindow() { window.open($(this).attr("href"), "printBookmarks", "status=0, toolbar=0, location=0, menubar=1, resizable=1, scrollbars=1, width=835, height=600"); trackLink("/script/bookmarks/print"); return false; } /* * Track link for google analytics if tracking object exists */ function trackLink(path) { if (typeof pageTracker != 'undefined') { pageTracker._trackPageview(path); } }