I need to remove the ::after
when only one div.portfolio-item
is displayed. The reason being is because an image is attached to each of the items but when there is only one item it conflicts with the footer. I'm thinking that if there is only one time then a class should be added called one-item, that way I can control the ::after via CSS.
Fiddle: http://jsfiddle.net/amesy/1ku221ds/
jQuery...
function StringContainsAllItems(stringVal, items) {
if (items.length == 0 || items.length == null) {
return false;
}
for (var i = 0; i < items.length; i++) {
console.log("Item: " + items[i]);
if (stringVal.indexOf(items[i]) == -1) {
return false;
}
}
return true;
}
$(function () {
//initialize first item
$('div.portfolio-item:visible:first').addClass("first-item");
var $checkboxes = $("input[id^='type-']");
$('input[type=checkbox]:checked').attr('checked', false);
$checkboxes.change(function () {
if ($('input[type=checkbox]:checked').length > 0) {
var selectorArray = [];
$checkboxes.filter(':checked').each(function () {
selectorArray.push($(this).attr('rel'));
console.log($(this).attr('rel'));
});
$('[data-category]').hide() // hide all rows
.filter(function () {
return StringContainsAllItems($(this).data('category'), selectorArray);
}).show(); // reduce set to matched and show
} else {
$('[data-category]').show();
}
$('div.portfolio-item').removeClass("first-item");
$('div.portfolio-item:visible:first').addClass("first-item");
});
});
So I added this function which doesn't work but you get an idea of what i'm trying to do...
$(function () {
var numItems = $('div.portfolio-item:visible').length;
if (numItems === 1) {
$('div.portfolio-item:visible').addClass("one-item");
}
});