Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CompactCode authored Apr 5, 2019
1 parent ee97983 commit c13182c
Show file tree
Hide file tree
Showing 68 changed files with 13,616 additions and 0 deletions.
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "compactcode/base",
"description": "",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0"
},
"suggest": {

},
"type": "magento2-module",
"version": "1.1.2",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"src/registration.php"
],
"psr-4": {
"CompactCode\\Base\\": "src"
}
}
}
16 changes: 16 additions & 0 deletions src/Block/Adminhtml/Form/Field/ColorPicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\Form\Field;

use CompactCode\Base\Block\Color;

class ColorPicker extends Color
{

}
23 changes: 23 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/AjaxSaveButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class AjaxSaveButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => 'Save',
'class' => 'primary',
'sort_order' => 80,
];
}
}
40 changes: 40 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/BackButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

/**
* Class BackButton
*/
class BackButton extends GenericButton implements ButtonProviderInterface
{
/**
* @return array
*/
public function getButtonData()
{
return [
'label' => __('Back'),
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
'class' => 'back',
'sort_order' => 10
];
}

/**
* Get URL for back (reset) button
*
* @return string
*/
public function getBackUrl()
{
return $this->getUrl('*/*/');
}
}
44 changes: 44 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/DeleteButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

/**
* Class DeleteButton
*/
class DeleteButton extends GenericButton implements ButtonProviderInterface
{
/**
* @return array
*/
public function getButtonData()
{
$data = [];
if ($this->getId()) {
$data = [
'label' => __('Delete'),
'class' => 'delete',
'on_click' => 'deleteConfirm(\'' . __(
'Are you sure you want to do this?'
) . '\', \'' . $this->getDeleteUrl() . '\')',
'sort_order' => 20,
];
}
return $data;
}

/**
* @return string
*/
public function getDeleteUrl()
{
return $this->getUrl('*/*/delete', ['id' => $this->getId()]);
}
}
60 changes: 60 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/GenericButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Backend\Block\Widget\Context;
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Class GenericButton
*/
class GenericButton
{
/**
* @var Context
*/
private $context;

/**
* @param Context $context
* @param BlockRepositoryInterface $blockRepository
*/
public function __construct(
Context $context
)
{
$this->context = $context;
}

/**
* Return CMS block ID
*
* @return int|null
*/
public function getId()
{
try {
return $this->context->getRequest()->getParam('id');
} catch (NoSuchEntityException $e) {
}
return null;
}

/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
{
return $this->context->getUrlBuilder()->getUrl($route, $params);
}
}
28 changes: 28 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/SaveAndContinueButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => 'Save and Continue',
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => ['event' => 'saveAndContinueEdit'],
],
],
'sort_order' => 80,
];
}
}
28 changes: 28 additions & 0 deletions src/Block/Adminhtml/UiComponent/Buttons/SaveButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\UiComponent\Buttons;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => 'Save',
'class' => 'save primary',
'data_attribute' => [
'mage-init' => [
'button' => ['event' => 'save'],
],
],
'sort_order' => 80,
];
}
}
70 changes: 70 additions & 0 deletions src/Block/Adminhtml/Widget/ColorPicker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Copyright (c) 2019
* Copyright Holder : CompactCode - CompactCode BvBa - Belgium
* Copyright : Unless granted permission from CompactCode BvBa.
* You can not distribute, reuse, edit, resell or sell this.
*/

namespace CompactCode\Base\Block\Adminhtml\Widget;

use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Data\Form\Element\CollectionFactory;
use Magento\Framework\Data\Form\Element\Factory;
use Magento\Framework\Escaper;

class ColorPicker extends AbstractElement
{

/**
* TemplateButtons constructor.
* @param Factory $factoryElement
* @param CollectionFactory $factoryCollection
* @param Escaper $escaper
* @param array $data
*/
public function __construct
(
Factory $factoryElement,
CollectionFactory $factoryCollection,
Escaper $escaper,
array $data = []
)
{
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
$this->setType('text');
}

public function getElementHtml()
{
$html = '<input name="' . $this->getName() .
'" id="' . $this->getHtmlId() .
'" value="' . $this->getValue() .
'" />';

return $html;
}

public function getDefaultHtml()
{
$value = $this->getData('value');
$result = $this->getElementHtml();
$result .= '<script type="text/javascript">
require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
$(document).ready(function () {
var $el = $("#' . $this->getHtmlId() . '");
$el.css("backgroundColor", "' . $value . '");
// Attach the color picker
$el.ColorPicker({
color: "' . $value . '",
onChange: function (hsb, hex, rgb) {
$el.css("backgroundColor", "#" + hex).val("#" + hex).trigger( "change" );
}
});
});
});
</script>';
return $result;
}
}
Loading

0 comments on commit c13182c

Please sign in to comment.