YITH WooCommerce Zoom Magnifier - Version 1.3.17

Version Description

Download this release

Release Info

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

Code changes from version 1.3.16 to 1.3.17

Files changed (54) hide show
  1. README.txt +7 -2
  2. assets/css/frontend.css +63 -31
  3. assets/js/yith_magnifier.js +946 -853
  4. assets/js/yith_magnifier.min.js +1 -1
  5. assets/js/ywzm_frontend.js +212 -8
  6. assets/js/ywzm_frontend.min.js +1 -1
  7. class.yith-wcmg-frontend.php +32 -31
  8. init.php +6 -4
  9. plugin-fw/.gitignore +15 -0
  10. plugin-fw/.jshintrc +26 -0
  11. plugin-fw/assets/css/admin.css +111 -97
  12. plugin-fw/assets/css/yit-plugin-panel.css +154 -16
  13. plugin-fw/assets/css/yith-fields.css +367 -153
  14. plugin-fw/assets/js/yit-plugin-panel.js +39 -4
  15. plugin-fw/assets/js/yit-plugin-panel.min.js +1 -1
  16. plugin-fw/assets/js/yith-colorpicker.min.js +1 -1
  17. plugin-fw/assets/js/yith-fields.js +82 -13
  18. plugin-fw/assets/js/yith-fields.min.js +1 -1
  19. plugin-fw/assets/js/yith-gutenberg.js +1 -0
  20. plugin-fw/assets/js/yith-gutenberg.min.js +1 -1
  21. plugin-fw/assets/js/yith-system-info.js +17 -11
  22. plugin-fw/assets/js/yith-system-info.min.js +1 -1
  23. plugin-fw/init.php +2 -2
  24. plugin-fw/languages/yith-plugin-fw-el.mo +0 -0
  25. plugin-fw/languages/yith-plugin-fw-el.po +236 -135
  26. plugin-fw/languages/yith-plugin-fw-es_ES.mo +0 -0
  27. plugin-fw/languages/yith-plugin-fw-es_ES.po +242 -138
  28. plugin-fw/languages/yith-plugin-fw-it_IT.mo +0 -0
  29. plugin-fw/languages/yith-plugin-fw-it_IT.po +235 -142
  30. plugin-fw/languages/yith-plugin-fw-nl_NL.mo +0 -0
  31. plugin-fw/languages/yith-plugin-fw-nl_NL.po +241 -135
  32. plugin-fw/languages/yith-plugin-fw.pot +194 -108
  33. plugin-fw/lib/privacy/yit-privacy.php +2 -2
  34. plugin-fw/lib/yit-assets.php +105 -91
  35. plugin-fw/lib/yit-plugin-panel-wc.php +109 -35
  36. plugin-fw/lib/yit-plugin-panel.php +1354 -1307
  37. plugin-fw/lib/yith-system-status.php +286 -78
  38. plugin-fw/package.json +2 -2
  39. plugin-fw/templates/fields/dimensions.php +123 -0
  40. plugin-fw/templates/fields/inline-fields.php +60 -0
  41. plugin-fw/templates/fields/onoff.php +3 -3
  42. plugin-fw/templates/fields/radio.php +1 -1
  43. plugin-fw/templates/fields/select-images.php +7 -6
  44. plugin-fw/templates/fields/textarea-editor.php +3 -1
  45. plugin-fw/templates/fields/toggle-element-fixed.php +11 -3
  46. plugin-fw/templates/fields/toggle-element.php +6 -1
  47. plugin-fw/templates/fields/upload.php +1 -1
  48. plugin-fw/templates/metaboxes/tab.php +5 -5
  49. plugin-fw/templates/panel/woocommerce/woocommerce-form.php +4 -2
  50. plugin-fw/templates/sysinfo/system-information-panel.php +147 -169
  51. plugin-fw/yit-functions.php +65 -13
  52. plugin-options/premium-options.php +2 -2
  53. templates/single-product/product-image-magnifier.php +6 -2
  54. templates/single-product/product-thumbnails-magnifier.php +45 -35
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.4
7
- Stable tag: 1.3.16
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,11 @@ YITH WooCommerce Zoom Magnifier will add a new tab called "Zoom Magnifier" in "Y
52
 
53
  == Changelog ==
54
 
 
 
 
 
 
55
  = Version 1.3.16 - Released: Mar 27, 2020 =
56
 
