CorlleteLab_Imagezoom - Version 0.1.5

Version Notes

N/A

Download this release

Release Info

Developer Desislav Yosifov
Extension CorlleteLab_Imagezoom
Version 0.1.5
Comparing to
See all releases


Version 0.1.5

Files changed (26) hide show
  1. app/code/community/CorlleteLab/Imagezoom/Block/Catalog/Product/View.php +69 -0
  2. app/code/community/CorlleteLab/Imagezoom/Block/Html/Head.php +83 -0
  3. app/code/community/CorlleteLab/Imagezoom/Helper/Data.php +69 -0
  4. app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Color.php +27 -0
  5. app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Config/Source/Position.php +26 -0
  6. app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Config/Source/Zoomeffect.php +24 -0
  7. app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Size.php +27 -0
  8. app/code/community/CorlleteLab/Imagezoom/controllers/IndexController.php +19 -0
  9. app/code/community/CorlleteLab/Imagezoom/controllers/ProductController.php +51 -0
  10. app/code/community/CorlleteLab/Imagezoom/etc/adminhtml.xml +38 -0
  11. app/code/community/CorlleteLab/Imagezoom/etc/config.xml +151 -0
  12. app/code/community/CorlleteLab/Imagezoom/etc/system.xml +297 -0
  13. app/design/frontend/base/default/layout/imagezoom.xml +48 -0
  14. app/design/frontend/base/default/template/corlletelab/imagezoom/grouped.phtml +81 -0
  15. app/design/frontend/base/default/template/corlletelab/imagezoom/media.phtml +145 -0
  16. app/design/frontend/default/default/layout/imagezoom.xml +48 -0
  17. app/design/frontend/default/default/template/corlletelab/imagezoom/grouped.phtml +81 -0
  18. app/design/frontend/default/default/template/corlletelab/imagezoom/media.phtml +145 -0
  19. app/etc/modules/CorlleteLab_Imagezoom.xml +21 -0
  20. app/locale/en_US/CorlleteLab_ImageZoom.csv +33 -0
  21. js/corlletelab/imagezoom/cloud-zoom.1.0.2.js +391 -0
  22. js/corlletelab/imagezoom/jquery-1.6.2.min.js +18 -0
  23. js/corlletelab/imagezoom/product_override.js +106 -0
  24. package.xml +18 -0
  25. skin/frontend/base/default/css/corlletelab/imagezoom.css +32 -0
  26. skin/frontend/default/default/css/corlletelab/imagezoom.css +43 -0
