[#29488053] add to wishlist now works for works without googlebooks_id
parent
5bd3f06903
commit
feb8650c10
|
@ -74,7 +74,11 @@
|
|||
{% comment %}status of book vis-a-vis user's wishlist{% endcomment %}
|
||||
{% if works and activetab %}
|
||||
<div class="moreinfo add-wishlist">
|
||||
<span id="p{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% if on_search_page %}
|
||||
<span class="gb_id" id="p{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% else %}
|
||||
<span class="work_id" id="p{{ work.id }}">Add to Wishlist</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
{% if request.user.id in supporters %}
|
||||
|
@ -96,7 +100,11 @@
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="moreinfo add-wishlist">
|
||||
<span id="p{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% if on_search_page %}
|
||||
<span class="gb_id" id="p{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% else %}
|
||||
<span class="work_id" id="p{{ work.id }}">Add to Wishlist</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}{% endif %}{% endifequal %}{% endif %}{% endif %}
|
||||
|
||||
|
@ -130,7 +138,11 @@
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="listview panelfront side1 add-wishlist">
|
||||
<span id="l{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% if on_search_page %}
|
||||
<span class="gb_id" id="l{{ googlebooks_id }}">Add to Wishlist</span>
|
||||
{% else %}
|
||||
<span class="work_id" id="l{{ work.id }}">Add to Wishlist</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}{% endif %}{% endifequal %}{% endif %}
|
||||
<div class="listview panelfront side1 booklist-status">
|
||||
|
|
|
@ -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 %}
|
||||
</div>
|
||||
{% empty %}
|
||||
<h2>Sorry, couldn't find that!</h2>
|
||||
|
|
|
@ -208,7 +208,7 @@ $j(document).ready(function(){
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="add-wishlist">
|
||||
<span id="w{{ work.googlebooks_id }}">Add to Wishlist</span>
|
||||
<span class="work_id" id="w{{ work.id }}">Add to Wishlist</span>
|
||||
</div>
|
||||
{% endif %}{% endif %}{% endif %}
|
||||
</div>
|
||||
|
|
|
@ -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('<i>an error occurred.</i>'); return;}
|
||||
|
||||
// give immediate feedback that action is in progress
|
||||
span.html('<b>Adding...</b>');
|
||||
|
||||
// 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('<b>Adding...</b>');
|
||||
|
||||
jQuery.post('/wishlist/', {'add_work_id': work_id}, function(data) {
|
||||
span.html('<span class="on-wishlist">On Wishlist!</span>');
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue