diff --git a/frontend/templates/book_panel.html b/frontend/templates/book_panel.html index d3d2d062..9124e6cc 100644 --- a/frontend/templates/book_panel.html +++ b/frontend/templates/book_panel.html @@ -74,7 +74,11 @@ {% comment %}status of book vis-a-vis user's wishlist{% endcomment %} {% if works and activetab %}
- Add to Wishlist + {% if on_search_page %} + Add to Wishlist + {% else %} + Add to Wishlist + {% endif %}
{% else %} {% if request.user.id in supporters %} @@ -96,7 +100,11 @@ {% else %}
- Add to Wishlist + {% if on_search_page %} + Add to Wishlist + {% else %} + Add to Wishlist + {% endif %}
{% endif %}{% endif %}{% endifequal %}{% endif %}{% endif %} @@ -130,7 +138,11 @@ {% else %}
- Add to Wishlist + {% if on_search_page %} + Add to Wishlist + {% else %} + Add to Wishlist + {% endif %}
{% endif %}{% endif %}{% endifequal %}{% endif %}
diff --git a/frontend/templates/search.html b/frontend/templates/search.html index 17fbb733..68eddc30 100644 --- a/frontend/templates/search.html +++ b/frontend/templates/search.html @@ -71,8 +71,9 @@ $j(document).ready(function() { {% with work.googlebooks_id as googlebooks_id %} {% with work.last_campaign_status as status %} {% with work.last_campaign.deadline as deadline %} + {% with 'yes' as on_search_page %} {% include "book_panel.html" %} - {% endwith %}{% endwith %}{% endwith %} + {% endwith %}{% endwith %}{% endwith %}{% endwith %}
{% empty %}

Sorry, couldn't find that!

diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 8a069943..3e6bb2b2 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -208,7 +208,7 @@ $j(document).ready(function(){ {% else %}
- Add to Wishlist + Add to Wishlist
{% endif %}{% endif %}{% endif %} diff --git a/static/js/wishlist.js b/static/js/wishlist.js index fc011ee0..9c08bae3 100644 --- a/static/js/wishlist.js +++ b/static/js/wishlist.js @@ -6,18 +6,27 @@ $j().ready(function() { contentblock.on("click", "div.add-wishlist", function () { var span = $j(this).find("span"); - var gb_id = span.attr('id').substring(1) - if (!gb_id) return; - + var id_val = span.attr('id').substring(1); + var id_type = span.attr('class'); + if (!id_val) {span.html('an error occurred.'); return;} + // give immediate feedback that action is in progress span.html('Adding...'); // actually perform action - jQuery.post('/wishlist/', {'googlebooks_id': gb_id}, function(data) { + if (id_type=='work_id'){ + jQuery.post('/wishlist/', { 'add_work_id': id_val}, function(data) { span.html('On Wishlist!').addClass('on-wishlist'); - }); + });} + else if (id_type=='gb_id'){ + jQuery.post('/wishlist/', { 'googlebooks_id': id_val}, function(data) { + span.html('On Wishlist!').addClass('on-wishlist'); + });} + else { + span.html('a type error occurred'); + } }); - + contentblock.on("click", "div.remove-wishlist", function() { var span = $j(this).find("span"); var book = $j(this).closest('.thewholebook'); @@ -56,20 +65,3 @@ $j().ready(function() { }); }); }); - -var $k = jQuery.noConflict(); - -$k().ready(function() { - $k("div.book-detail-info").on("click", "div.add-wishlist-workpage span", function() { - var span = $k(this); - var work_id = span.attr("class"); - if (!work_id || work_id === "on-wishlist") return; - - // give immediate feedback that action is in progress - span.html('Adding...'); - - jQuery.post('/wishlist/', {'add_work_id': work_id}, function(data) { - span.html('On Wishlist!'); - }); - }); -}); \ No newline at end of file