hikashop_child_image_active class wrong added to all images

  • Posts: 2293
  • Thank you received: 315
6 years 8 months ago #274684

-- HikaShop version -- : 3.1.1

I think that many years ago hikashop_child_image_active used to emphases current small image that shows big image on the product page like this:



But later code was broken and at the moment all small images get this class.... (not only that over cursor was).

I have fix this code and so please include it in your distributive. In file show_block_img.php need to change lines:
if(thumb_img) {
		for(var i = thumbs_img.length - 1; i >= 0; i--) {
			o.addClass(thumbs_img[i], 'hikashop_child_image_active');
		}
	}

to
	if(thumb_img) {
			o.addClass(thumb_img[0], 'hikashop_child_image_active');
	}


Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81508
  • Thank you received: 13064
  • MODERATOR
6 years 8 months ago #274695

Hi,

Thanks for the feedback on that being broken.
The fix is actually different as far as I could test.
Your patch will always add the hikashop_child_image_active class to the first thumbnail.
The patch should be:

if(thumb_img) {
		for(var i = thumb_img.length - 1; i >= 0; i--) {
			o.addClass(thumb_img[i], 'hikashop_child_image_active');
		}
	}
I've tested it on my end and it works fine. We'll include it on our end.

Please Log in or Create an account to join the conversation.

  • Posts: 2293
  • Thank you received: 315
6 years 8 months ago #274709

You are wrong!
thumb_img is active image (image where user hold cursor of the mouse) and it will always be one! There is no case there two or more active images!

Your patch still working too but there is no need to use "for" loop because it work only one time! from 0 to 0!

See to this line

thumb_img = el.getElementsByTagName('img');

el - is an active element!

thumb_img - is an active image!

There is no need to use for loop!
My patch is working and you can see it in work on two sites!
here evastyle.by/odezhda-dlya-devochek/kostyu...ka-shtany-zima-vesna

and here shop.elino.ru/myaso-tushenoe/product/1-tushenaya-govyadina

P.S. I also made some improvement so that images changes with fading

jQuery(target).stop(true,true);
jQuery(target).fadeTo(150,.01,function () {
target.src = url;
} );
jQuery(target).fadeTo(150,1);


Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!
Last edit: 6 years 8 months ago by progreccor.

Please Log in or Create an account to join the conversation.

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 8 months ago #274732

Hello,

Just for a manner of speaking, please do not start a message with a "you are wrong !" ; it is unfortunately not very constructive and does not help a peaceful and healthy dialogue.

I don't see why the Nicolas code will be wrong ; it add the desire class.
You need to understand that there is no absolute "wrong" and "right" in development, but you can have more efficient code depending what is your goal.
And the HikaShop goal is flexibility !

So let's image that a user need to have badges on the images ; the Nicolas code could handle the fact that there will be several images.
Even if there is no need to loop for most cases ; thumb_img.length would be " 1 " and there won't have any loop.

I'm really sorry but the Nicolas patch is working and his solution is the right one for the HikaShop coding style.

Best regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 2293
  • Thank you received: 315
6 years 8 months ago #274813

I'd like to apologize for how I reacted to the Nicolas post.
I hope you and Nicolas can forgive me...

May be there will be offtopic but I need to explain what I mean and why I wrote what I wrote.

Let's start from the begining:
Nicolas wrote:

Your patch will always add the hikashop_child_image_active class to the first thumbnail.
My code don't add hikashop_child_image_active to the first image.
We talk about a structure like this:
<a href=""><img /> </a>
<a href=""><img /> </a>
<a href=""><img /> </a>
<a href=""><img /> </a>
<a href=""><img /> </a>

this is "a href" for popup engine. We talk about loop that work with images inside "a" tag.
Inside "a" tag can't be two or more iamges. Hikashop don't add badges to small images. More over - most of popup engines broke if you want to add more that one image inside "a' tag.
So I can't imagine the case where will be more than one image inside any of the "a" tag.

And so I think that Nicolas confuse this code with code for main thumb or may be with previous loop. That's why I wrote my post.

Your code definitely will work but my code will work too. Necessity of the loop in this case don't clear for me.

That all what I want say about it


Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!
Last edit: 6 years 8 months ago by progreccor.
The following user(s) said Thank You: Jerome

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum