YITH WooCommerce Zoom Magnifier - Version 1.3.20

Version Description

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Zoom Magnifier
Version 1.3.20
Comparing to
See all releases

Code changes from version 1.3.19 to 1.3.20

README.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: yithemes
4
  Tags: zoom, magnifier, slider, carousel, woocommerce
5
  Requires at least: 4.0
6
- Tested up to: 5.5
7
- Stable tag: 1.3.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Documentation: https://docs.yithemes.com/yith-woocommerce-zoom-magnifier/
@@ -52,6 +52,14 @@ YITH WooCommerce Zoom Magnifier will add a new tab called "Zoom Magnifier" in "Y
52
 
53
  == Changelog ==
54
 
 
 
 
 
 
 
 
 
55
  = Version 1.3.19 - Released: Oct 01, 2020 =
56
 
57
  * New: support for WooCommerce 4.6
3
  Contributors: yithemes
4
  Tags: zoom, magnifier, slider, carousel, woocommerce
5
  Requires at least: 4.0
6
+ Tested up to: 5.6
7
+ Stable tag: 1.3.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Documentation: https://docs.yithemes.com/yith-woocommerce-zoom-magnifier/
52
 
53
  == Changelog ==
54
 
55
+ = Version 1.3.20 - Released: Oct 30, 2020 =
56
+
57
+ * New: support for WooCommerce 4.7
58
+ * New: support for WordPress 5.6
59
+ * Update: Plugin-fw
60
+ * Fix: reverting previous versions changes to fix different problems
61
+
62
+
63
  = Version 1.3.19 - Released: Oct 01, 2020 =
64
 
65
  * New: support for WooCommerce 4.6
assets/css/frontend.css CHANGED
@@ -1,97 +1,65 @@
1
  /* gallery */
2
  .yith_magnifier_gallery {
3
- margin: 0;
4
- padding: 0;
5
- text-align: center;
6
  }
7
 
8
  .yith_magnifier_gallery li {
9
- position: relative;
10
- display: inline-block;
11
- vertical-align: center;
12
- top: 0;
13
  }
14
 
15
  .yith_magnifier_gallery li.last {
16
- /*margin-right: 0; */
17
  }
18
 
19
  .yith_magnifier_gallery li a {
20
- width: 100% !important;
21
- display: block;
22
- margin-top: 10px;
23
- height: auto !important;
24
  }
25
 
26
  /* next/prev */
27
  .single-product.woocommerce .thumbnails {
28
- position: relative;
29
- overflow: hidden;
30
  }
31
 
32
  .single-product.woocommerce .thumbnails #slider-prev,
33
  .single-product.woocommerce .thumbnails #slider-next {
34
- display: none !important;
35
- cursor: pointer;
36
- width: 27px;
37
- height: 26px;
38
- background: url('../images/slider-arrow.png') no-repeat left center;
39
- position: absolute;
40
- top: 50%;
41
- transform: translateY( -50% );
42
  }
43
 
44
  .single-product.woocommerce .thumbnails #slider-prev {
45
- background-position: left center;
46
- left: 0px;
47
  }
48
 
49
  .single-product.woocommerce .thumbnails #slider-next {
50
- background-position: right center;
51
- right: 0px;
52
  }
53
 
54
  .single-product.woocommerce .thumbnails:hover #slider-prev,
55
  .single-product.woocommerce .thumbnails:hover #slider-next {
56
- display: block !important;
57
  }
58
 
59
  span.onsale {
60
- z-index: 10000
61
  }
62
 
63
- div.pp_woocommerce a.yith_expand {
64
- display: inline;
65
- bottom: 10px;
66
- top: initial;
67
- left: 10px;
68
- background-color: rgb(68, 68, 68);
69
- box-sizing: border-box;
70
- cursor: pointer;
71
- font-size: 25px;
72
- position: absolute;
73
- text-align: left;
74
- text-decoration: none;
75
- text-indent: -10000px;
76
- z-index: 20000;
77
- border-radius: 100%;
78
- height: 25px;
79
- width: 25px;
80
- text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
81
- line-height: 1em;
82
- transition: all ease-in-out .2s;
83
- color: #fff !important;
84
- }
85
-
86
- a.yith_expand:before {
87
- font-family: WooCommerce;
88
- content: "\e005";
89
- display: block;
90
- position: absolute;
91
- top: 0;
92
- left: 0;
93
- right: 0;
94
- bottom: 0;
95
- text-align: center;
96
- text-indent: 0;
97
- }
1
  /* gallery */
2
  .yith_magnifier_gallery {
3
+ margin: 0;
4
+ padding: 0;
 
5
  }
6
 
7
  .yith_magnifier_gallery li {
8
+ position: relative;
9
+ float: left;
10
+ display: block;
 
11
  }
12
 
13
  .yith_magnifier_gallery li.last {
14
+ margin-right: 0;
15
  }
16
 
17
  .yith_magnifier_gallery li a {
18
+ width: 100% !important;
19
+ display: block;
20
+ margin-top: 10px;
21
+ height: auto !important;
22
  }
23
 
24
  /* next/prev */
25
  .single-product.woocommerce .thumbnails {
26
+ position: relative;
 
27
  }
28
 
29
  .single-product.woocommerce .thumbnails #slider-prev,
30
  .single-product.woocommerce .thumbnails #slider-next {
31
+ display: none !important;
32
+ cursor: pointer;
33
+ width: 27px;
34
+ height: 26px;
35
+ background: url('../images/slider-arrow.png') no-repeat left center;
36
+ position: absolute;
37
+ top: 48%;
38
+ margin-top: -2px;
39
  }
40
 
41
  .single-product.woocommerce .thumbnails #slider-prev {
42
+ background-position: left center;
43
+ left: 0px;
44
  }
45
 
46
  .single-product.woocommerce .thumbnails #slider-next {
47
+ background-position: right center;
48
+ right: 0px;
49
  }
50
 
51
  .single-product.woocommerce .thumbnails:hover #slider-prev,
52
  .single-product.woocommerce .thumbnails:hover #slider-next {
53
+ display: block !important;
54
  }
55
 
56
  span.onsale {
57
+ z-index: 10000
58
  }
59
 
60
+ div.pp_woocommerce a.pp_expand {
61
+ display: inline;
62
+ bottom: 10px;
63
+ top: initial;
64
+ left: 10px;
65
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/yith_magnifier.js CHANGED
@@ -1,950 +1,853 @@
1
- /**
2
- * YITH Magnifier
3
- *
4
- * @version 0.1
5
- * @author Your Inspiration Themes Team <info@yithemes.com>
6
- *
7
- * MIT License.
8
- */
9
-
10
- ;
11
- (function (window, $, undefined) {
12
- 'use strict';
13
-
14
- //include imagesLoaded plugin
15
- if ($.fn.imagesLoaded === undefined) {
16
- /*!
17
- * jQuery imagesLoaded plugin v2.1.1
18
- * http://github.com/desandro/imagesloaded
19
- *
20
- * MIT License. by Paul Irish et al.
21
- */
22
-
23
- /*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
24
- /*global jQuery: false */
25
-
26
- ;
27
- (function ($, undefined) {
28
- 'use strict';
29
-
30
- // blank image data-uri bypasses webkit log warning (thx doug jones)
31
- var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
32
-
33
-
34
-
35
- $.fn.imagesLoaded = function (callback) {
36
- var $this = this,
37
- deferred = $.isFunction($.Deferred) ? $.Deferred() : 0,
38
- hasNotify = $.isFunction(deferred.notify),
39
- $images = $this.find('img').add($this.filter('img')),
40
- loaded = [],
41
- proper = [],
42
- broken = [];
43
-
44
- // Register deferred callbacks
45
- if ($.isPlainObject(callback)) {
46
- $.each(callback, function (key, value) {
47
- if (key === 'callback') {
48
- callback = value;
49
- } else if (deferred) {
50
- deferred[key](value);
51
- }
52
- });
53
- }
54
-
55
- function doneLoading() {
56
- var $proper = $(proper),
57
- $broken = $(broken);
58
-
59
- if (deferred) {
60
- if (broken.length) {
61
- deferred.reject($images, $proper, $broken);
62
- } else {
63
- deferred.resolve($images);
64
- }
65
- }
66
-
67
- if ($.isFunction(callback)) {
68
- callback.call($this, $images, $proper, $broken);
69
- }
70
- }
71
-
72
- function imgLoadedHandler(event) {
73
- imgLoaded(event.target, event.type === 'error');
74
- }
75
-
76
- function imgLoaded(img, isBroken) {
77
- // don't proceed if BLANK image, or image is already loaded
78
- if (img.src === BLANK || $.inArray(img, loaded) !== -1) {
79
- return;
80
- }
81
-
82
- // store element in loaded images array
83
- loaded.push(img);
84
-
85
- // keep track of broken and properly loaded images
86
- if (isBroken) {
87
- broken.push(img);
88
- } else {
89
- proper.push(img);
90
- }
91
-
92
- // cache image and its state for future calls
93
- $.data(img, 'imagesLoaded', {isBroken: isBroken, src: img.src});
94
-
95
- // trigger deferred progress method if present
96
- if (hasNotify) {
97
- deferred.notifyWith($(img), [isBroken, $images, $(proper), $(broken)]);
98
- }
99
-
100
- // call doneLoading and clean listeners if all images are loaded
101
- if (loaded.length) {
102
- setTimeout(doneLoading);
103
- $images.unbind('.imagesLoaded', imgLoadedHandler);
104
- }
105
- }
106
-
107
- // if no images, trigger immediately
108
- if (!$images.length) {
109
- doneLoading();
110
- } else {
111
- $images.bind('load.imagesLoaded error.imagesLoaded', imgLoadedHandler)
112
- .each(function (i, el) {
113
- var src = el.src;
114
-
115
- // find out if this image has been already checked for status
116
- // if it was, and src has not changed, call imgLoaded on it
117
- var cached = $.data(el, 'imagesLoaded');
118
- if (cached && cached.src === src) {
119
- imgLoaded(el, cached.isBroken);
120
- return;
121
- }
122
-
123
- // if complete is true and browser supports natural sizes, try
124
- // to check for image status manually
125
- if (el.complete && el.naturalWidth !== undefined) {
126
- imgLoaded(el, el.naturalWidth === 0 || el.naturalHeight === 0);
127
- return;
128
- }
129
-
130
- // cached images don't fire load sometimes, so we reset src, but only when
131
- // dealing with IE, or image is complete (loaded) and failed manual check
132
- // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
133
- if (el.readyState || el.complete) {
134
- el.src = BLANK;
135
- el.src = src;
136
- }
137
- });
138
- }
139
-
140
- return deferred ? deferred.promise($this) : $this;
141
- };
142
-
143
- })(jQuery);
144
- }
145
-
146
- $.yith_magnifier = function (options, element) {
147
- this.t = element;
148
- this.element = $(element);
149
- this._init(options);
150
- };
151
-
152
- $.yith_magnifier.defaults = {
153
- zoomWidth: 'auto',
154
- zoomHeight: 'auto',
155
- position: 'right',
156
- tint: false,
157
- tintOpacity: 0.5,
158
- lensOpacity: 0.5,
159
- softFocus: false,
160
- smoothMove: 3,
161
- showTitle: true,
162
- titleOpacity: 0.5,
163
- adjustX: 0,
164
- adjustY: 0,
165
-
166
- phoneBehavior: 'inside', //allowed values: inside, disable, default
167
- loadingLabel: 'Loading...',
168
-
169
- enableSlider: true,
170
- slider: 'carouFredSel',
171
- sliderOptions: {},
172
-
173
- from_gallery : 'no',
174
-
175
- onLoad: function () {
176
- return false;
177
- },
178
- onEnter: function () {
179
- return false
180
- },
181
- onLeave: function () {
182
- return false
183
- },
184
- onMove: function () {
185
- return false
186
- },
187
- onClick: function () {
188
- return false;
189
- },
190
-
191
- elements: {
192
- zoom: $('.yith_magnifier_zoom'),
193
- zoomImage: $('.yith_magnifier_zoom img').first(),
194
- gallery: $('.yith_magnifier_gallery li a')
195
- }
196
- };
197
-
198
- $.yith_magnifier.prototype = {
199
- /**
200
- * Let's start the magnifier
201
- *
202
- * @param {Object} options
203
- *
204
- * @private
205
- */
206
- _init: function (options) {
207
- var self = this;
208
-
209
- $(document).trigger('yith_magnifier_before_init');
210
-
211
- $.each($.yith_magnifier.defaults.elements, function (i, v) {
212
- var el = $.yith_magnifier.defaults.elements;
213
- el[i] = $(v, self);
214
- });
215
- self.options = $.extend(true, {}, $.yith_magnifier.defaults, options);
216
- self.isPhone = self._isPhone();
217
-
218
- self._loading();
219
-
220
- self.element.imagesLoaded(function () {
221
- self.options.onLoad();
222
- self._initZoom();
223
- self._initGallery();
224
-
225
- });
226
-
227
-
228
-
229
- $(document).trigger('yith_magnifier_after_init');
230
- },
231
-
232
-
233
- /**
234
- * Init gallery handlers
235
- *
236
- * @private
237
- *
238
- */
239
- _initGallery: function () {
240
-
241
- var self = this;
242
- var elements = self.options.elements;
243
-
244
- var gallery = elements.gallery;
245
- var zoom = elements.zoom;
246
- var zoomImage = elements.zoomImage;
247
-
248
- if ( gallery.length > 0 ) {
249
- gallery.on('click', function (e) {
250
- e.preventDefault();
251
- e.stopImmediatePropagation();
252
-
253
- if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
254
-
255
- $( '#yith_wczm_traffic_light' ).val( 'blocked' );
256
-
257
- self.options.from_gallery = 'yes';
258
-
259
- var t = $(this);
260
- self.destroy();
261
-
262
- zoom.attr('href', this.href);
263
-
264
- zoomImage.attr('src', t.data('small'))
265
- .attr('srcset', t.data('small'))
266
- .attr('src-orig', t.data('small'))
267
- .attr('title', '')
268
- .attr('title', t.attr('title'));
269
- $.data(self.t, 'yith_magnifier', new $.yith_magnifier(self.options, self.element));
270
-
271
- $( '#yith_wczm_traffic_light' ).val( 'free' );
272
-
273
-
274
- }
275
-
276
- });
277
-
278
- //gallery.filter(':first').trigger('click');
279
-
280
- if (self.options.enableSlider) {
281
- gallery.closest('ul').trigger('yith_magnifier_slider_destroy');
282
- //gallery.closest('ul')[self.options.slider](self.options.sliderOptions);
283
- }
284
-
285
- } else {
286
- gallery.on('click', function (e) {
287
- e.preventDefault();
288
- return false;
289
- })
290
- }
291
- },
292
-
293
- /**
294
- * Show a loading icon while image isn't properly loaded
295
- *
296
- * @private
297
- */
298
- _loading: function () {
299
- if (this.options.disableRightClick) {
300
- $(document).on('contextmenu', function (e) {
301
- return false;
302
- });
303
- }
304
-
305
- if (this.mouseTrap === undefined) {
306
- var w = this.options.elements.zoom.width();
307
-
308
- if (this.options.loadingLabel) {
309
- $('<div class="yith_magnifier_loading">' + this.options.loadingLabel + '</div>').css({
310
- 'width': w,
311
- 'text-align': 'center',
312
- opacity: .5
313
- }).appendTo(this.options.elements.zoom.parent());
314
- }
315
- }
316
- },
317
-
318
- /**
319
- * Initialize the zoom images
320
- *
321
- * @private
322
- */
323
- _initZoom: function () {
324
-
325
- if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
326
-
327
- $( '#yith_wczm_traffic_light' ).val( 'blocked' );
328
-
329
- var self = this;
330
- self.zoom = self.options.elements.zoom;
331
- self.zoomImage = self.options.elements.zoomImage;
332
-
333
- var zoom_wrap_css_class = "yith_magnifier_zoom_wrap";
334
-
335
- if (self.options.zoom_wrap_additional_css) {
336
- if (!$('.' + zoom_wrap_css_class).length) {
337
-
338
- zoom_wrap_css_class += " " + self.options.zoom_wrap_additional_css;
339
- } else {
340
- return;
341
- }
342
- }
343
- self.zoom.wrap('<div class="' + zoom_wrap_css_class + '"></div>');
344
-
345
- self.IMG_zoomImage = new Image();
346
-
347
- var product_id = $( '.woocommerce-variation-add-to-cart .variation_id' ).val();
348
-
349
- if ( $.isNumeric( product_id ) && product_id != 0 && self.options.from_gallery == 'no' && yith_wc_zoom_magnifier_storage_object.zoom_condition == '1' ){
350
-
351
- var data = {
352
- action : 'yith_wc_zoom_magnifier_get_main_image',
353
- product_id : product_id,
354
- context : 'frontend'
355
- }
356
-
357
- $.ajax({
358
- data : data,
359
- url : yith_wc_zoom_magnifier_storage_object.ajax_url,
360
- type : 'post',
361
- error : function ( response ) {
362
- console.log( 'ERROR - Yith_WC_Zoom_Magnifier' );
363
- console.log( response );
364
- $( '#yith_wczm_traffic_light' ).val( 'free' );
365
- },
366
- success : function ( response ) {
367
-
368
- self.zoom.attr( 'href', response.url );
369
-
370
- self.IMG_zoomImage.src = response.url;
371
-
372
- self.IMG_smallImage = new Image();
373
- self.IMG_smallImage.src = self.zoomImage.attr('src');
374
-
375
- // set new gallery
376
- if( response.gallery ) {
377
-
378
- if ($('.yith_magnifier_gallery').length)
379
- $('.yith_magnifier_gallery').closest('.thumbnails').replaceWith( response.gallery );
380
- else
381
- $( '.images').append( response.gallery );
382
-
383
- self.options.elements.gallery = $('.yith_magnifier_gallery li a' );
384
- }
385
-
386
- if ($.browser && $.browser.msie && $.browser.version == 8) {
387
- $(self.IMG_zoomImage).load(function () {
388
-
389
- self._initGallery();
390
- self._initTrap();
391
- });
392
- } else {
393
-
394
- $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
395
- self._initGallery();
396
- self._initTrap();
397
- });
398
- }
399
-
400
- $(document).on('click', 'a.yith_expand', function (e) {
401
-
402
- e.preventDefault();
403
-
404
- $().prettyPhoto({
405
- social_tools : false,
406
- theme : 'pp_woocommerce',
407
- horizontal_padding: 20,
408
- opacity : 0.8,
409
- deeplinking : false,
410
- callback : function () {
411
- $(".yith_expand").css('display', 'inline');
412
- }
413
- });
414
-
415
- $.prettyPhoto.open(self.zoom[0].href, '', '');
416
- $(".yith_expand").css('display', 'none');
417
- $(".pp_woocommerce .ppt").css({
418
- 'height' : 0,
419
- 'marginBottom': 0
420
- });
421
-
422
-
423
- });
424
- $(document).trigger('yith_magnifier_after_init_zoom');
425
- $( '#yith_wczm_traffic_light' ).val( 'free' );
426
- }
427
- });
428
-
429
- }
430
- else{
431
-
432
- self.IMG_zoomImage.src = self.zoom.attr('href');
433
-
434
- self.IMG_smallImage = new Image();
435
- self.IMG_smallImage.src = self.zoomImage.attr('src');
436
-
437
- if ($.browser && $.browser.msie && $.browser.version == 8) {
438
- $(self.IMG_zoomImage).load(function () {
439
-
440
- self._initTrap();
441
- });
442
- } else {
443
-
444
- $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
445
-
446
- self._initTrap();
447
- });
448
- }
449
-
450
- $(document).on('click', 'a.yith_expand', function (e) {
451
-
452
- e.preventDefault();
453
-
454
- $().prettyPhoto({
455
- social_tools : false,
456
- theme : 'pp_woocommerce',
457
- horizontal_padding: 20,
458
- opacity : 0.8,
459
- deeplinking : false,
460
- callback : function () {
461
- $(".yith_expand").css('display', 'inline');
462
- }
463
- });
464
-
465
- $.prettyPhoto.open(self.zoom[0].href, '', '');
466
- $(".yith_expand").css('display', 'none');
467
- $(".pp_woocommerce .ppt").css({
468
- 'height' : 0,
469
- 'marginBottom': 0
470
- });
471
-
472
-
473
- });
474
- $(document).trigger('yith_magnifier_after_init_zoom');
475
-
476
- $( '#yith_wczm_traffic_light' ).val( 'free' );
477
-
478
- }
479
-
480
- }
481
-
482
- },
483
-
484
- /**
485
- * Create the mouse trap
486
- *
487
- * @private
488
- */
489
- _initTrap: function () {
490
-
491
- var self = this;
492
- var zoomImg = self.IMG_zoomImage,
493
- thumbImg = self.IMG_smallImage;
494
-
495
- self.mx = 0;
496
- self.my = 0;
497
- self.controlTimer = 0;
498
- self.lens = null;
499
- self.tint = null;
500
- self.softFocus = null;
501
- self.zoomDiv = null;
502
- self.cw = 0;
503
- self.ch = 0;
504
- self.zw = 0;
505
- self.destU = 0;
506
- self.destV = 0;
507
- self.currU = 0;
508
- self.currV = 0;
509
- self.mouseTrap = null;
510
-
511
- var zoom = self.options.elements.zoom;
512
- var zoomImage = self.options.elements.zoomImage;
513
-
514
- //remove loading div
515
- //this.zoom.parent().siblings('.yith_magnifier_loading').remove();
516
- $('.yith_magnifier_loading').remove();
517
-
518
- if (this.element.find('.yith_magnifier_mousetrap')) {
519
- this.element.find('.yith_magnifier_mousetrap').remove();
520
- }
521
-
522
- this.mouseTrap = $('<div class="yith_magnifier_mousetrap pp_woocommerce" />').css({
523
- width : '100%', //zoomImage.outerWidth(),
524
- height: '100%', //zoomImage.outerHeight(),
525
- top : 0,
526
- left : 0
527
- }).appendTo(zoom.parent());
528
-
529
- if( typeof ywzm_data != 'undefined' ) {
530
- $('<a href="#" class="yith_expand" title="' + ywzm_data.expand_label + '" style="display: inline;">Expand</a>').appendTo(this.mouseTrap);
531
- }
532
-
533
- if (self.isPhone && self.options.phoneBehavior == 'disable') {
534
- return;
535
- }
536
-
537
- // Detect device type, normal mouse or touchy(ipad android) by albanx
538
- var touchy = ("ontouchstart" in document.documentElement) ? true : false;
539
- var event_move = 'touchmove mousemove';
540
- var event_end = 'touchend mouseleave';
541
- var event_ent = 'touchstart mouseenter';
542
- var event_click = 'touchstart click';
543
-
544
- this.mouseTrap.on(event_move, this, function (e) {
545
-
546
- self.options.onMove();
547
-
548
- self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
549
- self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
550
-
551
- }).on(event_end, this, function (e) {
552
-
553
- clearTimeout(self.controlTimer);
554
- //event.data.removeBits();
555
- if (self.lens) {
556
- self.lens.fadeOut(299);
557
- }
558
- if (self.tint) {
559
- self.tint.fadeOut(299);
560
- }
561
- if (self.softFocus) {
562
- self.softFocus.fadeOut(299);
563
- }
564
- self.zoomDiv.fadeOut(300, function () {
565
- self._onLeave();
566
- });
567
-
568
- return false;
569
-
570
- }).on(event_click, this, function (e) {
571
- self.options.onClick();
572
- }).on(event_ent, this, function (e) {
573
-
574
- if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
575
-
576
- self.options.onEnter();
577
-
578
- if (touchy) {
579
- e.preventDefault();
580
- }
581
-
582
- self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
583
- self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
584
-
585
- self.zw = e.data;
586
- if (self.zoomDiv) {
587
- self.zoomDiv.stop(true, false);
588
- self.zoomDiv.remove();
589
- }
590
-
591
- var xPos = self.options.adjustX,
592
- yPos = self.options.adjustY;
593
-
594
- var siw = zoomImage.outerWidth();
595
- var sih = zoomImage.outerHeight();
596
-
597
- var w = self.options.zoomWidth;
598
- var h = self.options.zoomHeight;
599
-
600
- if (self.options.zoomWidth == 'auto') {
601
- w = siw;
602
- }
603
-
604
- if (self.options.zoomHeight == 'auto') {
605
- h = sih;
606
- }
607
-
608
- var appendTo = zoom.parent();
609
- switch (self.options.position) {
610
- case 'top':
611
- yPos -= h;
612
- break;
613
- case 'right':
614
- xPos += siw;
615
- break;
616
- case 'bottom':
617
- yPos += sih;
618
- break;
619
- case 'left':
620
- xPos -= w;
621
- break;
622
- case 'inside':
623
- w = siw;
624
- h = sih;
625
- break;
626
-
627
- // All other values, try and find an id in the dom to attach to.
628
- default:
629
- appendTo = $('#' + self.options.position);
630
- // If dom element doesn't exit, just use 'right' position as default.
631
- if (!appendTo.length) {
632
- appendTo = zoom;
633
- xPos += siw; //+ opts.adjustX;
634
- yPos += sih; // + opts.adjustY;
635
- } else {
636
- w = appendTo.innerWidth();
637
- h = appendTo.innerHeight();
638
- }
639
- }
640
-
641
- if (self.isPhone && self.options.phoneBehavior == 'inside') {
642
- w = siw;
643
- h = sih;
644
- xPos = 0;
645
- yPos = 0;
646
- }
647
-
648
- self.zoomDiv = $('<div class="yith_magnifier_zoom_magnifier" />').css({
649
- left : xPos,
650
- top : yPos,
651
- width : w,
652
- height : h,
653
- 'background-repeat': 'no-repeat',
654
- backgroundImage : 'url(' + zoomImg.src + ')'
655
- }).appendTo(appendTo);
656
-
657
-
658
- // Add the title from title tag.
659
- if (zoomImage.attr('title') && self.options.showTitle) {
660
- $('<div class="yith_magnifier_title">' + zoomImage.attr('title') + '</div>').appendTo(self.zoomDiv);
661
- }
662
-
663
- if (self.isPhone) {
664
- if (self.options.phoneBehavior != 'disable') {
665
- self.zoomDiv.fadeIn(500);
666
- } else {
667
- self.lens.fadeOut(299);
668
- }
669
- } else {
670
- self.zoomDiv.fadeIn(500);
671
- }
672
-
673
- if (self.lens) {
674
- self.lens.remove();
675
- self.lens = null;
676
- }
677
-
678
- if (zoomImg.width <= 1) {
679
- self.cw = (zoomImage.outerWidth() / zoomImg.naturalWidth) * self.zoomDiv.width();
680
- } else {
681
- self.cw = (zoomImage.outerWidth() / zoomImg.width) * self.zoomDiv.width();
682
- }
683
-
684
- if (zoomImg.height <= 1) {
685
- self.ch = (zoomImage.outerHeight() / zoomImg.naturalHeight) * self.zoomDiv.height();
686
- } else {
687
- self.ch = (zoomImage.outerHeight() / zoomImg.height) * self.zoomDiv.height();
688
- }
689
-
690
- // Attach mouse, initially invisible to prevent first frame glitch
691
- self.lens = $('<div class="yith_magnifier_lens" />').css({
692
- width : self.cw,
693
- height: self.ch
694
- }).appendTo(zoom);
695
-
696
- self.mouseTrap.css('cursor', self.lens.css('cursor'));
697
-
698
- var noTrans = false;
699
-
700
-
701
- // Init tint layer if needed. (Not relevant if using inside mode)
702
- if (self.options.tint) {
703
- //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
704
- self.tint = $('<div />').css({
705
- display : 'none',
706
- position : 'absolute',
707
- left : 0,
708
- top : 0,
709
- width : zoomImage.outerWidth(),
710
- height : zoomImage.outerHeight(),
711
- backgroundColor: self.options.tint,
712
- opacity : self.options.tintOpacity
713
- }).appendTo(zoom);
714
-
715
-
716
- self.lens.append($('<img />', {
717
- src: zoomImage.attr('src')
718
- }));
719
-
720
- noTrans = true;
721
- self.tint.fadeIn(500);
722
- }
723
-
724
- if (self.options.softFocus) {
725
- //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
726
- self.softFocus = $('<div />').css({
727
- position: 'absolute',
728
- display : 'none',
729
- top : '1px',
730
- left : '1px',
731
- width : zoomImage.outerWidth(),
732
- height : zoomImage.outerHeight(),
733
- //background: 'url("' + zoomImage.attr('src') + '")',
734
- //backgroundSize: '100%',
735
- opacity : .5
736
- }).appendTo(zoom);
737
-
738
- self.softFocus.append($('<img />', {
739
- src: zoomImage.attr('src')
740
- }));
741
-
742
- if (self.lens.find('img').length == 0) {
743
- self.lens.append($('<img />', {
744
- src: zoomImage.attr('src')
745
- }));
746
- }
747
-
748
- noTrans = true;
749
- self.softFocus.fadeIn(500);
750
- }
751
-
752
-
753
- if (!noTrans) {
754
- self.lens.css('opacity', self.options.lensOpacity);
755
- }
756
- if (self.options.position !== 'inside') {
757
- self.lens.fadeIn(500);
758
- }
759
-
760
- // Start processing.
761
- self.zw._controlLoop();
762
-
763
- return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
764
-
765
- }
766
-
767
- });
768
-
769
- },
770
-
771
- /**
772
- *
773
- *
774
- * @private
775
- */
776
- _controlLoop: function () {
777
- var self = this;
778
-
779
- if (this.lens) {
780
- var x = (this.mx - this.zoomImage.offset().left - (this.cw * 0.5)) >> 0;
781
- var y = (this.my - this.zoomImage.offset().top - (this.ch * 0.5)) >> 0;
782
-
783
- if (x < 0) {
784
- x = 0;
785
- } else if (x > (this.zoomImage.outerWidth() - this.cw)) {
786
- x = (this.zoomImage.outerWidth() - this.cw);
787
- }
788
-
789
- if (y < 0) {
790
- y = 0;
791
- } else if (y > (this.zoomImage.outerHeight() - this.ch)) {
792
- y = (this.zoomImage.outerHeight() - this.ch);
793
- }
794
-
795
- this.lens.css({
796
- left: x - 2,
797
- top: y - 1
798
- });
799
-
800
- //this.lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
801
-
802
-
803
- this.lens.find('img').css({
804
- width: this.zoomImage.outerWidth(),
805
- height: this.zoomImage.outerHeight(),
806
- marginLeft: (-x) + 'px ',
807
- marginTop: (-y) + 'px'
808
- });
809
-
810
-
811
- if (this.IMG_zoomImage.width <= 1) {
812
- this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.naturalWidth) >> 0;
813
- } else {
814
- this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.width) >> 0;
815
- }
816
-
817
- if (this.IMG_zoomImage.height <= 1) {
818
- this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.naturalHeight) >> 0;
819
- } else {
820
- this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.height) >> 0;
821
- }
822
-
823
-
824
- this.currU += (this.destU - this.currU) / this.options.smoothMove;
825
- this.currV += (this.destV - this.currV) / this.options.smoothMove;
826
-
827
- this.zoomDiv.css('background-position', (-(this.currU >> 0) + 'px ') + (-(this.currV >> 0) + 'px'));
828
- }
829
-
830
- this.controlTimer = setTimeout(function () {
831
- self._controlLoop();
832
- }, 30);
833
- },
834
-
835
- /**
836
- * This method is called when the mouse leave the image
837
- *
838
- * @private
839
- */
840
- _onLeave: function () {
841
- this.options.onLeave();
842
-
843
- if (this.zoomDiv) {
844
- this.zoomDiv.remove();
845
- this.zoomDiv = null;
846
- }
847
-
848
- this._removeElements();
849
- },
850
-
851
- /**
852
- * Remove lens, tint and softfocus
853
- *
854
- * @private
855
- */
856
- _removeElements: function () {
857
- if (this.lens) {
858
- this.lens.remove();
859
- this.lens = null;
860
- }
861
-
862
- if (this.tint) {
863
- this.tint.remove();
864
- this.tint = null;
865
- }
866
-
867
- if (this.softFocus) {
868
- this.softFocus.remove();
869
- this.softFocus = null;
870
- }
871
-
872
- if (this.element.find('.yith_magnifier_loading').length > 0) {
873
- this.element.find('.yith_magnifier_loading').remove();
874
- }
875
- },
876
-
877
- /**
878
- * Detect if user is using a phone device (eg iPhone)
879
- *
880
- * @private
881
- */
882
- _isPhone: function () {
883
- var userAgent = navigator.userAgent.toLowerCase();
884
-
885
- return ( userAgent.match(/iphone/i) || userAgent.match(/ipod/i) || userAgent.match(/android/i) );
886
- },
887
-
888
- /**
889
- * Destroy the instance
890
- *
891
- */
892
- destroy: function () {
893
- if (this.zoom) {
894
- this.zoom.unwrap();
895
- }
896
-
897
- if (this.mouseTrap) {
898
- this.mouseTrap.unbind();
899
- this.mouseTrap.remove();
900
- this.mouseTrap = null;
901
- }
902
-
903
- if (this.zoomDiv) {
904
- this.zoomDiv.remove();
905
- this.zoomDiv = null;
906
- }
907
-
908
- if (this.options.disableRightClick) {
909
- $(document).unbind();
910
- }
911
-
912
- this._removeElements();
913
- this.options.elements.gallery.unbind();
914
- this.element.removeData('yith_magnifier');
915
- }
916
- };
917
-
918
- $.fn.yith_magnifier = function (options) {
919
-
920
- if (typeof options === 'string') {
921
- var args = Array.prototype.slice.call(arguments, 1);
922
-
923
- this.each(function () {
924
- var instance = $.data(this, 'yith_magnifier');
925
- if (!instance) {
926
- $.error("cannot call methods on yith_magnifier prior to initialization; " +
927
- "attempted to call method '" + options + "'");
928
- return;
929
- }
930
- if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
931
- $.error("no such method '" + options + "' for yith_magnifier instance");
932
- return;
933
- }
934
- instance[options].apply(instance, args);
935
- });
936
- } else {
937
- this.each(function () {
938
- var instance = $.data(this, 'yith_magnifier');
939
- if (!instance) {
940
- $.data(this, 'yith_magnifier', new $.yith_magnifier(options, this));
941
- } else {
942
- $.error('yith_magnifier already istantiated.');
943
- }
944
- });
945
- }
946
- return this;
947
- };
948
-
949
-
950
- })(window, jQuery);
1
+ /**
2
+ * YITH Magnifier
3
+ *
4
+ * @version 0.1
5
+ * @author Your Inspiration Themes Team <info@yithemes.com>
6
+ *
7
+ * MIT License.
8
+ */
9
+
10
+ ;
11
+ (function (window, $, undefined) {
12
+ 'use strict';
13
+
14
+ //include imagesLoaded plugin
15
+ if ($.fn.imagesLoaded === undefined) {
16
+ /*!
17
+ * jQuery imagesLoaded plugin v2.1.1
18
+ * http://github.com/desandro/imagesloaded
19
+ *
20
+ * MIT License. by Paul Irish et al.
21
+ */
22
+
23
+ /*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
24
+ /*global jQuery: false */
25
+
26
+ ;
27
+ (function ($, undefined) {
28
+ 'use strict';
29
+
30
+ // blank image data-uri bypasses webkit log warning (thx doug jones)
31
+ var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
32
+
33
+ $.fn.imagesLoaded = function (callback) {
34
+ var $this = this,
35
+ deferred = $.isFunction($.Deferred) ? $.Deferred() : 0,
36
+ hasNotify = $.isFunction(deferred.notify),
37
+ $images = $this.find('img').add($this.filter('img')),
38
+ loaded = [],
39
+ proper = [],
40
+ broken = [];
41
+
42
+ // Register deferred callbacks
43
+ if ($.isPlainObject(callback)) {
44
+ $.each(callback, function (key, value) {
45
+ if (key === 'callback') {
46
+ callback = value;
47
+ } else if (deferred) {
48
+ deferred[key](value);
49
+ }
50
+ });
51
+ }
52
+
53
+ function doneLoading() {
54
+ var $proper = $(proper),
55
+ $broken = $(broken);
56
+
57
+ if (deferred) {
58
+ if (broken.length) {
59
+ deferred.reject($images, $proper, $broken);
60
+ } else {
61
+ deferred.resolve($images);
62
+ }
63
+ }
64
+
65
+ if ($.isFunction(callback)) {
66
+ callback.call($this, $images, $proper, $broken);
67
+ }
68
+ }
69
+
70
+ function imgLoadedHandler(event) {
71
+ imgLoaded(event.target, event.type === 'error');
72
+ }
73
+
74
+ function imgLoaded(img, isBroken) {
75
+ // don't proceed if BLANK image, or image is already loaded
76
+ if (img.src === BLANK || $.inArray(img, loaded) !== -1) {
77
+ return;
78
+ }
79
+
80
+ // store element in loaded images array
81
+ loaded.push(img);
82
+
83
+ // keep track of broken and properly loaded images
84
+ if (isBroken) {
85
+ broken.push(img);
86
+ } else {
87
+ proper.push(img);
88
+ }
89
+
90
+ // cache image and its state for future calls
91
+ $.data(img, 'imagesLoaded', {isBroken: isBroken, src: img.src});
92
+
93
+ // trigger deferred progress method if present
94
+ if (hasNotify) {
95
+ deferred.notifyWith($(img), [isBroken, $images, $(proper), $(broken)]);
96
+ }
97
+
98
+ // call doneLoading and clean listeners if all images are loaded
99
+ if ($images.length === loaded.length) {
100
+ setTimeout(doneLoading);
101
+ $images.unbind('.imagesLoaded', imgLoadedHandler);
102
+ }
103
+ }
104
+
105
+ // if no images, trigger immediately
106
+ if (!$images.length) {
107
+ doneLoading();
108
+ } else {
109
+ $images.bind('load.imagesLoaded error.imagesLoaded', imgLoadedHandler)
110
+ .each(function (i, el) {
111
+ var src = el.src;
112
+
113
+ // find out if this image has been already checked for status
114
+ // if it was, and src has not changed, call imgLoaded on it
115
+ var cached = $.data(el, 'imagesLoaded');
116
+ if (cached && cached.src === src) {
117
+ imgLoaded(el, cached.isBroken);
118
+ return;
119
+ }
120
+
121
+ // if complete is true and browser supports natural sizes, try
122
+ // to check for image status manually
123
+ if (el.complete && el.naturalWidth !== undefined) {
124
+ imgLoaded(el, el.naturalWidth === 0 || el.naturalHeight === 0);
125
+ return;
126
+ }
127
+
128
+ // cached images don't fire load sometimes, so we reset src, but only when
129
+ // dealing with IE, or image is complete (loaded) and failed manual check
130
+ // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
131
+ if (el.readyState || el.complete) {
132
+ el.src = BLANK;
133
+ el.src = src;
134
+ }
135
+ });
136
+ }
137
+
138
+ return deferred ? deferred.promise($this) : $this;
139
+ };
140
+
141
+ })(jQuery);
142
+ }
143
+
144
+ $.yith_magnifier = function (options, element) {
145
+ this.t = element;
146
+ this.element = $(element);
147
+ this._init(options);
148
+ };
149
+
150
+ $.yith_magnifier.defaults = {
151
+ zoomWidth: 'auto',
152
+ zoomHeight: 'auto',
153
+ position: 'right',
154
+ tint: false,
155
+ tintOpacity: 0.5,
156
+ lensOpacity: 0.5,
157
+ softFocus: false,
158
+ smoothMove: 3,
159
+ showTitle: true,
160
+ titleOpacity: 0.5,
161
+ adjustX: 0,
162
+ adjustY: 0,
163
+
164
+ phoneBehavior: 'inside', //allowed values: inside, disable, default
165
+ loadingLabel: 'Loading...',
166
+
167
+ enableSlider: true,
168
+ slider: 'carouFredSel',
169
+ sliderOptions: {},
170
+
171
+ from_gallery : 'no',
172
+
173
+ onLoad: function () {
174
+ return false;
175
+ },
176
+ onEnter: function () {
177
+ return false
178
+ },
179
+ onLeave: function () {
180
+ return false
181
+ },
182
+ onMove: function () {
183
+ return false
184
+ },
185
+ onClick: function () {
186
+ return false;
187
+ },
188
+
189
+ elements: {
190
+ zoom: $('.yith_magnifier_zoom'),
191
+ zoomImage: $('.yith_magnifier_zoom img').first(),
192
+ gallery: $('.yith_magnifier_gallery li a')
193
+ }
194
+ };
195
+
196
+ $.yith_magnifier.prototype = {
197
+ /**
198
+ * Let's start the magnifier
199
+ *
200
+ * @param {Object} options
201
+ *
202
+ * @private
203
+ */
204
+ _init: function (options) {
205
+ var self = this;
206
+
207
+ $(document).trigger('yith_magnifier_before_init');
208
+
209
+ $.each($.yith_magnifier.defaults.elements, function (i, v) {
210
+ var el = $.yith_magnifier.defaults.elements;
211
+ el[i] = $(v, self);
212
+ });
213
+ self.options = $.extend(true, {}, $.yith_magnifier.defaults, options);
214
+ self.isPhone = self._isPhone();
215
+
216
+ self._loading();
217
+
218
+ self.element.imagesLoaded(function () {
219
+ self.options.onLoad();
220
+ self._initZoom();
221
+ self._initGallery();
222
+ });
223
+
224
+ $(document).trigger('yith_magnifier_after_init');
225
+ },
226
+
227
+
228
+ /**
229
+ * Init gallery handlers
230
+ *
231
+ * @private
232
+ *
233
+ */
234
+ _initGallery: function () {
235
+ var self = this;
236
+ var elements = self.options.elements;
237
+
238
+ var gallery = elements.gallery;
239
+ var zoom = elements.zoom;
240
+ var zoomImage = elements.zoomImage;
241
+
242
+ if (gallery.length > 0) {
243
+ gallery.on('click', function (e) {
244
+ e.preventDefault();
245
+
246
+ self.options.from_gallery = 'yes';
247
+
248
+ var t = $(this);
249
+ self.destroy();
250
+
251
+ zoom.attr('href', this.href);
252
+ zoomImage.attr('src', t.data('small'))
253
+ .attr('srcset', t.data('small'))
254
+ .attr('src-orig', t.data('small'))
255
+ .attr('title', '')
256
+ .attr('title', t.attr('title'));
257
+
258
+ $.data(self.t, 'yith_magnifier', new $.yith_magnifier(self.options, self.element));
259
+ });
260
+
261
+ //gallery.filter(':first').trigger('click');
262
+
263
+ if (self.options.enableSlider) {
264
+ gallery.closest('ul').trigger('yith_magnifier_slider_destroy');
265
+ gallery.closest('ul')[self.options.slider](self.options.sliderOptions);
266
+ }
267
+
268
+ } else {
269
+ gallery.on('click', function (e) {
270
+ e.preventDefault();
271
+ return false;
272
+ })
273
+ }
274
+ },
275
+
276
+ /**
277
+ * Show a loading icon while image isn't properly loaded
278
+ *
279
+ * @private
280
+ */
281
+ _loading: function () {
282
+ if (this.options.disableRightClick) {
283
+ $(document).on('contextmenu', function (e) {
284
+ return false;
285
+ });
286
+ }
287
+
288
+ if (this.mouseTrap === undefined) {
289
+ var w = this.options.elements.zoom.width();
290
+
291
+ if (this.options.loadingLabel) {
292
+ $('<div class="yith_magnifier_loading">' + this.options.loadingLabel + '</div>').css({
293
+ 'width': w,
294
+ 'text-align': 'center',
295
+ opacity: .5
296
+ }).appendTo(this.options.elements.zoom.parent());
297
+ }
298
+ }
299
+ },
300
+
301
+ /**
302
+ * Initialize the zoom images
303
+ *
304
+ * @private
305
+ */
306
+ _initZoom: function () {
307
+ var self = this;
308
+
309
+ self.zoom = self.options.elements.zoom;
310
+ self.zoomImage = self.options.elements.zoomImage;
311
+
312
+ //wrap the zoom image with a div
313
+ var zoom_wrap_css_class = "yith_magnifier_zoom_wrap";
314
+
315
+
316
+ if (self.options.zoom_wrap_additional_css) {
317
+ if ( !$('.' + zoom_wrap_css_class).length ) {
318
+
319
+ zoom_wrap_css_class += " " + self.options.zoom_wrap_additional_css;
320
+ }
321
+ }
322
+
323
+ self.zoom.wrap('<div class="' + zoom_wrap_css_class + '"></div>');
324
+
325
+ self.IMG_zoomImage = new Image();
326
+
327
+ var product_id = $( '.woocommerce-variation-add-to-cart .variation_id' ).val();
328
+ if ( $.isNumeric( product_id ) && product_id != 0 && self.options.from_gallery == 'no' ){
329
+
330
+ var data = {
331
+ action : 'yith_wc_zoom_magnifier_get_main_image',
332
+ product_id : product_id,
333
+ context : 'frontend'
334
+ }
335
+
336
+ $.ajax({
337
+ data : data,
338
+ url : yith_wc_zoom_magnifier_storage_object.ajax_url,
339
+ type : 'post',
340
+ error : function ( response ) {
341
+ console.log( 'ERROR - Yith_WC_Zoom_Magnifier' );
342
+ console.log( response );
343
+ },
344
+ success : function ( response ) {
345
+ self.IMG_zoomImage.src = response.url;
346
+
347
+ self.IMG_smallImage = new Image();
348
+ self.IMG_smallImage.src = self.zoomImage.attr('src');
349
+
350
+ // set new gallery
351
+ if( response.gallery ) {
352
+
353
+ if ($('.yith_magnifier_gallery').length)
354
+ $('.yith_magnifier_gallery').closest('.thumbnails').replaceWith( response.gallery );
355
+ else
356
+ $( '.images').append( response.gallery );
357
+
358
+ self.options.elements.gallery = $('.yith_magnifier_gallery li a' );
359
+ }
360
+
361
+ if ($.browser && $.browser.msie && $.browser.version == 8) {
362
+ $(self.IMG_zoomImage).load(function () {
363
+ self._initGallery();
364
+ self._initTrap();
365
+ });
366
+ } else {
367
+
368
+ $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
369
+ self._initGallery();
370
+ self._initTrap();
371
+ });
372
+ }
373
+
374
+ $(document).trigger('yith_magnifier_after_init_zoom');
375
+
376
+ }
377
+ });
378
+
379
+ }
380
+ else{
381
+ self.IMG_zoomImage.src = self.zoom.attr('href');
382
+
383
+ self.IMG_smallImage = new Image();
384
+ self.IMG_smallImage.src = self.zoomImage.attr('src');
385
+
386
+ if ($.browser && $.browser.msie && $.browser.version == 8) {
387
+ $(self.IMG_zoomImage).load(function () {
388
+
389
+ self._initTrap();
390
+ });
391
+ } else {
392
+
393
+ $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
394
+
395
+ self._initTrap();
396
+ });
397
+ }
398
+
399
+ $(document).trigger('yith_magnifier_after_init_zoom')
400
+
401
+ }
402
+
403
+ },
404
+
405
+ /**
406
+ * Create the mouse trap
407
+ *
408
+ * @private
409
+ */
410
+ _initTrap: function () {
411
+ var self = this;
412
+ var zoomImg = self.IMG_zoomImage,
413
+ thumbImg = self.IMG_smallImage;
414
+
415
+ self.mx = 0;
416
+ self.my = 0;
417
+ self.controlTimer = 0;
418
+ self.lens = null;
419
+ self.tint = null;
420
+ self.softFocus = null;
421
+ self.zoomDiv = null;
422
+ self.cw = 0;
423
+ self.ch = 0;
424
+ self.zw = 0;
425
+ self.destU = 0;
426
+ self.destV = 0;
427
+ self.currU = 0;
428
+ self.currV = 0;
429
+ self.mouseTrap = null;
430
+
431
+ var zoom = self.options.elements.zoom;
432
+ var zoomImage = self.options.elements.zoomImage;
433
+
434
+ //remove loading div
435
+ //this.zoom.parent().siblings('.yith_magnifier_loading').remove();
436
+ $('.yith_magnifier_loading').remove();
437
+
438
+ if (this.element.find('.yith_magnifier_mousetrap')) {
439
+ this.element.find('.yith_magnifier_mousetrap').remove();
440
+ }
441
+
442
+ this.mouseTrap = $('<div class="yith_magnifier_mousetrap" />').css({
443
+ width: '100%', //zoomImage.outerWidth(),
444
+ height: '100%', //zoomImage.outerHeight(),
445
+ top: 0,
446
+ left: 0
447
+ }).appendTo(zoom.parent());
448
+
449
+ // Detect device type, normal mouse or touchy(ipad android) by albanx
450
+ var touchy = ("ontouchstart" in document.documentElement) ? true : false;
451
+ var event_move = 'touchmove mousemove';
452
+ var event_end = 'touchend mouseleave';
453
+ var event_ent = 'touchstart mouseenter';
454
+ var event_click = 'touchstart click';
455
+
456
+ this.mouseTrap.on(event_move, this, function (e) {
457
+ self.options.onMove();
458
+
459
+ self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
460
+ self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
461
+
462
+ }).on(event_end, this, function (e) {
463
+
464
+ clearTimeout(self.controlTimer);
465
+ //event.data.removeBits();
466
+ if (self.lens) {
467
+ self.lens.fadeOut(299);
468
+ }
469
+ if (self.tint) {
470
+ self.tint.fadeOut(299);
471
+ }
472
+ if (self.softFocus) {
473
+ self.softFocus.fadeOut(299);
474
+ }
475
+ self.zoomDiv.fadeOut(300, function () {
476
+ self._onLeave();
477
+ });
478
+
479
+ return false;
480
+
481
+ }).on(event_click, this, function (e) {
482
+ self.options.onClick();
483
+ }).on(event_ent, this, function (e) {
484
+ self.options.onEnter();
485
+
486
+ if (touchy) {
487
+ e.preventDefault();
488
+ }
489
+
490
+ self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
491
+ self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
492
+
493
+ self.zw = e.data;
494
+ if (self.zoomDiv) {
495
+ self.zoomDiv.stop(true, false);
496
+ self.zoomDiv.remove();
497
+ }
498
+
499
+ var xPos = self.options.adjustX,
500
+ yPos = self.options.adjustY;
501
+
502
+ var siw = zoomImage.outerWidth();
503
+ var sih = zoomImage.outerHeight();
504
+
505
+ var w = self.options.zoomWidth;
506
+ var h = self.options.zoomHeight;
507
+
508
+ if (self.options.zoomWidth == 'auto') {
509
+ w = siw;
510
+ }
511
+
512
+ if (self.options.zoomHeight == 'auto') {
513
+ h = sih;
514
+ }
515
+
516
+ var appendTo = zoom.parent();
517
+ switch (self.options.position) {
518
+ case 'top':
519
+ yPos -= h;
520
+ break;
521
+ case 'right':
522
+ xPos += siw;
523
+ break;
524
+ case 'bottom':
525
+ yPos += sih;
526
+ break;
527
+ case 'left':
528
+ xPos -= w;
529
+ break;
530
+ case 'inside':
531
+ w = siw;
532
+ h = sih;
533
+ break;
534
+
535
+ // All other values, try and find an id in the dom to attach to.
536
+ default:
537
+ appendTo = $('#' + self.options.position);
538
+ // If dom element doesn't exit, just use 'right' position as default.
539
+ if (!appendTo.length) {
540
+ appendTo = zoom;
541
+ xPos += siw; //+ opts.adjustX;
542
+ yPos += sih; // + opts.adjustY;
543
+ } else {
544
+ w = appendTo.innerWidth();
545
+ h = appendTo.innerHeight();
546
+ }
547
+ }
548
+
549
+ if (self.isPhone && self.options.phoneBehavior == 'inside') {
550
+ w = siw;
551
+ h = sih;
552
+ xPos = 0;
553
+ yPos = 0;
554
+ }
555
+
556
+ self.zoomDiv = $('<div class="yith_magnifier_zoom_magnifier" />').css({
557
+ left: xPos,
558
+ top: yPos,
559
+ width: w,
560
+ height: h,
561
+ 'background-repeat': 'no-repeat',
562
+ backgroundImage: 'url(' + zoomImg.src + ')'
563
+ }).appendTo(appendTo);
564
+
565
+ // Add the title from title tag.
566
+ if (zoomImage.attr('title') && self.options.showTitle) {
567
+ $('<div class="yith_magnifier_title">' + zoomImage.attr('title') + '</div>').appendTo(self.zoomDiv);
568
+ }
569
+
570
+ if (self.isPhone) {
571
+ if (self.options.phoneBehavior != 'disable') {
572
+ self.zoomDiv.fadeIn(500);
573
+ } else {
574
+ self.lens.fadeOut(299);
575
+ }
576
+ } else {
577
+ self.zoomDiv.fadeIn(500);
578
+ }
579
+
580
+ if (self.lens) {
581
+ self.lens.remove();
582
+ self.lens = null;
583
+ }
584
+
585
+ if (zoomImg.width <= 1) {
586
+ self.cw = (zoomImage.outerWidth() / zoomImg.naturalWidth) * self.zoomDiv.width();
587
+ } else {
588
+ self.cw = (zoomImage.outerWidth() / zoomImg.width) * self.zoomDiv.width();
589
+ }
590
+
591
+ if (zoomImg.height <= 1) {
592
+ self.ch = (zoomImage.outerHeight() / zoomImg.naturalHeight) * self.zoomDiv.height();
593
+ } else {
594
+ self.ch = (zoomImage.outerHeight() / zoomImg.height) * self.zoomDiv.height();
595
+ }
596
+
597
+ // Attach mouse, initially invisible to prevent first frame glitch
598
+ self.lens = $('<div class="yith_magnifier_lens" />').css({
599
+ width: self.cw,
600
+ height: self.ch
601
+ }).appendTo(zoom);
602
+
603
+ self.mouseTrap.css('cursor', self.lens.css('cursor'));
604
+
605
+ var noTrans = false;
606
+
607
+
608
+ // Init tint layer if needed. (Not relevant if using inside mode)
609
+ if (self.options.tint) {
610
+ //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
611
+ self.tint = $('<div />').css({
612
+ display: 'none',
613
+ position: 'absolute',
614
+ left: 0,
615
+ top: 0,
616
+ width: zoomImage.outerWidth(),
617
+ height: zoomImage.outerHeight(),
618
+ backgroundColor: self.options.tint,
619
+ opacity: self.options.tintOpacity
620
+ }).appendTo(zoom);
621
+
622
+
623
+ self.lens.append($('<img />', {
624
+ src: zoomImage.attr('src')
625
+ }));
626
+
627
+ noTrans = true;
628
+ self.tint.fadeIn(500);
629
+ }
630
+
631
+ if (self.options.softFocus) {
632
+ //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
633
+ self.softFocus = $('<div />').css({
634
+ position: 'absolute',
635
+ display: 'none',
636
+ top: '1px',
637
+ left: '1px',
638
+ width: zoomImage.outerWidth(),
639
+ height: zoomImage.outerHeight(),
640
+ //background: 'url("' + zoomImage.attr('src') + '")',
641
+ //backgroundSize: '100%',
642
+ opacity: .5
643
+ }).appendTo(zoom);
644
+
645
+ self.softFocus.append($('<img />', {
646
+ src: zoomImage.attr('src')
647
+ }));
648
+
649
+ if (self.lens.find('img').length == 0) {
650
+ self.lens.append($('<img />', {
651
+ src: zoomImage.attr('src')
652
+ }));
653
+ }
654
+
655
+ noTrans = true;
656
+ self.softFocus.fadeIn(500);
657
+ }
658
+
659
+
660
+ if (!noTrans) {
661
+ self.lens.css('opacity', self.options.lensOpacity);
662
+ }
663
+ if (self.options.position !== 'inside') {
664
+ self.lens.fadeIn(500);
665
+ }
666
+
667
+ // Start processing.
668
+ self.zw._controlLoop();
669
+
670
+ return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
671
+ });
672
+ },
673
+
674
+ /**
675
+ *
676
+ *
677
+ * @private
678
+ */
679
+ _controlLoop: function () {
680
+ var self = this;
681
+
682
+ if (this.lens) {
683
+ var x = (this.mx - this.zoomImage.offset().left - (this.cw * 0.5)) >> 0;
684
+ var y = (this.my - this.zoomImage.offset().top - (this.ch * 0.5)) >> 0;
685
+
686
+ if (x < 0) {
687
+ x = 0;
688
+ } else if (x > (this.zoomImage.outerWidth() - this.cw)) {
689
+ x = (this.zoomImage.outerWidth() - this.cw);
690
+ }
691
+
692
+ if (y < 0) {
693
+ y = 0;
694
+ } else if (y > (this.zoomImage.outerHeight() - this.ch)) {
695
+ y = (this.zoomImage.outerHeight() - this.ch);
696
+ }
697
+
698
+ this.lens.css({
699
+ left: x - 2,
700
+ top: y - 1
701
+ });
702
+
703
+ //this.lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
704
+
705
+
706
+ this.lens.find('img').css({
707
+ width: this.zoomImage.outerWidth(),
708
+ height: this.zoomImage.outerHeight(),
709
+ marginLeft: (-x) + 'px ',
710
+ marginTop: (-y) + 'px'
711
+ });
712
+
713
+
714
+ if (this.IMG_zoomImage.width <= 1) {
715
+ this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.naturalWidth) >> 0;
716
+ } else {
717
+ this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.width) >> 0;
718
+ }
719
+
720
+ if (this.IMG_zoomImage.height <= 1) {
721
+ this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.naturalHeight) >> 0;
722
+ } else {
723
+ this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.height) >> 0;
724
+ }
725
+
726
+
727
+ this.currU += (this.destU - this.currU) / this.options.smoothMove;
728
+ this.currV += (this.destV - this.currV) / this.options.smoothMove;
729
+
730
+ this.zoomDiv.css('background-position', (-(this.currU >> 0) + 'px ') + (-(this.currV >> 0) + 'px'));
731
+ }
732
+
733
+ this.controlTimer = setTimeout(function () {
734
+ self._controlLoop();
735
+ }, 30);
736
+ },
737
+
738
+ /**
739
+ * This method is called when the mouse leave the image
740
+ *
741
+ * @private
742
+ */
743
+ _onLeave: function () {
744
+ this.options.onLeave();
745
+
746
+ if (this.zoomDiv) {
747
+ this.zoomDiv.remove();
748
+ this.zoomDiv = null;
749
+ }
750
+
751
+ this._removeElements();
752
+ },
753
+
754
+ /**
755
+ * Remove lens, tint and softfocus
756
+ *
757
+ * @private
758
+ */
759
+ _removeElements: function () {
760
+ if (this.lens) {
761
+ this.lens.remove();
762
+ this.lens = null;
763
+ }
764
+
765
+ if (this.tint) {
766
+ this.tint.remove();
767
+ this.tint = null;
768
+ }
769
+
770
+ if (this.softFocus) {
771
+ this.softFocus.remove();
772
+ this.softFocus = null;
773
+ }
774
+
775
+ if (this.element.find('.yith_magnifier_loading').length > 0) {
776
+ this.element.find('.yith_magnifier_loading').remove();
777
+ }
778
+ },
779
+
780
+ /**
781
+ * Detect if user is using a phone device (eg iPhone)
782
+ *
783
+ * @private
784
+ */
785
+ _isPhone: function () {
786
+ var userAgent = navigator.userAgent.toLowerCase();
787
+
788
+ return ( userAgent.match(/iphone/i) || userAgent.match(/ipod/i) || userAgent.match(/android/i) );
789
+ },
790
+
791
+ /**
792
+ * Destroy the instance
793
+ *
794
+ */
795
+ destroy: function () {
796
+ if (this.zoom) {
797
+ this.zoom.unwrap();
798
+ }
799
+
800
+ if (this.mouseTrap) {
801
+ this.mouseTrap.unbind();
802
+ this.mouseTrap.remove();
803
+ this.mouseTrap = null;
804
+ }
805
+
806
+ if (this.zoomDiv) {
807
+ this.zoomDiv.remove();
808
+ this.zoomDiv = null;
809
+ }
810
+
811
+ if (this.options.disableRightClick) {
812
+ $(document).unbind();
813
+ }
814
+
815
+ this._removeElements();
816
+ this.options.elements.gallery.unbind();
817
+ this.element.removeData('yith_magnifier');
818
+ }
819
+ };
820
+
821
+ $.fn.yith_magnifier = function (options) {
822
+
823
+ if (typeof options === 'string') {
824
+ var args = Array.prototype.slice.call(arguments, 1);
825
+
826
+ this.each(function () {
827
+ var instance = $.data(this, 'yith_magnifier');
828
+ if (!instance) {
829
+ $.error("cannot call methods on yith_magnifier prior to initialization; " +
830
+ "attempted to call method '" + options + "'");
831
+ return;
832
+ }
833
+ if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
834
+ $.error("no such method '" + options + "' for yith_magnifier instance");
835
+ return;
836
+ }
837
+ instance[options].apply(instance, args);
838
+ });
839
+ } else {
840
+ this.each(function () {
841
+ var instance = $.data(this, 'yith_magnifier');
842
+ if (!instance) {
843
+ $.data(this, 'yith_magnifier', new $.yith_magnifier(options, this));
844
+ } else {
845
+ $.error('yith_magnifier already istantiated.');
846
+ }
847
+ });
848
+ }
849
+ return this;
850
+ };
851
+
852
+
853
+ })(window, jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/yith_magnifier.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,i,o){"use strict";void 0===i.fn.imagesLoaded&&function(t,i){var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";t.fn.imagesLoaded=function(i){var e=this,n=t.isFunction(t.Deferred)?t.Deferred():0,a=t.isFunction(n.notify),s=e.find("img").add(e.filter("img")),r=[],m=[],h=[];function l(){var o=t(m),a=t(h);n&&(h.length?n.reject(s,o,a):n.resolve(s)),t.isFunction(i)&&i.call(e,s,o,a)}function c(t){d(t.target,"error"===t.type)}function d(i,e){i.src!==o&&-1===t.inArray(i,r)&&(r.push(i),e?h.push(i):m.push(i),t.data(i,"imagesLoaded",{isBroken:e,src:i.src}),a&&n.notifyWith(t(i),[e,s,t(m),t(h)]),r.length&&(setTimeout(l),s.unbind(".imagesLoaded",c)))}return t.isPlainObject(i)&&t.each(i,function(t,o){"callback"===t?i=o:n&&n[t](o)}),s.length?s.bind("load.imagesLoaded error.imagesLoaded",c).each(function(i,e){var n=e.src,a=t.data(e,"imagesLoaded");a&&a.src===n?d(e,a.isBroken):e.complete&&void 0!==e.naturalWidth?d(e,0===e.naturalWidth||0===e.naturalHeight):(e.readyState||e.complete)&&(e.src=o,e.src=n)}):l(),n?n.promise(e):e}}(jQuery),i.yith_magnifier=function(t,o){this.t=o,this.element=i(o),this._init(t)},i.yith_magnifier.defaults={zoomWidth:"auto",zoomHeight:"auto",position:"right",tint:!1,tintOpacity:.5,lensOpacity:.5,softFocus:!1,smoothMove:3,showTitle:!0,titleOpacity:.5,adjustX:0,adjustY:0,phoneBehavior:"inside",loadingLabel:"Loading...",enableSlider:!0,slider:"carouFredSel",sliderOptions:{},from_gallery:"no",onLoad:function(){return!1},onEnter:function(){return!1},onLeave:function(){return!1},onMove:function(){return!1},onClick:function(){return!1},elements:{zoom:i(".yith_magnifier_zoom"),zoomImage:i(".yith_magnifier_zoom img").first(),gallery:i(".yith_magnifier_gallery li a")}},i.yith_magnifier.prototype={_init:function(t){var o=this;i(document).trigger("yith_magnifier_before_init"),i.each(i.yith_magnifier.defaults.elements,function(t,e){i.yith_magnifier.defaults.elements[t]=i(e,o)}),o.options=i.extend(!0,{},i.yith_magnifier.defaults,t),o.isPhone=o._isPhone(),o._loading(),o.element.imagesLoaded(function(){o.options.onLoad(),o._initZoom(),o._initGallery()}),i(document).trigger("yith_magnifier_after_init")},_initGallery:function(){var t=this,o=t.options.elements,e=o.gallery,n=o.zoom,a=o.zoomImage;e.length>0?(e.on("click",function(o){if(o.preventDefault(),o.stopImmediatePropagation(),"free"==i("#yith_wczm_traffic_light").val()){i("#yith_wczm_traffic_light").val("blocked"),t.options.from_gallery="yes";var e=i(this);t.destroy(),n.attr("href",this.href),a.attr("src",e.data("small")).attr("srcset",e.data("small")).attr("src-orig",e.data("small")).attr("title","").attr("title",e.attr("title")),i.data(t.t,"yith_magnifier",new i.yith_magnifier(t.options,t.element)),i("#yith_wczm_traffic_light").val("free")}}),t.options.enableSlider&&e.closest("ul").trigger("yith_magnifier_slider_destroy")):e.on("click",function(t){return t.preventDefault(),!1})},_loading:function(){if(this.options.disableRightClick&&i(document).on("contextmenu",function(t){return!1}),void 0===this.mouseTrap){var t=this.options.elements.zoom.width();this.options.loadingLabel&&i('<div class="yith_magnifier_loading">'+this.options.loadingLabel+"</div>").css({width:t,"text-align":"center",opacity:.5}).appendTo(this.options.elements.zoom.parent())}},_initZoom:function(){if("free"==i("#yith_wczm_traffic_light").val()){i("#yith_wczm_traffic_light").val("blocked");var t=this;t.zoom=t.options.elements.zoom,t.zoomImage=t.options.elements.zoomImage;var o="yith_magnifier_zoom_wrap";if(t.options.zoom_wrap_additional_css){if(i("."+o).length)return;o+=" "+t.options.zoom_wrap_additional_css}t.zoom.wrap('<div class="'+o+'"></div>'),t.IMG_zoomImage=new Image;var e=i(".woocommerce-variation-add-to-cart .variation_id").val();if(i.isNumeric(e)&&0!=e&&"no"==t.options.from_gallery&&"1"==yith_wc_zoom_magnifier_storage_object.zoom_condition){var n={action:"yith_wc_zoom_magnifier_get_main_image",product_id:e,context:"frontend"};i.ajax({data:n,url:yith_wc_zoom_magnifier_storage_object.ajax_url,type:"post",error:function(t){console.log("ERROR - Yith_WC_Zoom_Magnifier"),console.log(t),i("#yith_wczm_traffic_light").val("free")},success:function(o){t.zoom.attr("href",o.url),t.IMG_zoomImage.src=o.url,t.IMG_smallImage=new Image,t.IMG_smallImage.src=t.zoomImage.attr("src"),o.gallery&&(i(".yith_magnifier_gallery").length?i(".yith_magnifier_gallery").closest(".thumbnails").replaceWith(o.gallery):i(".images").append(o.gallery),t.options.elements.gallery=i(".yith_magnifier_gallery li a")),i.browser&&i.browser.msie&&8==i.browser.version?i(t.IMG_zoomImage).load(function(){t._initGallery(),t._initTrap()}):i([t.IMG_zoomImage,t.IMG_smallImage]).imagesLoaded(function(){t._initGallery(),t._initTrap()}),i(document).on("click","a.yith_expand",function(o){o.preventDefault(),i().prettyPhoto({social_tools:!1,theme:"pp_woocommerce",horizontal_padding:20,opacity:.8,deeplinking:!1,callback:function(){i(".yith_expand").css("display","inline")}}),i.prettyPhoto.open(t.zoom[0].href,"",""),i(".yith_expand").css("display","none"),i(".pp_woocommerce .ppt").css({height:0,marginBottom:0})}),i(document).trigger("yith_magnifier_after_init_zoom"),i("#yith_wczm_traffic_light").val("free")}})}else t.IMG_zoomImage.src=t.zoom.attr("href"),t.IMG_smallImage=new Image,t.IMG_smallImage.src=t.zoomImage.attr("src"),i.browser&&i.browser.msie&&8==i.browser.version?i(t.IMG_zoomImage).load(function(){t._initTrap()}):i([t.IMG_zoomImage,t.IMG_smallImage]).imagesLoaded(function(){t._initTrap()}),i(document).on("click","a.yith_expand",function(o){o.preventDefault(),i().prettyPhoto({social_tools:!1,theme:"pp_woocommerce",horizontal_padding:20,opacity:.8,deeplinking:!1,callback:function(){i(".yith_expand").css("display","inline")}}),i.prettyPhoto.open(t.zoom[0].href,"",""),i(".yith_expand").css("display","none"),i(".pp_woocommerce .ppt").css({height:0,marginBottom:0})}),i(document).trigger("yith_magnifier_after_init_zoom"),i("#yith_wczm_traffic_light").val("free")}},_initTrap:function(){var t=this,o=t.IMG_zoomImage;t.IMG_smallImage;t.mx=0,t.my=0,t.controlTimer=0,t.lens=null,t.tint=null,t.softFocus=null,t.zoomDiv=null,t.cw=0,t.ch=0,t.zw=0,t.destU=0,t.destV=0,t.currU=0,t.currV=0,t.mouseTrap=null;var e=t.options.elements.zoom,n=t.options.elements.zoomImage;if(i(".yith_magnifier_loading").remove(),this.element.find(".yith_magnifier_mousetrap")&&this.element.find(".yith_magnifier_mousetrap").remove(),this.mouseTrap=i('<div class="yith_magnifier_mousetrap pp_woocommerce" />').css({width:"100%",height:"100%",top:0,left:0}).appendTo(e.parent()),"undefined"!=typeof ywzm_data&&i('<a href="#" class="yith_expand" title="'+ywzm_data.expand_label+'" style="display: inline;">Expand</a>').appendTo(this.mouseTrap),!t.isPhone||"disable"!=t.options.phoneBehavior){var a="ontouchstart"in document.documentElement;this.mouseTrap.on("touchmove mousemove",this,function(i){t.options.onMove(),t.mx=void 0!==i.originalEvent.touches?i.originalEvent.touches[0].pageX:i.pageX,t.my=void 0!==i.originalEvent.touches?i.originalEvent.touches[0].pageY:i.pageY}).on("touchend mouseleave",this,function(i){return clearTimeout(t.controlTimer),t.lens&&t.lens.fadeOut(299),t.tint&&t.tint.fadeOut(299),t.softFocus&&t.softFocus.fadeOut(299),t.zoomDiv.fadeOut(300,function(){t._onLeave()}),!1}).on("touchstart click",this,function(i){t.options.onClick()}).on("touchstart mouseenter",this,function(s){if("free"==i("#yith_wczm_traffic_light").val()){t.options.onEnter(),a&&s.preventDefault(),t.mx=void 0!==s.originalEvent.touches?s.originalEvent.touches[0].pageX:s.pageX,t.my=void 0!==s.originalEvent.touches?s.originalEvent.touches[0].pageY:s.pageY,t.zw=s.data,t.zoomDiv&&(t.zoomDiv.stop(!0,!1),t.zoomDiv.remove());var r=t.options.adjustX,m=t.options.adjustY,h=n.outerWidth(),l=n.outerHeight(),c=t.options.zoomWidth,d=t.options.zoomHeight;"auto"==t.options.zoomWidth&&(c=h),"auto"==t.options.zoomHeight&&(d=l);var g=e.parent();switch(t.options.position){case"top":m-=d;break;case"right":r+=h;break;case"bottom":m+=l;break;case"left":r-=c;break;case"inside":c=h,d=l;break;default:(g=i("#"+t.options.position)).length?(c=g.innerWidth(),d=g.innerHeight()):(g=e,r+=h,m+=l)}t.isPhone&&"inside"==t.options.phoneBehavior&&(c=h,d=l,r=0,m=0),t.zoomDiv=i('<div class="yith_magnifier_zoom_magnifier" />').css({left:r,top:m,width:c,height:d,"background-repeat":"no-repeat",backgroundImage:"url("+o.src+")"}).appendTo(g),n.attr("title")&&t.options.showTitle&&i('<div class="yith_magnifier_title">'+n.attr("title")+"</div>").appendTo(t.zoomDiv),t.isPhone?"disable"!=t.options.phoneBehavior?t.zoomDiv.fadeIn(500):t.lens.fadeOut(299):t.zoomDiv.fadeIn(500),t.lens&&(t.lens.remove(),t.lens=null),o.width<=1?t.cw=n.outerWidth()/o.naturalWidth*t.zoomDiv.width():t.cw=n.outerWidth()/o.width*t.zoomDiv.width(),o.height<=1?t.ch=n.outerHeight()/o.naturalHeight*t.zoomDiv.height():t.ch=n.outerHeight()/o.height*t.zoomDiv.height(),t.lens=i('<div class="yith_magnifier_lens" />').css({width:t.cw,height:t.ch}).appendTo(e),t.mouseTrap.css("cursor",t.lens.css("cursor"));var u=!1;return t.options.tint&&(t.tint=i("<div />").css({display:"none",position:"absolute",left:0,top:0,width:n.outerWidth(),height:n.outerHeight(),backgroundColor:t.options.tint,opacity:t.options.tintOpacity}).appendTo(e),t.lens.append(i("<img />",{src:n.attr("src")})),u=!0,t.tint.fadeIn(500)),t.options.softFocus&&(t.softFocus=i("<div />").css({position:"absolute",display:"none",top:"1px",left:"1px",width:n.outerWidth(),height:n.outerHeight(),opacity:.5}).appendTo(e),t.softFocus.append(i("<img />",{src:n.attr("src")})),0==t.lens.find("img").length&&t.lens.append(i("<img />",{src:n.attr("src")})),u=!0,t.softFocus.fadeIn(500)),u||t.lens.css("opacity",t.options.lensOpacity),"inside"!==t.options.position&&t.lens.fadeIn(500),void t.zw._controlLoop()}})}},_controlLoop:function(){var t=this;if(this.lens){var i=this.mx-this.zoomImage.offset().left-.5*this.cw>>0,o=this.my-this.zoomImage.offset().top-.5*this.ch>>0;i<0?i=0:i>this.zoomImage.outerWidth()-this.cw&&(i=this.zoomImage.outerWidth()-this.cw),o<0?o=0:o>this.zoomImage.outerHeight()-this.ch&&(o=this.zoomImage.outerHeight()-this.ch),this.lens.css({left:i-2,top:o-1}),this.lens.find("img").css({width:this.zoomImage.outerWidth(),height:this.zoomImage.outerHeight(),marginLeft:-i+"px ",marginTop:-o+"px"}),this.IMG_zoomImage.width<=1?this.destU=i/this.zoomImage.outerWidth()*this.IMG_zoomImage.naturalWidth>>0:this.destU=i/this.zoomImage.outerWidth()*this.IMG_zoomImage.width>>0,this.IMG_zoomImage.height<=1?this.destV=o/this.zoomImage.outerHeight()*this.IMG_zoomImage.naturalHeight>>0:this.destV=o/this.zoomImage.outerHeight()*this.IMG_zoomImage.height>>0,this.currU+=(this.destU-this.currU)/this.options.smoothMove,this.currV+=(this.destV-this.currV)/this.options.smoothMove,this.zoomDiv.css("background-position",-(this.currU>>0)+"px "+-(this.currV>>0)+"px")}this.controlTimer=setTimeout(function(){t._controlLoop()},30)},_onLeave:function(){this.options.onLeave(),this.zoomDiv&&(this.zoomDiv.remove(),this.zoomDiv=null),this._removeElements()},_removeElements:function(){this.lens&&(this.lens.remove(),this.lens=null),this.tint&&(this.tint.remove(),this.tint=null),this.softFocus&&(this.softFocus.remove(),this.softFocus=null),this.element.find(".yith_magnifier_loading").length>0&&this.element.find(".yith_magnifier_loading").remove()},_isPhone:function(){var t=navigator.userAgent.toLowerCase();return t.match(/iphone/i)||t.match(/ipod/i)||t.match(/android/i)},destroy:function(){this.zoom&&this.zoom.unwrap(),this.mouseTrap&&(this.mouseTrap.unbind(),this.mouseTrap.remove(),this.mouseTrap=null),this.zoomDiv&&(this.zoomDiv.remove(),this.zoomDiv=null),this.options.disableRightClick&&i(document).unbind(),this._removeElements(),this.options.elements.gallery.unbind(),this.element.removeData("yith_magnifier")}},i.fn.yith_magnifier=function(t){if("string"==typeof t){var o=Array.prototype.slice.call(arguments,1);this.each(function(){var e=i.data(this,"yith_magnifier");e?i.isFunction(e[t])&&"_"!==t.charAt(0)?e[t].apply(e,o):i.error("no such method '"+t+"' for yith_magnifier instance"):i.error("cannot call methods on yith_magnifier prior to initialization; attempted to call method '"+t+"'")})}else this.each(function(){i.data(this,"yith_magnifier")?i.error("yith_magnifier already istantiated."):i.data(this,"yith_magnifier",new i.yith_magnifier(t,this))});return this}}(window,jQuery);
1
+ !function(t,i,o){"use strict";void 0===i.fn.imagesLoaded&&function(t,i){var o="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";t.fn.imagesLoaded=function(i){var e=this,n=t.isFunction(t.Deferred)?t.Deferred():0,s=t.isFunction(n.notify),a=e.find("img").add(e.filter("img")),r=[],m=[],h=[];function l(){var o=t(m),s=t(h);n&&(h.length?n.reject(a,o,s):n.resolve(a)),t.isFunction(i)&&i.call(e,a,o,s)}function c(t){g(t.target,"error"===t.type)}function g(i,e){i.src!==o&&-1===t.inArray(i,r)&&(r.push(i),e?h.push(i):m.push(i),t.data(i,"imagesLoaded",{isBroken:e,src:i.src}),s&&n.notifyWith(t(i),[e,a,t(m),t(h)]),a.length===r.length&&(setTimeout(l),a.unbind(".imagesLoaded",c)))}return t.isPlainObject(i)&&t.each(i,function(t,o){"callback"===t?i=o:n&&n[t](o)}),a.length?a.bind("load.imagesLoaded error.imagesLoaded",c).each(function(i,e){var n=e.src,s=t.data(e,"imagesLoaded");s&&s.src===n?g(e,s.isBroken):e.complete&&void 0!==e.naturalWidth?g(e,0===e.naturalWidth||0===e.naturalHeight):(e.readyState||e.complete)&&(e.src=o,e.src=n)}):l(),n?n.promise(e):e}}(jQuery),i.yith_magnifier=function(t,o){this.t=o,this.element=i(o),this._init(t)},i.yith_magnifier.defaults={zoomWidth:"auto",zoomHeight:"auto",position:"right",tint:!1,tintOpacity:.5,lensOpacity:.5,softFocus:!1,smoothMove:3,showTitle:!0,titleOpacity:.5,adjustX:0,adjustY:0,phoneBehavior:"inside",loadingLabel:"Loading...",enableSlider:!0,slider:"carouFredSel",sliderOptions:{},from_gallery:"no",onLoad:function(){return!1},onEnter:function(){return!1},onLeave:function(){return!1},onMove:function(){return!1},onClick:function(){return!1},elements:{zoom:i(".yith_magnifier_zoom"),zoomImage:i(".yith_magnifier_zoom img").first(),gallery:i(".yith_magnifier_gallery li a")}},i.yith_magnifier.prototype={_init:function(t){var o=this;i(document).trigger("yith_magnifier_before_init"),i.each(i.yith_magnifier.defaults.elements,function(t,e){i.yith_magnifier.defaults.elements[t]=i(e,o)}),o.options=i.extend(!0,{},i.yith_magnifier.defaults,t),o.isPhone=o._isPhone(),o._loading(),o.element.imagesLoaded(function(){o.options.onLoad(),o._initZoom(),o._initGallery()}),i(document).trigger("yith_magnifier_after_init")},_initGallery:function(){var t=this,o=t.options.elements,e=o.gallery,n=o.zoom,s=o.zoomImage;e.length>0?(e.on("click",function(o){o.preventDefault(),t.options.from_gallery="yes";var e=i(this);t.destroy(),n.attr("href",this.href),s.attr("src",e.data("small")).attr("srcset",e.data("small")).attr("src-orig",e.data("small")).attr("title","").attr("title",e.attr("title")),i.data(t.t,"yith_magnifier",new i.yith_magnifier(t.options,t.element))}),t.options.enableSlider&&(e.closest("ul").trigger("yith_magnifier_slider_destroy"),e.closest("ul")[t.options.slider](t.options.sliderOptions))):e.on("click",function(t){return t.preventDefault(),!1})},_loading:function(){if(this.options.disableRightClick&&i(document).on("contextmenu",function(t){return!1}),void 0===this.mouseTrap){var t=this.options.elements.zoom.width();this.options.loadingLabel&&i('<div class="yith_magnifier_loading">'+this.options.loadingLabel+"</div>").css({width:t,"text-align":"center",opacity:.5}).appendTo(this.options.elements.zoom.parent())}},_initZoom:function(){var t=this;t.zoom=t.options.elements.zoom,t.zoomImage=t.options.elements.zoomImage;var o="yith_magnifier_zoom_wrap";t.options.zoom_wrap_additional_css&&(i("."+o).length||(o+=" "+t.options.zoom_wrap_additional_css)),t.zoom.wrap('<div class="'+o+'"></div>'),t.IMG_zoomImage=new Image;var e=i(".woocommerce-variation-add-to-cart .variation_id").val();if(i.isNumeric(e)&&0!=e&&"no"==t.options.from_gallery){var n={action:"yith_wc_zoom_magnifier_get_main_image",product_id:e,context:"frontend"};i.ajax({data:n,url:yith_wc_zoom_magnifier_storage_object.ajax_url,type:"post",error:function(t){console.log("ERROR - Yith_WC_Zoom_Magnifier"),console.log(t)},success:function(o){t.IMG_zoomImage.src=o.url,t.IMG_smallImage=new Image,t.IMG_smallImage.src=t.zoomImage.attr("src"),o.gallery&&(i(".yith_magnifier_gallery").length?i(".yith_magnifier_gallery").closest(".thumbnails").replaceWith(o.gallery):i(".images").append(o.gallery),t.options.elements.gallery=i(".yith_magnifier_gallery li a")),i.browser&&i.browser.msie&&8==i.browser.version?i(t.IMG_zoomImage).load(function(){t._initGallery(),t._initTrap()}):i([t.IMG_zoomImage,t.IMG_smallImage]).imagesLoaded(function(){t._initGallery(),t._initTrap()}),i(document).trigger("yith_magnifier_after_init_zoom")}})}else t.IMG_zoomImage.src=t.zoom.attr("href"),t.IMG_smallImage=new Image,t.IMG_smallImage.src=t.zoomImage.attr("src"),i.browser&&i.browser.msie&&8==i.browser.version?i(t.IMG_zoomImage).load(function(){t._initTrap()}):i([t.IMG_zoomImage,t.IMG_smallImage]).imagesLoaded(function(){t._initTrap()}),i(document).trigger("yith_magnifier_after_init_zoom")},_initTrap:function(){var t=this,o=t.IMG_zoomImage;t.IMG_smallImage;t.mx=0,t.my=0,t.controlTimer=0,t.lens=null,t.tint=null,t.softFocus=null,t.zoomDiv=null,t.cw=0,t.ch=0,t.zw=0,t.destU=0,t.destV=0,t.currU=0,t.currV=0,t.mouseTrap=null;var e=t.options.elements.zoom,n=t.options.elements.zoomImage;i(".yith_magnifier_loading").remove(),this.element.find(".yith_magnifier_mousetrap")&&this.element.find(".yith_magnifier_mousetrap").remove(),this.mouseTrap=i('<div class="yith_magnifier_mousetrap" />').css({width:"100%",height:"100%",top:0,left:0}).appendTo(e.parent());var s="ontouchstart"in document.documentElement;this.mouseTrap.on("touchmove mousemove",this,function(i){t.options.onMove(),t.mx=void 0!==i.originalEvent.touches?i.originalEvent.touches[0].pageX:i.pageX,t.my=void 0!==i.originalEvent.touches?i.originalEvent.touches[0].pageY:i.pageY}).on("touchend mouseleave",this,function(i){return clearTimeout(t.controlTimer),t.lens&&t.lens.fadeOut(299),t.tint&&t.tint.fadeOut(299),t.softFocus&&t.softFocus.fadeOut(299),t.zoomDiv.fadeOut(300,function(){t._onLeave()}),!1}).on("touchstart click",this,function(i){t.options.onClick()}).on("touchstart mouseenter",this,function(a){t.options.onEnter(),s&&a.preventDefault(),t.mx=void 0!==a.originalEvent.touches?a.originalEvent.touches[0].pageX:a.pageX,t.my=void 0!==a.originalEvent.touches?a.originalEvent.touches[0].pageY:a.pageY,t.zw=a.data,t.zoomDiv&&(t.zoomDiv.stop(!0,!1),t.zoomDiv.remove());var r=t.options.adjustX,m=t.options.adjustY,h=n.outerWidth(),l=n.outerHeight(),c=t.options.zoomWidth,g=t.options.zoomHeight;"auto"==t.options.zoomWidth&&(c=h),"auto"==t.options.zoomHeight&&(g=l);var u=e.parent();switch(t.options.position){case"top":m-=g;break;case"right":r+=h;break;case"bottom":m+=l;break;case"left":r-=c;break;case"inside":c=h,g=l;break;default:(u=i("#"+t.options.position)).length?(c=u.innerWidth(),g=u.innerHeight()):(u=e,r+=h,m+=l)}t.isPhone&&"inside"==t.options.phoneBehavior&&(c=h,g=l,r=0,m=0),t.zoomDiv=i('<div class="yith_magnifier_zoom_magnifier" />').css({left:r,top:m,width:c,height:g,"background-repeat":"no-repeat",backgroundImage:"url("+o.src+")"}).appendTo(u),n.attr("title")&&t.options.showTitle&&i('<div class="yith_magnifier_title">'+n.attr("title")+"</div>").appendTo(t.zoomDiv),t.isPhone?"disable"!=t.options.phoneBehavior?t.zoomDiv.fadeIn(500):t.lens.fadeOut(299):t.zoomDiv.fadeIn(500),t.lens&&(t.lens.remove(),t.lens=null),o.width<=1?t.cw=n.outerWidth()/o.naturalWidth*t.zoomDiv.width():t.cw=n.outerWidth()/o.width*t.zoomDiv.width(),o.height<=1?t.ch=n.outerHeight()/o.naturalHeight*t.zoomDiv.height():t.ch=n.outerHeight()/o.height*t.zoomDiv.height(),t.lens=i('<div class="yith_magnifier_lens" />').css({width:t.cw,height:t.ch}).appendTo(e),t.mouseTrap.css("cursor",t.lens.css("cursor"));var d=!1;t.options.tint&&(t.tint=i("<div />").css({display:"none",position:"absolute",left:0,top:0,width:n.outerWidth(),height:n.outerHeight(),backgroundColor:t.options.tint,opacity:t.options.tintOpacity}).appendTo(e),t.lens.append(i("<img />",{src:n.attr("src")})),d=!0,t.tint.fadeIn(500)),t.options.softFocus&&(t.softFocus=i("<div />").css({position:"absolute",display:"none",top:"1px",left:"1px",width:n.outerWidth(),height:n.outerHeight(),opacity:.5}).appendTo(e),t.softFocus.append(i("<img />",{src:n.attr("src")})),0==t.lens.find("img").length&&t.lens.append(i("<img />",{src:n.attr("src")})),d=!0,t.softFocus.fadeIn(500)),d||t.lens.css("opacity",t.options.lensOpacity),"inside"!==t.options.position&&t.lens.fadeIn(500),t.zw._controlLoop()})},_controlLoop:function(){var t=this;if(this.lens){var i=this.mx-this.zoomImage.offset().left-.5*this.cw>>0,o=this.my-this.zoomImage.offset().top-.5*this.ch>>0;i<0?i=0:i>this.zoomImage.outerWidth()-this.cw&&(i=this.zoomImage.outerWidth()-this.cw),o<0?o=0:o>this.zoomImage.outerHeight()-this.ch&&(o=this.zoomImage.outerHeight()-this.ch),this.lens.css({left:i-2,top:o-1}),this.lens.find("img").css({width:this.zoomImage.outerWidth(),height:this.zoomImage.outerHeight(),marginLeft:-i+"px ",marginTop:-o+"px"}),this.IMG_zoomImage.width<=1?this.destU=i/this.zoomImage.outerWidth()*this.IMG_zoomImage.naturalWidth>>0:this.destU=i/this.zoomImage.outerWidth()*this.IMG_zoomImage.width>>0,this.IMG_zoomImage.height<=1?this.destV=o/this.zoomImage.outerHeight()*this.IMG_zoomImage.naturalHeight>>0:this.destV=o/this.zoomImage.outerHeight()*this.IMG_zoomImage.height>>0,this.currU+=(this.destU-this.currU)/this.options.smoothMove,this.currV+=(this.destV-this.currV)/this.options.smoothMove,this.zoomDiv.css("background-position",-(this.currU>>0)+"px "+-(this.currV>>0)+"px")}this.controlTimer=setTimeout(function(){t._controlLoop()},30)},_onLeave:function(){this.options.onLeave(),this.zoomDiv&&(this.zoomDiv.remove(),this.zoomDiv=null),this._removeElements()},_removeElements:function(){this.lens&&(this.lens.remove(),this.lens=null),this.tint&&(this.tint.remove(),this.tint=null),this.softFocus&&(this.softFocus.remove(),this.softFocus=null),this.element.find(".yith_magnifier_loading").length>0&&this.element.find(".yith_magnifier_loading").remove()},_isPhone:function(){var t=navigator.userAgent.toLowerCase();return t.match(/iphone/i)||t.match(/ipod/i)||t.match(/android/i)},destroy:function(){this.zoom&&this.zoom.unwrap(),this.mouseTrap&&(this.mouseTrap.unbind(),this.mouseTrap.remove(),this.mouseTrap=null),this.zoomDiv&&(this.zoomDiv.remove(),this.zoomDiv=null),this.options.disableRightClick&&i(document).unbind(),this._removeElements(),this.options.elements.gallery.unbind(),this.element.removeData("yith_magnifier")}},i.fn.yith_magnifier=function(t){if("string"==typeof t){var o=Array.prototype.slice.call(arguments,1);this.each(function(){var e=i.data(this,"yith_magnifier");e?i.isFunction(e[t])&&"_"!==t.charAt(0)?e[t].apply(e,o):i.error("no such method '"+t+"' for yith_magnifier instance"):i.error("cannot call methods on yith_magnifier prior to initialization; attempted to call method '"+t+"'")})}else this.each(function(){i.data(this,"yith_magnifier")?i.error("yith_magnifier already istantiated."):i.data(this,"yith_magnifier",new i.yith_magnifier(t,this))});return this}}(window,jQuery);
assets/js/ywzm_frontend.js CHANGED
@@ -6,15 +6,12 @@
6
  */
7
  jQuery(document).ready(function ($) {
8
 
9
- var yith_wcmg = $('.images');
10
- var yith_wcmg_zoom = $('.yith_magnifier_zoom');
11
- var yith_wcmg_image = $('.yith_magnifier_zoom img').first();
12
-
13
- var yith_wcmg_default_zoom = yith_wcmg.find('.yith_magnifier_zoom').attr('href');
14
- var yith_wcmg_default_image = yith_wcmg.find('.yith_magnifier_zoom img').attr('src');
15
-
16
- var yith_wcmg_default_gallery = yith_wcmg.find('.thumbnails');
17
-
18
 
19
  if (typeof yith_magnifier_options == 'undefined') {
20
  return false;
@@ -23,6 +20,7 @@ jQuery(document).ready(function ($) {
23
  yith_wcmg.yith_magnifier(yith_magnifier_options);
24
 
25
  $(document).on('found_variation', 'form.variations_form', function (event, variation) {
 
26
  var image_magnifier = variation.image_magnifier ? variation.image_magnifier : yith_wcmg_default_zoom;
27
 
28
  var image_src = yith_wcmg_default_image;
@@ -46,7 +44,6 @@ jQuery(document).ready(function ($) {
46
 
47
  yith_wcmg.yith_magnifier(yith_magnifier_options);
48
  }).on('reset_image', function (event) {
49
-
50
  yith_wcmg_zoom.attr('href', yith_wcmg_default_zoom);
51
  yith_wcmg_image.attr('src', yith_wcmg_default_image);
52
  yith_wcmg_image.attr('srcset', yith_wcmg_default_image);
@@ -61,206 +58,5 @@ jQuery(document).ready(function ($) {
61
  yith_wcmg.yith_magnifier(yith_magnifier_options);
62
  });
63
 
64
- if ( $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery' ).length ){
65
-
66
- $('form.variations_form .variations select').trigger('change');
67
-
68
- function yith_wc_zm_carousel(){
69
-
70
- $( ".single-product.woocommerce div.product div.images div.thumbnails" ).css( 'width', $( ".single-product.woocommerce div.product div.images div.thumbnails" ).width() );
71
-
72
- var yith_wc_zm_circular = $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery' ).data( 'circular' );
73
- var yith_wc_zm_columns = $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery' ).data( 'columns' );
74
-
75
- var slider_infinite = $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery' ).data( 'slider_infinite' );
76
-
77
- // We retrieve the value of the width of a li and the margin to later on multiple it for the numeber of li's and set the width of the ul parent
78
- var li_width = $( ".single-product.woocommerce div.product div.images .yith_magnifier_gallery li" ).width();
79
- var li_margin_left = $( ".single-product.woocommerce div.product div.images .yith_magnifier_gallery li" ).css( 'margin-left' );
80
-
81
- if ( typeof li_margin_left == 'undefined') {
82
- var li_margin_left_num = 0;
83
- } else {
84
- var li_margin_left_num = li_margin_left.split( "px" ).shift();
85
- }
86
-
87
-
88
- // We create an array with all the possible positions and adjust all the li's with a width width px because they were created by % via PHP
89
- // and we are goint to set the width of the ul which contains the li's
90
- var yith_margins_array = [];
91
- var yith_margins_option = 0;
92
- yith_margins_array.push( yith_margins_option );
93
-
94
- var loop = 1;
95
- $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery li' ).each( function() {
96
-
97
- $( this ).css( 'width', li_width + 'px' );
98
- $( this ).css( 'margin-left', li_margin_left );
99
- $( this ).css( 'margin-right', li_margin_left );
100
- $( this ).show();
101
-
102
- yith_margins_option = yith_margins_option + ( ( li_margin_left_num * 2 ) + li_width );
103
-
104
- yith_margins_array.push( yith_margins_option );
105
-
106
- loop++;
107
-
108
- });
109
-
110
- // set the width of the ul parent
111
- var ul_w = yith_margins_option;
112
- $( ".single-product.woocommerce div.product div.images .yith_magnifier_gallery" ).css( 'width', ul_w + 'px' );
113
-
114
- $( "#slider-next" ).css( 'top', '50%' );
115
- $( "#slider-next" ).css( 'transform', 'translateY( -50% )' );
116
-
117
- $( "#slider-prev" ).css( 'top', '50%' );
118
- $( "#slider-prev" ).css( 'transform', 'translateY( -50% )' );
119
-
120
- var index_yith_margins_array = 0;
121
-
122
- $( "body" ).on( "click", "#slider-next", function () {
123
-
124
- if ( $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).next().is( 'li' ) ){
125
-
126
- index_yith_margins_array++;
127
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).animate({
128
- marginLeft: '-' + yith_margins_array[ index_yith_margins_array ] + 'px',
129
- });
130
-
131
- var next = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).next();
132
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).removeClass( 'first' );
133
- next.addClass( 'first' );
134
-
135
- next = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).next();
136
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).removeClass( 'last' );
137
- next.addClass( 'last' );
138
-
139
- }
140
- else
141
- if ( ( yith_wc_zm_circular == 'yes' ) && ! $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).is(':animated') ){
142
-
143
- index_yith_margins_array--;
144
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).css( 'margin-left', '-' + yith_margins_array[ index_yith_margins_array ] + 'px' );
145
-
146
- var last = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li' ).first();
147
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).after( last );
148
-
149
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).removeClass( 'last' );
150
- last.addClass( 'last' );
151
-
152
- var first = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).next();
153
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).removeClass( 'first' );
154
- first.addClass( 'first' );
155
-
156
- index_yith_margins_array++;
157
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).animate({
158
- marginLeft: '-' + yith_margins_array[ index_yith_margins_array ] + 'px',
159
- });
160
-
161
- }
162
- else
163
- if ( ( slider_infinite == 'yes' ) && ! $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).is(':animated') ){
164
-
165
- while( $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).prev().is( 'li' ) ){
166
-
167
- var prev = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).prev();
168
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).removeClass( 'first' );
169
- prev.addClass( 'first' );
170
-
171
- prev = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).prev();
172
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).removeClass( 'last' );
173
- prev.addClass( 'last' );
174
-
175
- }
176
-
177
- index_yith_margins_array = 0;
178
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).animate({
179
- marginLeft: '-' + yith_margins_array[ index_yith_margins_array ] + 'px',
180
- });
181
- }
182
-
183
- });
184
-
185
- $( "body" ).on( "click", "#slider-prev", function () {
186
-
187
- if ( $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).prev().is( 'li' ) ){
188
-
189
- index_yith_margins_array--;
190
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).animate({
191
- marginLeft: '-' + yith_margins_array[ index_yith_margins_array ] + 'px',
192
- });
193
-
194
- var prev = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).prev();
195
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).removeClass( 'first' );
196
- prev.addClass( 'first' );
197
-
198
- prev = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).prev();
199
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).removeClass( 'last' );
200
- prev.addClass( 'last' );
201
-
202
- }
203
- else
204
- if ( ( yith_wc_zm_circular == 'yes' ) && ! $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).is(':animated') ) {
205
-
206
- index_yith_margins_array++;
207
- $(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").css('margin-left', '-' + yith_margins_array[index_yith_margins_array] + 'px');
208
-
209
- var first = $('.single-product.woocommerce div.product div.images .yith_magnifier_gallery li').last();
210
- $('.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first').before(first);
211
-
212
- $('.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first').removeClass('first');
213
- first.addClass('first');
214
-
215
- var last = $('.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last').prev();
216
- $('.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last').removeClass('last');
217
- last.addClass('last');
218
-
219
- index_yith_margins_array--;
220
- $(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({
221
- marginLeft: '-' + yith_margins_array[index_yith_margins_array] + 'px',
222
- });
223
-
224
- }
225
- else
226
- if ( ( slider_infinite == 'yes' ) && ! $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).is(':animated') ){
227
-
228
- while( $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).next().is( 'li' ) ){
229
-
230
- var next = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).next();
231
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first' ).removeClass( 'first' );
232
- next.addClass( 'first' );
233
-
234
- next = $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).next();
235
- $( '.single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last' ).removeClass( 'last' );
236
- next.addClass( 'last' );
237
-
238
- }
239
-
240
- index_yith_margins_array = yith_margins_array.length -1 -yith_wc_zm_columns;
241
- $( ".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery" ).animate({
242
- marginLeft: '-' + yith_margins_array[ index_yith_margins_array ] + 'px',
243
- });
244
- }
245
-
246
- });
247
-
248
- }
249
-
250
- function yith_wc_zm_auto_carousel(){
251
-
252
- $( '#slider-next' ).click();
253
-
254
- setTimeout( yith_wc_zm_auto_carousel, 3000);
255
-
256
- }
257
-
258
- yith_wc_zm_carousel();
259
-
260
- var auto_carousel = $( '.single-product.woocommerce div.product div.images ul.yith_magnifier_gallery' ).data( 'auto_carousel' );
261
-
262
- if ( auto_carousel == 'yes' )
263
- setTimeout( yith_wc_zm_auto_carousel, 3000);
264
- }
265
-
266
  });
