1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| const trouve_ca_id = document.querySelector('img.picture');
const idImg = trouve_ca_id.id.split ('X');
const ca_id = idImg[0];
const tist = trouve_ca_id.alt;
const focused = [];
const imaxes = document.querySelectorAll('img.picture, img[src^="im/mu/' + ca_id + '-"] + img'); // Renommé en imaxes pour plus de clarté
imaxes.forEach (imax => {
let idImg = imax.id.split('X');
if (idImg.length < 3) return;
let ca_id = idImg[0];
let height = idImg[1];
let img_format = idImg[2];
imax.addEventListener('mousedown', function () {
let activeImg = document.activeElement.getAttribute('src');
focused[0] = activeImg;
PopGrand(ca_id, tist, height, img_format);
});
imax.addEventListener('mouseup', function () {
document.querySelector('img[src="' + focused[0] + '"]').focus ();
});
})
function PopGrand(ca_id, tist, height, img_format) {
if (!mobile.matches) {return false;}
else
{
window.open ('popup.php?nom='+ encodeURI (ca_id+'G.'+img_format+'&tit='+tist), 'popImg', 'popup=yes,scrollbars=yes,resizable=yes,width=420,height='+height);
}
}; |