Handle sold out items a bit better

This commit is contained in:
David Kelly 2017-12-14 11:52:56 -07:00
parent ed5082e5d4
commit a49ee46f54

View file

@ -199,7 +199,7 @@
var purchasesElement = document.createElement('a'); var purchasesElement = document.createElement('a');
var dropDownElement = document.getElementById('user-dropdown'); var dropDownElement = document.getElementById('user-dropdown');
$('#user-dropdown').find('.username')[0].style = "max-width:80px;white-space:nowrap;overflow:hidden;" + $('#user-dropdown').find('.username')[0].style = "max-width:80px;white-space:nowrap;overflow:hidden;" +
"text-overflow:ellipsis;display:inline-block;position:relative;top:4px;"; "text-overflow:ellipsis;display:inline-block;position:relative;top:4px;";
$('#user-dropdown').find('.caret')[0].style = "position:relative;top:-3px;"; $('#user-dropdown').find('.caret')[0].style = "position:relative;top:-3px;";
@ -387,27 +387,40 @@
var href = purchaseButton.attr('href'); var href = purchaseButton.attr('href');
purchaseButton.attr('href', '#'); purchaseButton.attr('href', '#');
purchaseButton.css({ var availability = $.trim($('.item-availability').text());
"background": "linear-gradient(#00b4ef, #0093C5)", if (availability === 'available') {
"color": "#FFF", purchaseButton.css({
"font-weight": "600", "background": "linear-gradient(#00b4ef, #0093C5)",
"padding-bottom": "10px" "color": "#FFF",
}); "font-weight": "600",
"padding-bottom": "10px"
});
} else {
purchaseButton.css({
"background": "linear-gradient(#a2a2a2, #fefefe)",
"color": "#000",
"font-weight": "600",
"padding-bottom": "10px"
});
}
var cost = $('.item-cost').text(); var cost = $('.item-cost').text();
if (availability !== 'available') {
if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) { purchaseButton.html('UNAVAILABLE (' + availability + ')');
} else if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) {
purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' + purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
'width:20px;height:20px;position:relative;top:5px;"></span> ' + cost); 'width:20px;height:20px;position:relative;top:5px;"></span> ' + cost);
} }
purchaseButton.on('click', function () { purchaseButton.on('click', function () {
buyButtonClicked(window.location.pathname.split("/")[3], if ('availabile' === availability) {
$('#top-center').find('h1').text(), buyButtonClicked(window.location.pathname.split("/")[3],
$('#creator').find('.value').text(), $('#top-center').find('h1').text(),
cost, $('#creator').find('.value').text(),
href); cost,
}); href);
}
});
maybeAddPurchasesButton(); maybeAddPurchasesButton();
} }
} }