-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from mageplaza/develop
Develop
- Loading branch information
Showing
4 changed files
with
112 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Core | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
namespace Mageplaza\Core\Block\Adminhtml\System\Config; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
/** | ||
* Class ColorPicker | ||
* @package Mageplaza\Core\Block\Adminhtml\System\Config | ||
*/ | ||
class ColorPicker extends Field { | ||
|
||
/** | ||
* Colorpicker constructor. | ||
* | ||
* @param Context $context | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @param AbstractElement $element | ||
* | ||
* @return string | ||
*/ | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
$html = $element->getElementHtml(); | ||
$value = $element->getData('value'); | ||
|
||
$html .= '<script type="text/javascript"> | ||
require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) { | ||
$(document).ready(function () { | ||
var $el = $("#' . $element->getHtmlId() . '"); | ||
$el.css("backgroundColor", "' . $value . '"); | ||
$el.ColorPicker({ | ||
color: "' . $value . '", | ||
onChange: function (hsb, hex, rgb) { | ||
$el.css("backgroundColor", "#" + hex).val("#" + hex); | ||
} | ||
}); | ||
}); | ||
}); | ||
</script>'; | ||
|
||
return $html; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Core | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<head> | ||
<script src="Mageplaza_Core::js/jscolor.min.js"/> | ||
</head> | ||
</page> | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://www.mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Core | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license https://www.mageplaza.com/LICENSE.txt | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<head> | ||
<script src="Mageplaza_Core::js/jscolor.min.js"/> | ||
<css src="jquery/colorpicker/css/colorpicker.css"/> | ||
</head> | ||
</page> |
Oops, something went wrong.