Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Currently it seems you're missing the <code>imgover</code> class on your images and their <code>src</code> is wrong (<code>_e</code> instead of <code>_s</code>), so the hover/swap doesn't work at all. </p> <p>Just to get going, I fixed that by executing</p> <pre><code>$('#photos img').attr('src','images/iso_s.jpg').addClass('imgover'); </code></pre> <p>in the console first. </p> <p>Then re-apply the image-swapping code, as modified here:</p> <pre><code>$(function(){ $('.imgover').each(function() { var std = $(this).attr("src"); var hover = std.replace("_s", "_o"); $(this).clone().insertAfter(this).attr('src', hover).removeClass('imgover').siblings().css({ position:'absolute' }); var $img = $(this); function isActive(){ // Regex for extracting the ID number for the image group type var reg = /^(.*\s)?ff-item-type-(\d+)[^\d]*.*/; var classes = $img.closest('li').attr('class'); var id = reg.exec(classes)[2]; console.log('Checking image with group id',id); var found = $('#select-type-all, #select-type-'+id).filter(':checked').length; console.log('Matching and checked input count:', found); return found&gt;0; } $(this).mouseenter(function() { if (isActive()){ $(this).stop().fadeTo(200, 0); } }).mouseleave(function() { $(this).stop().fadeTo(200, 1); }); }); }); </code></pre> <p>This appears to work. Note though that for some reason the b/w pictures are scale too big, probably a problem with your CSS. Applying the following fixes that well enough to see the swapping working as intended:</p> <pre><code>$('#photos img').css('width','auto !important') </code></pre> <p>The only change I made to the swapping code was adding the <code>isActive</code>function add checking that before performing the swap.</p> <p><code>isActive</code> extracts the i image group id from the class of its parent <code>&lt;li&gt;</code>, and then checks if the corresponding input <code>#select-type-[id]</code> (or the <code>#select-type-all</code>-input) is checked.</p> <hr> <p>Ooops, I see now that you wanted the swapping to be triggered by the filtering directly. To do that, try this instead:</p> <pre><code>$(function(){ $('#photos img').attr('src','images/iso_s.jpg').addClass('imgover'); $('#photos img').css('width','auto !important') $('.imgover').each(function() { var std = $(this).attr("src"); var hover = std.replace("_s", "_o"); $(this).clone().insertAfter(this).attr('src', hover).removeClass('imgover').siblings().css({ position:'absolute' }); var $img = $(this); function isActive(){ // Regex for extracting the ID number for the image group type var reg = /^(.*\s)?ff-item-type-(\d+)[^\d]*.*/; var classes = $img.closest('li').attr('class'); var id = reg.exec(classes)[2]; console.log('Checking image with group id',id); var found = $('#select-type-'+id).filter(':checked').length; console.log('Matching and checked input count:', found); return found&gt;0; } $('#container input').change(function(){ if (isActive()){ $img.stop().fadeTo(200, 0); } else { $img.stop().fadeTo(200, 1); } }); }); }); </code></pre> <p>Not the most effective or elegant solution (binding an <code>onchange</code> event for each image), but it gets the job done.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload