2011-12-13 18:22:40 +00:00
|
|
|
var $j = jQuery.noConflict();
|
2011-10-14 05:23:46 +00:00
|
|
|
|
2011-12-13 18:22:40 +00:00
|
|
|
$j(document).ready(function() {
|
|
|
|
|
|
|
|
$j(".add-wishlist").each(function (index, element) {
|
|
|
|
$j(element).click(function() {
|
|
|
|
var span = $j(element).find("span");
|
2011-10-14 05:23:46 +00:00
|
|
|
var gb_id = span.attr('id')
|
|
|
|
if (!gb_id) return;
|
2011-12-07 17:04:49 +00:00
|
|
|
jQuery.post('/wishlist/', {'googlebooks_id': gb_id}, function(data) {
|
2011-10-14 05:23:46 +00:00
|
|
|
span.fadeOut();
|
2011-12-28 00:17:44 +00:00
|
|
|
var newSpan = $j('<span class="on-wishlist">On Wishlist!</span>').hide();
|
2011-10-14 05:23:46 +00:00
|
|
|
span.replaceWith(newSpan);
|
2011-10-18 02:32:31 +00:00
|
|
|
newSpan.fadeIn('slow');
|
2011-10-14 05:23:46 +00:00
|
|
|
newSpan.removeAttr("id");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-12-13 18:22:40 +00:00
|
|
|
$j(".remove-wishlist").each(function (index, element) {
|
|
|
|
$j(element).click(function() {
|
|
|
|
var span = $j(element).find("span");
|
2011-10-14 05:23:46 +00:00
|
|
|
var work_id = span.attr('id')
|
2011-12-07 17:04:49 +00:00
|
|
|
jQuery.post('/wishlist/', {'remove_work_id': work_id}, function(data) {
|
2011-12-28 00:17:44 +00:00
|
|
|
var book = $j(element).closest('.thewholebook');
|
2011-10-14 05:23:46 +00:00
|
|
|
book.fadeOut();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-12-13 18:22:40 +00:00
|
|
|
$j(".create-account").each(function (index, element) {
|
|
|
|
$j(element).click(function() {
|
|
|
|
var span = $j(element).find("span");
|
2011-12-06 04:31:03 +00:00
|
|
|
var work_url = span.attr('title')
|
|
|
|
window.location = "/accounts/login/?next=" + work_url;
|
2011-10-18 02:32:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-10-14 05:23:46 +00:00
|
|
|
});
|
|
|
|
|