Skip to content

Commit

Permalink
Free version
Browse files Browse the repository at this point in the history
  • Loading branch information
magiccart committed May 12, 2021
1 parent e4af20d commit c2ef556
Show file tree
Hide file tree
Showing 24 changed files with 2,048 additions and 84 deletions.
46 changes: 46 additions & 0 deletions Block/System/Config/Form/Field/Color.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* @Author: Alex Dong
* @Date: 2020-07-09 22:24:37
* @Last Modified by: Alex Dong
* @Last Modified time: 2020-07-09 22:24:46
*/

namespace Magepow\Productzoom\Block\System\Config\Form\Field;

class Color extends \Magento\Config\Block\System\Config\Form\Field
{

public function __construct(
\Magento\Backend\Block\Template\Context $context, array $data = []
) {
parent::__construct($context, $data);
}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = $element->getElementHtml();
$value = $element->getData('value');

$html .= '<script type="text/javascript">
require(["jquery", "jquery/colorpicker/js/colorpicker"], function ($) {
$(document).ready(function (e) {
var $el = $("#' . $element->getHtmlId() . '");
$el.css("backgroundColor", "'. $value .'");
// Attach the color picker
$el.ColorPicker({
color: "'. $value .'",
onChange: function (hsb, hex, rgb) {
$el.css("backgroundColor", "#" + hex).val("#" + hex);
}
});
});
});
</script>';

return $html;
}

}
34 changes: 34 additions & 0 deletions Block/System/Config/Form/Field/Position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/**
* @Author: Alex Dong
* @Date: 2020-07-09 22:24:37
* @Last Modified by: nguyen
* @Last Modified time: 2020-07-10 13:51:02
*/

namespace Magepow\Productzoom\Block\System\Config\Form\Field;

class Position extends \Magento\Config\Block\System\Config\Form\Field
{

private $assetRepository;

public function __construct(
\Magento\Backend\Block\Template\Context $context, array $data = []
) {
$this->assetRepository = $context->getAssetRepository();
parent::__construct($context, $data);
}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = $element->getElementHtml();
$value = $element->getData('value');

$asset = $this->assetRepository->createAsset('Magepow_Productzoom::images/window-positions.png');
$html .= '<div style="position: relative; margin-top:10px"><img id="window-positions" src="' . $asset->getUrl() . '" alt="" border="0"></div>';
return $html;
}

}
6 changes: 3 additions & 3 deletions Block/Zoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/**
* @Author: Alex Dong
* @Date: 2020-07-09 16:45:27
* @Last Modified by: nguyen
* @Last Modified time: 2021-05-12 11:53:28
* @Last Modified by: Alex Dong
* @Last Modified time: 2020-07-09 16:46:08
*/

namespace Magepow\Zoom\Block;
namespace Magepow\Productzoom\Block;

class Zoom extends \Magento\Framework\View\Element\Template
{
Expand Down
6 changes: 3 additions & 3 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
/**
* @Author: nguyen
* @Date: 2020-02-12 14:01:01
* @Last Modified by: nguyen
* @Last Modified time: 2021-05-12 11:53:21
* @Last Modified by: Alex Dong
* @Last Modified time: 2020-07-09 16:31:52
*/

namespace Magepow\Zoom\Helper;
namespace Magepow\Productzoom\Helper;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
Expand Down
22 changes: 22 additions & 0 deletions Model/Config/Source/Cursor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @Author: nguyen
* @Date: 2020-06-09 20:10:33
* @Last Modified by: nguyen
* @Last Modified time: 2020-07-09 22:34:47
*/

namespace Magepow\Productzoom\Model\Config\Source;

class Cursor implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
'default' => 'Default',
'cursor' => 'Cursor',
'crosshair' => 'Crosshair'
];
}
}
21 changes: 21 additions & 0 deletions Model/Config/Source/Lensshape.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* @Author: nguyen
* @Date: 2020-06-09 20:10:33
* @Last Modified by: nguyen
* @Last Modified time: 2020-07-09 22:34:47
*/

namespace Magepow\Productzoom\Model\Config\Source;

class Lensshape implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
'square' => 'Square',
'round' => 'Round'
];
}
}
30 changes: 30 additions & 0 deletions Model/Config/Source/Opacity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @Author: nguyen
* @Date: 2020-06-09 20:10:33
* @Last Modified by: nguyen
* @Last Modified time: 2020-07-10 11:57:27
*/

namespace Magepow\Productzoom\Model\Config\Source;

class Opacity implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
'0' => 0,
'0.1' => 0.1,
'0.2' => 0.2,
'0.3' => 0.3,
'0.4' => 0.4,
'0.5' => 0.5,
'0.6' => 0.6,
'0.7' => 0.7,
'0.8' => 0.8,
'0.9' => 0.9,
'1' => 1
];
}
}
35 changes: 35 additions & 0 deletions Model/Config/Source/Position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/**
* @Author: nguyen
* @Date: 2020-06-09 20:10:33
* @Last Modified by: nguyen
* @Last Modified time: 2020-08-17 22:14:54
*/

namespace Magepow\Productzoom\Model\Config\Source;