6
  */
7
  jQuery(document).ready(function ($) {
8
 
9
+ var yith_wcmg = $('.images'),
10
+ yith_wcmg_zoom = $('.yith_magnifier_zoom'),
11
+ yith_wcmg_image = $('.yith_magnifier_zoom img').first(),
12
+ yith_wcmg_default_zoom = yith_wcmg.find('.yith_magnifier_zoom').attr('href'),
13
+ yith_wcmg_default_image = yith_wcmg.find('.yith_magnifier_zoom img').attr('src');
14
+ yith_wcmg_default_gallery = yith_wcmg.find('.thumbnails');
 
 
 
15
 
16
  if (typeof yith_magnifier_options == 'undefined') {
17
  return false;
20
  yith_wcmg.yith_magnifier(yith_magnifier_options);
21
 
22
  $(document).on('found_variation', 'form.variations_form', function (event, variation) {
23
+
24
  var image_magnifier = variation.image_magnifier ? variation.image_magnifier : yith_wcmg_default_zoom;
25
 
26
  var image_src = yith_wcmg_default_image;
44
 
45
  yith_wcmg.yith_magnifier(yith_magnifier_options);
46
  }).on('reset_image', function (event) {
 
47
  yith_wcmg_zoom.attr('href', yith_wcmg_default_zoom);
48
  yith_wcmg_image.attr('src', yith_wcmg_default_image);
49
  yith_wcmg_image.attr('srcset', yith_wcmg_default_image);
58
  yith_wcmg.yith_magnifier(yith_magnifier_options);
59
  });
60
 
61
+ $('form.variations_form .variations select').trigger('change');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  });
assets/js/ywzm_frontend.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(i){var e=i(".images"),r=i(".yith_magnifier_zoom"),t=i(".yith_magnifier_zoom img").first(),a=e.find(".yith_magnifier_zoom").attr("href"),o=e.find(".yith_magnifier_zoom img").attr("src"),s=e.find(".thumbnails");if("undefined"==typeof yith_magnifier_options)return!1;if(e.yith_magnifier(yith_magnifier_options),i(document).on("found_variation","form.variations_form",function(i,s){var l=s.image_magnifier?s.image_magnifier:a,m=o;ywzm_data.wc_before_3_0?s.image_src&&(m=s.image_src):s.image.src&&(m=s.image.src),r.attr("href",l),t.attr("src",m),t.attr("srcset",m),t.attr("src-orig",m),e.data("yith_magnifier")&&e.yith_magnifier("destroy"),e.yith_magnifier(yith_magnifier_options)}).on("reset_image",function(i){r.attr("href",a),t.attr("src",o),t.attr("srcset",o),t.attr("src-orig",o),e.find(".thumbnails").replaceWith(s),e.data("yith_magnifier")&&e.yith_magnifier("destroy"),e.yith_magnifier(yith_magnifier_options)}),i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").length){i("form.variations_form .variations select").trigger("change"),function(){i(".single-product.woocommerce div.product div.images div.thumbnails").css("width",i(".single-product.woocommerce div.product div.images div.thumbnails").width());var e=i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").data("circular"),r=i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").data("columns"),t=i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").data("slider_infinite"),a=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li").width(),o=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li").css("margin-left");if(void 0===o)var s=0;else s=o.split("px").shift();var l=[],m=0;l.push(m),i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery li").each(function(){i(this).css("width",a+"px"),i(this).css("margin-left",o),i(this).css("margin-right",o),i(this).show(),m+=2*s+a,l.push(m)});var d=m;i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery").css("width",d+"px"),i("#slider-next").css("top","50%"),i("#slider-next").css("transform","translateY( -50% )"),i("#slider-prev").css("top","50%"),i("#slider-prev").css("transform","translateY( -50% )");var c=0;i("body").on("click","#slider-next",function(){if(i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").next().is("li")){c++,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"});var r=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").next();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),r.addClass("first"),r=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").next(),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),r.addClass("last")}else if("yes"!=e||i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").is(":animated")){if("yes"==t&&!i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").is(":animated")){for(;i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").prev().is("li");){var a=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").prev();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),a.addClass("first"),a=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").prev(),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),a.addClass("last")}c=0,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"})}}else{c--,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").css("margin-left","-"+l[c]+"px");var o=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li").first();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").after(o),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),o.addClass("last");var s=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").next();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),s.addClass("first"),c++,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"})}}),i("body").on("click","#slider-prev",function(){if(i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").prev().is("li")){c--,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"});var a=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").prev();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),a.addClass("first"),a=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").prev(),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),a.addClass("last")}else if("yes"!=e||i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").is(":animated")){if("yes"==t&&!i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").is(":animated")){for(;i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").next().is("li");){var o=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").next();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),o.addClass("first"),o=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").next(),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),o.addClass("last")}c=l.length-1-r,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"})}}else{c++,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").css("margin-left","-"+l[c]+"px");var s=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li").last();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").before(s),i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.first").removeClass("first"),s.addClass("first");var m=i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").prev();i(".single-product.woocommerce div.product div.images .yith_magnifier_gallery li.last").removeClass("last"),m.addClass("last"),c--,i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").animate({marginLeft:"-"+l[c]+"px"})}})}(),"yes"==i(".single-product.woocommerce div.product div.images ul.yith_magnifier_gallery").data("auto_carousel")&&setTimeout(function e(){i("#slider-next").click(),setTimeout(e,3e3)},3e3)}});
1
+ jQuery(document).ready(function(i){var e=i(".images"),n=i(".yith_magnifier_zoom"),m=i(".yith_magnifier_zoom img").first(),_=e.find(".yith_magnifier_zoom").attr("href"),f=e.find(".yith_magnifier_zoom img").attr("src");if(yith_wcmg_default_gallery=e.find(".thumbnails"),"undefined"==typeof yith_magnifier_options)return!1;e.yith_magnifier(yith_magnifier_options),i(document).on("found_variation","form.variations_form",function(i,t){var r=t.image_magnifier?t.image_magnifier:_,a=f;ywzm_data.wc_before_3_0?t.image_src&&(a=t.image_src):t.image.src&&(a=t.image.src),n.attr("href",r),m.attr("src",a),m.attr("srcset",a),m.attr("src-orig",a),e.data("yith_magnifier")&&e.yith_magnifier("destroy"),e.yith_magnifier(yith_magnifier_options)}).on("reset_image",function(i){n.attr("href",_),m.attr("src",f),m.attr("srcset",f),m.attr("src-orig",f),e.find(".thumbnails").replaceWith(yith_wcmg_default_gallery),e.data("yith_magnifier")&&e.yith_magnifier("destroy"),e.yith_magnifier(yith_magnifier_options)}),i("form.variations_form .variations select").trigger("change")});
class.yith-wcmg-frontend.php CHANGED
@@ -19,8 +19,8 @@ if ( ! class_exists ( 'YITH_WCMG_Frontend' ) ) {
19
  * @since 1.0.0
20
  */
21
  class YITH_WCMG_Frontend {
22
-
23
-
24
  /**
25
  * Constructor
26
  *
@@ -41,16 +41,16 @@ if ( ! class_exists ( 'YITH_WCMG_Frontend' ) ) {
41
  remove_action ( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
42
  add_action ( 'woocommerce_before_single_product_summary', array( $this, 'show_product_images' ), 20 );
43
  add_action ( 'woocommerce_product_thumbnails', array( $this, 'show_product_thumbnails' ), 20 );
44
-
45
  //custom styles and javascripts
46
  add_action ( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
47
-
48
  //add attributes to product variations
49
  add_filter ( 'woocommerce_available_variation', array( $this, 'available_variation' ), 10, 3 );
50
  }
51
  }
52
-
53
-
54
  /**
55