Version Description
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Zoom Magnifier |
Version | 1.2.18 |
Comparing to | |
See all releases |
Code changes from version 1.2.17 to 1.2.18
- README.txt +246 -240
- assets/css/admin.css +19 -19
- assets/css/frontend.css +64 -64
- assets/css/yith_magnifier.css +70 -70
- assets/js/frontend.js +47 -47
- assets/js/yith_magnifier.js +790 -790
- class.yith-wcmg-admin.php +168 -168
- class.yith-wcmg-frontend.php +165 -165
- class.yith-wcmg.php +79 -79
- functions.yith-wcmg.php +78 -78
- init.php +158 -158
- lib/class.yith-woocommerce-zoom-magnifier.php +85 -85
- lib/class.yith-ywzm-custom-types.php +180 -180
- lib/class.yith-ywzm-plugin-fw-loader.php +300 -300
- plugin-fw/assets/css/colorbox.css +66 -0
- plugin-fw/assets/css/metaboxes.css +663 -629
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_flat_10_000000_40x100.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-icons_222222_256x240.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-icons_228ef1_256x240.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-icons_ef8c08_256x240.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-icons_ffd27a_256x240.png +0 -0
- plugin-fw/assets/css/overcast/images/jquery_ui/ui-icons_ffffff_256x240.png +0 -0
- plugin-fw/assets/css/overcast/jquery-ui-custom/jquery-ui-1.8.9.custom.css +578 -0
- plugin-fw/assets/css/yit-plugin-panel-sidebar.css +377 -0
- plugin-fw/assets/css/yit-plugin-panel.css +713 -664
- plugin-fw/assets/css/yit-upgrade-to-pro.css +77 -0
- plugin-fw/assets/css/yit-upgrader.css +13 -13
- plugin-fw/assets/images/colorbox/border1.png +0 -0
- plugin-fw/assets/images/colorbox/border2.png +0 -0
- plugin-fw/assets/images/colorbox/loading.gif +0 -0
- plugin-fw/assets/images/upgrade-page/01.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/02.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/03.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/04.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/05.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/06.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/07.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/08.jpg +0 -0
- plugin-fw/assets/images/upgrade-page/09.jpg +0 -0
- plugin-fw/assets/images/widgets/box-icon.png +0 -0
- plugin-fw/assets/images/widgets/box-white-icon.png +0 -0
- plugin-fw/assets/images/widgets/despacho.png +0 -0
- plugin-fw/assets/images/widgets/info-icon.png +0 -0
- plugin-fw/assets/images/widgets/link-bg.png +0 -0
- plugin-fw/assets/images/widgets/link-bg2.png +0 -0
- plugin-fw/assets/images/widgets/link-icon.png +0 -0
- plugin-fw/assets/images/widgets/membership-bg.png +0 -0
- plugin-fw/assets/js/jquery.colorbox.js +1105 -0
- plugin-fw/assets/js/metabox.js +354 -353
- plugin-fw/assets/js/metabox.min.js +8 -8
- plugin-fw/assets/js/multisite-updater.js +216 -216
- plugin-fw/assets/js/multisite-updater.min.js +3 -3
- plugin-fw/assets/js/yit-cpt-unlimited.js +78 -78
- plugin-fw/assets/js/yit-cptu-sortable-posts.js +31 -31
- plugin-fw/assets/js/yit-plugin-panel-sidebar.js +56 -0
- plugin-fw/assets/js/yit-plugin-panel-sidebar.min.js +1 -0
- plugin-fw/assets/js/yit-plugin-panel.js +328 -328
- plugin-fw/assets/js/yit-plugin-panel.min.js +2 -2
- plugin-fw/assets/js/yit-wp-pointer.js +83 -83
- plugin-fw/assets/js/yit-wp-pointer.min.js +2 -2
- plugin-fw/init.php +56 -56
- plugin-fw/languages/yith-plugin-fw-it_IT.mo +0 -0
- plugin-fw/languages/yith-plugin-fw-it_IT.po +235 -89
- plugin-fw/languages/yith-plugin-fw.pot +96 -86
- plugin-fw/lib/yit-ajax.php +76 -0
- plugin-fw/lib/yit-cpt-unlimited.php +1774 -1774
- plugin-fw/lib/yit-metabox.php +549 -549
- plugin-fw/lib/yit-plugin-common.php +1259 -1259
- plugin-fw/lib/yit-plugin-gradients.php +535 -535
- plugin-fw/lib/yit-plugin-panel-sidebar.php +427 -0
- plugin-fw/lib/yit-plugin-panel-wc.php +450 -427
- plugin-fw/lib/yit-plugin-panel.php +920 -802
- plugin-fw/lib/yit-plugin-subpanel.php +164 -164
- plugin-fw/lib/yit-pointers.php +389 -389
- plugin-fw/lib/yit-upgrade.php +556 -556
- plugin-fw/lib/yit-video.php +199 -199
- plugin-fw/licence/assets/css/yit-licence.css +439 -439
- plugin-fw/licence/assets/js/yit-licence.js +0 -182
README.txt
CHANGED
@@ -1,241 +1,247 @@
|
|
1 |
-
=== YITH WooCommerce Zoom Magnifier ===
|
2 |
-
|
3 |
-
Contributors: yithemes
|
4 |
-
Tags: zoom, magnifier, woocommerce, product image, themes, yit, e-commerce, shop, thumbnail, thumbnail slider, zoom image, carousel, image carousel
|
5 |
-
Requires at least: 3.5.1
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.2.
|
8 |
-
License: GPLv2 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
-
YITH WooCommerce Zoom Magnifier add zoom effect to product images and a customizable image slider.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
= Improve the user experience, improve your sales =
|
16 |
-
|
17 |
-
Offer to your visitors a chance to inspect in detail the quality of your products. With YITH WooCommerce Zoom Magnifier you can add a zoom effect to all your product images.
|
18 |
-
The Wordpress plugin also adds a slider below the featured image with your product gallery images.
|
19 |
-
|
20 |
-
= Main features =
|
21 |
-
|
22 |
-
* Show a bigger size product image on mouseover.
|
23 |
-
* Customize zoom area width and height and the size of the image to show as zoomed image.
|
24 |
-
* Enable or disable it on mobile devices.
|
25 |
-
* Add a slider showing product image thumbnails.
|
26 |
-
* Customize the slider behavior.
|
27 |
-
|
28 |
-
For a more detailed list of options and features of the plugin, please look at the [official documentation](http://yithemes.com/docs-plugins/yith_woocommerce_magnifier/ "Yith WooCommerce Zoom Magnifier official documentation").
|
29 |
-
|
30 |
-
Discover all the features of the plugin and install it in your theme: the result will be extremely satisfying.
|
31 |
-
|
32 |
-
== Installation ==
|
33 |
-
Important: First of all, you have to download and activate WooCommerce plugin, which is mandatory for Yith WooCommerce Zoom Magnifier to be working.
|
34 |
-
|
35 |
-
1. Unzip the downloaded zip file.
|
36 |
-
2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
|
37 |
-
3. Activate `YITH WooCommerce Zoom Magnifier` from Plugins page
|
38 |
-
|
39 |
-
= Configuration =
|
40 |
-
|
41 |
-
YITH WooCommerce Zoom Magnifier will add a new tab called "Zoom Magnifier" in "YIT Plugins" menu item. There, you will find all Yithemes plugins with quick access to plugin setting page.
|
42 |
-
|
43 |
-
== Frequently Asked Questions ==
|
44 |
-
|
45 |
-
= The size of the Zoom image is not the size I setted. Why? =
|
46 |
-
If you enabled the plugin after you uploaded the images of the product you need to [regenerate the thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/ "regenerate the thumbnails") before to use it. Another reason could be that the size setted for the zoom images is greather than the original image size.
|
47 |
-
|
48 |
-
= I'm not able to change the sizes of Zoom Image. Why? =
|
49 |
-
The size of the Zoom Image is automatically setted. If you want to change these values you just need to untick the option Forcing Zoom Image sizes.
|
50 |
-
|
51 |
-
== Screenshots ==
|
52 |
-
|
53 |
-
1. The General plugin settings page. You can disable the plugin for mobile devices.
|
54 |
-
2. The Magnifier settings page. Choose the size of the zoom area, the size of the image to be shown in zoom area and the its position (on the right or over the image).
|
55 |
-
3. The slider settings page. You can choose to use the slider for product image thumbnails, set how many images to show within the slider, and the behavior of the slider, choosing if circular, infinite or standard carousel.
|
56 |
-
4. The zoom applied to a product image, showing zoomed image on the right side.
|
57 |
-
5. The zoom applied to a product image, showing zoomed image over the same image.
|
58 |
-
6. Choose how many items the slider should show, the image thumbnails will fit the available width.
|
59 |
-
|
60 |
-
== Changelog ==
|
61 |
-
|
62 |
-
= Version 1.2.
|
63 |
-
|
64 |
-
* Updated:
|
65 |
-
*
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
*
|
71 |
-
*
|
72 |
-
|
73 |
-
= Version 1.2.
|
74 |
-
|
75 |
-
*
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
*
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
* Fixed:
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
* Fixed:
|
163 |
-
|
164 |
-
= 1.1.
|
165 |
-
|
166 |
-
*
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
*
|
173 |
-
*
|
174 |
-
|
175 |
-
= 1.1.
|
176 |
-
|
177 |
-
*
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
241 |
Â
Initial release
|
1 |
+
=== YITH WooCommerce Zoom Magnifier ===
|
2 |
+
|
3 |
+
Contributors: yithemes
|
4 |
+
Tags: zoom, magnifier, woocommerce, product image, themes, yit, e-commerce, shop, thumbnail, thumbnail slider, zoom image, carousel, image carousel
|
5 |
+
Requires at least: 3.5.1
|
6 |
+
Tested up to: 4.5
|
7 |
+
Stable tag: 1.2.18
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
YITH WooCommerce Zoom Magnifier add zoom effect to product images and a customizable image slider.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
= Improve the user experience, improve your sales =
|
16 |
+
|
17 |
+
Offer to your visitors a chance to inspect in detail the quality of your products. With YITH WooCommerce Zoom Magnifier you can add a zoom effect to all your product images.
|
18 |
+
The Wordpress plugin also adds a slider below the featured image with your product gallery images.
|
19 |
+
|
20 |
+
= Main features =
|
21 |
+
|
22 |
+
* Show a bigger size product image on mouseover.
|
23 |
+
* Customize zoom area width and height and the size of the image to show as zoomed image.
|
24 |
+
* Enable or disable it on mobile devices.
|
25 |
+
* Add a slider showing product image thumbnails.
|
26 |
+
* Customize the slider behavior.
|
27 |
+
|
28 |
+
For a more detailed list of options and features of the plugin, please look at the [official documentation](http://yithemes.com/docs-plugins/yith_woocommerce_magnifier/ "Yith WooCommerce Zoom Magnifier official documentation").
|
29 |
+
|
30 |
+
Discover all the features of the plugin and install it in your theme: the result will be extremely satisfying.
|
31 |
+
|
32 |
+
== Installation ==
|
33 |
+
Important: First of all, you have to download and activate WooCommerce plugin, which is mandatory for Yith WooCommerce Zoom Magnifier to be working.
|
34 |
+
|
35 |
+
1. Unzip the downloaded zip file.
|
36 |
+
2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
|
37 |
+
3. Activate `YITH WooCommerce Zoom Magnifier` from Plugins page
|
38 |
+
|
39 |
+
= Configuration =
|
40 |
+
|
41 |
+
YITH WooCommerce Zoom Magnifier will add a new tab called "Zoom Magnifier" in "YIT Plugins" menu item. There, you will find all Yithemes plugins with quick access to plugin setting page.
|
42 |
+
|
43 |
+
== Frequently Asked Questions ==
|
44 |
+
|
45 |
+
= The size of the Zoom image is not the size I setted. Why? =
|
46 |
+
If you enabled the plugin after you uploaded the images of the product you need to [regenerate the thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/ "regenerate the thumbnails") before to use it. Another reason could be that the size setted for the zoom images is greather than the original image size.
|
47 |
+
|
48 |
+
= I'm not able to change the sizes of Zoom Image. Why? =
|
49 |
+
The size of the Zoom Image is automatically setted. If you want to change these values you just need to untick the option Forcing Zoom Image sizes.
|
50 |
+
|
51 |
+
== Screenshots ==
|
52 |
+
|
53 |
+
1. The General plugin settings page. You can disable the plugin for mobile devices.
|
54 |
+
2. The Magnifier settings page. Choose the size of the zoom area, the size of the image to be shown in zoom area and the its position (on the right or over the image).
|
55 |
+
3. The slider settings page. You can choose to use the slider for product image thumbnails, set how many images to show within the slider, and the behavior of the slider, choosing if circular, infinite or standard carousel.
|
56 |
+
4. The zoom applied to a product image, showing zoomed image on the right side.
|
57 |
+
5. The zoom applied to a product image, showing zoomed image over the same image.
|
58 |
+
6. Choose how many items the slider should show, the image thumbnails will fit the available width.
|
59 |
+
|
60 |
+
== Changelog ==
|
61 |
+
|
62 |
+
= Version 1.2.18 - Released: May 02, 2016 =
|
63 |
+
|
64 |
+
* Updated: plugin compatible with WordPress 4.5
|
65 |
+
* Updated: plugin author name
|
66 |
+
* Updated: YITH Plugin Framework
|
67 |
+
|
68 |
+
= Version 1.2.17 - Released: Feb 24, 2016 =
|
69 |
+
|
70 |
+
* Updated: YITH Plugin FW
|
71 |
+
* Fixed: removed trailing comma in JS script that break the page rendering on old IE browser
|
72 |
+
|
73 |
+
= Version 1.2.16 - Released: Jan 18, 2016 =
|
74 |
+
|
75 |
+
* Updated: YITH Plugin FW loading remove unused YIT constant
|
76 |
+
* Added: filter yith_ywzm_zoom_wrap_additional_css for customizing CSS class for the wrapping div
|
77 |
+
* Updated: plugin ready for WooCommerce 2.5
|
78 |
+
|
79 |
+
= Version 1.2.15 - Released: Jan 04, 2016 =
|
80 |
+
|
81 |
+
* Fixed: Cannot redeclare yith_ywzm_install_woocommerce_admin_notice() when the plugin is loaded from YITH Essential Kit
|
82 |
+
|
83 |
+
= Version 1.2.14 - Released: Dec 29, 2015 =
|
84 |
+
|
85 |
+
* Added: Compatibility with YIT WooCommerce Featured Audio & Video Content
|
86 |
+
|
87 |
+
= Version 1.2.13 - Released: Dec 21, 2015 =
|
88 |
+
|
89 |
+
* Fixed: multiple wrap of zoom element with the div with class yith_magnifier_zoom_wrap
|
90 |
+
* Updated: jquery-ui.css is no more linked as external resource but shipped within the plugin, as wordpress.org asked
|
91 |
+
|
92 |
+
= Version 1.2.12 - Released: Oct 29, 2015 =
|
93 |
+
|
94 |
+
* Updated: YITH plugin framework
|
95 |
+
|
96 |
+
= Version 1.2.11 - Released: Oct 23, 2015 =
|
97 |
+
|
98 |
+
* Updated: compatibility with YITH WooCommerce Quick View.
|
99 |
+
|
100 |
+
= Version 1.2.10 - Released: Sep 24, 2015 =
|
101 |
+
|
102 |
+
* Updated: changed text domain as translate.wordpress.org requisite.
|
103 |
+
|
104 |
+
= Version 1.2.9 - Released: Sep 04, 2015 =
|
105 |
+
|
106 |
+
* Updated: Languages file
|
107 |
+
* Fixed: Changed plugin text domain from yit to ywmz
|
108 |
+
* Fixed: featured image shown one time on slider.
|
109 |
+
* Fixed: div not shown if loading text is empty.
|
110 |
+
|
111 |
+
= Version 1.2.8 - Released: Sep 01, 2015 =
|
112 |
+
|
113 |
+
* Fixed: removed deprecated woocommerce_update_option_X hook.
|
114 |
+
|
115 |
+
= Version 1.2.7 - Released: Aug 27, 2015 =
|
116 |
+
|
117 |
+
* Fixed: resolved XSS vulnerability.
|
118 |
+
|
119 |
+
= Version 1.2.6 - Released: Aug 12, 2015 =
|
120 |
+
|
121 |
+
* Tweak: update YITH Plugin framework.
|
122 |
+
|
123 |
+
= Version 1.2.5 - Released: Jul 23, 2015 =
|
124 |
+
|
125 |
+
* Added: italian language.
|
126 |
+
|
127 |
+
= Version 1.2.4 - Released: Jun 26, 2015 =
|
128 |
+
|
129 |
+
* Added: support to srcset and src-orig attributes.
|
130 |
+
|
131 |
+
= Version 1.2.3 - Released: May 29, 2015 =
|
132 |
+
|
133 |
+
* Added: included jquery-migrate as prerequisite.
|
134 |
+
|
135 |
+
= Version 1.2.2 - Released: May 22, 2015 =
|
136 |
+
|
137 |
+
* Fixed: CSS fix for EssentialGrid conflicts.
|
138 |
+
|
139 |
+
= Version 1.2.1 - Released: May 04, 2015 =
|
140 |
+
|
141 |
+
* Fixed: removed z-index that made the zoom area hiding other elements in certain themes.
|
142 |
+
|
143 |
+
= Version 1.2.0 - Released: Apr 22, 2015 =
|
144 |
+
|
145 |
+
* Fix : security issue (https://make.wordpress.org/plugins/2015/04/20/fixing-add_query_arg-and-remove_query_arg-usage/)
|
146 |
+
* Tweak : support up to Wordpress 4.2
|
147 |
+
|
148 |
+
= 1.1.8 =
|
149 |
+
|
150 |
+
* Fixed: compatibility with some YITHEMES themes.
|
151 |
+
|
152 |
+
= 1.1.7 =
|
153 |
+
|
154 |
+
* Fixed: Unwanted expand link on product image.
|
155 |
+
|
156 |
+
= 1.1.6 =
|
157 |
+
|
158 |
+
* Added: the plugin can be disabled on mobile devices.
|
159 |
+
|
160 |
+
= 1.1.5 =
|
161 |
+
|
162 |
+
* Fixed: multiple wrap
|
163 |
+
|
164 |
+
= 1.1.4 =
|
165 |
+
|
166 |
+
* Tweak: WooCommerce 2.2. support
|
167 |
+
* Fixed: Placeholder in product without featured image
|
168 |
+
* Fixed: Slider items number options doesn't work
|
169 |
+
|
170 |
+
= 1.1.3 =
|
171 |
+
|
172 |
+
* Added: Support to WC 2.2.2
|
173 |
+
* Updated: Plugin Core Framework
|
174 |
+
|
175 |
+
= 1.1.2 =
|
176 |
+
|
177 |
+
* Restored: Image size options on WC 2.1.x
|
178 |
+
* Fixed: Items number option on thumb slider
|
179 |
+
* Fixed: Hard crop issue on WC 2.1.x
|
180 |
+
|
181 |
+
= 1.1.1 =
|
182 |
+
|
183 |
+
* Fixed: Thumbnails slider direction on single product page
|
184 |
+
|
185 |
+
= 1.1.0 =
|
186 |
+
|
187 |
+
* Added: Support to WooCommerce 2.1.x
|
188 |
+
|
189 |
+
= 1.0.8 =
|
190 |
+
|
191 |
+
* Added: ability to change the slider programmatically
|
192 |
+
|
193 |
+
= 1.0.7 =
|
194 |
+
|
195 |
+
* Fixed: zoomed image did not change when select a variation
|
196 |
+
|
197 |
+
= 1.0.6 =
|
198 |
+
|
199 |
+
* Removed white space from frontend.php
|
200 |
+
|
201 |
+
= 1.0.5 =
|
202 |
+
|
203 |
+
* Fixed: magnifier override the plugin for featured video
|
204 |
+
|
205 |
+
= 1.0.4 =
|
206 |
+
|
207 |
+
* Minor bugs fixes
|
208 |
+
|
209 |
+
= 1.0.3 =
|
210 |
+
|
211 |
+
* Added ability to load the plugin even when WooCommerce is installed in a different folder
|
212 |
+
|
213 |
+
= 1.0.2 =
|
214 |
+
|
215 |
+
* Fixed fatal error to yit_debug with yit themes
|
216 |
+
|
217 |
+
= 1.0.1 =
|
218 |
+
|
219 |
+
* Optimized images
|
220 |
+
* Updated internal framework
|
221 |
+
|
222 |
+
= 1.0.0 =
|
223 |
+
|
224 |
+
* Initial release
|
225 |
+
|
226 |
+
== Suggestions ==
|
227 |
+
|
228 |
+
If you have suggestions about how to improve YITH WooCommerce Zoom Magnifier, you can [write us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle them into YITH Zoom WooCommerce Magnifier.
|
229 |
+
|
230 |
+
== Translators ==
|
231 |
+
|
232 |
+
= Available Languages =
|
233 |
+
* English (Default)
|
234 |
+
* Italiano
|
235 |
+
|
236 |
+
If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
|
237 |
+
[use](http://yithemes.com/contact/ "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Zoom Magnfier Languages.
|
238 |
+
|
239 |
+
== Documentation ==
|
240 |
+
|
241 |
+
Full documentation is available [here](http://yithemes.com/docs-plugins/yith_woocommerce_magnifier/).
|
242 |
+
|
243 |
+
== Upgrade notice ==
|
244 |
+
|
245 |
+
= 1.0.0 =
|
246 |
+
|
247 |
Â
Initial release
|
assets/css/admin.css
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
.yith_woocommerce_slider {
|
2 |
-
width: 300px;
|
3 |
-
float: left
|
4 |
-
}
|
5 |
-
.yith_woocommerce_slider_value {
|
6 |
-
margin-top: -5px;
|
7 |
-
margin-left: 10px;
|
8 |
-
width: 50px;
|
9 |
-
float: left;
|
10 |
-
text-align: center;
|
11 |
-
font-weight: bold;
|
12 |
-
}
|
13 |
-
|
14 |
-
.yith_banner {
|
15 |
-
margin-top: 10px;
|
16 |
-
}
|
17 |
-
|
18 |
-
#eg-wrap .select_fake {/* solve back-end conflict with Essential Grid */
|
19 |
-
height: 24px;
|
20 |
Â
}
|
1 |
+
.yith_woocommerce_slider {
|
2 |
+
width: 300px;
|
3 |
+
float: left
|
4 |
+
}
|
5 |
+
.yith_woocommerce_slider_value {
|
6 |
+
margin-top: -5px;
|
7 |
+
margin-left: 10px;
|
8 |
+
width: 50px;
|
9 |
+
float: left;
|
10 |
+
text-align: center;
|
11 |
+
font-weight: bold;
|
12 |
+
}
|
13 |
+
|
14 |
+
.yith_banner {
|
15 |
+
margin-top: 10px;
|
16 |
+
}
|
17 |
+
|
18 |
+
#eg-wrap .select_fake {/* solve back-end conflict with Essential Grid */
|
19 |
+
height: 24px;
|
20 |
Â
}
|
assets/css/frontend.css
CHANGED
@@ -1,65 +1,65 @@
|
|
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 |
+
}
|
6 |
+
|
7 |
+
.yith_magnifier_gallery li {
|
8 |
+
position: relative;
|
9 |
+
float: left;
|
10 |
+
display: block;
|
11 |
+
}
|
12 |
+
|
13 |
+
.yith_magnifier_gallery li.last {
|
14 |
+
margin-right: 0;
|
15 |
+
}
|
16 |
+
|
17 |
+
.yith_magnifier_gallery li a {
|
18 |
+
width: 100% !important;
|
19 |
+
display: block;
|
20 |
+
margin-top: 10px;
|
21 |
+
height: auto !important;
|
22 |
+
}
|
23 |
+
|
24 |
+
/* next/prev */
|
25 |
+
.single-product.woocommerce .thumbnails {
|
26 |
+
position: relative;
|
27 |
+
}
|
28 |
+
|
29 |
+
.single-product.woocommerce .thumbnails #slider-prev,
|
30 |
+
.single-product.woocommerce .thumbnails #slider-next {
|
31 |
+
display: none !important;
|
32 |
+
cursor: pointer;
|
33 |
+
width: 27px;
|
34 |
+
height: 26px;
|
35 |
+
background: url('../images/slider-arrow.png') no-repeat left center;
|
36 |
+
position: absolute;
|
37 |
+
top: 48%;
|
38 |
+
margin-top: -2px;
|
39 |
+
}
|
40 |
+
|
41 |
+
.single-product.woocommerce .thumbnails #slider-prev {
|
42 |
+
background-position: left center;
|
43 |
+
left: 0px;
|
44 |
+
}
|
45 |
+
|
46 |
+
.single-product.woocommerce .thumbnails #slider-next {
|
47 |
+
background-position: right center;
|
48 |
+
right: 0px;
|
49 |
+
}
|
50 |
+
|
51 |
+
.single-product.woocommerce .thumbnails:hover #slider-prev,
|
52 |
+
.single-product.woocommerce .thumbnails:hover #slider-next {
|
53 |
+
display: block !important;
|
54 |
+
}
|
55 |
+
|
56 |
+
span.onsale {
|
57 |
+
z-index: 10000
|
58 |
+
}
|
59 |
+
|
60 |
+
div.pp_woocommerce a.pp_expand {
|
61 |
+
display: inline;
|
62 |
+
bottom: 10px;
|
63 |
+
top: initial;
|
64 |
+
left: 10px;
|
65 |
Â
}
|
assets/css/yith_magnifier.css
CHANGED
@@ -1,70 +1,70 @@
|
|
1 |
-
.yith_magnifier_zoom_wrap {
|
2 |
-
top: 0;
|
3 |
-
position: relative;
|
4 |
-
}
|
5 |
-
|
6 |
-
.yith_magnifier_loading {
|
7 |
-
color:white;
|
8 |
-
background:#222;
|
9 |
-
padding:3px;
|
10 |
-
border:1px solid #000;
|
11 |
-
position: absolute;
|
12 |
-
text-align: center;
|
13 |
-
top: 10%;
|
14 |
-
z-index: 9999;
|
15 |
-
}
|
16 |
-
|
17 |
-
.yith_magnifier_zoom {
|
18 |
-
position: relative;
|
19 |
-
display: block;
|
20 |
-
}
|
21 |
-
|
22 |
-
.yith_magnifier_zoom img {
|
23 |
-
display: block;
|
24 |
-
}
|
25 |
-
|
26 |
-
.yith_magnifier_mousetrap {
|
27 |
-
z-index: 999;
|
28 |
-
position: absolute;
|
29 |
-
width: 0px;
|
30 |
-
height :0px;
|
31 |
-
left: 0;
|
32 |
-
top: 0;
|
33 |
-
}
|
34 |
-
|
35 |
-
/* ie fix */
|
36 |
-
.ie .yith_magnifier_mousetrap {
|
37 |
-
background-image: url(".");
|
38 |
-
}
|
39 |
-
|
40 |
-
.yith_magnifier_lens {
|
41 |
-
display: none;
|
42 |
-
z-index:98;
|
43 |
-
position:absolute;
|
44 |
-
overflow: hidden;
|
45 |
-
|
46 |
-
border: 1px solid #ccc;
|
47 |
-
}
|
48 |
-
|
49 |
-
.yith_magnifier_lens img {
|
50 |
-
width: auto !important;
|
51 |
-
max-width: none !important;
|
52 |
-
|
53 |
-
-webkit-transition: all ease-in-out 0s !important;
|
54 |
-
-moz-transition: all ease-in-out 0s !important;
|
55 |
-
-o-transition: all ease-in-out 0s !important;
|
56 |
-
transition: all ease-in-out 0s !important;
|
57 |
-
}
|
58 |
-
|
59 |
-
.yith_magnifier_zoom_magnifier {
|
60 |
-
display:none;
|
61 |
-
position:absolute;
|
62 |
-
z-index: 99;
|
63 |
-
|
64 |
-
border:4px solid #ccc;
|
65 |
-
overflow:hidden;
|
66 |
-
}
|
67 |
-
|
68 |
-
.yith_magnifier_gallery {
|
69 |
-
list-style: none;
|
70 |
-
}
|
1 |
+
.yith_magnifier_zoom_wrap {
|
2 |
+
top: 0;
|
3 |
+
position: relative;
|
4 |
+
}
|
5 |
+
|
6 |
+
.yith_magnifier_loading {
|
7 |
+
color:white;
|
8 |
+
background:#222;
|
9 |
+
padding:3px;
|
10 |
+
border:1px solid #000;
|
11 |
+
position: absolute;
|
12 |
+
text-align: center;
|
13 |
+
top: 10%;
|
14 |
+
z-index: 9999;
|
15 |
+
}
|
16 |
+
|
17 |
+
.yith_magnifier_zoom {
|
18 |
+
position: relative;
|
19 |
+
display: block;
|
20 |
+
}
|
21 |
+
|
22 |
+
.yith_magnifier_zoom img {
|
23 |
+
display: block;
|
24 |
+
}
|
25 |
+
|
26 |
+
.yith_magnifier_mousetrap {
|
27 |
+
z-index: 999;
|
28 |
+
position: absolute;
|
29 |
+
width: 0px;
|
30 |
+
height :0px;
|
31 |
+
left: 0;
|
32 |
+
top: 0;
|
33 |
+
}
|
34 |
+
|
35 |
+
/* ie fix */
|
36 |
+
.ie .yith_magnifier_mousetrap {
|
37 |
+
background-image: url(".");
|
38 |
+
}
|
39 |
+
|
40 |
+
.yith_magnifier_lens {
|
41 |
+
display: none;
|
42 |
+
z-index:98;
|
43 |
+
position:absolute;
|
44 |
+
overflow: hidden;
|
45 |
+
|
46 |
+
border: 1px solid #ccc;
|
47 |
+
}
|
48 |
+
|
49 |
+
.yith_magnifier_lens img {
|
50 |
+
width: auto !important;
|
51 |
+
max-width: none !important;
|
52 |
+
|
53 |
+
-webkit-transition: all ease-in-out 0s !important;
|
54 |
+
-moz-transition: all ease-in-out 0s !important;
|
55 |
+
-o-transition: all ease-in-out 0s !important;
|
56 |
+
transition: all ease-in-out 0s !important;
|
57 |
+
}
|
58 |
+
|
59 |
+
.yith_magnifier_zoom_magnifier {
|
60 |
+
display:none;
|
61 |
+
position:absolute;
|
62 |
+
z-index: 99;
|
63 |
+
|
64 |
+
border:4px solid #ccc;
|
65 |
+
overflow:hidden;
|
66 |
+
}
|
67 |
+
|
68 |
+
.yith_magnifier_gallery {
|
69 |
+
list-style: none;
|
70 |
+
}
|
assets/js/frontend.js
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
/**
|
2 |
-
* frontend.js
|
3 |
-
*
|
4 |
-
* @author Your Inspiration Themes
|
5 |
-
* @package YITH WooCommerce Zoom Magnifier
|
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');
|
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 |
-
if( typeof yith_magnifier_options == 'undefined' ) {
|
17 |
-
return false;
|
18 |
-
}
|
19 |
-
|
20 |
-
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
21 |
-
|
22 |
-
$(document).on('found_variation', 'form.variations_form', function (event, variation) {
|
23 |
-
var image_magnifier = variation.image_magnifier ? variation.image_magnifier : yith_wcmg_default_zoom;
|
24 |
-
var image_src = variation.image_src ? variation.image_src : yith_wcmg_default_image;
|
25 |
-
|
26 |
-
yith_wcmg_zoom.attr('href', image_magnifier);
|
27 |
-
yith_wcmg_image.attr('src', image_src);
|
28 |
-
yith_wcmg_image.attr('srcset', image_src);
|
29 |
-
yith_wcmg_image.attr('src-orig', image_src);
|
30 |
-
|
31 |
-
if (yith_wcmg.data('yith_magnifier')) {
|
32 |
-
yith_wcmg.yith_magnifier('destroy');
|
33 |
-
}
|
34 |
-
|
35 |
-
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
36 |
-
}).on('reset_image', function (event) {
|
37 |
-
yith_wcmg_zoom.attr('href', yith_wcmg_default_zoom);
|
38 |
-
yith_wcmg_image.attr('src', yith_wcmg_default_image);
|
39 |
-
yith_wcmg_image.attr('srcset', yith_wcmg_default_image);
|
40 |
-
yith_wcmg_image.attr('src-orig', yith_wcmg_default_image);
|
41 |
-
|
42 |
-
if (yith_wcmg.data('yith_magnifier')) {
|
43 |
-
yith_wcmg.yith_magnifier('destroy');
|
44 |
-
}
|
45 |
-
|
46 |
-
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
47 |
-
});
|
48 |
Â
});
|
1 |
+
/**
|
2 |
+
* frontend.js
|
3 |
+
*
|
4 |
+
* @author Your Inspiration Themes
|
5 |
+
* @package YITH WooCommerce Zoom Magnifier
|
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');
|
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 |
+
if( typeof yith_magnifier_options == 'undefined' ) {
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
|
20 |
+
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
21 |
+
|
22 |
+
$(document).on('found_variation', 'form.variations_form', function (event, variation) {
|
23 |
+
var image_magnifier = variation.image_magnifier ? variation.image_magnifier : yith_wcmg_default_zoom;
|
24 |
+
var image_src = variation.image_src ? variation.image_src : yith_wcmg_default_image;
|
25 |
+
|
26 |
+
yith_wcmg_zoom.attr('href', image_magnifier);
|
27 |
+
yith_wcmg_image.attr('src', image_src);
|
28 |
+
yith_wcmg_image.attr('srcset', image_src);
|
29 |
+
yith_wcmg_image.attr('src-orig', image_src);
|
30 |
+
|
31 |
+
if (yith_wcmg.data('yith_magnifier')) {
|
32 |
+
yith_wcmg.yith_magnifier('destroy');
|
33 |
+
}
|
34 |
+
|
35 |
+
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
36 |
+
}).on('reset_image', function (event) {
|
37 |
+
yith_wcmg_zoom.attr('href', yith_wcmg_default_zoom);
|
38 |
+
yith_wcmg_image.attr('src', yith_wcmg_default_image);
|
39 |
+
yith_wcmg_image.attr('srcset', yith_wcmg_default_image);
|
40 |
+
yith_wcmg_image.attr('src-orig', yith_wcmg_default_image);
|
41 |
+
|
42 |
+
if (yith_wcmg.data('yith_magnifier')) {
|
43 |
+
yith_wcmg.yith_magnifier('destroy');
|
44 |
+
}
|
45 |
+
|
46 |
+
yith_wcmg.yith_magnifier(yith_magnifier_options);
|
47 |
+
});
|
48 |
Â
});
|
assets/js/yith_magnifier.js
CHANGED
@@ -1,791 +1,791 @@
|
|
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 |
-
onLoad: function () {
|
172 |
-
return false;
|
173 |
-
},
|
174 |
-
onEnter: function () {
|
175 |
-
return false
|
176 |
-
},
|
177 |
-
onLeave: function () {
|
178 |
-
return false
|
179 |
-
},
|
180 |
-
onMove: function () {
|
181 |
-
return false
|
182 |
-
},
|
183 |
-
onClick: function () {
|
184 |
-
return false;
|
185 |
-
},
|
186 |
-
|
187 |
-
elements: {
|
188 |
-
zoom: $('.yith_magnifier_zoom'),
|
189 |
-
zoomImage: $('.yith_magnifier_zoom img'),
|
190 |
-
gallery: $('.yith_magnifier_gallery li a')
|
191 |
-
}
|
192 |
-
};
|
193 |
-
|
194 |
-
$.yith_magnifier.prototype = {
|
195 |
-
/**
|
196 |
-
* Let's start the magnifier
|
197 |
-
*
|
198 |
-
* @param {Object} options
|
199 |
-
*
|
200 |
-
* @private
|
201 |
-
*/
|
202 |
-
_init: function (options) {
|
203 |
-
var self = this;
|
204 |
-
|
205 |
-
$(document).trigger('yith_magnifier_before_init');
|
206 |
-
|
207 |
-
$.each($.yith_magnifier.defaults.elements, function (i, v) {
|
208 |
-
var el = $.yith_magnifier.defaults.elements;
|
209 |
-
el[i] = $(v, self);
|
210 |
-
});
|
211 |
-
self.options = $.extend(true, {}, $.yith_magnifier.defaults, options);
|
212 |
-
self.isPhone = self._isPhone();
|
213 |
-
|
214 |
-
self._loading();
|
215 |
-
|
216 |
-
self.element.imagesLoaded(function () {
|
217 |
-
self.options.onLoad();
|
218 |
-
self._initZoom();
|
219 |
-
self._initGallery();
|
220 |
-
});
|
221 |
-
|
222 |
-
$(document).trigger('yith_magnifier_after_init');
|
223 |
-
},
|
224 |
-
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Init gallery handlers
|
228 |
-
*
|
229 |
-
* @private
|
230 |
-
*
|
231 |
-
*/
|
232 |
-
_initGallery: function () {
|
233 |
-
var self = this;
|
234 |
-
var elements = self.options.elements;
|
235 |
-
|
236 |
-
var gallery = elements.gallery;
|
237 |
-
var zoom = elements.zoom;
|
238 |
-
var zoomImage = elements.zoomImage;
|
239 |
-
|
240 |
-
if (gallery.length > 0) {
|
241 |
-
gallery.on('click', function (e) {
|
242 |
-
e.preventDefault();
|
243 |
-
|
244 |
-
var t = $(this);
|
245 |
-
self.destroy();
|
246 |
-
|
247 |
-
zoom.attr('href', this.href);
|
248 |
-
zoomImage.attr('src', t.data('small'))
|
249 |
-
.attr('srcset', t.data('small'))
|
250 |
-
.attr('src-orig', t.data('small'))
|
251 |
-
.attr('title', '')
|
252 |
-
.attr('title', t.attr('title'));
|
253 |
-
|
254 |
-
$.data(self.t, 'yith_magnifier', new $.yith_magnifier(self.options, self.element));
|
255 |
-
});
|
256 |
-
|
257 |
-
//gallery.filter(':first').trigger('click');
|
258 |
-
|
259 |
-
if (self.options.enableSlider) {
|
260 |
-
gallery.closest('ul').trigger('yith_magnifier_slider_destroy');
|
261 |
-
gallery.closest('ul')[self.options.slider](self.options.sliderOptions);
|
262 |
-
}
|
263 |
-
|
264 |
-
} else {
|
265 |
-
gallery.on('click', function (e) {
|
266 |
-
e.preventDefault();
|
267 |
-
return false;
|
268 |
-
})
|
269 |
-
}
|
270 |
-
},
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Show a loading icon while image isn't properly loaded
|
274 |
-
*
|
275 |
-
* @private
|
276 |
-
*/
|
277 |
-
_loading: function () {
|
278 |
-
if (this.options.disableRightClick) {
|
279 |
-
$(document).on('contextmenu', function (e) {
|
280 |
-
return false;
|
281 |
-
});
|
282 |
-
}
|
283 |
-
|
284 |
-
if (this.mouseTrap === undefined) {
|
285 |
-
var w = this.options.elements.zoom.width();
|
286 |
-
|
287 |
-
if (this.options.loadingLabel) {
|
288 |
-
$('<div class="yith_magnifier_loading">' + this.options.loadingLabel + '</div>').css({
|
289 |
-
'width': w,
|
290 |
-
'text-align': 'center',
|
291 |
-
opacity: .5
|
292 |
-
}).appendTo(this.options.elements.zoom.parent());
|
293 |
-
}
|
294 |
-
}
|
295 |
-
},
|
296 |
-
|
297 |
-
/**
|
298 |
-
* Initialize the zoom images
|
299 |
-
*
|
300 |
-
* @private
|
301 |
-
*/
|
302 |
-
_initZoom: function () {
|
303 |
-
var self = this;
|
304 |
-
|
305 |
-
self.zoom = self.options.elements.zoom;
|
306 |
-
self.zoomImage = self.options.elements.zoomImage;
|
307 |
-
|
308 |
-
//wrap the zoom image with a div
|
309 |
-
var zoom_wrap_css_class = "yith_magnifier_zoom_wrap";
|
310 |
-
|
311 |
-
|
312 |
-
if (self.options.zoom_wrap_additional_css) {
|
313 |
-
if ( !$('.' + zoom_wrap_css_class).length ) {
|
314 |
-
|
315 |
-
zoom_wrap_css_class += " " + self.options.zoom_wrap_additional_css;
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
self.zoom.wrap('<div class="' + zoom_wrap_css_class + '"></div>');
|
320 |
-
|
321 |
-
self.IMG_zoomImage = new Image();
|
322 |
-
self.IMG_zoomImage.src = self.zoom.attr('href');
|
323 |
-
|
324 |
-
self.IMG_smallImage = new Image();
|
325 |
-
self.IMG_smallImage.src = self.zoomImage.attr('src');
|
326 |
-
|
327 |
-
if ($.browser.msie && $.browser.version == 8) {
|
328 |
-
$(self.IMG_zoomImage).load(function () {
|
329 |
-
|
330 |
-
self._initTrap();
|
331 |
-
});
|
332 |
-
} else {
|
333 |
-
|
334 |
-
$([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
|
335 |
-
|
336 |
-
self._initTrap();
|
337 |
-
});
|
338 |
-
}
|
339 |
-
|
340 |
-
$(document).trigger('yith_magnifier_after_init_zoom')
|
341 |
-
},
|
342 |
-
|
343 |
-
/**
|
344 |
-
* Create the mouse trap
|
345 |
-
*
|
346 |
-
* @private
|
347 |
-
*/
|
348 |
-
_initTrap: function () {
|
349 |
-
var self = this;
|
350 |
-
var zoomImg = self.IMG_zoomImage,
|
351 |
-
thumbImg = self.IMG_smallImage;
|
352 |
-
|
353 |
-
self.mx = 0;
|
354 |
-
self.my = 0;
|
355 |
-
self.controlTimer = 0;
|
356 |
-
self.lens = null;
|
357 |
-
self.tint = null;
|
358 |
-
self.softFocus = null;
|
359 |
-
self.zoomDiv = null;
|
360 |
-
self.cw = 0;
|
361 |
-
self.ch = 0;
|
362 |
-
self.zw = 0;
|
363 |
-
self.destU = 0;
|
364 |
-
self.destV = 0;
|
365 |
-
self.currU = 0;
|
366 |
-
self.currV = 0;
|
367 |
-
self.mouseTrap = null;
|
368 |
-
|
369 |
-
var zoom = self.options.elements.zoom;
|
370 |
-
var zoomImage = self.options.elements.zoomImage;
|
371 |
-
|
372 |
-
//remove loading div
|
373 |
-
//this.zoom.parent().siblings('.yith_magnifier_loading').remove();
|
374 |
-
$('.yith_magnifier_loading').remove();
|
375 |
-
|
376 |
-
if (this.element.find('.yith_magnifier_mousetrap')) {
|
377 |
-
this.element.find('.yith_magnifier_mousetrap').remove();
|
378 |
-
}
|
379 |
-
|
380 |
-
this.mouseTrap = $('<div class="yith_magnifier_mousetrap" />').css({
|
381 |
-
width: '100%', //zoomImage.outerWidth(),
|
382 |
-
height: '100%', //zoomImage.outerHeight(),
|
383 |
-
top: 0,
|
384 |
-
left: 0
|
385 |
-
}).appendTo(zoom.parent());
|
386 |
-
|
387 |
-
// Detect device type, normal mouse or touchy(ipad android) by albanx
|
388 |
-
var touchy = ("ontouchstart" in document.documentElement) ? true : false;
|
389 |
-
var event_move = 'touchmove mousemove';
|
390 |
-
var event_end = 'touchend mouseleave';
|
391 |
-
var event_ent = 'touchstart mouseenter';
|
392 |
-
var event_click = 'touchstart click';
|
393 |
-
|
394 |
-
this.mouseTrap.on(event_move, this, function (e) {
|
395 |
-
self.options.onMove();
|
396 |
-
|
397 |
-
self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
|
398 |
-
self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
|
399 |
-
|
400 |
-
}).on(event_end, this, function (e) {
|
401 |
-
|
402 |
-
clearTimeout(self.controlTimer);
|
403 |
-
//event.data.removeBits();
|
404 |
-
if (self.lens) {
|
405 |
-
self.lens.fadeOut(299);
|
406 |
-
}
|
407 |
-
if (self.tint) {
|
408 |
-
self.tint.fadeOut(299);
|
409 |
-
}
|
410 |
-
if (self.softFocus) {
|
411 |
-
self.softFocus.fadeOut(299);
|
412 |
-
}
|
413 |
-
self.zoomDiv.fadeOut(300, function () {
|
414 |
-
self._onLeave();
|
415 |
-
});
|
416 |
-
|
417 |
-
return false;
|
418 |
-
|
419 |
-
}).on(event_click, this, function (e) {
|
420 |
-
self.options.onClick();
|
421 |
-
}).on(event_ent, this, function (e) {
|
422 |
-
self.options.onEnter();
|
423 |
-
|
424 |
-
if (touchy) {
|
425 |
-
e.preventDefault();
|
426 |
-
}
|
427 |
-
|
428 |
-
self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
|
429 |
-
self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
|
430 |
-
|
431 |
-
self.zw = e.data;
|
432 |
-
if (self.zoomDiv) {
|
433 |
-
self.zoomDiv.stop(true, false);
|
434 |
-
self.zoomDiv.remove();
|
435 |
-
}
|
436 |
-
|
437 |
-
var xPos = self.options.adjustX,
|
438 |
-
yPos = self.options.adjustY;
|
439 |
-
|
440 |
-
var siw = zoomImage.outerWidth();
|
441 |
-
var sih = zoomImage.outerHeight();
|
442 |
-
|
443 |
-
var w = self.options.zoomWidth;
|
444 |
-
var h = self.options.zoomHeight;
|
445 |
-
|
446 |
-
if (self.options.zoomWidth == 'auto') {
|
447 |
-
w = siw;
|
448 |
-
}
|
449 |
-
|
450 |
-
if (self.options.zoomHeight == 'auto') {
|
451 |
-
h = sih;
|
452 |
-
}
|
453 |
-
|
454 |
-
var appendTo = zoom.parent();
|
455 |
-
switch (self.options.position) {
|
456 |
-
case 'top':
|
457 |
-
yPos -= h;
|
458 |
-
break;
|
459 |
-
case 'right':
|
460 |
-
xPos += siw;
|
461 |
-
break;
|
462 |
-
case 'bottom':
|
463 |
-
yPos += sih;
|
464 |
-
break;
|
465 |
-
case 'left':
|
466 |
-
xPos -= w;
|
467 |
-
break;
|
468 |
-
case 'inside':
|
469 |
-
w = siw;
|
470 |
-
h = sih;
|
471 |
-
break;
|
472 |
-
|
473 |
-
// All other values, try and find an id in the dom to attach to.
|
474 |
-
default:
|
475 |
-
appendTo = $('#' + self.options.position);
|
476 |
-
// If dom element doesn't exit, just use 'right' position as default.
|
477 |
-
if (!appendTo.length) {
|
478 |
-
appendTo = zoom;
|
479 |
-
xPos += siw; //+ opts.adjustX;
|
480 |
-
yPos += sih; // + opts.adjustY;
|
481 |
-
} else {
|
482 |
-
w = appendTo.innerWidth();
|
483 |
-
h = appendTo.innerHeight();
|
484 |
-
}
|
485 |
-
}
|
486 |
-
|
487 |
-
if (self.isPhone && self.options.phoneBehavior == 'inside') {
|
488 |
-
w = siw;
|
489 |
-
h = sih;
|
490 |
-
xPos = 0;
|
491 |
-
yPos = 0;
|
492 |
-
}
|
493 |
-
|
494 |
-
self.zoomDiv = $('<div class="yith_magnifier_zoom_magnifier" />').css({
|
495 |
-
left: xPos,
|
496 |
-
top: yPos,
|
497 |
-
width: w,
|
498 |
-
height: h,
|
499 |
-
'background-repeat': 'no-repeat',
|
500 |
-
backgroundImage: 'url(' + zoomImg.src + ')'
|
501 |
-
}).appendTo(appendTo);
|
502 |
-
|
503 |
-
// Add the title from title tag.
|
504 |
-
if (zoomImage.attr('title') && self.options.showTitle) {
|
505 |
-
$('<div class="yith_magnifier_title">' + zoomImage.attr('title') + '</div>').appendTo(self.zoomDiv);
|
506 |
-
}
|
507 |
-
|
508 |
-
if (self.isPhone) {
|
509 |
-
if (self.options.phoneBehavior != 'disable') {
|
510 |
-
self.zoomDiv.fadeIn(500);
|
511 |
-
} else {
|
512 |
-
self.lens.fadeOut(299);
|
513 |
-
}
|
514 |
-
} else {
|
515 |
-
self.zoomDiv.fadeIn(500);
|
516 |
-
}
|
517 |
-
|
518 |
-
if (self.lens) {
|
519 |
-
self.lens.remove();
|
520 |
-
self.lens = null;
|
521 |
-
}
|
522 |
-
|
523 |
-
if (zoomImg.width <= 1) {
|
524 |
-
self.cw = (zoomImage.outerWidth() / zoomImg.naturalWidth) * self.zoomDiv.width();
|
525 |
-
} else {
|
526 |
-
self.cw = (zoomImage.outerWidth() / zoomImg.width) * self.zoomDiv.width();
|
527 |
-
}
|
528 |
-
|
529 |
-
if (zoomImg.height <= 1) {
|
530 |
-
self.ch = (zoomImage.outerHeight() / zoomImg.naturalHeight) * self.zoomDiv.height();
|
531 |
-
} else {
|
532 |
-
self.ch = (zoomImage.outerHeight() / zoomImg.height) * self.zoomDiv.height();
|
533 |
-
}
|
534 |
-
|
535 |
-
// Attach mouse, initially invisible to prevent first frame glitch
|
536 |
-
self.lens = $('<div class="yith_magnifier_lens" />').css({
|
537 |
-
width: self.cw,
|
538 |
-
height: self.ch
|
539 |
-
}).appendTo(zoom);
|
540 |
-
|
541 |
-
self.mouseTrap.css('cursor', self.lens.css('cursor'));
|
542 |
-
|
543 |
-
var noTrans = false;
|
544 |
-
|
545 |
-
|
546 |
-
// Init tint layer if needed. (Not relevant if using inside mode)
|
547 |
-
if (self.options.tint) {
|
548 |
-
//self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
|
549 |
-
self.tint = $('<div />').css({
|
550 |
-
display: 'none',
|
551 |
-
position: 'absolute',
|
552 |
-
left: 0,
|
553 |
-
top: 0,
|
554 |
-
width: zoomImage.outerWidth(),
|
555 |
-
height: zoomImage.outerHeight(),
|
556 |
-
backgroundColor: self.options.tint,
|
557 |
-
opacity: self.options.tintOpacity
|
558 |
-
}).appendTo(zoom);
|
559 |
-
|
560 |
-
|
561 |
-
self.lens.append($('<img />', {
|
562 |
-
src: zoomImage.attr('src')
|
563 |
-
}));
|
564 |
-
|
565 |
-
noTrans = true;
|
566 |
-
self.tint.fadeIn(500);
|
567 |
-
}
|
568 |
-
|
569 |
-
if (self.options.softFocus) {
|
570 |
-
//self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
|
571 |
-
self.softFocus = $('<div />').css({
|
572 |
-
position: 'absolute',
|
573 |
-
display: 'none',
|
574 |
-
top: '1px',
|
575 |
-
left: '1px',
|
576 |
-
width: zoomImage.outerWidth(),
|
577 |
-
height: zoomImage.outerHeight(),
|
578 |
-
//background: 'url("' + zoomImage.attr('src') + '")',
|
579 |
-
//backgroundSize: '100%',
|
580 |
-
opacity: .5
|
581 |
-
}).appendTo(zoom);
|
582 |
-
|
583 |
-
self.softFocus.append($('<img />', {
|
584 |
-
src: zoomImage.attr('src')
|
585 |
-
}));
|
586 |
-
|
587 |
-
if (self.lens.find('img').length == 0) {
|
588 |
-
self.lens.append($('<img />', {
|
589 |
-
src: zoomImage.attr('src')
|
590 |
-
}));
|
591 |
-
}
|
592 |
-
|
593 |
-
noTrans = true;
|
594 |
-
self.softFocus.fadeIn(500);
|
595 |
-
}
|
596 |
-
|
597 |
-
|
598 |
-
if (!noTrans) {
|
599 |
-
self.lens.css('opacity', self.options.lensOpacity);
|
600 |
-
}
|
601 |
-
if (self.options.position !== 'inside') {
|
602 |
-
self.lens.fadeIn(500);
|
603 |
-
}
|
604 |
-
|
605 |
-
// Start processing.
|
606 |
-
self.zw._controlLoop();
|
607 |
-
|
608 |
-
return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
|
609 |
-
});
|
610 |
-
},
|
611 |
-
|
612 |
-
/**
|
613 |
-
*
|
614 |
-
*
|
615 |
-
* @private
|
616 |
-
*/
|
617 |
-
_controlLoop: function () {
|
618 |
-
var self = this;
|
619 |
-
|
620 |
-
if (this.lens) {
|
621 |
-
var x = (this.mx - this.zoomImage.offset().left - (this.cw * 0.5)) >> 0;
|
622 |
-
var y = (this.my - this.zoomImage.offset().top - (this.ch * 0.5)) >> 0;
|
623 |
-
|
624 |
-
if (x < 0) {
|
625 |
-
x = 0;
|
626 |
-
} else if (x > (this.zoomImage.outerWidth() - this.cw)) {
|
627 |
-
x = (this.zoomImage.outerWidth() - this.cw);
|
628 |
-
}
|
629 |
-
|
630 |
-
if (y < 0) {
|
631 |
-
y = 0;
|
632 |
-
} else if (y > (this.zoomImage.outerHeight() - this.ch)) {
|
633 |
-
y = (this.zoomImage.outerHeight() - this.ch);
|
634 |
-
}
|
635 |
-
|
636 |
-
this.lens.css({
|
637 |
-
left: x - 2,
|
638 |
-
top: y - 1
|
639 |
-
});
|
640 |
-
|
641 |
-
//this.lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
|
642 |
-
|
643 |
-
|
644 |
-
this.lens.find('img').css({
|
645 |
-
width: this.zoomImage.outerWidth(),
|
646 |
-
height: this.zoomImage.outerHeight(),
|
647 |
-
marginLeft: (-x) + 'px ',
|
648 |
-
marginTop: (-y) + 'px'
|
649 |
-
});
|
650 |
-
|
651 |
-
|
652 |
-
if (this.IMG_zoomImage.width <= 1) {
|
653 |
-
this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.naturalWidth) >> 0;
|
654 |
-
} else {
|
655 |
-
this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.width) >> 0;
|
656 |
-
}
|
657 |
-
|
658 |
-
if (this.IMG_zoomImage.height <= 1) {
|
659 |
-
this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.naturalHeight) >> 0;
|
660 |
-
} else {
|
661 |
-
this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.height) >> 0;
|
662 |
-
}
|
663 |
-
|
664 |
-
|
665 |
-
this.currU += (this.destU - this.currU) / this.options.smoothMove;
|
666 |
-
this.currV += (this.destV - this.currV) / this.options.smoothMove;
|
667 |
-
|
668 |
-
this.zoomDiv.css('background-position', (-(this.currU >> 0) + 'px ') + (-(this.currV >> 0) + 'px'));
|
669 |
-
}
|
670 |
-
|
671 |
-
this.controlTimer = setTimeout(function () {
|
672 |
-
self._controlLoop();
|
673 |
-
}, 30);
|
674 |
-
},
|
675 |
-
|
676 |
-
/**
|
677 |
-
* This method is called when the mouse leave the image
|
678 |
-
*
|
679 |
-
* @private
|
680 |
-
*/
|
681 |
-
_onLeave: function () {
|
682 |
-
this.options.onLeave();
|
683 |
-
|
684 |
-
if (this.zoomDiv) {
|
685 |
-
this.zoomDiv.remove();
|
686 |
-
this.zoomDiv = null;
|
687 |
-
}
|
688 |
-
|
689 |
-
this._removeElements();
|
690 |
-
},
|
691 |
-
|
692 |
-
/**
|
693 |
-
* Remove lens, tint and softfocus
|
694 |
-
*
|
695 |
-
* @private
|
696 |
-
*/
|
697 |
-
_removeElements: function () {
|
698 |
-
if (this.lens) {
|
699 |
-
this.lens.remove();
|
700 |
-
this.lens = null;
|
701 |
-
}
|
702 |
-
|
703 |
-
if (this.tint) {
|
704 |
-
this.tint.remove();
|
705 |
-
this.tint = null;
|
706 |
-
}
|
707 |
-
|
708 |
-
if (this.softFocus) {
|
709 |
-
this.softFocus.remove();
|
710 |
-
this.softFocus = null;
|
711 |
-
}
|
712 |
-
|
713 |
-
if (this.element.find('.yith_magnifier_loading').length > 0) {
|
714 |
-
this.element.find('.yith_magnifier_loading').remove();
|
715 |
-
}
|
716 |
-
},
|
717 |
-
|
718 |
-
/**
|
719 |
-
* Detect if user is using a phone device (eg iPhone)
|
720 |
-
*
|
721 |
-
* @private
|
722 |
-
*/
|
723 |
-
_isPhone: function () {
|
724 |
-
var userAgent = navigator.userAgent.toLowerCase();
|
725 |
-
|
726 |
-
return ( userAgent.match(/iphone/i) || userAgent.match(/ipod/i) || userAgent.match(/android/i) );
|
727 |
-
},
|
728 |
-
|
729 |
-
/**
|
730 |
-
* Destroy the instance
|
731 |
-
*
|
732 |
-
*/
|
733 |
-
destroy: function () {
|
734 |
-
if (this.zoom) {
|
735 |
-
this.zoom.unwrap();
|
736 |
-
}
|
737 |
-
|
738 |
-
if (this.mouseTrap) {
|
739 |
-
this.mouseTrap.unbind();
|
740 |
-
this.mouseTrap.remove();
|
741 |
-
this.mouseTrap = null;
|
742 |
-
}
|
743 |
-
|
744 |
-
if (this.zoomDiv) {
|
745 |
-
this.zoomDiv.remove();
|
746 |
-
this.zoomDiv = null;
|
747 |
-
}
|
748 |
-
|
749 |
-
if (this.options.disableRightClick) {
|
750 |
-
$(document).unbind();
|
751 |
-
}
|
752 |
-
|
753 |
-
this._removeElements();
|
754 |
-
this.options.elements.gallery.unbind();
|
755 |
-
this.element.removeData('yith_magnifier');
|
756 |
-
}
|
757 |
-
};
|
758 |
-
|
759 |
-
$.fn.yith_magnifier = function (options) {
|
760 |
-
|
761 |
-
if (typeof options === 'string') {
|
762 |
-
var args = Array.prototype.slice.call(arguments, 1);
|
763 |
-
|
764 |
-
this.each(function () {
|
765 |
-
var instance = $.data(this, 'yith_magnifier');
|
766 |
-
if (!instance) {
|
767 |
-
$.error("cannot call methods on yith_magnifier prior to initialization; " +
|
768 |
-
"attempted to call method '" + options + "'");
|
769 |
-
return;
|
770 |
-
}
|
771 |
-
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
|
772 |
-
$.error("no such method '" + options + "' for yith_magnifier instance");
|
773 |
-
return;
|
774 |
-
}
|
775 |
-
instance[options].apply(instance, args);
|
776 |
-
});
|
777 |
-
} else {
|
778 |
-
this.each(function () {
|
779 |
-
var instance = $.data(this, 'yith_magnifier');
|
780 |
-
if (!instance) {
|
781 |
-
$.data(this, 'yith_magnifier', new $.yith_magnifier(options, this));
|
782 |
-
} else {
|
783 |
-
$.error('yith_magnifier already istantiated.');
|
784 |
-
}
|
785 |
-
});
|
786 |
-
}
|
787 |
-
return this;
|
788 |
-
};
|
789 |
-
|
790 |
-
|
791 |
Â
})(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 |
+
onLoad: function () {
|
172 |
+
return false;
|
173 |
+
},
|
174 |
+
onEnter: function () {
|
175 |
+
return false
|
176 |
+
},
|
177 |
+
onLeave: function () {
|
178 |
+
return false
|
179 |
+
},
|
180 |
+
onMove: function () {
|
181 |
+
return false
|
182 |
+
},
|
183 |
+
onClick: function () {
|
184 |
+
return false;
|
185 |
+
},
|
186 |
+
|
187 |
+
elements: {
|
188 |
+
zoom: $('.yith_magnifier_zoom'),
|
189 |
+
zoomImage: $('.yith_magnifier_zoom img'),
|
190 |
+
gallery: $('.yith_magnifier_gallery li a')
|
191 |
+
}
|
192 |
+
};
|
193 |
+
|
194 |
+
$.yith_magnifier.prototype = {
|
195 |
+
/**
|
196 |
+
* Let's start the magnifier
|
197 |
+
*
|
198 |
+
* @param {Object} options
|
199 |
+
*
|
200 |
+
* @private
|
201 |
+
*/
|
202 |
+
_init: function (options) {
|
203 |
+
var self = this;
|
204 |
+
|
205 |
+
$(document).trigger('yith_magnifier_before_init');
|
206 |
+
|
207 |
+
$.each($.yith_magnifier.defaults.elements, function (i, v) {
|
208 |
+
var el = $.yith_magnifier.defaults.elements;
|
209 |
+
el[i] = $(v, self);
|
210 |
+
});
|
211 |
+
self.options = $.extend(true, {}, $.yith_magnifier.defaults, options);
|
212 |
+
self.isPhone = self._isPhone();
|
213 |
+
|
214 |
+
self._loading();
|
215 |
+
|
216 |
+
self.element.imagesLoaded(function () {
|
217 |
+
self.options.onLoad();
|
218 |
+
self._initZoom();
|
219 |
+
self._initGallery();
|
220 |
+
});
|
221 |
+
|
222 |
+
$(document).trigger('yith_magnifier_after_init');
|
223 |
+
},
|
224 |
+
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Init gallery handlers
|
228 |
+
*
|
229 |
+
* @private
|
230 |
+
*
|
231 |
+
*/
|
232 |
+
_initGallery: function () {
|
233 |
+
var self = this;
|
234 |
+
var elements = self.options.elements;
|
235 |
+
|
236 |
+
var gallery = elements.gallery;
|
237 |
+
var zoom = elements.zoom;
|
238 |
+
var zoomImage = elements.zoomImage;
|
239 |
+
|
240 |
+
if (gallery.length > 0) {
|
241 |
+
gallery.on('click', function (e) {
|
242 |
+
e.preventDefault();
|
243 |
+
|
244 |
+
var t = $(this);
|
245 |
+
self.destroy();
|
246 |
+
|
247 |
+
zoom.attr('href', this.href);
|
248 |
+
zoomImage.attr('src', t.data('small'))
|
249 |
+
.attr('srcset', t.data('small'))
|
250 |
+
.attr('src-orig', t.data('small'))
|
251 |
+
.attr('title', '')
|
252 |
+
.attr('title', t.attr('title'));
|
253 |
+
|
254 |
+
$.data(self.t, 'yith_magnifier', new $.yith_magnifier(self.options, self.element));
|
255 |
+
});
|
256 |
+
|
257 |
+
//gallery.filter(':first').trigger('click');
|
258 |
+
|
259 |
+
if (self.options.enableSlider) {
|
260 |
+
gallery.closest('ul').trigger('yith_magnifier_slider_destroy');
|
261 |
+
gallery.closest('ul')[self.options.slider](self.options.sliderOptions);
|
262 |
+
}
|
263 |
+
|
264 |
+
} else {
|
265 |
+
gallery.on('click', function (e) {
|
266 |
+
e.preventDefault();
|
267 |
+
return false;
|
268 |
+
})
|
269 |
+
}
|
270 |
+
},
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Show a loading icon while image isn't properly loaded
|
274 |
+
*
|
275 |
+
* @private
|
276 |
+
*/
|
277 |
+
_loading: function () {
|
278 |
+
if (this.options.disableRightClick) {
|
279 |
+
$(document).on('contextmenu', function (e) {
|
280 |
+
return false;
|
281 |
+
});
|
282 |
+
}
|
283 |
+
|
284 |
+
if (this.mouseTrap === undefined) {
|
285 |
+
var w = this.options.elements.zoom.width();
|
286 |
+
|
287 |
+
if (this.options.loadingLabel) {
|
288 |
+
$('<div class="yith_magnifier_loading">' + this.options.loadingLabel + '</div>').css({
|
289 |
+
'width': w,
|
290 |
+
'text-align': 'center',
|
291 |
+
opacity: .5
|
292 |
+
}).appendTo(this.options.elements.zoom.parent());
|
293 |
+
}
|
294 |
+
}
|
295 |
+
},
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Initialize the zoom images
|
299 |
+
*
|
300 |
+
* @private
|
301 |
+
*/
|
302 |
+
_initZoom: function () {
|
303 |
+
var self = this;
|
304 |
+
|
305 |
+
self.zoom = self.options.elements.zoom;
|
306 |
+
self.zoomImage = self.options.elements.zoomImage;
|
307 |
+
|
308 |
+
//wrap the zoom image with a div
|
309 |
+
var zoom_wrap_css_class = "yith_magnifier_zoom_wrap";
|
310 |
+
|
311 |
+
|
312 |
+
if (self.options.zoom_wrap_additional_css) {
|
313 |
+
if ( !$('.' + zoom_wrap_css_class).length ) {
|
314 |
+
|
315 |
+
zoom_wrap_css_class += " " + self.options.zoom_wrap_additional_css;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
self.zoom.wrap('<div class="' + zoom_wrap_css_class + '"></div>');
|
320 |
+
|
321 |
+
self.IMG_zoomImage = new Image();
|
322 |
+
self.IMG_zoomImage.src = self.zoom.attr('href');
|
323 |
+
|
324 |
+
self.IMG_smallImage = new Image();
|
325 |
+
self.IMG_smallImage.src = self.zoomImage.attr('src');
|
326 |
+
|
327 |
+
if ($.browser.msie && $.browser.version == 8) {
|
328 |
+
$(self.IMG_zoomImage).load(function () {
|
329 |
+
|
330 |
+
self._initTrap();
|
331 |
+
});
|
332 |
+
} else {
|
333 |
+
|
334 |
+
$([self.IMG_zoomImage, self.IMG_smallImage]).imagesLoaded(function () {
|
335 |
+
|
336 |
+
self._initTrap();
|
337 |
+
});
|
338 |
+
}
|
339 |
+
|
340 |
+
$(document).trigger('yith_magnifier_after_init_zoom')
|
341 |
+
},
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Create the mouse trap
|
345 |
+
*
|
346 |
+
* @private
|
347 |
+
*/
|
348 |
+
_initTrap: function () {
|
349 |
+
var self = this;
|
350 |
+
var zoomImg = self.IMG_zoomImage,
|
351 |
+
thumbImg = self.IMG_smallImage;
|
352 |
+
|
353 |
+
self.mx = 0;
|
354 |
+
self.my = 0;
|
355 |
+
self.controlTimer = 0;
|
356 |
+
self.lens = null;
|
357 |
+
self.tint = null;
|
358 |
+
self.softFocus = null;
|
359 |
+
self.zoomDiv = null;
|
360 |
+
self.cw = 0;
|
361 |
+
self.ch = 0;
|
362 |
+
self.zw = 0;
|
363 |
+
self.destU = 0;
|
364 |
+
self.destV = 0;
|
365 |
+
self.currU = 0;
|
366 |
+
self.currV = 0;
|
367 |
+
self.mouseTrap = null;
|
368 |
+
|
369 |
+
var zoom = self.options.elements.zoom;
|
370 |
+
var zoomImage = self.options.elements.zoomImage;
|
371 |
+
|
372 |
+
//remove loading div
|
373 |
+
//this.zoom.parent().siblings('.yith_magnifier_loading').remove();
|
374 |
+
$('.yith_magnifier_loading').remove();
|
375 |
+
|
376 |
+
if (this.element.find('.yith_magnifier_mousetrap')) {
|
377 |
+
this.element.find('.yith_magnifier_mousetrap').remove();
|
378 |
+
}
|
379 |
+
|
380 |
+
this.mouseTrap = $('<div class="yith_magnifier_mousetrap" />').css({
|
381 |
+
width: '100%', //zoomImage.outerWidth(),
|
382 |
+
height: '100%', //zoomImage.outerHeight(),
|
383 |
+
top: 0,
|
384 |
+
left: 0
|
385 |
+
}).appendTo(zoom.parent());
|
386 |
+
|
387 |
+
// Detect device type, normal mouse or touchy(ipad android) by albanx
|
388 |
+
var touchy = ("ontouchstart" in document.documentElement) ? true : false;
|
389 |
+
var event_move = 'touchmove mousemove';
|
390 |
+
var event_end = 'touchend mouseleave';
|
391 |
+
var event_ent = 'touchstart mouseenter';
|
392 |
+
var event_click = 'touchstart click';
|
393 |
+
|
394 |
+
this.mouseTrap.on(event_move, this, function (e) {
|
395 |
+
self.options.onMove();
|
396 |
+
|
397 |
+
self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
|
398 |
+
self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
|
399 |
+
|
400 |
+
}).on(event_end, this, function (e) {
|
401 |
+
|
402 |
+
clearTimeout(self.controlTimer);
|
403 |
+
//event.data.removeBits();
|
404 |
+
if (self.lens) {
|
405 |
+
self.lens.fadeOut(299);
|
406 |
+
}
|
407 |
+
if (self.tint) {
|
408 |
+
self.tint.fadeOut(299);
|
409 |
+
}
|
410 |
+
if (self.softFocus) {
|
411 |
+
self.softFocus.fadeOut(299);
|
412 |
+
}
|
413 |
+
self.zoomDiv.fadeOut(300, function () {
|
414 |
+
self._onLeave();
|
415 |
+
});
|
416 |
+
|
417 |
+
return false;
|
418 |
+
|
419 |
+
}).on(event_click, this, function (e) {
|
420 |
+
self.options.onClick();
|
421 |
+
}).on(event_ent, this, function (e) {
|
422 |
+
self.options.onEnter();
|
423 |
+
|
424 |
+
if (touchy) {
|
425 |
+
e.preventDefault();
|
426 |
+
}
|
427 |
+
|
428 |
+
self.mx = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageX : e.pageX;
|
429 |
+
self.my = ( typeof(e.originalEvent.touches) != 'undefined' ) ? e.originalEvent.touches[0].pageY : e.pageY;
|
430 |
+
|
431 |
+
self.zw = e.data;
|
432 |
+
if (self.zoomDiv) {
|
433 |
+
self.zoomDiv.stop(true, false);
|
434 |
+
self.zoomDiv.remove();
|
435 |
+
}
|
436 |
+
|
437 |
+
var xPos = self.options.adjustX,
|
438 |
+
yPos = self.options.adjustY;
|
439 |
+
|
440 |
+
var siw = zoomImage.outerWidth();
|
441 |
+
var sih = zoomImage.outerHeight();
|
442 |
+
|
443 |
+
var w = self.options.zoomWidth;
|
444 |
+
var h = self.options.zoomHeight;
|
445 |
+
|
446 |
+
if (self.options.zoomWidth == 'auto') {
|
447 |
+
w = siw;
|
448 |
+
}
|
449 |
+
|
450 |
+
if (self.options.zoomHeight == 'auto') {
|
451 |
+
h = sih;
|
452 |
+
}
|
453 |
+
|
454 |
+
var appendTo = zoom.parent();
|
455 |
+
switch (self.options.position) {
|
456 |
+
case 'top':
|
457 |
+
yPos -= h;
|
458 |
+
break;
|
459 |
+
case 'right':
|
460 |
+
xPos += siw;
|
461 |
+
break;
|
462 |
+
case 'bottom':
|
463 |
+
yPos += sih;
|
464 |
+
break;
|
465 |
+
case 'left':
|
466 |
+
xPos -= w;
|
467 |
+
break;
|
468 |
+
case 'inside':
|
469 |
+
w = siw;
|
470 |
+
h = sih;
|
471 |
+
break;
|
472 |
+
|
473 |
+
// All other values, try and find an id in the dom to attach to.
|
474 |
+
default:
|
475 |
+
appendTo = $('#' + self.options.position);
|
476 |
+
// If dom element doesn't exit, just use 'right' position as default.
|
477 |
+
if (!appendTo.length) {
|
478 |
+
appendTo = zoom;
|
479 |
+
xPos += siw; //+ opts.adjustX;
|
480 |
+
yPos += sih; // + opts.adjustY;
|
481 |
+
} else {
|
482 |
+
w = appendTo.innerWidth();
|
483 |
+
h = appendTo.innerHeight();
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
if (self.isPhone && self.options.phoneBehavior == 'inside') {
|
488 |
+
w = siw;
|
489 |
+
h = sih;
|
490 |
+
xPos = 0;
|
491 |
+
yPos = 0;
|
492 |
+
}
|
493 |
+
|
494 |
+
self.zoomDiv = $('<div class="yith_magnifier_zoom_magnifier" />').css({
|
495 |
+
left: xPos,
|
496 |
+
top: yPos,
|
497 |
+
width: w,
|
498 |
+
height: h,
|
499 |
+
'background-repeat': 'no-repeat',
|
500 |
+
backgroundImage: 'url(' + zoomImg.src + ')'
|
501 |
+
}).appendTo(appendTo);
|
502 |
+
|
503 |
+
// Add the title from title tag.
|
504 |
+
if (zoomImage.attr('title') && self.options.showTitle) {
|
505 |
+
$('<div class="yith_magnifier_title">' + zoomImage.attr('title') + '</div>').appendTo(self.zoomDiv);
|
506 |
+
}
|
507 |
+
|
508 |
+
if (self.isPhone) {
|
509 |
+
if (self.options.phoneBehavior != 'disable') {
|
510 |
+
self.zoomDiv.fadeIn(500);
|
511 |
+
} else {
|
512 |
+
self.lens.fadeOut(299);
|
513 |
+
}
|
514 |
+
} else {
|
515 |
+
self.zoomDiv.fadeIn(500);
|
516 |
+
}
|
517 |
+
|
518 |
+
if (self.lens) {
|
519 |
+
self.lens.remove();
|
520 |
+
self.lens = null;
|
521 |
+
}
|
522 |
+
|
523 |
+
if (zoomImg.width <= 1) {
|
524 |
+
self.cw = (zoomImage.outerWidth() / zoomImg.naturalWidth) * self.zoomDiv.width();
|
525 |
+
} else {
|
526 |
+
self.cw = (zoomImage.outerWidth() / zoomImg.width) * self.zoomDiv.width();
|
527 |
+
}
|
528 |
+
|
529 |
+
if (zoomImg.height <= 1) {
|
530 |
+
self.ch = (zoomImage.outerHeight() / zoomImg.naturalHeight) * self.zoomDiv.height();
|
531 |
+
} else {
|
532 |
+
self.ch = (zoomImage.outerHeight() / zoomImg.height) * self.zoomDiv.height();
|
533 |
+
}
|
534 |
+
|
535 |
+
// Attach mouse, initially invisible to prevent first frame glitch
|
536 |
+
self.lens = $('<div class="yith_magnifier_lens" />').css({
|
537 |
+
width: self.cw,
|
538 |
+
height: self.ch
|
539 |
+
}).appendTo(zoom);
|
540 |
+
|
541 |
+
self.mouseTrap.css('cursor', self.lens.css('cursor'));
|
542 |
+
|
543 |
+
var noTrans = false;
|
544 |
+
|
545 |
+
|
546 |
+
// Init tint layer if needed. (Not relevant if using inside mode)
|
547 |
+
if (self.options.tint) {
|
548 |
+
//self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
|
549 |
+
self.tint = $('<div />').css({
|
550 |
+
display: 'none',
|
551 |
+
position: 'absolute',
|
552 |
+
left: 0,
|
553 |
+
top: 0,
|
554 |
+
width: zoomImage.outerWidth(),
|
555 |
+
height: zoomImage.outerHeight(),
|
556 |
+
backgroundColor: self.options.tint,
|
557 |
+
opacity: self.options.tintOpacity
|
558 |
+
}).appendTo(zoom);
|
559 |
+
|
560 |
+
|
561 |
+
self.lens.append($('<img />', {
|
562 |
+
src: zoomImage.attr('src')
|
563 |
+
}));
|
564 |
+
|
565 |
+
noTrans = true;
|
566 |
+
self.tint.fadeIn(500);
|
567 |
+
}
|
568 |
+
|
569 |
+
if (self.options.softFocus) {
|
570 |
+
//self.lens.css('background', 'url("' + zoomImage.attr('src') + '")');
|
571 |
+
self.softFocus = $('<div />').css({
|
572 |
+
position: 'absolute',
|
573 |
+
display: 'none',
|
574 |
+
top: '1px',
|
575 |
+
left: '1px',
|
576 |
+
width: zoomImage.outerWidth(),
|
577 |
+
height: zoomImage.outerHeight(),
|
578 |
+
//background: 'url("' + zoomImage.attr('src') + '")',
|
579 |
+
//backgroundSize: '100%',
|
580 |
+
opacity: .5
|
581 |
+
}).appendTo(zoom);
|
582 |
+
|
583 |
+
self.softFocus.append($('<img />', {
|
584 |
+
src: zoomImage.attr('src')
|
585 |
+
}));
|
586 |
+
|
587 |
+
if (self.lens.find('img').length == 0) {
|
588 |
+
self.lens.append($('<img />', {
|
589 |
+
src: zoomImage.attr('src')
|
590 |
+
}));
|
591 |
+
}
|
592 |
+
|
593 |
+
noTrans = true;
|
594 |
+
self.softFocus.fadeIn(500);
|
595 |
+
}
|
596 |
+
|
597 |
+
|
598 |
+
if (!noTrans) {
|
599 |
+
self.lens.css('opacity', self.options.lensOpacity);
|
600 |
+
}
|
601 |
+
if (self.options.position !== 'inside') {
|
602 |
+
self.lens.fadeIn(500);
|
603 |
+
}
|
604 |
+
|
605 |
+
// Start processing.
|
606 |
+
self.zw._controlLoop();
|
607 |
+
|
608 |
+
return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
|
609 |
+
});
|
610 |
+
},
|
611 |
+
|
612 |
+
/**
|
613 |
+
*
|
614 |
+
*
|
615 |
+
* @private
|
616 |
+
*/
|
617 |
+
_controlLoop: function () {
|
618 |
+
var self = this;
|
619 |
+
|
620 |
+
if (this.lens) {
|
621 |
+
var x = (this.mx - this.zoomImage.offset().left - (this.cw * 0.5)) >> 0;
|
622 |
+
var y = (this.my - this.zoomImage.offset().top - (this.ch * 0.5)) >> 0;
|
623 |
+
|
624 |
+
if (x < 0) {
|
625 |
+
x = 0;
|
626 |
+
} else if (x > (this.zoomImage.outerWidth() - this.cw)) {
|
627 |
+
x = (this.zoomImage.outerWidth() - this.cw);
|
628 |
+
}
|
629 |
+
|
630 |
+
if (y < 0) {
|
631 |
+
y = 0;
|
632 |
+
} else if (y > (this.zoomImage.outerHeight() - this.ch)) {
|
633 |
+
y = (this.zoomImage.outerHeight() - this.ch);
|
634 |
+
}
|
635 |
+
|
636 |
+
this.lens.css({
|
637 |
+
left: x - 2,
|
638 |
+
top: y - 1
|
639 |
+
});
|
640 |
+
|
641 |
+
//this.lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
|
642 |
+
|
643 |
+
|
644 |
+
this.lens.find('img').css({
|
645 |
+
width: this.zoomImage.outerWidth(),
|
646 |
+
height: this.zoomImage.outerHeight(),
|
647 |
+
marginLeft: (-x) + 'px ',
|
648 |
+
marginTop: (-y) + 'px'
|
649 |
+
});
|
650 |
+
|
651 |
+
|
652 |
+
if (this.IMG_zoomImage.width <= 1) {
|
653 |
+
this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.naturalWidth) >> 0;
|
654 |
+
} else {
|
655 |
+
this.destU = (((x) / this.zoomImage.outerWidth()) * this.IMG_zoomImage.width) >> 0;
|
656 |
+
}
|
657 |
+
|
658 |
+
if (this.IMG_zoomImage.height <= 1) {
|
659 |
+
this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.naturalHeight) >> 0;
|
660 |
+
} else {
|
661 |
+
this.destV = (((y) / this.zoomImage.outerHeight()) * this.IMG_zoomImage.height) >> 0;
|
662 |
+
}
|
663 |
+
|
664 |
+
|
665 |
+
this.currU += (this.destU - this.currU) / this.options.smoothMove;
|
666 |
+
this.currV += (this.destV - this.currV) / this.options.smoothMove;
|
667 |
+
|
668 |
+
this.zoomDiv.css('background-position', (-(this.currU >> 0) + 'px ') + (-(this.currV >> 0) + 'px'));
|
669 |
+
}
|
670 |
+
|
671 |
+
this.controlTimer = setTimeout(function () {
|
672 |
+
self._controlLoop();
|
673 |
+
}, 30);
|
674 |
+
},
|
675 |
+
|
676 |
+
/**
|
677 |
+
* This method is called when the mouse leave the image
|
678 |
+
*
|
679 |
+
* @private
|
680 |
+
*/
|
681 |
+
_onLeave: function () {
|
682 |
+
this.options.onLeave();
|
683 |
+
|
684 |
+
if (this.zoomDiv) {
|
685 |
+
this.zoomDiv.remove();
|
686 |
+
this.zoomDiv = null;
|
687 |
+
}
|
688 |
+
|
689 |
+
this._removeElements();
|
690 |
+
},
|
691 |
+
|
692 |
+
/**
|
693 |
+
* Remove lens, tint and softfocus
|
694 |
+
*
|
695 |
+
* @private
|
696 |
+
*/
|
697 |
+
_removeElements: function () {
|
698 |
+
if (this.lens) {
|
699 |
+
this.lens.remove();
|
700 |
+
this.lens = null;
|
701 |
+
}
|
702 |
+
|
703 |
+
if (this.tint) {
|
704 |
+
this.tint.remove();
|
705 |
+
this.tint = null;
|
706 |
+
}
|
707 |
+
|
708 |
+
if (this.softFocus) {
|
709 |
+
this.softFocus.remove();
|
710 |
+
this.softFocus = null;
|
711 |
+
}
|
712 |
+
|
713 |
+
if (this.element.find('.yith_magnifier_loading').length > 0) {
|
714 |
+
this.element.find('.yith_magnifier_loading').remove();
|
715 |
+
}
|
716 |
+
},
|
717 |
+
|
718 |
+
/**
|
719 |
+
* Detect if user is using a phone device (eg iPhone)
|
720 |
+
*
|
721 |
+
* @private
|
722 |
+
*/
|
723 |
+
_isPhone: function () {
|
724 |
+
var userAgent = navigator.userAgent.toLowerCase();
|
725 |
+
|
726 |
+
return ( userAgent.match(/iphone/i) || userAgent.match(/ipod/i) || userAgent.match(/android/i) );
|
727 |
+
},
|
728 |
+
|
729 |
+
/**
|
730 |
+
* Destroy the instance
|
731 |
+
*
|
732 |
+
*/
|
733 |
+
destroy: function () {
|
734 |
+
if (this.zoom) {
|
735 |
+
this.zoom.unwrap();
|
736 |
+
}
|
737 |
+
|
738 |
+
if (this.mouseTrap) {
|
739 |
+
this.mouseTrap.unbind();
|
740 |
+
this.mouseTrap.remove();
|
741 |
+
this.mouseTrap = null;
|
742 |
+
}
|
743 |
+
|
744 |
+
if (this.zoomDiv) {
|
745 |
+
this.zoomDiv.remove();
|
746 |
+
this.zoomDiv = null;
|
747 |
+
}
|
748 |
+
|
749 |
+
if (this.options.disableRightClick) {
|
750 |
+
$(document).unbind();
|
751 |
+
}
|
752 |
+
|
753 |
+
this._removeElements();
|
754 |
+
this.options.elements.gallery.unbind();
|
755 |
+
this.element.removeData('yith_magnifier');
|
756 |
+
}
|
757 |
+
};
|
758 |
+
|
759 |
+
$.fn.yith_magnifier = function (options) {
|
760 |
+
|
761 |
+
if (typeof options === 'string') {
|
762 |
+
var args = Array.prototype.slice.call(arguments, 1);
|
763 |
+
|
764 |
+
this.each(function () {
|
765 |
+
var instance = $.data(this, 'yith_magnifier');
|
766 |
+
if (!instance) {
|
767 |
+
$.error("cannot call methods on yith_magnifier prior to initialization; " +
|
768 |
+
"attempted to call method '" + options + "'");
|
769 |
+
return;
|
770 |
+
}
|
771 |
+
if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
|
772 |
+
$.error("no such method '" + options + "' for yith_magnifier instance");
|
773 |
+
return;
|
774 |
+
}
|
775 |
+
instance[options].apply(instance, args);
|
776 |
+
});
|
777 |
+
} else {
|
778 |
+
this.each(function () {
|
779 |
+
var instance = $.data(this, 'yith_magnifier');
|
780 |
+
if (!instance) {
|
781 |
+
$.data(this, 'yith_magnifier', new $.yith_magnifier(options, this));
|
782 |
+
} else {
|
783 |
+
$.error('yith_magnifier already istantiated.');
|
784 |
+
}
|
785 |
+
});
|
786 |
+
}
|
787 |
+
return this;
|
788 |
+
};
|
789 |
+
|
790 |
+
|
791 |
Â
})(window, jQuery);
|
class.yith-wcmg-admin.php
CHANGED
@@ -1,168 +1,168 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin class
|
4 |
-
*
|
5 |
-
* @author Your Inspiration Themes
|
6 |
-
* @package YITH WooCommerce Zoom Magnifier
|
7 |
-
* @version 1.1.2
|
8 |
-
*/
|
9 |
-
|
10 |
-
if ( ! defined( 'YITH_WCMG' ) ) {
|
11 |
-
exit;
|
12 |
-
} // Exit if accessed directly
|
13 |
-
|
14 |
-
if ( ! class_exists( 'YITH_WCMG_Admin' ) ) {
|
15 |
-
/**
|
16 |
-
* Admin class.
|
17 |
-
* The class manage all the admin behaviors.
|
18 |
-
*
|
19 |
-
* @since 1.0.0
|
20 |
-
*/
|
21 |
-
class YITH_WCMG_Admin {
|
22 |
-
/**
|
23 |
-
* Plugin options
|
24 |
-
*
|
25 |
-
* @var array
|
26 |
-
* @access public
|
27 |
-
* @since 1.0.0
|
28 |
-
*/
|
29 |
-
public $options = array();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Various links
|
33 |
-
*
|
34 |
-
* @var string
|
35 |
-
* @access public
|
36 |
-
* @since 1.0.0
|
37 |
-
*/
|
38 |
-
public $banner_url = 'http://cdn.yithemes.com/plugins/yith_magnifier.php?url';
|
39 |
-
public $banner_img = 'http://cdn.yithemes.com/plugins/yith_magnifier.php';
|
40 |
-
public $doc_url = 'http://yithemes.com/docs-plugins/yith_magnifier/';
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*
|
45 |
-
* @access public
|
46 |
-
* @since 1.0.0
|
47 |
-
*/
|
48 |
-
public function __construct( ) {
|
49 |
-
|
50 |
-
//Actions
|
51 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
|
52 |
-
|
53 |
-
add_action( 'woocommerce_update_options_yith_wcmg', array( $this, 'update_options' ) );
|
54 |
-
|
55 |
-
add_action( 'woocommerce_admin_field_banner', array( $this, 'admin_fields_banner' ) );
|
56 |
-
add_action( 'admin_print_footer_scripts', array( $this, 'admin_fields_image_deps' ) );
|
57 |
-
|
58 |
-
add_filter( 'woocommerce_catalog_settings', array( $this, 'add_catalog_image_size' ) );
|
59 |
-
|
60 |
-
//Apply filters
|
61 |
-
$this->banner_url = apply_filters( 'yith_wcmg_banner_url', $this->banner_url );
|
62 |
-
|
63 |
-
// YITH WCMG Loaded
|
64 |
-
do_action( 'yith_wcmg_loaded' );
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Add Zoom Image size to Woocommerce -> Catalog
|
69 |
-
*
|
70 |
-
* @access public
|
71 |
-
*
|
72 |
-
* @param array $settings
|
73 |
-
*
|
74 |
-
* @return array
|
75 |
-
*/
|
76 |
-
public function add_catalog_image_size( $settings ) {
|
77 |
-
$tmp = $settings[count( $settings ) - 1];
|
78 |
-
unset( $settings[count( $settings ) - 1] );
|
79 |
-
|
80 |
-
$settings[] = array(
|
81 |
-
'name' => __( 'Image Size', 'yith-woocommerce-zoom-magnifier' ),
|
82 |
-
'desc' => __( 'The size of the images used within the magnifier box', 'yith-woocommerce-zoom-magnifier' ),
|
83 |
-
'id' => 'woocommerce_magnifier_image',
|
84 |
-
'css' => '',
|
85 |
-
'type' => 'image_width',
|
86 |
-
'default' => array(
|
87 |
-
'width' => 600,
|
88 |
-
'height' => 600,
|
89 |
-
'crop' => true
|
90 |
-
),
|
91 |
-
'std' => array(
|
92 |
-
'width' => 600,
|
93 |
-
'height' => 600,
|
94 |
-
'crop' => true
|
95 |
-
),
|
96 |
-
'desc_tip' => true
|
97 |
-
);
|
98 |
-
$settings[] = $tmp;
|
99 |
-
return $settings;
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Create new Woocommerce admin field: image deps
|
104 |
-
*
|
105 |
-
* @access public
|
106 |
-
*
|
107 |
-
* @param array $value
|
108 |
-
*
|
109 |
-
* @return void
|
110 |
-
* @since 1.0.0
|
111 |
-
*/
|
112 |
-
public function admin_fields_image_deps( $value ) {
|
113 |
-
global $woocommerce;
|
114 |
-
|
115 |
-
$force = get_option( 'yith_wcmg_force_sizes' ) == 'yes';
|
116 |
-
|
117 |
-
if ( $force ) {
|
118 |
-
$value['desc'] = 'These values ??are automatically calculated based on the values ??of the Single product. If you\'d like to customize yourself the values, please disable the "Forcing Zoom Image sizes" in "Magnifier" tab.';
|
119 |
-
}
|
120 |
-
|
121 |
-
if ( $force && isset( $_GET['page'] ) && isset( $_GET['tab'] ) && ( $_GET['page'] == 'woocommerce_settings' || $_GET['page'] == 'wc-settings' ) && $_GET['tab'] == 'catalog' ): ?>
|
122 |
-
<script>
|
123 |
-
jQuery(document).ready(function ($) {
|
124 |
-
$('#woocommerce_magnifier_image-width, #woocommerce_magnifier_image-height, #woocommerce_magnifier_image-crop').attr('disabled', 'disabled');
|
125 |
-
|
126 |
-
$('#shop_single_image_size-width, #shop_single_image_size-height').on('keyup', function () {
|
127 |
-
var value = parseInt($(this).val());
|
128 |
-
var input = (this.id).indexOf('width') >= 0 ? 'width' : 'height';
|
129 |
-
|
130 |
-
if (!isNaN(value)) {
|
131 |
-
$('#woocommerce_magnifier_image-' + input).val(value * 2);
|
132 |
-
}
|
133 |
-
});
|
134 |
-
|
135 |
-
$('#shop_single_image_size-crop').on('change', function () {
|
136 |
-
if ($(this).is(':checked')) {
|
137 |
-
$('#woocommerce_magnifier_image-crop').attr('checked', 'checked');
|
138 |
-
} else {
|
139 |
-
$('#woocommerce_magnifier_image-crop').removeAttr('checked');
|
140 |
-
}
|
141 |
-
});
|
142 |
-
|
143 |
-
$('#mainform').on('submit', function () {
|
144 |
-
$(':disabled').removeAttr('disabled');
|
145 |
-
});
|
146 |
-
});
|
147 |
-
</script>
|
148 |
-
<?php endif;
|
149 |
-
}
|
150 |
-
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Enqueue admin styles and scripts
|
154 |
-
*
|
155 |
-
* @access public
|
156 |
-
* @return void
|
157 |
-
* @since 1.0.0
|
158 |
-
*/
|
159 |
-
public function enqueue_styles_scripts() {
|
160 |
-
wp_enqueue_script( 'jquery-ui' );
|
161 |
-
wp_enqueue_script( 'jquery-ui-core' );
|
162 |
-
wp_enqueue_script( 'jquery-ui-mouse' );
|
163 |
-
wp_enqueue_script( 'jquery-ui-slider' );
|
164 |
-
|
165 |
-
wp_enqueue_style( 'yith_wcmg_admin', YITH_WCMG_URL . 'assets/css/admin.css' );
|
166 |
-
}
|
167 |
-
}
|
168 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin class
|
4 |
+
*
|
5 |
+
* @author Your Inspiration Themes
|
6 |
+
* @package YITH WooCommerce Zoom Magnifier
|
7 |
+
* @version 1.1.2
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'YITH_WCMG' ) ) {
|
11 |
+
exit;
|
12 |
+
} // Exit if accessed directly
|
13 |
+
|
14 |
+
if ( ! class_exists( 'YITH_WCMG_Admin' ) ) {
|
15 |
+
/**
|
16 |
+
* Admin class.
|
17 |
+
* The class manage all the admin behaviors.
|
18 |
+
*
|
19 |
+
* @since 1.0.0
|
20 |
+
*/
|
21 |
+
class YITH_WCMG_Admin {
|
22 |
+
/**
|
23 |
+
* Plugin options
|
24 |
+
*
|
25 |
+
* @var array
|
26 |
+
* @access public
|
27 |
+
* @since 1.0.0
|
28 |
+
*/
|
29 |
+
public $options = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Various links
|
33 |
+
*
|
34 |
+
* @var string
|
35 |
+
* @access public
|
36 |
+
* @since 1.0.0
|
37 |
+
*/
|
38 |
+
public $banner_url = 'http://cdn.yithemes.com/plugins/yith_magnifier.php?url';
|
39 |
+
public $banner_img = 'http://cdn.yithemes.com/plugins/yith_magnifier.php';
|
40 |
+
public $doc_url = 'http://yithemes.com/docs-plugins/yith_magnifier/';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*
|
45 |
+
* @access public
|
46 |
+
* @since 1.0.0
|
47 |
+
*/
|
48 |
+
public function __construct( ) {
|
49 |
+
|
50 |
+
//Actions
|
51 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
|
52 |
+
|
53 |
+
add_action( 'woocommerce_update_options_yith_wcmg', array( $this, 'update_options' ) );
|
54 |
+
|
55 |
+
add_action( 'woocommerce_admin_field_banner', array( $this, 'admin_fields_banner' ) );
|
56 |
+
add_action( 'admin_print_footer_scripts', array( $this, 'admin_fields_image_deps' ) );
|
57 |
+
|
58 |
+
add_filter( 'woocommerce_catalog_settings', array( $this, 'add_catalog_image_size' ) );
|
59 |
+
|
60 |
+
//Apply filters
|
61 |
+
$this->banner_url = apply_filters( 'yith_wcmg_banner_url', $this->banner_url );
|
62 |
+
|
63 |
+
// YITH WCMG Loaded
|
64 |
+
do_action( 'yith_wcmg_loaded' );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Add Zoom Image size to Woocommerce -> Catalog
|
69 |
+
*
|
70 |
+
* @access public
|
71 |
+
*
|
72 |
+
* @param array $settings
|
73 |
+
*
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
public function add_catalog_image_size( $settings ) {
|
77 |
+
$tmp = $settings[count( $settings ) - 1];
|
78 |
+
unset( $settings[count( $settings ) - 1] );
|
79 |
+
|
80 |
+
$settings[] = array(
|
81 |
+
'name' => __( 'Image Size', 'yith-woocommerce-zoom-magnifier' ),
|
82 |
+
'desc' => __( 'The size of the images used within the magnifier box', 'yith-woocommerce-zoom-magnifier' ),
|
83 |
+
'id' => 'woocommerce_magnifier_image',
|
84 |
+
'css' => '',
|
85 |
+
'type' => 'image_width',
|
86 |
+
'default' => array(
|
87 |
+
'width' => 600,
|
88 |
+
'height' => 600,
|
89 |
+
'crop' => true
|
90 |
+
),
|
91 |
+
'std' => array(
|
92 |
+
'width' => 600,
|
93 |
+
'height' => 600,
|
94 |
+
'crop' => true
|
95 |
+
),
|
96 |
+
'desc_tip' => true
|
97 |
+
);
|
98 |
+
$settings[] = $tmp;
|
99 |
+
return $settings;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Create new Woocommerce admin field: image deps
|
104 |
+
*
|
105 |
+
* @access public
|
106 |
+
*
|
107 |
+
* @param array $value
|
108 |
+
*
|
109 |
+
* @return void
|
110 |
+
* @since 1.0.0
|
111 |
+
*/
|
112 |
+
public function admin_fields_image_deps( $value ) {
|
113 |
+
global $woocommerce;
|
114 |
+
|
115 |
+
$force = get_option( 'yith_wcmg_force_sizes' ) == 'yes';
|
116 |
+
|
117 |
+
if ( $force ) {
|
118 |
+
$value['desc'] = 'These values ??are automatically calculated based on the values ??of the Single product. If you\'d like to customize yourself the values, please disable the "Forcing Zoom Image sizes" in "Magnifier" tab.';
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( $force && isset( $_GET['page'] ) && isset( $_GET['tab'] ) && ( $_GET['page'] == 'woocommerce_settings' || $_GET['page'] == 'wc-settings' ) && $_GET['tab'] == 'catalog' ): ?>
|
122 |
+
<script>
|
123 |
+
jQuery(document).ready(function ($) {
|
124 |
+
$('#woocommerce_magnifier_image-width, #woocommerce_magnifier_image-height, #woocommerce_magnifier_image-crop').attr('disabled', 'disabled');
|
125 |
+
|
126 |
+
$('#shop_single_image_size-width, #shop_single_image_size-height').on('keyup', function () {
|
127 |
+
var value = parseInt($(this).val());
|
128 |
+
var input = (this.id).indexOf('width') >= 0 ? 'width' : 'height';
|
129 |
+
|
130 |
+
if (!isNaN(value)) {
|
131 |
+
$('#woocommerce_magnifier_image-' + input).val(value * 2);
|
132 |
+
}
|
133 |
+
});
|
134 |
+
|
135 |
+
$('#shop_single_image_size-crop').on('change', function () {
|
136 |
+
if ($(this).is(':checked')) {
|
137 |
+
$('#woocommerce_magnifier_image-crop').attr('checked', 'checked');
|
138 |
+
} else {
|