57
  * New: support for WooCommerce 4.0
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.17
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.17 - Released: Sept 17, 2020 =
56
+
57
+ * New: support for WooCommerce 4.5
58
+ * Update: Plugin-fw
59
+
60
  = Version 1.3.16 - Released: Mar 27, 2020 =
61
 
62
  * New: support for WooCommerce 4.0
assets/css/frontend.css CHANGED
@@ -1,65 +1,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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
assets/js/yith_magnifier.js CHANGED
@@ -1,853 +1,946 @@
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);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
236
+ var self = this;
237
+ var elements = self.options.elements;
238
+
239
+ var gallery = elements.gallery;
240
+ var zoom = elements.zoom;
241
+ var zoomImage = elements.zoomImage;
242
+
243
+ if ( gallery.length > 0 ) {
244
+ gallery.on('click', function (e) {
245
+ e.preventDefault();
246
+
247
+ if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
248
+
249
+ $( '#yith_wczm_traffic_light' ).val( 'blocked' );
250
+
251
+
252
+ self.options.from_gallery = 'yes';
253
+
254
+ var t = $(this);
255
+ self.destroy();
256
+
257
+ zoom.attr('href', this.href);
258
+
259
+ zoomImage.attr('src', t.data('small'))
260
+ .attr('srcset', t.data('small'))
261
+ .attr('src-orig', t.data('small'))
262
+ .attr('title', '')
263
+ .attr('title', t.attr('title'));
264
+ $.data(self.t, 'yith_magnifier', new $.yith_magnifier(self.options, self.element));
265
+
266
+ $( '#yith_wczm_traffic_light' ).val( 'free' );
267
+
268
+
269
+ }
270
+
271
+ });
272
+
273
+ //gallery.filter(':first').trigger('click');
274
+
275
+ if (self.options.enableSlider) {
276
+ gallery.closest('ul').trigger('yith_magnifier_slider_destroy');
277
+ //gallery.closest('ul')[self.options.slider](self.options.sliderOptions);
278
+ }
279
+
280
+ } else {
281
+ gallery.on('click', function (e) {
282
+ e.preventDefault();
283
+ return false;
284
+ })
285
+ }
286
+ },
287
+
288
+ /**
289
+ * Show a loading icon while image isn't properly loaded
290
+ *
291
+ * @private
292
+ */
293
+ _loading: function () {
294
+ if (this.options.disableRightClick) {
295
+ $(document).on('contextmenu', function (e) {
296
+ return false;
297
+ });
298
+ }
299
+
300
+ if (this.mouseTrap === undefined) {
301
+ var w = this.options.elements.zoom.width();
302
+
303
+ if (this.options.loadingLabel) {
304
+ $('<div class="yith_magnifier_loading">' + this.options.loadingLabel + '</div>').css({
305
+ 'width': w,
306
+ 'text-align': 'center',
307
+ opacity: .5
308
+ }).appendTo(this.options.elements.zoom.parent());
309
+ }
310
+ }
311
+ },
312
+
313
+ /**
314
+ * Initialize the zoom images
315
+ *
316
+ * @private
317
+ */
318
+ _initZoom: function () {
319
+
320
+ if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
321
+
322
+ $( '#yith_wczm_traffic_light' ).val( 'blocked' );
323
+
324
+ var self = this;
325
+ self.zoom = self.options.elements.zoom;
326
+ self.zoomImage = self.options.elements.zoomImage;
327
+
328
+ var zoom_wrap_css_class = "yith_magnifier_zoom_wrap";
329
+
330
+ if (self.options.zoom_wrap_additional_css) {
331
+ if (!$('.' + zoom_wrap_css_class).length) {
332
+
333
+ zoom_wrap_css_class += " " + self.options.zoom_wrap_additional_css;
334
+ } else {
335
+ return;
336
+ }
337
+ }
338
+ self.zoom.wrap('<div class="' + zoom_wrap_css_class + '"></div>');
339
+
340
+ self.IMG_zoomImage = new Image();
341
+
342
+ var product_id = $( '.woocommerce-variation-add-to-cart .variation_id' ).val();
343
+
344
+ if ( $.isNumeric( product_id ) && product_id != 0 && self.options.from_gallery == 'no' && yith_wc_zoom_magnifier_storage_object.zoom_condition == '1' ){
345
+
346
+ var data = {
347
+ action : 'yith_wc_zoom_magnifier_get_main_image',
348
+ product_id : product_id,
349
+ context : 'frontend'
350
+ }
351
+
352
+ $.ajax({
353
+ data : data,
354
+ url : yith_wc_zoom_magnifier_storage_object.ajax_url,
355
+ type : 'post',
356
+ error : function ( response ) {
357
+ console.log( 'ERROR - Yith_WC_Zoom_Magnifier' );
358
+ console.log( response );
359
+ $( '#yith_wczm_traffic_light' ).val( 'free' );
360
+ },
361
+ success : function ( response ) {
362
+
363
+ self.zoom.attr( 'href', response.url );
364
+
365
+ self.IMG_zoomImage.src = response.url;
366
+
367
+ self.IMG_smallImage = new Image();
368
+ self.IMG_smallImage.src = self.zoomImage.attr('src');
369
+
370
+ // set new gallery
371
+ if( response.gallery ) {
372
+
373
+ if ($('.yith_magnifier_gallery').length)
374
+ $('.yith_magnifier_gallery').closest('.thumbnails').replaceWith( response.gallery );
375
+ else
376
+ $( '.images').append( response.gallery );
377
+
378
+ self.options.elements.gallery = $('.yith_magnifier_gallery li a' );
379
+ }
380
+
381
+ if ($.browser && $.browser.msie && $.browser.version == 8) {
382
+ $(self.IMG_zoomImage).load(function () {
383
+
384
+ self._initGallery();
385
+ self._initTrap();
386
+ });
387
+ } else {
388
+
389
+ $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
390
+
391
+ self._initGallery();
392
+ self._initTrap();
393
+ });
394
+ }
395
+
396
+ $(document).on('click', 'a.yith_expand', function (e) {
397
+
398
+ e.preventDefault();
399
+
400
+ $().prettyPhoto({
401
+ social_tools : false,
402
+ theme : 'pp_woocommerce',
403
+ horizontal_padding: 20,
404
+ opacity : 0.8,
405
+ deeplinking : false,
406
+ callback : function () {
407
+ $(".yith_expand").css('display', 'inline');
408
+ }
409
+ });
410
+
411
+ $.prettyPhoto.open(self.zoom[0].href, '', '');
412
+ $(".yith_expand").css('display', 'none');
413
+ $(".pp_woocommerce .ppt").css({
414
+ 'height' : 0,
415
+ 'marginBottom': 0
416
+ });
417
+
418
+
419
+ });
420
+ $(document).trigger('yith_magnifier_after_init_zoom');
421
+ $( '#yith_wczm_traffic_light' ).val( 'free' );
422
+ }
423
+ });
424
+
425
+ }
426
+ else{
427
+
428
+ self.IMG_zoomImage.src = self.zoom.attr('href');
429
+
430
+ self.IMG_smallImage = new Image();
431
+ self.IMG_smallImage.src = self.zoomImage.attr('src');
432
+
433
+ if ($.browser && $.browser.msie && $.browser.version == 8) {
434
+ $(self.IMG_zoomImage).load(function () {
435
+
436
+ self._initTrap();
437
+ });
438
+ } else {
439
+
440
+ $([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
441
+
442
+ self._initTrap();
443
+ });
444
+ }
445
+
446
+ $(document).on('click', 'a.yith_expand', function (e) {
447
+
448
+ e.preventDefault();
449
+
450
+ $().prettyPhoto({
451
+ social_tools : false,
452
+ theme : 'pp_woocommerce',
453
+ horizontal_padding: 20,
454
+ opacity : 0.8,
455
+ deeplinking : false,
456
+ callback : function () {
457
+ $(".yith_expand").css('display', 'inline');
458
+ }
459
+ });
460
+
461
+ $.prettyPhoto.open(self.zoom[0].href, '', '');
462
+ $(".yith_expand").css('display', 'none');
463
+ $(".pp_woocommerce .ppt").css({
464
+ 'height' : 0,
465
+ 'marginBottom': 0
466
+ });
467
+
468
+
469
+ });
470
+ $(document).trigger('yith_magnifier_after_init_zoom');
471
+
472
+ $( '#yith_wczm_traffic_light' ).val( 'free' );
473
+
474
+ }
475
+
476
+ }
477
+
478
+ },
479
+
480
+ /**
481
+ * Create the mouse trap
482
+ *
483
+ * @private
484
+ */
485
+ _initTrap: function () {
486
+
487
+ var self = this;
488
+ var zoomImg = self.IMG_zoomImage,
489
+ thumbImg = self.IMG_smallImage;
490
+
491
+ self.mx = 0;
492
+ self.my = 0;
493
+ self.controlTimer = 0;
494
+ self.lens = null;
495
+ self.tint = null;
496
+ self.softFocus = null;
497
+ self.zoomDiv = null;
498
+ self.cw = 0;
499
+ self.ch = 0;
500
+ self.zw = 0;
501
+ self.destU = 0;
502
+ self.destV = 0;
503
+ self.currU = 0;
504
+ self.currV = 0;
505
+ self.mouseTrap = null;
506
+
507
+ var zoom = self.options.elements.zoom;
508
+ var zoomImage = self.options.elements.zoomImage;
509
+
510
+ //remove loading div
511
+ //this.zoom.parent().siblings('.yith_magnifier_loading').remove();
512
+ $('.yith_magnifier_loading').remove();
513
+
514
+ if (this.element.find('.yith_magnifier_mousetrap')) {
515
+ this.element.find('.yith_magnifier_mousetrap').remove();
516
+ }
517
+
518
+ this.mouseTrap = $('<div class="yith_magnifier_mousetrap pp_woocommerce" />').css({
519
+ width : '100%', //zoomImage.outerWidth(),
520
+ height: '100%', //zoomImage.outerHeight(),
521
+ top : 0,
522
+ left : 0
523
+ }).appendTo(zoom.parent());
524
+
525
+ if( typeof ywzm_data != 'undefined' ) {
526
+ $('<a href="#" class="yith_expand" title="' + ywzm_data.expand_label + '" style="display: inline;">Expand</a>').appendTo(this.mouseTrap);
527
+ }
528
+
529
+ if (self.isPhone && self.options.phoneBehavior == 'disable') {
530
+ return;
531
+ }
532
+
533
+ // Detect device type, normal mouse or touchy(ipad android) by albanx
534
+ var touchy = ("ontouchstart" in document.documentElement) ? true : false;
535
+ var event_move = 'touchmove mousemove';
536
+ var event_end = 'touchend mouseleave';
537
+ var event_ent = 'touchstart mouseenter';
538
+ var event_click = 'touchstart click';
539
+
540
+ this.mouseTrap.on(event_move, this, function (e) {
541
+
542
+ self.options.onMove();
543
+
544
+ self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
545
+ self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
546
+
547
+ }).on(event_end, this, function (e) {
548
+
549
+ clearTimeout(self.controlTimer);
550
+ //event.data.removeBits();
551
+ if (self.lens) {
552
+ self.lens.fadeOut(299);
553
+ }
554
+ if (self.tint) {
555
+ self.tint.fadeOut(299);
556
+ }
557
+ if (self.softFocus) {
558
+ self.softFocus.fadeOut(299);
559
+ }
560
+ self.zoomDiv.fadeOut(300, function () {
561
+ self._onLeave();
562
+ });
563
+
564
+ return false;
565
+
566
+ }).on(event_click, this, function (e) {
567
+ self.options.onClick();
568
+ }).on(event_ent, this, function (e) {
569
+
570
+ if ( $( '#yith_wczm_traffic_light' ).val() == 'free' ){
571
+
572
+ self.options.onEnter();
573
+
574
+ if (touchy) {
575
+ e.preventDefault();
576
+ }
577
+
578
+ self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
579
+ self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
580
+
581
+ self.zw = e.data;
582
+ if (self.zoomDiv) {
583
+ self.zoomDiv.stop(true, false);
584
+ self.zoomDiv.remove();
585
+ }
586
+
587
+ var xPos = self.options.adjustX,
588
+ yPos = self.options.adjustY;
589
+
590
+ var siw = zoomImage.outerWidth();
591
+ var sih = zoomImage.outerHeight();
592
+
593
+ var w = self.options.zoomWidth;
594
+ var h = self.options.zoomHeight;
595
+
596
+ if (self.options.zoomWidth == 'auto') {
597
+ w = siw;
598
+ }
599
+
600
+ if (self.options.zoomHeight == 'auto') {
601
+ h = sih;
602
+ }
603
+
604
+ var appendTo = zoom.parent();
605
+ switch (self.options.position) {
606
+ case 'top':
607
+ yPos -= h;
608
+ break;
609
+ case 'right':
610
+ xPos += siw;
611
+ break;
612
+ case 'bottom':
613
+ yPos += sih;
614
+ break;
615
+ case 'left':
616
+ xPos -= w;
617
+ break;
618
+ case 'inside':
619
+ w = siw;
620
+ h = sih;
621
+ break;
622
+
623
+ // All other values, try and find an id in the dom to attach to.
624
+ default:
625
+ appendTo = $('#' + self.options.position);
626
+ // If dom element doesn't exit, just use 'right' position as default.
627
+ if (!appendTo.length) {
628
+ appendTo = zoom;
629
+ xPos += siw; //+ opts.adjustX;
630
+ yPos += sih; // + opts.adjustY;
631
+ } else {
632
+ w = appendTo.innerWidth();
633
+ h = appendTo.innerHeight();
634
+ }
635
+ }
636
+
637
+ if (self.isPhone && self.options.phoneBehavior == 'inside') {
638
+ w = siw;
639
+ h = sih;
640
+ xPos = 0;
641
+ yPos = 0;
642
+ }
643
+
644
+ self.zoomDiv = $('<div class="yith_magnifier_zoom_magnifier" />').css({
645
+ left : xPos,
646
+ top : yPos,
647
+ width : w,
648
+ height : h,
649
+ 'background-repeat': 'no-repeat',
650
+ backgroundImage : 'url(' + zoomImg.src + ')'
651
+ }).appendTo(appendTo);
652
+
653
+
654
+ // Add the title from title tag.
655
+ if (zoomImage.attr('title') && self.options.showTitle) {
656
+ $('<div class="yith_magnifier_title">' + zoomImage.attr('title') + '</div>').appendTo(self.zoomDiv);
657
+ }
658
+
659
+ if (self.isPhone) {
660
+ if (self.options.phoneBehavior != 'disable') {
661
+ self.zoomDiv.fadeIn(500);
662
+ } else {
663
+ self.lens.fadeOut(299);
664
+ }
665
+ } else {
666
+ self.zoomDiv.fadeIn(500);
667
+ }
668
+
669
+ if (self.lens) {
670
+ self.lens.remove();
671
+ self.lens = null;
672
+ }
673
+
674
+ if (zoomImg.width <= 1) {
675
+ self.cw = (zoomImage.outerWidth() / zoomImg.naturalWidth) * self.zoomDiv.width();
676
+ } else {
677
+ self.cw = (zoomImage.outerWidth() / zoomImg.width) * self.zoomDiv.width();
678
+ }
679
+
680
+ if (zoomImg.height <= 1) {
681
+ self.ch = (zoomImage.outerHeight() / zoomImg.naturalHeight) * self.zoomDiv.height();
682
+ } else {
683
+ self.ch = (zoomImage.outerHeight() / zoomImg.height) * self.zoomDiv.height();
684
+ }
685
+
686
+ // Attach mouse, initially invisible to prevent first frame glitch
687
+ self.lens = $('<div class="yith_magnifier_lens" />').css({
688
+ width : self.cw,
689
+ height: self.ch
690
+ }).appendTo(zoom);
691
+
692
+ self.mouseTrap.css('cursor', self.lens.css('cursor'));
693
+
694
+ var noTrans = false;
695
+
696
+
697
+ // Init tint layer if needed. (Not relevant if using inside mode)
698
+ if (self.options.tint) {
699
+ //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
700
+ self.tint = $('<div />').css({
701
+ display : 'none',
702
+ position : 'absolute',
703
+ left : 0,
704
+ top : 0,
705
+ width : zoomImage.outerWidth(),
706
+ height : zoomImage.outerHeight(),
707
+ backgroundColor: self.options.tint,
708
+ opacity : self.options.tintOpacity
709
+ }).appendTo(zoom);
710
+
711
+
712
+ self.lens.append($('<img />', {
713
+ src: zoomImage.attr('src')
714
+ }));
715
+
716
+ noTrans = true;
717
+ self.tint.fadeIn(500);
718
+ }
719
+
720
+ if (self.options.softFocus) {
721
+ //self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
722
+ self.softFocus = $('<div />').css({
723
+ position: 'absolute',
724
+ display : 'none',
725
+ top : '1px',
726
+ left : '1px',
727
+ width : zoomImage.outerWidth(),
728
+ height : zoomImage.outerHeight(),
729
+ //background: 'url("' + zoomImage.attr('src') + '")',
730
+ //backgroundSize: '100%',
731
+ opacity : .5
732
+ }).appendTo(zoom);
733
+
734
+ self.softFocus.append($('<img />', {
735
+ src: zoomImage.attr('src')
736
+ }));
737
+
738
+ if (self.lens.find('img').length == 0) {
739
+ self.lens.append($('<img />', {
740
+ src: zoomImage.attr('src')
741
+ }));
742
+ }
743
+
744
+ noTrans = true;
745
+ self.softFocus.fadeIn(500);
746
+ }
747
+
748
+
749
+ if (!noTrans) {
750
+ self.lens.css('opacity', self.options.lensOpacity);
751
+ }
752
+ if (self.options.position !== 'inside') {
753
+ self.lens.fadeIn(500);
754
+ }
755
+
756
+ // Start processing.
757
+ self.zw._controlLoop();
758
+
759
+ return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
760
+
761
+ }
762
+
763
+ });
764
+
765
+ },
766
+
767
+ /**
768
+ *
769
+ *
770
+ * @private
771
+ */
772
+ _controlLoop: function () {
773
+ var self = this;
774
+
775
+ if (this.lens) {
776
+ var x = (this.mx - this.zoomImage.offset().left - (this.cw * 0.5)) >> 0;
777
+ var y = (this.my - this.zoomImage.offset().top - (this.ch * 0.5)) >> 0;
778
+
779
+ if (x < 0) {
780
+ x = 0;
781
+ } else if (x > (this.zoomImage.outerWidth() - this.cw)) {
782
+ x = (this.zoomImage.outerWidth() - this.cw);
783
+ }
784
+
785
+ if (y < 0) {
786
+ y = 0;
787
+ } else if (y > (this.zoomImage.outerHeight() - this.ch)) {
788
+ y = (this.zoomImage.outerHeight() - this.ch);
789
+ }
790
+
791
+ this.lens.css({
792
+ left: x - 2,
793
+ top: y - 1
794
+ });
795
+
796
+ //this.lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
797
+
798
+
799
+ this.lens.find('img').css({
800
+ width: this.zoomImage.outerWidth(),
801
+ height: this.zoomImage.outerHeight(),
802
+ marginLeft: (-x) + 'px ',
803
+ marginTop: (-y) + 'px'
804
+ });
805
+
806
+
807
+ if (this.IMG_zoomImage.width <= 1) {
808
+ this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.naturalWidth) >> 0;
809
+ } else {
810
+ this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.width) >> 0;
811
+ }
812
+
813
+ if (this.IMG_zoomImage.height <= 1) {
814
+ this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.naturalHeight) >> 0;
815
+ } else {
816
+ this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.height) >> 0;
817
+ }
818
+
819
+
820
+ this.currU += (this.destU - this.currU) / this.options.smoothMove;
821
+ this.currV += (this.destV - this.currV) / this.options.smoothMove;
822
+
823
+ this.zoomDiv.css('background-position', (-(this.currU >> 0) + 'px ') + (-(this.currV >> 0) + 'px'));
824
+ }
825
+
826
+ this.controlTimer = setTimeout(function () {
827
+ self._controlLoop();
828
+ }, 30);
829
+ },
830
+
831
+ /**
832
+ * This method is called when the mouse leave the image
833
+ *
834
+ * @private
835
+ */
836
+ _onLeave: function () {
837
+ this.options.onLeave();
838
+
839
+ if (this.zoomDiv) {
840
+ this.zoomDiv.remove();
841
+ this.zoomDiv = null;
842
+ }
843
+
844
+ this._removeElements();
845
+ },
846
+
847
+ /**
848
+ * Remove lens, tint and softfocus
849
+ *
850
+ * @private
851
+ */
852
+ _removeElements: function () {
853
+ if (this.lens) {
854
+ this.lens.remove();
855
+ this.lens = null;
856
+ }
857
+
858
+ if (this.tint) {
859
+ this.tint.remove();
860
+ this.tint = null;
861
+ }
862
+
863
+ if (this.softFocus) {
864
+ this.softFocus.remove();
865
+ this.softFocus = null;
866
+ }
867
+
868
+ if (this.element.find('.yith_magnifier_loading').length > 0) {
869
+ this.element.find('.yith_magnifier_loading').remove();
870
+ }
871
+ },
872
+
873
+ /**
874
+ * Detect if user is using a phone device (eg iPhone)
875
+ *
876
+ * @private
877
+ */
878
+ _isPhone: function () {
879
+ var userAgent = navigator.userAgent.toLowerCase();
880
+
881
+ return ( userAgent.match(/iphone/i) || userAgent.match(/ipod/i) || userAgent.match(/android/i) );
882
+ },
883
+
884
+ /**
885
+ * Destroy the instance
886
+ *
887
+ */
888
+ destroy: function () {
889
+ if (this.zoom) {
890
+ this.zoom.unwrap();
891
+ }
892
+
893
+ if (this.mouseTrap) {
894
+ this.mouseTrap.unbind();
895
+ this.mouseTrap.remove();
896
+ this.mouseTrap = null;
897
+ }
898
+
899
+ if (this.zoomDiv) {
900
+ this.zoomDiv.remove();
901
+ this.zoomDiv = null;
902
+ }
903
+
904
+ if (this.options.disableRightClick) {
905
+ $(document).unbind();
906
+ }
907
+
908
+ this._removeElements();
909
+ this.options.elements.gallery.unbind();
910
+ this.element.removeData('yith_magnifier');
911
+ }
912
+ };
913
+
914
+ $.fn.yith_magnifier = function (options) {
915
+
916
+ if (typeof options === 'string') {
917
+ var args = Array.prototype.slice.call(arguments, 1);
918
+
919
+ this.each(function () {
920
+ var instance = $.data(this, 'yith_magnifier');
921
+ if (!instance) {
922
+ $.error("cannot call methods on yith_magnifier prior to initialization; " +
923
+ "attempted to call method '" + options + "'");
924
+ return;
925
+ }
926
+ if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
927
+ $.error("no such method '" + options + "' for yith_magnifier instance");
928
+ return;
929
+ }
930
+ instance[options].apply(instance, args);
931
+ });
932
+ } else {
933
+ this.each(function () {
934
+ var instance = $.data(this, 'yith_magnifier');
935
+ if (!instance) {
936
+ $.data(this, 'yith_magnifier', new $.yith_magnifier(options, this));
937
+ } else {
938
+ $.error('yith_magnifier already istantiated.');
939
+ }
940
+ });
941
+ }
942
+ return this;
943
+ };
944
+
945
+
946
+ })(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,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);
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=[],h=[],m=[];function l(){var o=t(h),a=t(m);n&&(m.length?n.reject(s,o,a):n.resolve(s)),t.isFunction(i)&&i.call(e,s,o,a)}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?m.push(i):h.push(i),t.data(i,"imagesLoaded",{isBroken:e,src:i.src}),a&&n.notifyWith(t(i),[e,s,t(h),t(m)]),s.length===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?g(e,a.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,a=o.zoomImage;e.length>0?(e.on("click",function(o){if(o.preventDefault(),"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,h=t.options.adjustY,m=n.outerWidth(),l=n.outerHeight(),c=t.options.zoomWidth,g=t.options.zoomHeight;"auto"==t.options.zoomWidth&&(c=m),"auto"==t.options.zoomHeight&&(g=l);var d=e.parent();switch(t.options.position){case"top":h-=g;break;case"right":r+=m;break;case"bottom":h+=l;break;case"left":r-=c;break;case"inside":c=m,g=l;break;default:(d=i("#"+t.options.position)).length?(c=d.innerWidth(),g=d.innerHeight()):(d=e,r+=m,h+=l)}t.isPhone&&"inside"==t.options.phoneBehavior&&(c=m,g=l,r=0,h=0),t.zoomDiv=i('<div class="yith_magnifier_zoom_magnifier" />').css({left:r,top:h,width:c,height:g,"background-repeat":"no-repeat",backgroundImage:"url("+o.src+")"}).appendTo(d),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);
assets/js/ywzm_frontend.js CHANGED
@@ -6,12 +6,15 @@
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,7 +23,6 @@ jQuery(document).ready(function ($) {
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,6 +46,7 @@ jQuery(document).ready(function ($) {
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,5 +61,206 @@ jQuery(document).ready(function ($) {
58
  yith_wcmg.yith_magnifier(yith_magnifier_options);
59
  });
60
 
61
- $('form.variations_form .variations select').trigger('change');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  });
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
  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
 
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
  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
  });
assets/js/ywzm_frontend.min.js CHANGED
@@ -1 +1 @@
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")});
1
+