Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
magiccart committed Oct 31, 2023
1 parent ee077f9 commit 614f77a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Magicslider/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function toHtml()
document.querySelectorAll(".copy-to-clipboard").forEach((button) => {
button.addEventListener("click", function(e){
e.stopPropagation();
var copyInput = button.closest(".magicslider-snippet").querySelector(".copy-input");
var copyInput = button.closest(".magiccart-snippet").querySelector(".copy-input");
copyInput.type = "text";
copyInput.select();
copyInput.setSelectionRange(0, 99999);
Expand Down
3 changes: 1 addition & 2 deletions Block/Adminhtml/Magicslider/Helper/Grid/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ class Image extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractR
/**
* Magicslider factory.
*
* @var \Magestore\Magicslider\Model\MagicsliderFactory
* @var \Magiccart\Magicslider\Model\MagicsliderFactory
*/
protected $_magicsliderFactory;

/**
* [__construct description].
*
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
Expand Down
19 changes: 9 additions & 10 deletions Block/Adminhtml/Magicslider/Helper/Grid/Snippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ class Snippet extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstrac
*
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;
protected $storeManager;

/**
* Magicslider factory.
*
* @var \Magestore\Magicslider\Model\MagicsliderFactory
* @var \Magiccart\Magicslider\Model\MagicsliderFactory
*/
protected $_magicsliderFactory;
protected $magicsliderFactory;

/**
* [__construct description].
*
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
Expand All @@ -44,8 +43,8 @@ public function __construct(
array $data = []
) {
parent::__construct($context, $data);
$this->_storeManager = $storeManager;
$this->_magicsliderFactory = $magicsliderFactory;
$this->storeManager = $storeManager;
$this->magicsliderFactory = $magicsliderFactory;
}

/**
Expand All @@ -58,13 +57,13 @@ public function __construct(
public function render(\Magento\Framework\DataObject $row)
{
$storeViewId = $this->getRequest()->getParam('store');
$item = $this->_magicsliderFactory->create()->setStoreViewId($storeViewId)->load($row->getId());
$item = $this->magicsliderFactory->create()->setStoreViewId($storeViewId)->load($row->getId());
$identifier = $item->getIdentifier();
$shortcodeWidget = $this->_escaper->escapeHtml('{{widget type="Magiccart\Magicslider\Block\Widget\Slider" identifier="' . $identifier . '" template="magicslider.phtml"}}');
$shortcodeBlock = $this->_escaper->escapeHtml('<?= $block->getLayout()->createBlock(\'Magiccart\Magicslider\Block\Widget\Slider\')->setIdentifier("' . $identifier . '")->setTemplate(\'magicslider.phtml\')->toHtml(); ?>');
$iconSvg = '<svg width="100%" height="35px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 115.77 122.88" style="enable-background:new 0 0 115.77 122.88" xml:space="preserve"><style type="text/css">.st0{fill-rule:evenodd;clip-rule:evenodd;}</style><g><path class="st0" d="M89.62,13.96v7.73h12.19h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02v0.02 v73.27v0.01h-0.02c-0.01,3.84-1.57,7.33-4.1,9.86c-2.51,2.5-5.98,4.06-9.82,4.07v0.02h-0.02h-61.7H40.1v-0.02 c-3.84-0.01-7.34-1.57-9.86-4.1c-2.5-2.51-4.06-5.98-4.07-9.82h-0.02v-0.02V92.51H13.96h-0.01v-0.02c-3.84-0.01-7.34-1.57-9.86-4.1 c-2.5-2.51-4.06-5.98-4.07-9.82H0v-0.02V13.96v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07V0h0.02h61.7 h0.01v0.02c3.85,0.01,7.34,1.57,9.86,4.1c2.5,2.51,4.06,5.98,4.07,9.82h0.02V13.96L89.62,13.96z M79.04,21.69v-7.73v-0.02h0.02 c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v64.59v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h12.19V35.65 v-0.01h0.02c0.01-3.85,1.58-7.34,4.1-9.86c2.51-2.5,5.98-4.06,9.82-4.07v-0.02h0.02H79.04L79.04,21.69z M105.18,108.92V35.65v-0.02 h0.02c0-0.91-0.39-1.75-1.01-2.37c-0.61-0.61-1.46-1-2.37-1v0.02h-0.01h-61.7h-0.02v-0.02c-0.91,0-1.75,0.39-2.37,1.01 c-0.61,0.61-1,1.46-1,2.37h0.02v0.01v73.27v0.02h-0.02c0,0.91,0.39,1.75,1.01,2.37c0.61,0.61,1.46,1,2.37,1v-0.02h0.01h61.7h0.02 v0.02c0.91,0,1.75-0.39,2.37-1.01c0.61-0.61,1-1.46,1-2.37h-0.02V108.92L105.18,108.92z"></path></g></svg>';
$html = '<div class="magicslider-snippet" style="display:inline-block;width:150px; float:left"><input class="copy-input" type="hidden" value="' . $shortcodeWidget . '" readonly><button style="display: inline-flex" class="copy-to-clipboard action-default scalable add primary">' . __('Copy to Page/Block') . $iconSvg . '</button></div>';
$html .= '<div class="magicslider-snippet" style="display:inline-block;width:150px; float:right"><input class="copy-input" type="hidden" value="' . $shortcodeBlock . '" readonly><button style="display: inline-flex" class="copy-to-clipboard action-default scalable add primary">' . __('Copy to .phtml') . $iconSvg . '</button></div>';
$emojiCopy = '<span style="font-size:30px">✂️</span>';
$html = '<div class="magiccart-snippet" style="display:inline-block;width:150px; float:left"><input class="copy-input" type="hidden" value="' . $shortcodeWidget . '" readonly><button style="display: inline-flex" class="copy-to-clipboard action-default scalable add primaryx">' . __('Copy to Page|Block') . $emojiCopy . '</button></div>';
$html .= '<div class="magiccart-snippet" style="display:inline-block;width:150px; float:right"><input class="copy-input" type="hidden" value="' . $shortcodeBlock . '" readonly><button style="display: inline-flex" class="copy-to-clipboard action-default scalable add primaryx">' . __('Copy to .phtml') . $emojiCopy . '</button></div>';

return $html;
}
Expand Down

0 comments on commit 614f77a

Please sign in to comment.