PageSourceSearch

https://picoxr-ru.ru/js/addons/ab__video_gallery/product_image_gallery.js?ver=1790242472

js picoxr-ru.ru collected 2026-10-08 14:30:51 UTC 12,602 bytes, 370 lines download raw bytes

1/*******************************************************************************************
2*   ___  _          ______                     _ _                _                        *
3*  / _ \| |         | ___ \                   | (_)              | |              © 2023   *
4* / /_\ | | _____  _| |_/ /_ __ __ _ _ __   __| |_ _ __   __ _   | |_ ___  __ _ _ __ ___   *
5* |  _  | |/ _ \ \/ / ___ \ '__/ _` | '_ \ / _` | | '_ \ / _` |  | __/ _ \/ _` | '_ ` _ \  *
6* | | | | |  __/>  <| |_/ / | | (_| | | | | (_| | | | | | (_| |  | ||  __/ (_| | | | | | | *
7* \_| |_/_|\___/_/\_\____/|_|  \__,_|_| |_|\__,_|_|_| |_|\__, |  \___\___|\__,_|_| |_| |_| *
8*                                                         __/ |                            *
9*                                                        |___/                             *
10* ---------------------------------------------------------------------------------------- *
11* This is commercial software, only users who have purchased a valid license and accept    *
12* to the terms of the License Agreement can install and use this program.                  *
13* ---------------------------------------------------------------------------------------- *
14* website: https://cs-cart.alexbranding.com                                                *
15*   email: [email protected]                                                           *
16*******************************************************************************************/
17(function(_, $) {
18const ITEMS_COUNT_DEFAULT = 3;
19const theme_name = _.ab__video_gallery?.settings?.theme_name;
20var scroller_type;
21var methods = {
22init: function() {
23var container = $(this);
24var params = {
25items_count: container.data('caItemsCount') ? container.data('caItemsCount') : ITEMS_COUNT_DEFAULT,
26items_responsive: !!container.data('caItemsResponsive'),
27cycle: container.data('caCycle') === 'Y',
28vertical: container.data('caVertical') === 'Y',
29total_img: methods.countElms(container)
30};
31if (params.vertical && $(window).width() > 767) {
32scroller_type = 'jcarousel';
33} else {
34scroller_type = 'owlcarousel';
35}
36if (params.total_img <= params.items_count && container.parents('.ab_vg-images-wrapper').length) {
37container.removeClass('owl-carousel');
38}
39if (
40(
41params.total_img > params.items_count
42|| (!params.vertical && ['bright_theme', 'responsive'].includes(theme_name))
43)
44|| scroller_type === 'jcarousel'
45|| !container.parents('.ab_vg-images-wrapper').length
46) {
47if (container.data('owl-carousel') || container.data('jcarousel')) {
48return true;
49}
50methods.check(container, params);
51} else {
52container.addClass('ab__vg_loaded');
53}
54methods.bind(container);
55return true;
56},
57load: function(container, params) {
58if (scroller_type === 'owlcarousel') {
59container.owlCarousel({
60direction: _.language_direction,
61items: params.items_count,
62singleItem: params.items_count === 1,
63responsive: params.items_responsive,
64pagination: false,
65navigation: true,
66lazyLoad: true,
67navigationText: params.items_count === 1 ? ['<i class="icon-left-circle ty-icon-left-circle"></i>', '<i class="icon-right-circle ty-icon-right-circle"></i>'] : ['<i class="icon-left-open-thin ty-icon-left-open-thin"></i>', '<i class="icon-right-open-thin ty-icon-right-open-thin"></i>'],
68theme: params.items_count === 1 ? 'owl-one-theme' : 'owl-more-theme',
69beforeInit: function beforeInit() {
70$.ceEvent('trigger', 'ce.product_image_gallery.inner.beforeInit', [this]);
71},
72afterInit: function(item) {
73
74let elem = $('.cm-thumbnails-mini.active', item);
75if (elem.length) {
76var pos = elem.data('caImageOrder') || 0;
77for (let i=2; i<pos; i++) {
78item.trigger('owl.next');
79}
80}
81}
82});
83} else {
84container.css({
85'height': (params.items_count * params.i_height),
86'overflow': 'hidden',
87'padding': 0,
88'margin': 0,
89'position': 'relative',
90'z-index': 'auto'
91});
92var wrapper = container.parent();
93var nav_prev = $('<i class="icon-up-open ty-icon-up-open hand ty-hand" />').prependTo(wrapper);
94var nav_next = $('<i class="icon-down-open ty-icon-down-open hand ty-hand" />').appendTo(wrapper);
95var wrapper_height = container.outerHeight(true)+nav_prev.outerHeight(true)+nav_next.outerHeight(true);
96if (params.main_image_height < wrapper_height && params.items_count > ITEMS_COUNT_DEFAULT) {
97params.items_count--;
98container.height(params.items_count * params.i_height);
99}
100var scrolled = 0;
101if (!params.cycle) {
102nav_prev.css('visibility', 'hidden');
103}
104nav_next.on('click', function(){
105if ((scrolled + params.items_count) < params.items_amount) {
106scrolled += 1;
107if ((scrolled + params.items_count) === params.items_amount && !params.cycle) {
108nav_next.css('visibility', 'hidden');
109}
110} else if ((scrolled + params.items_count) === params.items_amount && params.cycle) {
111scrolled = 0;
112} else {
113return false;
114}
115nav_prev.css('visibility', 'visible');
116container.stop(true, false).animate({
117scrollTop: scrolled*params.i_height
118});
119});
120nav_prev.on('click', function(){
121if (scrolled > 0) {
122scrolled -= 1;
123if (scrolled === 0 && !params.cycle) {
124nav_prev.css('visibility', 'hidden');
125}
126} else if (scrolled === 0 && params.cycle) {
127scrolled = params.items_amount - params.items_count;
128} else {
129return false;
130}
131nav_next.css('visibility', 'visible');
132container.stop(true, false).animate({
133scrollTop: scrolled*params.i_height
134});
135});
136let elem = $('.cm-thumbnails-mini.active', container);
137if (elem.length) {
138let pos = elem.data('caImageOrder') || 0;
139while (scrolled <= (pos - params.items_count)) {
140nav_next.trigger('click');
141}
142}
143}
144container.addClass('ab__vg_loaded');
145},
146check: function(container, params) {
147if (container.data('owl-carousel') || container.data('jcarousel')) {
148return true;
149}
150const set_image_gallery_wraper_width = function (container, params) {
151if ((!params.vertical || $(window).width() < 767) && (['bright_theme', 'responsive'].includes(theme_name))) {
152const reserved_width = 50,
153max_container_width = params.main_image_width - reserved_width;
154if (params.c_width > max_container_width) {
155params.c_width = max_container_width;
156container.closest('.cm-image-gallery-wrapper').width(params.c_width);
157params.items_count = Math.floor(params.c_width / params.i_width);
158}
159container.closest('.cm-image-gallery-wrapper').width(params.c_width);
160} else if (scroller_type === 'owlcarousel') {
161container.closest('.cm-image-gallery-wrapper').width(params.c_width);
162}
163}
164if (!params.i_width || !params.i_height) {
165var t_elm = false;
166var wrapper = container.closest('.ab_vg-images-wrapper');
167if ($('.cm-thumbnails-mini', container).length) {
168var load = false;
169if (!t_elm) {
170t_elm = $('.cm-thumbnails-mini:first', container);
171var i_elm = $('img', t_elm);
172if (i_elm.height() <= 5 || i_elm.width() <= 5) {
173load = true;
174}
175let t_elm_image = null;
176if ((t_elm_image = $('.cm-previewer:first', wrapper).find('img')[0] ?? null)) {
177if (!t_elm_image.complete && t_elm_image.naturalWidth === 0) {
178load = true;
179}
180}
181if (load) {
182var check_load = function() {
183methods.check(container, params);
184};
185setTimeout(check_load, 500);
186return false;
187}
188}
189} else {
190t_elm = $('img:first', container);
191}
192params.i_width = t_elm.outerWidth(true);
193params.i_height = t_elm.outerHeight(true);
194params.c_width = params.i_width * params.items_count;
195params.main_image_width = $('.cm-preview-wrapper', wrapper).outerWidth(false);
196params.main_image_height = $('.cm-preview-wrapper', wrapper).outerHeight(false);
197set_image_gallery_wraper_width(container, params);
198if (scroller_type !== 'owlcarousel') {
199params.items_count = parseInt(params.main_image_height/params.i_height);
200params.items_amount = methods.countElms(container);
201if (params.items_count < ITEMS_COUNT_DEFAULT) {
202params.items_count = params.items_amount < 3 ? params.items_amount : ITEMS_COUNT_DEFAULT;
203}
204set_image_gallery_wraper_width(container, params);
205if ((params.main_image_height > params.items_amount * params.i_height) || params.items_amount <= params.items_count) {
206container.addClass('ab__vg_loaded');
207return false;
208} else {
209container.data('jcarousel', true);
210}
211}
212}
213return methods.load(container, params);
214},
215bind: function(container) {
216container.click(function(e) {
217var jelm = $(e.target);
218var pjelm;
219var in_elm;
220if (scroller_type === 'owlcarousel') {
221in_elm = (jelm.parents('.cm-item-gallery') || jelm.parents('div.cm-thumbnails-mini'));
222} else {
223in_elm = (jelm.parents('.cm-item-gallery') || jelm.parents('.cm-thumbnails-mini'));
224}
225if (in_elm && !jelm.is('img')) {
226return false;
227}
228if (jelm.hasClass('cm-thumbnails-mini') || (pjelm = jelm.parents('a:first.cm-thumbnails-mini'))) {
229jelm = (pjelm && pjelm.length) ? pjelm : jelm;
230var c_id = jelm.data('caGalleryLargeId');
231$('#' + c_id).closest('.cm-preview-wrapper').trigger('owl.goTo', $(jelm).data('caImageOrder') || 0);
232}
233});
234},
235countElms: function(container) {
236if (scroller_type === 'owlcarousel') {
237return $('.cm-thumbnails-mini', container).length;
238} else {
239return $('.cm-thumbnails-mini', container).length;
240}
241}
242};
243$.fn.AB_ceProductImageGallery = function( method ) {
244if (!$().owlCarousel) {
245var gelms = $(this);
246$.getScript('js/lib/owlcarousel/owl.carousel.min.js', function() {
247gelms.AB_ceProductImageGallery();
248});
249return false;
250}
251return $(this).each(function(i, elm) {
252var errors = { };
253if (methods[method]) {
254return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
255} else if ( typeof method === 'object' || !method ) {
256return methods.init.apply(this, arguments);
257} else {
258$.error('ty.productimagegallery: method ' + method + ' does not exist');
259}
260});
261};
262$.ceEvent('on', 'ce.commoninit', function(context) {
263context.find('.cm-image-gallery:not(.ab__vg_loaded)').each(function () {
264let self = $(this);
265self.AB_ceProductImageGallery();
266});
267});
268$.ceEvent('on', 'ce.commoninit', function (context) {
269var wrapper = $('.cm-preview-wrapper', context);
270var gallery_items_view = +(_.abt__ut2?.settings?.products[_.abt__ut2?.details_layout]?.multiple_product_images[_.abt__ut2?.device]||1);
271if (gallery_items_view == 2) {
272var item = gallery_items_view,
273itemsDesktop = gallery_items_view,
274itemsDesktopSmall = 2,
275itemsTablet = 1,
276itemsMobile = 1;
277}
278if (gallery_items_view == 3) {
279var item = gallery_items_view,
280itemsDesktop = gallery_items_view,
281itemsDesktopSmall = 2,
282itemsTablet = 2,
283itemsMobile = 1;
284}
285var desktop = [1400, itemsDesktop],
286desktopSmall = [1230, itemsDesktopSmall],
287tablet = [1040, itemsTablet],
288mobile = [900, itemsMobile];
289if (wrapper.length) {
290let params = {
291direction: _.language_direction,
292lazyLoad: true,
293pagination: false,
294center: true,
295addClassActive: true,
296beforeInit: function beforeInit() {
297$.ceEvent('trigger', 'ce.product_image_gallery.beforeInit', [this]);
298},
299afterInit: function (item) {
300var thumbnails = $('.cm-thumbnails-mini', item.parents('[data-ca-previewer]')),
301previewers = $('.cm-image-previewer', item.parents('[data-ca-previewer]')),
302previousScreenX = 0,
303newScreenX = 0,
304swipeThreshold = 7;
305previewers.each(function (index, elm) {
306$(elm).data('caImageOrder', index);
307});
308thumbnails.on('click', function () {
309item.trigger('owl.goTo', $(this).data('caImageOrder') ? $(this).data('caImageOrder') : 0);
310});
311item.on('touchstart', function (e) {
312previousScreenX = e.changedTouches[0].screenX;
313});
314item.on('touchmove', function (e) {
315newScreenX = e.changedTouches[0].screenX;
316if (Math.abs(newScreenX - previousScreenX) > swipeThreshold && e.cancelable) {
317e.preventDefault();
318}
319previousScreenX = newScreenX;
320});
321$('.cm-image-previewer.hidden', item).toggleClass('hidden', false);
322$.ceEvent('trigger', 'ce.product_image_gallery.ready');
323},
324beforeMove: function (item) {
325$('.ty-image-zoom__flyout--visible').removeClass('ty-image-zoom__flyout--visible');
326},
327afterMove: function (item) {
328var _parent = item.parent();
329$('.cm-thumbnails-mini', _parent)
330.toggleClass('active', false);
331var elmOrderInGallery = $('.owl-item.active', item).index();
332$('[data-ca-image-order=' + elmOrderInGallery + ']', _parent)
333.toggleClass('active', true);
334$('.owl-carousel.cm-image-gallery', _parent)
335.trigger('owl.goTo', elmOrderInGallery);
336$.ceEvent('trigger', 'ce.product_image_gallery.image_changed');
337}
338}
339$('.ut2-pb__img').addClass('images-' + gallery_items_view);
340if($('.ty-quick-view__wrapper').length) {
341params = {
342...params,
343singleItem: true,
344items: 1,
345navigation: false
346}
347} else if(gallery_items_view > 1 ) {
348params = {
349...params,
350singleItem: false,
351items: item,
352itemsDesktop: desktop,
353itemsDesktopSmall: desktopSmall,
354itemsTablet: tablet,
355itemsMobile: mobile,
356navigation: true,
357navigationText: ['<i class="icon-left-open ty-icon-left-open hand ty-hand" />', '<i class="icon-right-open ty-icon-right-open hand ty-hand" />']
358}
359} else {
360params = {
361...params,
362singleItem: true,
363items: 1,
364navigation: false
365}
366}
367wrapper.owlCarousel(params);
368}
369});
370})(Tygh, Tygh.$);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.