class Position implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
1 => 1,
2 => 2,
3 => 3,
4 => 4,
// 5 => 5,
// 6 => 6,
// 7 => 7,
// 8 => 8,
// 9 => 9,
// 10 => 10,
// 11 => 11,
// 12 => 12,
// 13 => 13,
// 14 => 14,
// 15 => 15,
// 16 => 16
];
}
}
4 changes: 2 additions & 2 deletions Model/Config/Source/Truefalse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* @Author: nguyen
* @Date: 2020-07-09 20:12:00
* @Last Modified by: nguyen
* @Last Modified time: 2021-05-12 11:53:20
* @Last Modified time: 2020-07-09 20:12:44
*/

namespace Magepow\Zoom\Model\Config\Source;
namespace Magepow\Productzoom\Model\Config\Source;

class Truefalse implements \Magento\Framework\Option\ArrayInterface
{
Expand Down
11 changes: 5 additions & 6 deletions Model/Config/Source/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* @Author: nguyen
* @Date: 2020-06-09 20:10:33
* @Last Modified by: nguyen
* @Last Modified time: 2021-05-12 11:53:19
* @Last Modified time: 2020-07-09 22:33:39
*/

namespace Magepow\Zoom\Model\Config\Source;
namespace Magepow\Productzoom\Model\Config\Source;

class Type implements \Magento\Framework\Option\ArrayInterface
{
public function toOptionArray()
{
return [
'grab' => 'grab',
'click' => 'click',
'toggle' => 'toggle',
'mouseover' => 'mouseover'
'window' => 'Window',
'inner' => 'Inner',
'lens' => 'Lens'
];
}
}
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "magepow/zoom",
"description": "Zoom images.",
"name": "magepow/productzoom",
"description": "Magento 2 Product zoom images.",
"require": {
"magepow/core" : ">=1.0"
"magepow/core": "^1.0.0"
},
"type": "magento2-module",
"license": [
Expand All @@ -22,7 +22,7 @@
"registration.php"
],
"psr-4": {
"Magepow\\Zoom\\": ""
"Magepow\\Productzoom\\": ""
}
}
}
2 changes: 1 addition & 1 deletion etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Magepow_Zoom::config" title="Zoom" />
<resource id="Magepow_Productzoom::config_productzoom" title="Product Zoom" />
</resource>
</resource>
</resource>
Expand Down
35 changes: 3 additions & 32 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,18 @@
<tab id="magepow" translate="label" sortOrder="86">
<label>Magepow</label>
</tab>
<section id="magepow_zoom" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<section id="magepow_productzoom" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Zoom</label>
<label>Product Zoom</label>
<tab>magepow</tab>
<resource>Magepow_Zoom::config</resource>
<resource>Magepow_Productzoom::config_productzoom</resource>
<group id="general" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>

<field id="enabled" translate="label comment" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Enabled</label>
<comment>Enabled Module</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>

<field id="on" translate="label comment" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Zoom Event</label>
<comment>mouseover', grab, click, toggle</comment>
<source_model>Magepow\Zoom\Model\Config\Source\Type</source_model>
</field>

<field id="target" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Target</label>
<validate>validate-digits validate-greater-than-zero</validate>
</field>

<field id="magnify" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Magnify</label>
<validate>validate-digits validate-greater-than-zero</validate>
</field>

<field id="duration" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Duration</label>
<validate>validate-digits validate-greater-than-zero</validate>
</field>

<field id="touch" translate="label comment" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Touch</label>
<comment>enables a touch fallback</comment>
<source_model>Magepow\Zoom\Model\Config\Source\Truefalse</source_model>
</field>

</group>
</section>
</system>
Expand Down
35 changes: 25 additions & 10 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@
*/ -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<magepow_zoom>
<magepow_productzoom>
<general>
<enabled>1</enabled>
<duration>120</duration>
<magnify>1</magnify>
<target>false</target>
<on>mouseover</on>
<touch>true</touch>
<onZoomIn>false</onZoomIn>
<onZoomOut>false</onZoomOut>
<target>false</target>
<responsive>false</responsive>
<scrollZoom>false</scrollZoom>
<zoomType>inner</zoomType>
<zoomWindowPosition>1</zoomWindowPosition>
<zoomWindowFadeIn>true</zoomWindowFadeIn>
<zoomWindowFadeOut>true</zoomWindowFadeOut>
<zIndex>99</zIndex>
<imageCrossfade>false</imageCrossfade>
<loadingIcon>false</loadingIcon>
<cursor>default</cursor>
<borderSize>1</borderSize>
<borderColour>#666</borderColour>
<easing>false</easing>
<easingType>zoomdefault</easingType>
<easingDuration>2000</easingDuration>
<lensShape>square</lensShape>
<lensFadeIn>false</lensFadeIn>
<lensFadeOut>false</lensFadeOut>
<lensBorder>1</lensBorder>
<lensColour>#fff</lensColour>
<lensOpacity>0.4</lensOpacity>
<tintColour>#333</tintColour>
<tintOpacity>0.4</tintOpacity>
</general>
</magepow_zoom>
</magepow_productzoom>
</default>
</config>
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
* @Last Modified time: 2020-02-15 18:55:34
*/ -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magepow_Zoom" setup_version="2.0"/>
<module name="Magepow_Productzoom" setup_version="2.0"/>
</config>
Loading

0 comments on commit c2ef556

Please sign in to comment.