app/code/community/CorlleteLab/Imagezoom/Block/Catalog/Product/View.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Block_Catalog_Product_View extends Mage_Catalog_Block_Product_View
14
+ {
15
+ /**
16
+ * Add meta information from product to head block
17
+ *
18
+ * @return Mage_Catalog_Block_Product_View
19
+ */
20
+ protected function _prepareLayout()
21
+ {
22
+ $this->getLayout()->createBlock('catalog/breadcrumbs');
23
+ $headBlock = $this->getLayout()->getBlock('head');
24
+
25
+ if ($headBlock) {
26
+ /* ImageZoom Options */
27
+ if (Mage::getStoreConfig('imagezoomconfig/moduleoptions/moduleenable')) {
28
+ $jq_noConflict = '
29
+ <script type="text/javascript">
30
+ //<![CDATA[
31
+ var jq = jQuery.noConflict();
32
+ //]]>
33
+ </script>
34
+ ';
35
+
36
+ if (Mage::getStoreConfig('imagezoomconfig/moduleoptions/jquery')) {
37
+ if (Mage::getStoreConfig('imagezoomconfig/moduleoptions/jqueryexternal')) {
38
+ $headBlock -> addExternalItem('external_js','https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');
39
+ } else {
40
+ $headBlock -> addExternalItem('external_js',Mage::getBaseUrl().'js/corlletelab/imagezoom/jquery-1.6.2.min.js');
41
+ }
42
+
43
+ $headBlock -> addExternalItem('source',$jq_noConflict);
44
+ }
45
+
46
+ $headBlock -> addExternalItem('external_js', Mage::getBaseUrl().'js/corlletelab/imagezoom/cloud-zoom.1.0.2.js');
47
+ $headBlock -> addItem('skin_css','css/corlletelab/imagezoom.css');
48
+
49
+ $css = '
50
+ <style type="text/css">
51
+ .cloud-zoom-lens {
52
+ border: '.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/lens_border').'px solid #'.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/lens_border_color').';
53
+ margin:-'.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/lens_border').'px; /* Set this to minus the border thickness. */
54
+ background-color: #'.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/lens_background_color').';
55
+ }
56
+ .cloud-zoom-big {
57
+ border: '.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/zoom_window_border').'px solid #'.Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/zoom_window_border_color').';
58
+ }
59
+ </style>
60
+ ';
61
+
62
+ $headBlock -> addExternalItem('source',$css);
63
+ }
64
+
65
+ }
66
+
67
+ return parent::_prepareLayout();
68
+ }
69
+ }
app/code/community/CorlleteLab/Imagezoom/Block/Html/Head.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ /**
3
+ * Inchoo Xternal Html page block
4
+ *
5
+ * @category Inchoo
6
+ * @package Inchoo_Xternal
7
+ * @author Vedran Subotic, Inchoo <web@inchoo.net>
8
+ */
9
+ class CorlleteLab_Imagezoom_Block_Html_Head extends Mage_Page_Block_Html_Head
10
+ {
11
+ /**
12
+ * Add HEAD External Item
13
+ *
14
+ * Allowed types:
15
+ * - js
16
+ * - js_css
17
+ * - skin_js
18
+ * - skin_css
19
+ * - rss
20
+ *
21
+ * @param string $type
22
+ * @param string $name
23
+ * @param string $params
24
+ * @param string $if
25
+ * @param string $cond
26
+ * @return Mage_Page_Block_Html_Head
27
+ */
28
+ public function addExternalItem($type, $name, $params=null, $if=null, $cond=null)
29
+ {
30
+ parent::addItem($type, $name, $params=null, $if=null, $cond=null);
31
+ }
32
+
33
+ /**
34
+ * Remove External Item from HEAD entity
35
+ *
36
+ * @param string $type
37
+ * @param string $name
38
+ * @return Mage_Page_Block_Html_Head
39
+ */
40
+ public function removeExternalItem($type, $name)
41
+ {
42
+ parent::removeItem($type, $name);
43
+ }
44
+
45
+ /**
46
+ * Classify HTML head item and queue it into "lines" array
47
+ *
48
+ * @see self::getCssJsHtml()
49
+ * @param array &$lines
50
+ * @param string $itemIf
51
+ * @param string $itemType
52
+ * @param string $itemParams
53
+ * @param string $itemName
54
+ * @param array $itemThe
55
+ */
56
+ protected function _separateOtherHtmlHeadElements(&$lines, $itemIf, $itemType, $itemParams, $itemName, $itemThe)
57
+ {
58
+ $params = $itemParams ? ' ' . $itemParams : '';
59
+ $href = $itemName;
60
+ switch ($itemType) {
61
+ case 'rss':
62
+ $lines[$itemIf]['other'][] = sprintf('<link href="%s"%s rel="alternate" type="application/rss+xml" />',
63
+ $href, $params
64
+ );
65
+ break;
66
+ case 'link_rel':
67
+ $lines[$itemIf]['other'][] = sprintf('<link%s href="%s" />', $params, $href);
68
+ break;
69
+
70
+ case 'external_js':
71
+ $lines[$itemIf]['other'][] = sprintf('<script type="text/javascript" src="%s" %s></script>', $href, $params);
72
+ break;
73
+
74
+ case 'external_css':
75
+ $lines[$itemIf]['other'][] = sprintf('<link rel="stylesheet" type="text/css" href="%s" %s/>', $href, $params);
76
+ break;
77
+ case 'source':
78
+ $lines[$itemIf]['other'][] = sprintf('%s', $href);
79
+ break;
80
+ }
81
+ }
82
+
83
+ }
app/code/community/CorlleteLab/Imagezoom/Helper/Data.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Helper_Data extends Mage_Core_Helper_Abstract
14
+ {
15
+ public function getZoomConfig()
16
+ {
17
+
18
+ $zoom_options = Mage::getStoreConfig('imagezoomconfig/imagezoom_options');
19
+ $zoom_cfg = '';
20
+ $cnt = 0;
21
+
22
+ switch($zoom_options['zoomeffect'])
23
+ {
24
+ case '1':
25
+ $zoom_options['tint'] = "'#".$zoom_options['tintColor']."'";
26
+ break;
27
+ case '2':
28
+ $zoom_options['softFocus'] = true;
29
+ break;
30
+ }
31
+
32
+ foreach ($zoom_options as $key => $value )
33
+ {
34
+ if ($value != '' && $key != 'img_size')
35
+ {
36
+ $cnt++;
37
+
38
+ $zoom_cfg .= ($cnt != 1 ) ? ',' : '';
39
+ $zoom_cfg .= $key.':'.$value;
40
+ }
41
+ }
42
+
43
+ return $zoom_cfg;
44
+ }
45
+
46
+ public function getAllImages($product)
47
+ {
48
+ $productID = Mage::getModel('catalog/product')->load($product->getId());
49
+
50
+ if ($productID['media_gallery'])
51
+ {
52
+ $images = new Varien_Data_Collection();
53
+
54
+ foreach ($productID->getMediaGallery('images') as $image)
55
+ {
56
+ $image['url'] = $productID->getMediaConfig()->getMediaUrl($image['file']);
57
+ $image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
58
+ $image['path'] = $productID->getMediaConfig()->getMediaPath($image['file']);
59
+ $image['main_image'] = ($productID['image'] == $image['file']) ? true : false;
60
+ $images->addItem(new Varien_Object($image));
61
+ }
62
+
63
+ $productID->setData('media_gallery_images', $images);
64
+ }
65
+
66
+ return $productID->getData('media_gallery_images');
67
+ }
68
+ }
69
+ ?>
app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Color.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Model_Adminhtml_System_Color extends Mage_Core_Model_Config_Data
14
+ {
15
+ public function save()
16
+ {
17
+ $value = $this->getValue(); //get the value from our config
18
+
19
+ if((strlen($value) >0 && strlen($value) < 3) || (strlen($value) > 3 && strlen($value) < 6) || strlen($value) > 6)
20
+ {
21
+ Mage::throwException("Please enter valid color value (3 or 6 characters). Colours should be specified in hex format");
22
+ }
23
+
24
+ return parent::save();
25
+ }
26
+ }
27
+ ?>
app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Config/Source/Position.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Model_Adminhtml_System_Config_Source_Position
14
+ {
15
+ public function toOptionArray()
16
+ {
17
+ return array(
18
+ array('value' => "'left'", 'label' => Mage::helper('imagezoom')->__('Left')),
19
+ array('value' => "'right'", 'label' => Mage::helper('imagezoom')->__('Right')),
20
+ array('value' => "'top'", 'label' => Mage::helper('imagezoom')->__('Top')),
21
+ array('value' => "'bottom'", 'label' => Mage::helper('imagezoom')->__('Bottom')),
22
+ array('value' => "'inside'", 'label' => Mage::helper('imagezoom')->__('Inside (Inner Zoom)'))
23
+ );
24
+ }
25
+ }
26
+ ?>
app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Config/Source/Zoomeffect.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Model_Adminhtml_System_Config_Source_Zoomeffect
14
+ {
15
+ public function toOptionArray()
16
+ {
17
+ return array(
18
+ array('value' => "0", 'label' => Mage::helper('imagezoom')->__('None')),
19
+ array('value' => "1", 'label' => Mage::helper('imagezoom')->__('Tint')),
20
+ array('value' => "2", 'label' => Mage::helper('imagezoom')->__('Soft Focus')),
21
+ );
22
+ }
23
+ }
24
+ ?>
app/code/community/CorlleteLab/Imagezoom/Model/Adminhtml/System/Size.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_Model_Adminhtml_System_Size extends Mage_Core_Model_Config_Data
14
+ {
15
+ public function save()
16
+ {
17
+ $value = $this->getValue(); //get the value from our config
18
+
19
+ if($value == '')
20
+ {
21
+ $this->setValue(265); //set default value
22
+ }
23
+
24
+ return parent::save();
25
+ }
26
+ }
27
+ ?>
app/code/community/CorlleteLab/Imagezoom/controllers/IndexController.php ADDED
@@ -0,0 +1,19 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ class CorlleteLab_Imagezoom_IndexController extends Mage_Core_Controller_Front_Action
14
+ {
15
+ public function indexAction()
16
+ {
17
+ }
18
+ }
19
+ ?>
app/code/community/CorlleteLab/Imagezoom/controllers/ProductController.php ADDED
@@ -0,0 +1,51 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+
13
+ /**
14
+ * Override Mage_Catalog_ProductController controller
15
+ */
16
+
17
+ require_once("Mage/Catalog/controllers/ProductController.php");
18
+
19
+ class CorlleteLab_Imagezoom_ProductController extends Mage_Core_Controller_Front_Action
20
+ {
21
+ public function viewAction()
22
+ {
23
+ // Get initial data from request
24
+ $categoryId = (int) $this->getRequest()->getParam('category', false);
25
+ $productId = (int) $this->getRequest()->getParam('id');
26
+ $specifyOptions = $this->getRequest()->getParam('options');
27
+
28
+ // Prepare helper and params
29
+ $viewHelper = Mage::helper('catalog/product_view');
30
+
31
+ $params = new Varien_Object();
32
+ $params->setCategoryId($categoryId);
33
+ $params->setSpecifyOptions($specifyOptions);
34
+
35
+ // Render page
36
+ try {
37
+ $viewHelper->prepareAndRender($productId, $this, $params);
38
+ } catch (Exception $e) {
39
+ if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) {
40
+ if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
41
+ $this->_redirect('');
42
+ } elseif (!$this->getResponse()->isRedirect()) {
43
+ $this->_forward('noRoute');
44
+ }
45
+ } else {
46
+ Mage::logException($e);
47
+ $this->_forward('noRoute');
48
+ }
49
+ }
50
+ }
51
+ }
app/code/community/CorlleteLab/Imagezoom/etc/adminhtml.xml ADDED
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+ <config>
15
+ <acl>
16
+ <resources>
17
+ <all>
18
+ <title>Allow Everything</title>
19
+ </all>
20
+ <admin>
21
+ <children>
22
+ <system>
23
+ <children>
24
+ <config>
25
+ <children>
26
+ <imagezoomconfig translate="title">
27
+ <title>ImageZoom Config Section</title>
28
+ <sort_order>0</sort_order>
29
+ </imagezoomconfig>
30
+ </children>
31
+ </config>
32
+ </children>
33
+ </system>
34
+ </children>
35
+ </admin>
36
+ </resources>
37
+ </acl>
38
+ </config>
app/code/community/CorlleteLab/Imagezoom/etc/config.xml ADDED
@@ -0,0 +1,151 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+
15
+ <config>
16
+ <modules>
17
+ <CorlleteLab_Imagezoom>
18
+ <version>0.1.0</version>
19
+ </CorlleteLab_Imagezoom>
20
+ </modules>
21
+ <global>
22
+ <models>
23
+ <imagezoom>
24
+ <class>CorlleteLab_Imagezoom_Model</class>
25
+ </imagezoom>
26
+ </models>
27
+ <helpers>
28
+ <imagezoom>
29
+ <class>CorlleteLab_Imagezoom_Helper</class>
30
+ </imagezoom>
31
+ </helpers>
32
+ <blocks>
33
+ <imagezoom>
34
+ <class>CorlleteLab_Imagezoom_Block</class>
35
+ </imagezoom>
36
+ <page>
37
+ <rewrite>
38
+ <html_head>CorlleteLab_Imagezoom_Block_Html_Head</html_head>
39
+ </rewrite>
40
+ </page>
41
+ <catalog>
42
+ <rewrite>
43
+ <product_view>CorlleteLab_Imagezoom_Block_Catalog_Product_View</product_view>
44
+ </rewrite>
45
+ </catalog>
46
+ </blocks>
47
+ </global>
48
+ <frontend>
49
+ <routers>
50
+ <!--
51
+ <imagezoom>
52
+ <use>standard</use>
53
+ <args>
54
+ <module>CorlleteLab_Imagezoom</module>
55
+ <frontName>imagezoom</frontName>
56
+ </args>
57
+ </imagezoom>
58
+ -->
59
+ <catalog>
60
+ <args>
61
+ <modules>
62
+ <CorlleteLab_Imagezoom before="Mage_Catalog">CorlleteLab_Imagezoom</CorlleteLab_Imagezoom><!-- Tell Magento to call our custom module before the Mage/Catalog module -->
63
+ </modules>
64
+ </args>
65
+ </catalog>
66
+ </routers>
67
+ <layout>
68
+ <updates>
69
+ <imagezoom>
70
+ <file>imagezoom.xml</file>
71
+ </imagezoom>
72
+ </updates>
73
+ </layout>
74
+ <translate>
75
+ <modules>
76
+ <imagezoom>
77
+ <files>
78
+ <default>CorlleteLab_ImageZoom.csv</default>
79
+ </files>
80
+ </imagezoom>
81
+ </modules>
82
+ </translate>
83
+ </frontend>
84
+ <backend_model>imagezoom/adminhtml_system_config</backend_model>
85
+ <adminhtml>
86
+ <translate>
87
+ <modules>
88
+ <imagezoom>
89
+ <files>
90
+ <default>CorlleteLab_ImageZoom.csv</default>
91
+ </files>
92
+ </imagezoom>
93
+ </modules>
94
+ </translate>
95
+ <acl>
96
+ <resources>
97
+ <all>
98
+ <title>Allow Everything</title>
99
+ </all>
100
+ <admin>
101
+ <children>
102
+ <system>
103
+ <children>
104
+ <config>
105
+ <children>
106
+ <imagezoomconfig translate="title">
107
+ <title>ImageZoom Config Section</title>
108
+ <sort_order>0</sort_order>
109
+ </imagezoomconfig>
110
+ </children>
111
+ </config>
112
+ </children>
113
+ </system>
114
+ </children>
115
+ </admin>
116
+ </resources>
117
+ </acl>
118
+ </adminhtml>
119
+ <default>
120
+ <imagezoomconfig>
121
+ <moduleoptions>
122
+ <moduleenable>1</moduleenable>
123
+ <jquery>1</jquery>
124
+ <jqueryexternal>1</jqueryexternal>
125
+ </moduleoptions>
126
+ <imagezoom_style_css>
127
+ <img_size>265</img_size>
128
+ <lens_border>3</lens_border>
129
+ <lens_border_color>CCCCCC</lens_border_color>
130
+ <lens_background_color>FFFFFF</lens_background_color>
131
+ <zoom_window_border>3</zoom_window_border>
132
+ <zoom_window_border_color>CCCCCC</zoom_window_border_color>
133
+ </imagezoom_style_css>
134
+ <imagezoom_options>
135
+ <zoomWidth></zoomWidth>
136
+ <zoomHeight></zoomHeight>
137
+ <position>'right'</position>
138
+ <adjustX></adjustX>
139
+ <adjustY>-3</adjustY>
140
+ <tintenable>0</tintenable>
141
+ <zoomeffect>0</zoomeffect>
142
+ <tintColor></tintColor>
143
+ <tintOpacity></tintOpacity>
144
+ <lensOpacity></lensOpacity>
145
+ <smoothMove></smoothMove>
146
+ <showTitle>1</showTitle>
147
+ <titleOpacity></titleOpacity>
148
+ </imagezoom_options>
149
+ </imagezoomconfig>
150
+ </default>
151
+ </config>
app/code/community/CorlleteLab/Imagezoom/etc/system.xml ADDED
@@ -0,0 +1,297 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+ <config>
15
+ <tabs>
16
+ <corlletetab translate="label" module="imagezoom">
17
+ <label>CorlleteLab Plugins</label>
18
+ <sort_order>0</sort_order>
19
+ </corlletetab>
20
+ </tabs>
21
+ <sections>
22
+ <imagezoomconfig translate="label" module="imagezoom">
23
+ <label>Image Zoom Configuration</label>
24
+ <tab>corlletetab</tab>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>1000</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <groups>
31
+ <moduleoptions translate="label">
32
+ <label>Module Options</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>100</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ <fields>
39
+ <moduleenable translate="label comment">
40
+ <label>Enable Module</label>
41
+ <comment></comment>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>10</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </moduleenable>
49
+ <jquery translate="label comment">
50
+ <label>Load jQuery</label>
51
+ <comment>This will load the jQuery library.</comment>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>adminhtml/system_config_source_yesno</source_model>
54
+ <sort_order>20</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </jquery>
59
+ <jqueryexternal translate="label comment">
60
+ <label>Load External jQuery</label>
61
+ <comment>
62
+ <![CDATA[This will load the jQuery library from the Google Content Network.
63
+ <span class="notice">Probably better than from your own server. </span>
64
+ ]]>
65
+ </comment>
66
+ <depends>
67
+ <jquery>1</jquery>
68
+ </depends>
69
+ <frontend_type>select</frontend_type>
70
+ <source_model>adminhtml/system_config_source_yesno</source_model>
71
+ <sort_order>30</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </jqueryexternal>
76
+ </fields>
77
+ </moduleoptions>
78
+ <imagezoom_style_css translate="label">
79
+ <label>Image Zoom Style</label>
80
+ <frontend_type>text</frontend_type>
81
+ <sort_order>200</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ <fields>
86
+ <img_size translate="label comment">
87
+ <label>Image Size (pixel)</label>
88
+ <comment>Leave empty for default (265px)</comment>
89
+ <backend_model>imagezoom/adminhtml_system_size</backend_model>
90
+ <validate>validate-number</validate>
91
+ <frontend_type>text</frontend_type>
92
+ <sort_order>9</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </img_size>
97
+ <lens_border translate="label comment">
98
+ <label>Moving Lens Border Thickness</label>
99
+ <comment></comment>
100
+ <validate>validate-number</validate>
101
+ <frontend_type>text</frontend_type>
102
+ <sort_order>10</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ </lens_border>
107
+ <lens_border_color translate="label comment">
108
+ <label>Moving Lens Border Color</label>
109
+ <comment>e.g. 77CC99</comment>
110
+ <backend_model>imagezoom/adminhtml_system_color</backend_model>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>20</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </lens_border_color>
117
+ <lens_background_color translate="label comment">
118
+ <label>Moving Lens Background Color</label>
119
+ <comment>e.g. 77CC99</comment>
120
+ <backend_model>imagezoom/adminhtml_system_color</backend_model>
121
+ <frontend_type>text</frontend_type>
122
+ <sort_order>30</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ </lens_background_color>
127
+ <zoom_window_border translate="label comment">
128
+ <label>Zoom Window Border Thickness</label>
129
+ <comment></comment>
130
+ <validate>validate-number</validate>
131
+ <frontend_type>text</frontend_type>
132
+ <sort_order>40</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </zoom_window_border>
137
+ <zoom_window_border_color translate="label comment">
138
+ <label>Zoom Window Border Color</label>
139
+ <comment>e.g. 77CC99</comment>
140
+ <backend_model>imagezoom/adminhtml_system_color</backend_model>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>50</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </zoom_window_border_color>
147
+ </fields>
148
+ </imagezoom_style_css>
149
+ <imagezoom_options translate="label">
150
+ <label>Image Zoom Options</label>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>300</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ <fields>
157
+ <zoomWidth translate="label comment">
158
+ <label>Zoom Width</label>
159
+ <comment>Leave empty for default (same as imge size)</comment>
160
+ <validate>validate-number</validate>
161
+ <frontend_type>text</frontend_type>
162
+ <sort_order>50</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ </zoomWidth>
167
+
168
+ <zoomHeight translate="label comment">
169
+ <label>Zoom Height</label>
170
+ <comment>Leave empty for default (same as imge size)</comment>
171
+ <validate>validate-number</validate>
172
+ <frontend_type>text</frontend_type>
173
+ <sort_order>51</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ </zoomHeight>
178
+ <position translate="label comment">
179
+ <label>Position</label>
180
+ <comment>Specifies the position of the zoom window relative to the small image.</comment>
181
+ <frontend_type>select</frontend_type>
182
+ <source_model>imagezoom/adminhtml_system_config_source_position</source_model>
183
+ <sort_order>52</sort_order>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ </position>
188
+ <adjustX translate="label comment">
189
+ <label>Adjust X (pixel)</label>
190
+ <validate>validate-number</validate>
191
+ <comment>Leave empty for default (default: 0). Negative values are allowed</comment>
192
+ <frontend_type>text</frontend_type>
193
+ <sort_order>53</sort_order>
194
+ <show_in_default>1</show_in_default>
195
+ <show_in_website>1</show_in_website>
196
+ <show_in_store>1</show_in_store>
197
+ </adjustX>
198
+ <adjustY translate="label comment">
199
+ <label>Adjust Y (pixel)</label>
200
+ <validate>validate-number</validate>
201
+ <comment>Leave empty for default (default: -3). Negative values are allowed</comment>
202
+ <frontend_type>text</frontend_type>
203
+ <sort_order>54</sort_order>
204
+ <show_in_default>1</show_in_default>
205
+ <show_in_website>1</show_in_website>
206
+ <show_in_store>1</show_in_store>
207
+ </adjustY>
208
+
209
+ <zoomeffect translate="label comment">
210
+ <label>Zoom Effect</label>
211
+ <comment></comment>
212
+
213
+ <frontend_type>select</frontend_type>
214
+ <source_model>imagezoom/adminhtml_system_config_source_zoomeffect</source_model>
215
+ <sort_order>55</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>1</show_in_store>
219
+ </zoomeffect>
220
+
221
+ <tintColor translate="label comment">
222
+ <label>Tint Color</label>
223
+ <comment>e.g. 77CC99</comment>
224
+ <backend_model>imagezoom/adminhtml_system_color</backend_model>
225
+ <frontend_type>text</frontend_type>
226
+ <validate>required-entry validate-number</validate>
227
+ <sort_order>56</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>1</show_in_store>
231
+ <depends>
232
+ <zoomeffect>1</zoomeffect>
233
+ </depends>
234
+ </tintColor>
235
+ <tintOpacity translate="label comment">
236
+ <label>Tint Opacity</label>
237
+ <comment>Number between 0 and 1, where 0 is fully transparent and 1 is fully opaque.</comment>
238
+ <frontend_type>text</frontend_type>
239
+ <validate>validate-number</validate>
240
+ <sort_order>57</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>1</show_in_website>
243
+ <show_in_store>1</show_in_store>
244
+ <depends>
245
+ <zoomeffect>1</zoomeffect>
246
+ </depends>
247
+ </tintOpacity>
248
+
249
+ <lensOpacity translate="label comment">
250
+ <label>Lens Opacity</label>
251
+ <comment>Opacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent.</comment>
252
+ <validate>validate-number</validate>
253
+ <frontend_type>text</frontend_type>
254
+ <sort_order>58</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ </lensOpacity>
259
+ <smoothMove translate="label comment">
260
+ <label>Smooth Move</label>
261
+ <validate>validate-number</validate>
262
+ <comment>Amount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing.</comment>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>60</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ </smoothMove>
269
+ <showTitle translate="label comment">
270
+ <label>Show Title</label>
271
+ <comment>Shows the title tag of the image</comment>
272
+ <frontend_type>select</frontend_type>
273
+ <source_model>adminhtml/system_config_source_yesno</source_model>
274
+ <sort_order>61</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_website>1</show_in_website>
277
+ <show_in_store>1</show_in_store>
278
+ </showTitle>
279
+ <titleOpacity translate="label comment">
280
+ <label>Title Opacity</label>
281
+ <comment>Specifies the opacity of the title if displayed, where 0 is fully transparent, and 1 is fully opaque.</comment>
282
+ <validate>validate-number</validate>
283
+ <frontend_type>text</frontend_type>
284
+ <sort_order>62</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ <depends>
289
+ <showTitle>1</showTitle>
290
+ </depends>
291
+ </titleOpacity>
292
+ </fields>
293
+ </imagezoom_options>
294
+ </groups>
295
+ </imagezoomconfig>
296
+ </sections>
297
+ </config>
app/design/frontend/base/default/layout/imagezoom.xml ADDED
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+
15
+ <layout>
16
+ <catalog_product_view>
17
+ <reference name="product.info.media">
18
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
19
+ <template>corlletelab/imagezoom/media.phtml</template>
20
+ </action>
21
+ </reference>
22
+ </catalog_product_view>
23
+ <review_product_list>
24
+ <reference name="product.info.media">
25
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
26
+ <template>corlletelab/imagezoom/media.phtml</template>
27
+ </action>
28
+ </reference>
29
+ </review_product_list>
30
+ <catalog_product_view translate="label">
31
+ <reference name="head">
32
+ <action method="addJs" ifconfig="imagezoomconfig/moduleoptions/moduleenable"><script>corlletelab/imagezoom/product_override.js</script></action>
33
+ </reference>
34
+ </catalog_product_view>
35
+ <PRODUCT_TYPE_grouped translate="label" module="catalog">
36
+ <label>Catalog Product View (Grouped)</label>
37
+ <reference name="product.info">
38
+ <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml">
39
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
40
+ <template>corlletelab/imagezoom/grouped.phtml</template>
41
+ </action>
42
+ <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label">
43
+ <label>Product Extra Info</label>
44
+ </block>
45
+ </block>
46
+ </reference>
47
+ </PRODUCT_TYPE_grouped>
48
+ </layout>
app/design/frontend/base/default/template/corlletelab/imagezoom/grouped.phtml ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+ ?>
13
+
14
+ <?php $this->setPreconfiguredValue(); ?>
15
+ <?php $_product = $this->getProduct(); ?>
16
+ <?php $_associatedProducts = $this->getAssociatedProducts(); ?>
17
+ <?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
18
+ <?php
19
+ $zoom_image_size = Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/img_size');
20
+ ?>
21
+
22
+ <?php if ($_product->isAvailable() && $_hasAssociatedProducts): ?>
23
+ <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
24
+ <?php else: ?>
25
+ <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
26
+ <?php endif; ?>
27
+ <?php echo $this->getChildHtml('product_type_data_extra') ?>
28
+ <table class="data-table grouped-items-table" id="super-product-table">
29
+ <col style="width: 50px; text-align:center"/>
30
+ <col />
31
+ <col width="1" />
32
+ <thead>
33
+ <tr>
34
+ <th ></th>
35
+ <th><?php echo $this->__('Product Name') ?></th>
36
+ <?php if ($this->getCanShowProductPrice($_product)): ?>
37
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
38
+ <?php endif; ?>
39
+ <?php if ($_product->isSaleable()): ?>
40
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
41
+ <?php endif; ?>
42
+ </tr>
43
+ </thead>
44
+ <tbody>
45
+ <?php if ($_hasAssociatedProducts): ?>
46
+ <?php foreach ($_associatedProducts as $_item): ?>
47
+ <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
48
+ <tr>
49
+ <td>
50
+ <a href="<?php echo $this->helper('catalog/image')->init($_item, 'image'); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_item->getName()) ?>"
51
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize($zoom_image_size) ?>'" >
52
+ <img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(40) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
53
+ </a>
54
+ <td><?php echo $this->htmlEscape($_item->getName()) ?></td>
55
+ <?php if ($this->getCanShowProductPrice($_product)): ?>
56
+ <td class="a-right">
57
+ <?php if ($this->getCanShowProductPrice($_item)): ?>
58
+ <?php echo $this->getPriceHtml($_item, true) ?>
59
+ <?php echo $this->getTierPriceHtml($_item) ?>
60
+ <?php endif; ?>
61
+ </td>
62
+ <?php endif; ?>
63
+ <?php if ($_product->isSaleable()): ?>
64
+ <td class="a-center">
65
+ <?php if ($_item->isSaleable()) : ?>
66
+ <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
67
+ <?php else: ?>
68
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
69
+ <?php endif; ?>
70
+ </td>
71
+ <?php endif; ?>
72
+ </tr>
73
+ <?php endforeach; ?>
74
+ <?php else: ?>
75
+ <tr>
76
+ <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
77
+ </tr>
78
+ <?php endif; ?>
79
+ </tbody>
80
+ </table>
81
+ <script type="text/javascript">decorateTable('super-product-table')</script>
app/design/frontend/base/default/template/corlletelab/imagezoom/media.phtml ADDED
@@ -0,0 +1,145 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+ ?>
13
+
14
+ <?php
15
+ $_product = $this->getProduct();
16
+ $_helper = $this->helper('catalog/output');
17
+ $zoom_image_size = Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/img_size');
18
+
19
+ $img_arr = array();
20
+
21
+
22
+ if ($_product->getTypeId() == 'configurable') {
23
+
24
+ $_childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProductCollection($_product);
25
+
26
+ if (count($_childProducts) > 0) {
27
+ $cnt = 0;
28
+ $js = '';
29
+ foreach ($_childProducts as $_child) {
30
+ $_child_images = $this->helper('imagezoom')->getAllImages($_child);
31
+ foreach($_child_images as $_child_image) {
32
+ $img_arr[$cnt] = array(
33
+ 'id' => $_child->getId(),
34
+ 'small_image' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_child_image->getFile())->resize($zoom_image_size),
35
+ 'big_image' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'image', $_child_image->getFile()),
36
+ 'thumb' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_child_image->getFile())->resize(56),
37
+ 'label' => (string)$this->htmlEscape($_child_image->getLabel()),
38
+ 'main_image' => (string)$_child_image['main_image']
39
+ );
40
+ $cnt++;
41
+ }
42
+ }
43
+ }
44
+
45
+
46
+
47
+ } else if($_product->getTypeId() == 'grouped') { //TODO
48
+ //$_childProducts = $_product->getTypeInstance()->getAssociatedProducts();
49
+ }
50
+
51
+ ?>
52
+ <script type="text/javascript">
53
+ var assocIMG = { // Added
54
+ <?php
55
+ if(isset($img_arr) && count($img_arr) > 0) {
56
+ foreach ($img_arr as $img) {
57
+ if ($img['main_image']) {
58
+ $dados[] = "small_image_".$img['id'].":'".$img['small_image']."'";
59
+ $dados[] = "big_image_".$img['id'].":'".$img['big_image']."'";
60
+ }
61
+ }
62
+ echo implode(',', $dados );
63
+ }
64
+ ?>
65
+ }
66
+ </script>
67
+
68
+ <script type="text/javascript">
69
+ function jSelectImage(id) {
70
+ var add = $('.more-views li.add');
71
+ if (add && add.length > 0) {
72
+ $('show-all').show();
73
+ add.each(function(item,i){
74
+ item.hide();
75
+ var className = 'item-'+id;
76
+
77
+ if (item.hasClassName(className)){
78
+ item.show();
79
+ }
80
+ })
81
+ }
82
+
83
+ if (assocIMG['big_image_'+id] && assocIMG['small_image_'+id]) {
84
+ // Destroy the previous zoom
85
+ jQuery('#image-zoom').data('zoom').destroy();
86
+ // Change the biglink to point to the new big image.
87
+ jQuery('#image-zoom').attr('href', assocIMG['big_image_'+id]);
88
+ // Change the small image to point to the new small image.
89
+ jQuery('#image-zoom img').attr('src', assocIMG['small_image_'+id]);
90
+ // Init a new zoom with the new images.
91
+ jQuery('#image-zoom').CloudZoom();
92
+ //console.log('yes')
93
+ }
94
+ }
95
+
96
+ function showAll() {
97
+ var add = $('.more-views li.add');
98
+ if (add && add.length > 0) {
99
+ $('show-all').hide();
100
+ add.each(function(item,i){
101
+ item.show();
102
+ })
103
+ }
104
+ }
105
+
106
+ </script>
107
+
108
+ <p class="product-image">
109
+ <a href="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" class="cloud-zoom" id="image-zoom" rel="<?php echo $this->helper('imagezoom')->getZoomConfig(); ?>">
110
+ <?php
111
+ $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize($zoom_image_size).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
112
+ echo $_helper->productAttribute($_product, $_img, 'image');
113
+ ?>
114
+ </a>
115
+ </p>
116
+
117
+
118
+ <?php if (count($this->getGalleryImages()) > 0 || (isset($_childProducts) && count($_childProducts) > 0) ): ?>
119
+ <div class="more-views">
120
+ <a id="show-all" class="f-right" style="display: none; font-size: 11px" href="#" onclick="javascript:showAll(); return false;" title="Show All">Show All</a>
121
+ <h2><?php echo $this->__('More Views') ?></h2>
122
+ <ul>
123
+ <?php foreach ($this->getGalleryImages() as $_image): ?>
124
+ <li>
125
+ <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"
126
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($zoom_image_size) ?>'" >
127
+ <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56) ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
128
+ </a>
129
+ </li>
130
+ <?php endforeach; ?>
131
+ <?php if (isset($_childProducts) && count($_childProducts) > 0):?>
132
+ <?php foreach ($img_arr as $img): ?>
133
+ <li class="add item-<?php echo $img['id']; ?>">
134
+ <a href="<?php echo $img['big_image']; ?>" class="cloud-zoom-gallery" title="<?php echo $img['label'] ?>"
135
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $img['small_image']; ?>'" >
136
+ <img src="<?php echo $img['thumb']; ?>" alt="<?php echo $img['label'] ?>" />
137
+ </a>
138
+ </li>
139
+ <?php endforeach; ?>
140
+ <li style=" padding: 0; background-color: transparent; display: none"></li>
141
+ <?php endif; ?>
142
+ </ul>
143
+
144
+ </div>
145
+ <?php endif; ?>
app/design/frontend/default/default/layout/imagezoom.xml ADDED
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+
15
+ <layout>
16
+ <catalog_product_view>
17
+ <reference name="product.info.media">
18
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
19
+ <template>corlletelab/imagezoom/media.phtml</template>
20
+ </action>
21
+ </reference>
22
+ </catalog_product_view>
23
+ <review_product_list>
24
+ <reference name="product.info.media">
25
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
26
+ <template>corlletelab/imagezoom/media.phtml</template>
27
+ </action>
28
+ </reference>
29
+ </review_product_list>
30
+ <catalog_product_view translate="label">
31
+ <reference name="head">
32
+ <action method="addJs" ifconfig="imagezoomconfig/moduleoptions/moduleenable"><script>corlletelab/imagezoom/product_override.js</script></action>
33
+ </reference>
34
+ </catalog_product_view>
35
+ <PRODUCT_TYPE_grouped translate="label" module="catalog">
36
+ <label>Catalog Product View (Grouped)</label>
37
+ <reference name="product.info">
38
+ <block type="catalog/product_view_type_grouped" name="product.info.grouped" as="product_type_data" template="catalog/product/view/type/grouped.phtml">
39
+ <action method="setTemplate" ifconfig="imagezoomconfig/moduleoptions/moduleenable">
40
+ <template>corlletelab/imagezoom/grouped.phtml</template>
41
+ </action>
42
+ <block type="core/text_list" name="product.info.grouped.extra" as="product_type_data_extra" translate="label">
43
+ <label>Product Extra Info</label>
44
+ </block>
45
+ </block>
46
+ </reference>
47
+ </PRODUCT_TYPE_grouped>
48
+ </layout>
app/design/frontend/default/default/template/corlletelab/imagezoom/grouped.phtml ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+ ?>
13
+
14
+ <?php $this->setPreconfiguredValue(); ?>
15
+ <?php $_product = $this->getProduct(); ?>
16
+ <?php $_associatedProducts = $this->getAssociatedProducts(); ?>
17
+ <?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
18
+ <?php
19
+ $zoom_image_size = Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/img_size');
20
+ ?>
21
+
22
+ <?php if ($_product->isAvailable() && $_hasAssociatedProducts): ?>
23
+ <p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
24
+ <?php else: ?>
25
+ <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
26
+ <?php endif; ?>
27
+ <?php echo $this->getChildHtml('product_type_data_extra') ?>
28
+ <table class="data-table grouped-items-table" id="super-product-table">
29
+ <col style="width: 50px; text-align:center"/>
30
+ <col />
31
+ <col width="1" />
32
+ <thead>
33
+ <tr>
34
+ <th ></th>
35
+ <th><?php echo $this->__('Product Name') ?></th>
36
+ <?php if ($this->getCanShowProductPrice($_product)): ?>
37
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
38
+ <?php endif; ?>
39
+ <?php if ($_product->isSaleable()): ?>
40
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
41
+ <?php endif; ?>
42
+ </tr>
43
+ </thead>
44
+ <tbody>
45
+ <?php if ($_hasAssociatedProducts): ?>
46
+ <?php foreach ($_associatedProducts as $_item): ?>
47
+ <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
48
+ <tr>
49
+ <td>
50
+ <a href="<?php echo $this->helper('catalog/image')->init($_item, 'image'); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_item->getName()) ?>"
51
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize($zoom_image_size) ?>'" >
52
+ <img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(40) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" />
53
+ </a>
54
+ <td><?php echo $this->htmlEscape($_item->getName()) ?></td>
55
+ <?php if ($this->getCanShowProductPrice($_product)): ?>
56
+ <td class="a-right">
57
+ <?php if ($this->getCanShowProductPrice($_item)): ?>
58
+ <?php echo $this->getPriceHtml($_item, true) ?>
59
+ <?php echo $this->getTierPriceHtml($_item) ?>
60
+ <?php endif; ?>
61
+ </td>
62
+ <?php endif; ?>
63
+ <?php if ($_product->isSaleable()): ?>
64
+ <td class="a-center">
65
+ <?php if ($_item->isSaleable()) : ?>
66
+ <input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
67
+ <?php else: ?>
68
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
69
+ <?php endif; ?>
70
+ </td>
71
+ <?php endif; ?>
72
+ </tr>
73
+ <?php endforeach; ?>
74
+ <?php else: ?>
75
+ <tr>
76
+ <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
77
+ </tr>
78
+ <?php endif; ?>
79
+ </tbody>
80
+ </table>
81
+ <script type="text/javascript">decorateTable('super-product-table')</script>
app/design/frontend/default/default/template/corlletelab/imagezoom/media.phtml ADDED
@@ -0,0 +1,145 @@
1
+ <?php
2
+ /**
3
+ * CorlleteLab
4
+ *
5
+ * Imagezoom extension
6
+ *
7
+ * @category CorlleteLab
8
+ * @package CorlleteLab_Imagezoom
9
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
10
+ * @author CorlleteLab Dev Team <office@clabteam.com>
11
+ */
12
+ ?>
13
+
14
+ <?php
15
+ $_product = $this->getProduct();
16
+ $_helper = $this->helper('catalog/output');
17
+ $zoom_image_size = Mage::getStoreConfig('imagezoomconfig/imagezoom_style_css/img_size');
18
+
19
+ $img_arr = array();
20
+
21
+
22
+ if ($_product->getTypeId() == 'configurable') {
23
+
24
+ $_childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProductCollection($_product);
25
+
26
+ if (count($_childProducts) > 0) {
27
+ $cnt = 0;
28
+ $js = '';
29
+ foreach ($_childProducts as $_child) {
30
+ $_child_images = $this->helper('imagezoom')->getAllImages($_child);
31
+ foreach($_child_images as $_child_image) {
32
+ $img_arr[$cnt] = array(
33
+ 'id' => $_child->getId(),
34
+ 'small_image' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_child_image->getFile())->resize($zoom_image_size),
35
+ 'big_image' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'image', $_child_image->getFile()),
36
+ 'thumb' => (string)$this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_child_image->getFile())->resize(56),
37
+ 'label' => (string)$this->htmlEscape($_child_image->getLabel()),
38
+ 'main_image' => (string)$_child_image['main_image']
39
+ );
40
+ $cnt++;
41
+ }
42
+ }
43
+ }
44
+
45
+
46
+
47
+ } else if($_product->getTypeId() == 'grouped') { //TODO
48
+ //$_childProducts = $_product->getTypeInstance()->getAssociatedProducts();
49
+ }
50
+
51
+ ?>
52
+ <script type="text/javascript">
53
+ var assocIMG = { // Added
54
+ <?php
55
+ if(isset($img_arr) && count($img_arr) > 0) {
56
+ foreach ($img_arr as $img) {
57
+ if ($img['main_image']) {
58
+ $dados[] = "small_image_".$img['id'].":'".$img['small_image']."'";
59
+ $dados[] = "big_image_".$img['id'].":'".$img['big_image']."'";
60
+ }
61
+ }
62
+ echo implode(',', $dados );
63
+ }
64
+ ?>
65
+ }
66
+ </script>
67
+
68
+ <script type="text/javascript">
69
+ function jSelectImage(id) {
70
+ var add = $('.more-views li.add');
71
+ if (add && add.length > 0) {
72
+ $('show-all').show();
73
+ add.each(function(item,i){
74
+ item.hide();
75
+ var className = 'item-'+id;
76
+
77
+ if (item.hasClassName(className)){
78
+ item.show();
79
+ }
80
+ })
81
+ }
82
+
83
+ if (assocIMG['big_image_'+id] && assocIMG['small_image_'+id]) {
84
+ // Destroy the previous zoom
85
+ jQuery('#image-zoom').data('zoom').destroy();
86
+ // Change the biglink to point to the new big image.
87
+ jQuery('#image-zoom').attr('href', assocIMG['big_image_'+id]);
88
+ // Change the small image to point to the new small image.
89
+ jQuery('#image-zoom img').attr('src', assocIMG['small_image_'+id]);
90
+ // Init a new zoom with the new images.
91
+ jQuery('#image-zoom').CloudZoom();
92
+ //console.log('yes')
93
+ }
94
+ }
95
+
96
+ function showAll() {
97
+ var add = $('.more-views li.add');
98
+ if (add && add.length > 0) {
99
+ $('show-all').hide();
100
+ add.each(function(item,i){
101
+ item.show();
102
+ })
103
+ }
104
+ }
105
+
106
+ </script>
107
+
108
+ <p class="product-image">
109
+ <a href="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" class="cloud-zoom" id="image-zoom" rel="<?php echo $this->helper('imagezoom')->getZoomConfig(); ?>">
110
+ <?php
111
+ $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize($zoom_image_size).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
112
+ echo $_helper->productAttribute($_product, $_img, 'image');
113
+ ?>
114
+ </a>
115
+ </p>
116
+
117
+
118
+ <?php if (count($this->getGalleryImages()) > 0 || (isset($_childProducts) && count($_childProducts) > 0) ): ?>
119
+ <div class="more-views">
120
+ <a id="show-all" class="f-right" style="display: none; font-size: 11px" href="#" onclick="javascript:showAll(); return false;" title="Show All">Show All</a>
121
+ <h2><?php echo $this->__('More Views') ?></h2>
122
+ <ul>
123
+ <?php foreach ($this->getGalleryImages() as $_image): ?>
124
+ <li>
125
+ <a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" class="cloud-zoom-gallery" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"
126
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($zoom_image_size) ?>'" >
127
+ <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56) ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
128
+ </a>
129
+ </li>
130
+ <?php endforeach; ?>
131
+ <?php if (isset($_childProducts) && count($_childProducts) > 0):?>
132
+ <?php foreach ($img_arr as $img): ?>
133
+ <li class="add item-<?php echo $img['id']; ?>">
134
+ <a href="<?php echo $img['big_image']; ?>" class="cloud-zoom-gallery" title="<?php echo $img['label'] ?>"
135
+ rel="useZoom: 'image-zoom', smallImage: '<?php echo $img['small_image']; ?>'" >
136
+ <img src="<?php echo $img['thumb']; ?>" alt="<?php echo $img['label'] ?>" />
137
+ </a>
138
+ </li>
139
+ <?php endforeach; ?>
140
+ <li style=" padding: 0; background-color: transparent; display: none"></li>
141
+ <?php endif; ?>
142
+ </ul>
143
+
144
+ </div>
145
+ <?php endif; ?>
app/etc/modules/CorlleteLab_Imagezoom.xml ADDED
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * CorlleteLab
5
+ *
6
+ * Imagezoom extension
7
+ *
8
+ * @category CorlleteLab
9
+ * @package CorlleteLab_Imagezoom
10
+ * @copyright Copyright (c) 2011 Corllete Ltd. (http://www.clabteam.com/)
11
+ * @author CorlleteLab Dev Team <office@clabteam.com>
12
+ */
13
+ -->
14
+ <config>
15
+ <modules>
16
+ <CorlleteLab_Imagezoom>
17
+ <active>true</active>
18
+ <codePool>community</codePool>
19
+ </CorlleteLab_Imagezoom>
20
+ </modules>
21
+ </config>
app/locale/en_US/CorlleteLab_ImageZoom.csv ADDED
@@ -0,0 +1,33 @@
1
+ "Adjust X (pixel)","Adjust X (pixel)"
2
+ "Adjust Y (pixel)","Adjust Y (pixel)"
3
+ "Amount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing.","Amount of smoothness/drift of the zoom image as it moves. The higher the number, the smoother/more drifty the movement will be. 1 = no smoothing."
4
+ "CorlleteLab Plugins","CorlleteLab Plugins"
5
+ "e.g. 77CC99","e.g. 77CC100"
6
+ "Enable Module","Enable Module"
7
+ "Image Size (pixel)","Image Size (pixel)"
8
+ "Image Zoom Configuration","Image Zoom Configuration"
9
+ "Image Zoom Options","Image Zoom Options"
10
+ "Image Zoom Style","Image Zoom Style"
11
+ "Leave empty for default (default: 0). Negative values are allowed","Leave empty for default (default: 0). Negative values are allowed"
12
+ "Leave empty for default (same as imge size)","Leave empty for default (same as imge size)"
13
+ "Lens Opacity","Lens Opacity"
14
+ "Load External jQuery","Load External jQuery"
15
+ "Module Options","Module Options"
16
+ "Moving Lens Background Color","Moving Lens Background Color"
17
+ "Moving Lens Border Color","Moving Lens Border Color"
18
+ "Moving Lens Border Thickness","Moving Lens Border Thickness"
19
+ "Number between 0 and 1, where 0 is fully transparent and 1 is fully opaque.","Number between 0 and 1, where 0 is fully transparent and 1 is fully opaque."
20
+ "Opacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent.","Opacity of the lens mouse pointer, where 0 is fully transparent, and 1 is fully opaque. In tint and soft-focus modes, it will always be transparent."
21
+ "Position","Position"
22
+ "Show Title","Show Title"
23
+ "Smooth Move","Smooth Move"
24
+ "Specifies the position of the zoom window relative to the small image.","Specifies the position of the zoom window relative to the small image."
25
+ "This will load the jQuery library from the This will load the jQuery library from the Google Content Network.<span class=""notice"">Probably better than from your own server. </span>","This will load the jQuery library from the This will load the jQuery library from the Google Content Network.<span class=""notice"">Probably better than from your own server. </span>"
26
+ "Tint Color","Tint Color"
27
+ "Tint Opacity","Tint Opacity"
28
+ "Title Opacity","Title Opacity"
29
+ "Zoom Effect","Zoom Effect"
30
+ "Zoom Height","Zoom Height"
31
+ "Zoom Width","Zoom Width"
32
+ "Zoom Window Border Color","Zoom Window Border Color"
33
+ "Zoom Window Border Thickness","Zoom Window Border Thickness"
js/corlletelab/imagezoom/cloud-zoom.1.0.2.js ADDED
@@ -0,0 +1,391 @@
1
+ //////////////////////////////////////////////////////////////////////////////////
2
+ // Cloud Zoom V1.0.2
3
+ // (c) 2010 by R Cecco. <http://www.professorcloud.com>
4
+ // MIT License
5
+ //
6
+ // Please retain this copyright header in all versions of the software
7
+ //////////////////////////////////////////////////////////////////////////////////
8
+ (function ($) {
9
+
10
+ $(document).ready(function () {
11
+ $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
12
+ });
13
+
14
+ function format(str) {
15
+ for (var i = 1; i < arguments.length; i++) {
16
+ str = str.replace('%' + (i - 1), arguments[i]);
17
+ }
18
+ return str;
19
+ }
20
+
21
+ function CloudZoom(jWin, opts) {
22
+ var sImg = $('img', jWin);
23
+ var img1;
24
+ var img2;
25
+ var zoomDiv = null;
26
+ var $mouseTrap = null;
27
+ var lens = null;
28
+ var $tint = null;
29
+ var softFocus = null;
30
+ var $ie6Fix = null;
31
+ var zoomImage;
32
+ var controlTimer = 0;
33
+ var cw, ch;
34
+ var destU = 0;
35
+ var destV = 0;
36
+ var currV = 0;
37
+ var currU = 0;
38
+ var filesLoaded = 0;
39
+ var mx,
40
+ my;
41
+ var ctx = this, zw;
42
+ // Display an image loading message. This message gets deleted when the images have loaded and the zoom init function is called.
43
+ // We add a small delay before the message is displayed to avoid the message flicking on then off again virtually immediately if the
44
+ // images load really fast, e.g. from the cache.
45
+ //var ctx = this;
46
+ setTimeout(function () {
47
+ // <img src="/images/loading.gif"/>
48
+ if ($mouseTrap === null) {
49
+ var w = jWin.width();
50
+ jWin.parent().append(format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>', w / 3, (w / 2) - (w / 6))).find(':last').css('opacity', 0.5);
51
+ }
52
+ }, 200);
53
+
54
+
55
+ var ie6FixRemove = function () {
56
+
57
+ if ($ie6Fix !== null) {
58
+ $ie6Fix.remove();
59
+ $ie6Fix = null;
60
+ }
61
+ };
62
+
63
+ // Removes cursor, tint layer, blur layer etc.
64
+ this.removeBits = function () {
65
+ //$mouseTrap.unbind();
66
+ if (lens) {
67
+ lens.remove();
68
+ lens = null;
69
+ }
70
+ if ($tint) {
71
+ $tint.remove();
72
+ $tint = null;
73
+ }
74
+ if (softFocus) {
75
+ softFocus.remove();
76
+ softFocus = null;
77
+ }
78
+ ie6FixRemove();
79
+
80
+ $('.cloud-zoom-loading', jWin.parent()).remove();
81
+ };
82
+
83
+
84
+ this.destroy = function () {
85
+ jWin.data('zoom', null);
86
+
87
+ if ($mouseTrap) {
88
+ $mouseTrap.unbind();
89
+ $mouseTrap.remove();
90
+ $mouseTrap = null;
91
+ }
92
+ if (zoomDiv) {
93
+ zoomDiv.remove();
94
+ zoomDiv = null;
95
+ }
96
+ //ie6FixRemove();
97
+ this.removeBits();
98
+ // DON'T FORGET TO REMOVE JQUERY 'DATA' VALUES
99
+ };
100
+
101
+
102
+ // This is called when the zoom window has faded out so it can be removed.
103
+ this.fadedOut = function () {
104
+
105
+ if (zoomDiv) {
106
+ zoomDiv.remove();
107
+ zoomDiv = null;
108
+ }
109
+ this.removeBits();
110
+ //ie6FixRemove();
111
+ };
112
+
113
+ this.controlLoop = function () {
114
+ if (lens) {
115
+ var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0;
116
+ var y = (my - sImg.offset().top - (ch * 0.5)) >> 0;
117
+
118
+ if (x < 0) {
119
+ x = 0;
120
+ }
121
+ else if (x > (sImg.outerWidth() - cw)) {
122
+ x = (sImg.outerWidth() - cw);
123
+ }
124
+ if (y < 0) {
125
+ y = 0;
126
+ }
127
+ else if (y > (sImg.outerHeight() - ch)) {
128
+ y = (sImg.outerHeight() - ch);
129
+ }
130
+
131
+ lens.css({
132
+ left: x,
133
+ top: y
134
+ });
135
+ lens.css('background-position', (-x) + 'px ' + (-y) + 'px');
136
+
137
+ destU = (((x) / sImg.outerWidth()) * zoomImage.width) >> 0;
138
+ destV = (((y) / sImg.outerHeight()) * zoomImage.height) >> 0;
139
+ currU += (destU - currU) / opts.smoothMove;
140
+ currV += (destV - currV) / opts.smoothMove;
141
+
142
+ zoomDiv.css('background-position', (-(currU >> 0) + 'px ') + (-(currV >> 0) + 'px'));
143
+ }
144
+ controlTimer = setTimeout(function () {
145
+ ctx.controlLoop();
146
+ }, 30);
147
+ };
148
+
149
+ this.init2 = function (img, id) {
150
+
151
+ filesLoaded++;
152
+ //console.log(img.src + ' ' + id + ' ' + img.width);
153
+ if (id === 1) {
154
+ zoomImage = img;
155
+ }
156
+ //this.images[id] = img;
157
+ if (filesLoaded === 2) {
158
+ this.init();
159
+ }
160
+ };
161
+
162
+ /* Init function start. */
163
+ this.init = function () {
164
+ // Remove loading message (if present);
165
+ $('.cloud-zoom-loading', jWin.parent()).remove();
166
+
167
+
168
+ /* Add a box (mouseTrap) over the small image to trap mouse events.
169
+ It has priority over zoom window to avoid issues with inner zoom.
170
+ We need the dummy background image as IE does not trap mouse events on
171
+ transparent parts of a div.
172
+ */
173
+ $mouseTrap = jWin.parent().append(format("<div class='mousetrap' style='background-image:url(\".\");z-index:998;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;\'></div>", sImg.outerWidth(), sImg.outerHeight(), 0, 0)).find(':last');
174
+
175
+ //////////////////////////////////////////////////////////////////////
176
+ /* Do as little as possible in mousemove event to prevent slowdown. */
177
+ $mouseTrap.bind('mousemove', this, function (event) {
178
+ // Just update the mouse position
179
+ mx = event.pageX;
180
+ my = event.pageY;
181
+ });
182
+ //////////////////////////////////////////////////////////////////////
183
+ $mouseTrap.bind('mouseleave', this, function (event) {
184
+ clearTimeout(controlTimer);
185
+ //event.data.removeBits();
186
+ if(lens) { lens.fadeOut(299); }
187
+ if($tint) { $tint.fadeOut(299); }
188
+ if(softFocus) { softFocus.fadeOut(299); }
189
+ zoomDiv.fadeOut(300, function () {
190
+ ctx.fadedOut();
191
+ });
192
+ return false;
193
+ });
194
+ //////////////////////////////////////////////////////////////////////
195
+ $mouseTrap.bind('mouseenter', this, function (event) {
196
+ mx = event.pageX;
197
+ my = event.pageY;
198
+ zw = event.data;
199
+ if (zoomDiv) {
200
+ zoomDiv.stop(true, false);
201
+ zoomDiv.remove();
202
+ }
203
+
204
+ var xPos = opts.adjustX,
205
+ yPos = opts.adjustY;
206
+
207
+ var siw = sImg.outerWidth();
208
+ var sih = sImg.outerHeight();
209
+
210
+ var w = opts.zoomWidth;
211
+ var h = opts.zoomHeight;
212
+ if (opts.zoomWidth == 'auto') {
213
+ w = siw;
214
+ }
215
+ if (opts.zoomHeight == 'auto') {
216
+ h = sih;
217
+ }
218
+ //$('#info').text( xPos + ' ' + yPos + ' ' + siw + ' ' + sih );
219
+ var appendTo = jWin.parent(); // attach to the wrapper
220
+ switch (opts.position) {
221
+ case 'top':
222
+ yPos -= h; // + opts.adjustY;
223
+ break;
224
+ case 'right':
225
+ xPos += siw; // + opts.adjustX;
226
+ break;
227
+ case 'bottom':
228
+ yPos += sih; // + opts.adjustY;
229
+ break;
230
+ case 'left':
231
+ xPos -= w; // + opts.adjustX;
232
+ break;
233
+ case 'inside':
234
+ w = siw;
235
+ h = sih;
236
+ break;
237
+ // All other values, try and find an id in the dom to attach to.
238
+ default:
239
+ appendTo = $('#' + opts.position);
240
+ // If dom element doesn't exit, just use 'right' position as default.
241
+ if (!appendTo.length) {
242
+ appendTo = jWin;
243
+ xPos += siw; //+ opts.adjustX;
244
+ yPos += sih; // + opts.adjustY;
245
+ } else {
246
+ w = appendTo.innerWidth();
247
+ h = appendTo.innerHeight();
248
+ }
249
+ }
250
+
251
+ zoomDiv = appendTo.append(format('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:99;"></div>', xPos, yPos, w, h, zoomImage.src)).find(':last');
252
+
253
+ // Add the title from title tag.
254
+ if (sImg.attr('title') && opts.showTitle) {
255
+ zoomDiv.append(format('<div class="cloud-zoom-title">%0</div>', sImg.attr('title'))).find(':last').css('opacity', opts.titleOpacity);
256
+ }
257
+
258
+ // Fix ie6 select elements wrong z-index bug. Placing an iFrame over the select element solves the issue...
259
+ if ($.browser.msie && $.browser.version < 7) {
260
+ $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({
261
+ position: "absolute",
262
+ left: xPos,
263
+ top: yPos,
264
+ zIndex: 99,
265
+ width: w,
266
+ height: h
267
+ }).insertBefore(zoomDiv);
268
+ }
269
+
270
+ zoomDiv.fadeIn(500);
271
+
272
+ if (lens) {
273
+ lens.remove();
274
+ lens = null;
275
+ } /* Work out size of cursor */
276
+ cw = (sImg.outerWidth() / zoomImage.width) * zoomDiv.width();
277
+ ch = (sImg.outerHeight() / zoomImage.height) * zoomDiv.height();
278
+
279
+ // Attach mouse, initially invisible to prevent first frame glitch
280
+ lens = jWin.append(format("<div class = 'cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>", cw, ch)).find(':last');
281
+
282
+ $mouseTrap.css('cursor', lens.css('cursor'));
283
+
284
+ var noTrans = false;
285
+
286
+ // Init tint layer if needed. (Not relevant if using inside mode)
287
+ if (opts.tint) {
288
+ lens.css('background', 'url("' + sImg.attr('src') + '")');
289
+ $tint = jWin.append(format('<div style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />', sImg.outerWidth(), sImg.outerHeight(), opts.tint)).find(':last');
290
+ $tint.css('opacity', opts.tintOpacity);
291
+ noTrans = true;
292
+ $tint.fadeIn(500);
293
+
294
+ }
295
+ if (opts.softFocus) {
296
+ lens.css('background', 'url("' + sImg.attr('src') + '")');
297
+ softFocus = jWin.append(format('<div style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />', sImg.outerWidth() - 2, sImg.outerHeight() - 2, opts.tint)).find(':last');
298
+ softFocus.css('background', 'url("' + sImg.attr('src') + '")');
299
+ softFocus.css('opacity', 0.5);
300
+ noTrans = true;
301
+ softFocus.fadeIn(500);
302
+ }
303
+
304
+ if (!noTrans) {
305
+ lens.css('opacity', opts.lensOpacity);
306
+ }
307
+ if ( opts.position !== 'inside' ) { lens.fadeIn(500); }
308
+
309
+ // Start processing.
310
+ zw.controlLoop();
311
+
312
+ return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
313
+ });
314
+ };
315
+
316
+ img1 = new Image();
317
+ $(img1).load(function () {
318
+ ctx.init2(this, 0);
319
+ });
320
+ img1.src = sImg.attr('src');
321
+
322
+ img2 = new Image();
323
+ $(img2).load(function () {
324
+ ctx.init2(this, 1);
325
+ });
326
+ img2.src = jWin.attr('href');
327
+ }
328
+
329
+ $.fn.CloudZoom = function (options) {
330
+ // IE6 background image flicker fix
331
+ try {
332
+ document.execCommand("BackgroundImageCache", false, true);
333
+ } catch (e) {}
334
+ this.each(function () {
335
+ var relOpts, opts;
336
+ // Hmm...eval...slap on wrist.
337
+ eval('var a = {' + $(this).attr('rel') + '}');
338
+ relOpts = a;
339
+ if ($(this).is('.cloud-zoom')) {
340
+ $(this).css({
341
+ 'position': 'relative',
342
+ 'display': 'block'
343
+ });
344
+ $('img', $(this)).css({
345
+ 'display': 'block'
346
+ });
347
+ // Wrap an outer div around the link so we can attach things without them becoming part of the link.
348
+ // But not if wrap already exists.
349
+ if ($(this).parent().attr('id') != 'wrap') {
350
+ $(this).wrap('<div id="wrap" style="top:0px;z-index:995;position:relative;"></div>');
351
+ }
352
+ opts = $.extend({}, $.fn.CloudZoom.defaults, options);
353
+ opts = $.extend({}, opts, relOpts);
354
+ $(this).data('zoom', new CloudZoom($(this), opts));
355
+
356
+ } else if ($(this).is('.cloud-zoom-gallery')) {
357
+ opts = $.extend({}, relOpts, options);
358
+ $(this).data('relOpts', opts);
359
+ $(this).bind('click', $(this), function (event) {
360
+ var data = event.data.data('relOpts');
361
+ // Destroy the previous zoom
362
+ $('#' + data.useZoom).data('zoom').destroy();
363
+ // Change the biglink to point to the new big image.
364
+ $('#' + data.useZoom).attr('href', event.data.attr('href'));
365
+ // Change the small image to point to the new small image.
366
+ $('#' + data.useZoom + ' img').attr('src', event.data.data('relOpts').smallImage);
367
+ // Init a new zoom with the new images.
368
+ $('#' + event.data.data('relOpts').useZoom).CloudZoom();
369
+ return false;
370
+ });
371
+ }
372
+ });
373
+ return this;
374
+ };
375
+
376
+ $.fn.CloudZoom.defaults = {
377
+ zoomWidth: 'auto',
378
+ zoomHeight: 'auto',
379
+ position: 'right',
380
+ tint: false,
381
+ tintOpacity: 0.5,
382
+ lensOpacity: 0.5,
383
+ softFocus: false,
384
+ smoothMove: 3,
385
+ showTitle: true,
386
+ titleOpacity: 0.5,
387
+ adjustX: 0,
388
+ adjustY: 0
389
+ };