PageSourceSearch

https://pleervox.ru/js/addons/ab__video_gallery/product_image_gallery.js?ver=1790659589

js pleervox.ru collected 2026-10-04 22:51:53 UTC 10,001 bytes, 290 lines download raw bytes

1/*******************************************************************************************
2*   ___  _          ______                     _ _                _                        *
3*  / _ \| |         | ___ \                   | (_)              | |              © 2021   *
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(_, $) {
18var ITEMS_COUNT_DEFAULT = 3;
19var scroller_type;
20var methods = {
21init: function() {
22var container = $(this);
23var params = {
24items_count: container.data('caItemsCount') ? container.data('caItemsCount') : ITEMS_COUNT_DEFAULT,
25items_responsive: !!container.data('caItemsResponsive'),
26cycle: container.data('caCycle') === 'Y',
27vertical: container.data('caVertical') === 'Y',
28total_img: methods.countElms(container)
29};
30if (params.vertical && $(window).width() > 767) {
31scroller_type = 'jcarousel';
32} else {
33scroller_type = 'owlcarousel';
34}
35if (params.total_img <= params.items_count && container.parents('.ab_vg-images-wrapper').length) {
36container.removeClass('owl-carousel');
37}
38if (params.total_img > params.items_count || scroller_type === 'jcarousel' || !container.parents('.ab_vg-images-wrapper').length) {
39if (container.data('owl-carousel') || container.data('jcarousel')) {
40return true;
41}
42methods.check(container, params);
43} else {
44container.addClass('ab__vg_loaded');
45}
46methods.bind(container);
47return true;
48},
49load: function(container, params) {
50if (scroller_type === 'owlcarousel') {
51container.owlCarousel({
52direction: _.language_direction,
53items: params.items_count,
54singleItem: params.items_count === 1,
55responsive: params.items_responsive,
56pagination: false,
57navigation: true,
58lazyLoad: true,
59navigationText: 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>'],
60theme: params.items_count === 1 ? 'owl-one-theme' : 'owl-more-theme',
61afterInit: function(item) {
62
63let elem = $('.cm-thumbnails-mini.active', item);
64if (elem.length) {
65var pos = elem.data('caImageOrder') || 0;
66for (let i=2; i<pos; i++) {
67item.trigger('owl.next');
68}
69}
70}
71});
72} else {
73container.css({
74'height': (params.items_count * params.i_height),
75'overflow': 'hidden',
76'padding': 0,
77'margin': 0,
78'position': 'relative',
79'z-index': 'auto'
80});
81var wrapper = container.parent();
82var nav_prev = $('<i class="icon-up-open ty-icon-up-open hand ty-hand" />').prependTo(wrapper);
83var nav_next = $('<i class="icon-down-open ty-icon-down-open hand ty-hand" />').appendTo(wrapper);
84var wrapper_height = container.outerHeight(true)+nav_prev.outerHeight(true)+nav_next.outerHeight(true);
85if (params.main_image_height < wrapper_height && params.items_count > 1) {
86params.items_count--;
87container.height(params.items_count * params.i_height);
88}
89var scrolled = 0;
90if (!params.cycle) {
91nav_prev.css('visibility', 'hidden');
92}
93nav_next.on('click', function(){
94if ((scrolled + params.items_count) < params.items_amount) {
95scrolled += 1;
96if ((scrolled + params.items_count) === params.items_amount && !params.cycle) {
97nav_next.css('visibility', 'hidden');
98}
99} else if ((scrolled + params.items_count) === params.items_amount && params.cycle) {
100scrolled = 0;
101} else {
102return false;
103}
104nav_prev.css('visibility', 'visible');
105container.stop(true, false).animate({
106scrollTop: scrolled*params.i_height
107});
108});
109nav_prev.on('click', function(){
110if (scrolled > 0) {
111scrolled -= 1;
112if (scrolled === 0 && !params.cycle) {
113nav_prev.css('visibility', 'hidden');
114}
115} else if (scrolled === 0 && params.cycle) {
116scrolled = params.items_amount - params.items_count;
117} else {
118return false;
119}
120nav_next.css('visibility', 'visible');
121container.stop(true, false).animate({
122scrollTop: scrolled*params.i_height
123});
124});
125let elem = $('.cm-thumbnails-mini.active', container);
126if (elem.length) {
127let pos = elem.data('caImageOrder') || 0;
128while (scrolled <= (pos - params.items_count)) {
129nav_next.trigger('click');
130}
131}
132}
133container.addClass('ab__vg_loaded');
134},
135check: function(container, params) {
136if (container.data('owl-carousel') || container.data('jcarousel')) {
137return true;
138}
139if (!params.i_width || !params.i_height) {
140var t_elm = false;
141var wrapper = container.closest('.ab_vg-images-wrapper');
142if ($('.cm-thumbnails-mini', container).length) {
143var load = false;
144if (!t_elm) {
145t_elm = $('.cm-thumbnails-mini:first', container);
146var i_elm = $('img', t_elm);
147if (i_elm.height() <= 5 || i_elm.width() <= 5) {
148load = true;
149}
150if ($('.cm-previewer:first', wrapper).innerHeight() < t_elm.innerHe
150ight()) {
151load = true;
152}
153if (load) {
154var check_load = function() {
155methods.check(container, params);
156};
157setTimeout(check_load, 500);
158return false;
159}
160}
161} else {
162t_elm = $('img:first', container);
163}
164params.i_width = t_elm.outerWidth(true);
165params.i_height = t_elm.outerHeight(true);
166params.c_width = params.i_width * params.items_count;
167params.main_image_height = $('.cm-preview-wrapper', wrapper).outerHeight(false);
168if (scroller_type === 'owlcarousel') {
169container.closest('.cm-image-gallery-wrapper').width(params.c_width);
170} else {
171params.items_count = parseInt(params.main_image_height/params.i_height);
172params.items_amount = methods.countElms(container);
173if (params.items_count < 1) {
174params.items_count = 1;
175}
176if (params.main_image_height > params.items_amount * params.i_height) {
177container.addClass('ab__vg_loaded');
178return false;
179} else {
180container.data('jcarousel', true);
181}
182}
183}
184return methods.load(container, params);
185},
186bind: function(container) {
187container.click(function(e) {
188var jelm = $(e.target);
189var pjelm;
190var in_elm;
191if (scroller_type === 'owlcarousel') {
192in_elm = (jelm.parents('.cm-item-gallery') || jelm.parents('div.cm-thumbnails-mini'));
193} else {
194in_elm = (jelm.parents('.cm-item-gallery') || jelm.parents('.cm-thumbnails-mini'));
195}
196if (in_elm && !jelm.is('img')) {
197return false;
198}
199if (jelm.hasClass('cm-thumbnails-mini') || (pjelm = jelm.parents('a:first.cm-thumbnails-mini'))) {
200jelm = (pjelm && pjelm.length) ? pjelm : jelm;
201var c_id = jelm.data('caGalleryLargeId');
202$('#' + c_id).closest('.cm-preview-wrapper').trigger('owl.goTo', $(jelm).data('caImageOrder') || 0);
203}
204});
205},
206countElms: function(container) {
207if (scroller_type === 'owlcarousel') {
208return $('.cm-thumbnails-mini', container).length;
209} else {
210return $('.cm-thumbnails-mini', container).length;
211}
212}
213};
214$.fn.AB_ceProductImageGallery = function( method ) {
215if (!$().owlCarousel) {
216var gelms = $(this);
217$.getScript('js/lib/owlcarousel/owl.carousel.min.js', function() {
218gelms.AB_ceProductImageGallery();
219});
220return false;
221}
222return $(this).each(function(i, elm) {
223var errors = { };
224if (methods[method]) {
225return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
226} else if ( typeof method === 'object' || !method ) {
227return methods.init.apply(this, arguments);
228} else {
229$.error('ty.productimagegallery: method ' + method + ' does not exist');
230}
231});
232};
233$.ceEvent('on', 'ce.commoninit', function(context) {
234context.find('.cm-image-gallery:not(.ab__vg_loaded)').each(function () {
235let self = $(this);
236self.AB_ceProductImageGallery();
237});
238});
239$.ceEvent('on', 'ce.commoninit', function (context) {
240var wrapper = $('.cm-preview-wrapper', context);
241if (wrapper.length) {
242wrapper.owlCarousel({
243direction: _.language_direction,
244lazyLoad: true,
245pagination: false,
246singleItem: true,
247addClassActive: true,
248afterInit: function (item) {
249var thumbnails = $('.cm-thumbnails-mini', item.parents('[data-ca-previewer]')),
250previewers = $('.cm-image-previewer', item.parents('[data-ca-previewer]')),
251previousScreenX = 0,
252newScreenX = 0,
253swipeThreshold = 7;
254previewers.each(function (index, elm) {
255$(elm).data('caImageOrder', index);
256});
257thumbnails.on('click', function () {
258item.trigger('owl.goTo', $(this).data('caImageOrder') ? $(this).data('caImageOrder') : 0);
259});
260item.on('touchstart', function (e) {
261previousScreenX = e.changedTouches[0].screenX;
262});
263item.on('touchmove', function (e) {
264newScreenX = e.changedTouches[0].screenX;
265if (Math.abs(newScreenX - previousScreenX) > swipeThreshold && e.cancelable) {
266e.preventDefault();
267}
268previousScreenX = newScreenX;
269});
270$('.cm-image-previewer.hidden', item).toggleClass('hidden', false);
271$.ceEvent('trigger', 'ce.product_image_gallery.ready');
272},
273beforeMove: function (item) {
274$('.ty-image-zoom__flyout--visible').removeClass('ty-image-zoom__flyout--visible');
275},
276afterMove: function (item) {
277var _parent = item.parent();
278$('.cm-thumbnails-mini', _parent)
279.toggleClass('active', false);
280var elmOrderInGallery = $('.owl-item.active', item).index();
281$('[data-ca-image-order=' + elmOrderInGallery + ']', _parent)
282.toggleClass('active', true);
283$('.owl-carousel.cm-image-gallery', _parent)
284.trigger('owl.goTo', elmOrderInGallery);
285$.ceEvent('trigger', 'ce.product_image_gallery.image_changed');
286}
287}
287);
288}
289});
290})(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.