Only show 'buy' on costed items'

This commit is contained in:
Zach Fox 2017-08-24 16:38:44 -07:00
parent 8d3c394d00
commit 3980a478d9

View file

@ -121,11 +121,19 @@
} }
function injectBuyButtonOnMainPage() { function injectBuyButtonOnMainPage() {
var cost;
$('.grid-item').find('#price-or-edit').find('a').each(function() { $('.grid-item').find('#price-or-edit').find('a').each(function() {
$(this).attr('data-href', $(this).attr('href')); $(this).attr('data-href', $(this).attr('href'));
$(this).attr('href', '#'); $(this).attr('href', '#');
}); cost = $(this).closest('.col-xs-3').find('.item-cost').text();
$('.grid-item').find('#price-or-edit').find('.price').text("BUY");
if (parseInt(cost) > 0) {
$(this).find('.price').text("BUY");
}
});
$('.grid-item').find('#price-or-edit').find('a').on('click', function () { $('.grid-item').find('#price-or-edit').find('a').on('click', function () {
buyButtonClicked($(this).closest('.grid-item').attr('data-item-id'), buyButtonClicked($(this).closest('.grid-item').attr('data-item-id'),
$(this).closest('.grid-item').find('.item-title').text(), $(this).closest('.grid-item').find('.item-title').text(),
@ -161,12 +169,18 @@
if (confirmAllPurchases) { if (confirmAllPurchases) {
var href = $('#side-info').find('.btn').attr('href'); var href = $('#side-info').find('.btn').attr('href');
$('#side-info').find('.btn').attr('href', '#'); $('#side-info').find('.btn').attr('href', '#');
$('#side-info').find('.btn').html('<span class="glyphicon glyphicon-download"></span>Buy Item ');
var cost = $('.item-cost').text();
if (parseInt(cost) > 0) {
$('#side-info').find('.btn').html('<span class="glyphicon glyphicon-download"></span>Buy Item ');
}
$('#side-info').find('.btn').on('click', function () { $('#side-info').find('.btn').on('click', function () {
buyButtonClicked(window.location.pathname.split("/")[3], buyButtonClicked(window.location.pathname.split("/")[3],
$('#top-center').find('h1').text(), $('#top-center').find('h1').text(),
$('#creator').find('.value').text(), $('#creator').find('.value').text(),
$('.item-cost').text(), cost,
href); href);
}); });
addInventoryButton(); addInventoryButton();