ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @author Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\MegaMenu\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
class Info extends \Olegnax\Core\Block\Adminhtml\System\Config\Form\Info
|
||||
{
|
||||
}
|
||||
|
||||
+1061
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\MegaMenu\Block\System\Config\Form\Field;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
class Spacer extends Field
|
||||
{
|
||||
public function __construct(
|
||||
Context $context, array $data = []
|
||||
)
|
||||
{
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
protected function _decorateRowHtml(AbstractElement $element, $html)
|
||||
{
|
||||
return '<tr id="row_' . $element->getHtmlId() . '"><td colspan="3"><hr class="ox-settings-spacer"></td></tr>';
|
||||
}
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
/**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Block\Widget;
|
||||
|
||||
use Magento\Customer\Model\Context;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
use Magento\Widget\Block\BlockInterface;
|
||||
use Olegnax\Core\Block\SimpleTemplate as coreTemplate;
|
||||
|
||||
class Megamenu extends coreTemplate implements BlockInterface
|
||||
{
|
||||
|
||||
protected $_topMenu;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Http\Context
|
||||
*/
|
||||
protected $httpContext;
|
||||
|
||||
/**
|
||||
* Json Serializer Instance
|
||||
*
|
||||
* @var Json
|
||||
*/
|
||||
private $json;
|
||||
|
||||
public function __construct(
|
||||
\Magento\Backend\Block\Template\Context $context, \Olegnax\MegaMenu\Block\Html\Megamenu $topMenu,
|
||||
\Magento\Framework\App\Http\Context $httpContext, Json $json = null,
|
||||
array $data = []
|
||||
)
|
||||
{
|
||||
$this->_topMenu = $topMenu;
|
||||
|
||||
$this->httpContext = $httpContext;
|
||||
$this->json = $json ?: $this->_loadObject(Json::class);
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
public function getValueOption($path, $default = '')
|
||||
{
|
||||
if ($this->hasData($path)) {
|
||||
$value = $this->getData($path);
|
||||
if (is_null($value)) {
|
||||
$value = '';
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
$value = $this->getConfig($path);
|
||||
if (is_null($value)) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getConfig($path, $storeCode = null)
|
||||
{
|
||||
$value = $this->_scopeConfig->getValue('ox_megamenu_settings/general/' . $path, ScopeInterface::SCOPE_STORE, $storeCode);
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getCacheKeyInfo($newval = [])
|
||||
{
|
||||
return array_merge([
|
||||
'OLEGNAX_MEGAMENU_WIDGET',
|
||||
$this->_storeManager->getStore()->getId(),
|
||||
$this->_design->getDesignTheme()->getId(),
|
||||
$this->httpContext->getValue(Context::CONTEXT_GROUP),
|
||||
$this->json->serialize($this->getRequest()->getParams()),
|
||||
$this->json->serialize($this->getData()),
|
||||
$this->getUrl('*/*/*', ['_current' => true, '_query' => '']),
|
||||
], parent::getCacheKeyInfo(), $newval);
|
||||
}
|
||||
|
||||
public function getHtml($outermostClass = '', $childrenWrapClass = '', $limit = 0)
|
||||
{
|
||||
$this->_topMenu->setData('enable_megamenu', true);
|
||||
$data = array_diff_key($this->getData(), ['type' => '', 'module_name' => '', 'cache_lifetime' => '', 'type_name' => '']);
|
||||
foreach ($data as $key => $value) {
|
||||
$this->_topMenu->setData($key, $value);
|
||||
}
|
||||
|
||||
return $this->_topMenu->getHtml($outermostClass, $childrenWrapClass, $limit);
|
||||
}
|
||||
|
||||
protected function _construct()
|
||||
{
|
||||
$this->addData([
|
||||
'cache_lifetime' => 86400,
|
||||
]);
|
||||
if (!$this->hasData('template') && !$this->getTemplate()) {
|
||||
$this->setTemplate('Olegnax_MegaMenu::widgetmenu.phtml');
|
||||
}
|
||||
parent::_construct();
|
||||
}
|
||||
|
||||
protected function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\MegaMenu\Controller\Adminhtml\Category\Image;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
|
||||
/**
|
||||
* Agorae Adminhtml Category Image Upload Controller
|
||||
*/
|
||||
class Upload extends \Magento\Catalog\Controller\Adminhtml\Category\Image\Upload
|
||||
{
|
||||
|
||||
/**
|
||||
* Upload file controller action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$imageId = $this->_request->getParam('param_name', 'ox_cat_image');
|
||||
try {
|
||||
$result = $this->imageUploader->saveFileToTmpDir($imageId);
|
||||
$result['cookie'] = [
|
||||
'name' => $this->_getSession()->getName(),
|
||||
'value' => $this->_getSession()->getSessionId(),
|
||||
'lifetime' => $this->_getSession()->getCookieLifetime(),
|
||||
'path' => $this->_getSession()->getCookiePath(),
|
||||
'domain' => $this->_getSession()->getCookieDomain(),
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
|
||||
}
|
||||
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
|
||||
}
|
||||
}
|
||||
Executable
+132
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Olegnax\MegaMenu\Helper;
|
||||
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Magento\Framework\App\Cache\State;
|
||||
use Magento\Framework\App\Helper\AbstractHelper;
|
||||
use Magento\Framework\App\Helper\Context;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Serialize\Serializer\Json;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
class Cache extends AbstractHelper
|
||||
{
|
||||
const CACHE_TAG = 'OXMEGAMENU';
|
||||
const CACHE_ID = 'ox_megamenu';
|
||||
const CACHE_LIFETIME = 86400;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Cache
|
||||
*/
|
||||
protected $cache;
|
||||
/**
|
||||
* @var State
|
||||
*/
|
||||
protected $cacheState;
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $storeManager;
|
||||
/**
|
||||
* @var Json
|
||||
*/
|
||||
protected $json;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $storeId;
|
||||
|
||||
/**
|
||||
* Cache constructor.
|
||||
* @param Context $context
|
||||
* @param \Magento\Framework\App\Cache $cache
|
||||
* @param State $cacheState
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param Json|null $json
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
\Magento\Framework\App\Cache $cache,
|
||||
State $cacheState,
|
||||
StoreManagerInterface $storeManager,
|
||||
Json $json = null
|
||||
) {
|
||||
$this->cache = $cache;
|
||||
$this->cacheState = $cacheState;
|
||||
$this->storeManager = $storeManager;
|
||||
$this->storeId = $storeManager->getStore()->getId();
|
||||
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $vars
|
||||
* @return string
|
||||
*/
|
||||
public function getId($method, $vars = array())
|
||||
{
|
||||
return base64_encode($this->storeId . static::CACHE_ID . $method . implode('#', (array)$vars));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheId
|
||||
* @return bool|object
|
||||
*/
|
||||
public function loadObject($cacheId)
|
||||
{
|
||||
$result = $this->load($cacheId);
|
||||
|
||||
if (!empty($result)) {
|
||||
try {
|
||||
$result = $this->json->unserialize($result);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $cacheId
|
||||
* @return bool|string
|
||||
*/
|
||||
public function load($cacheId)
|
||||
{
|
||||
if ($this->cacheState->isEnabled(static::CACHE_ID)) {
|
||||
return $this->cache->load($cacheId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @param string $cacheId
|
||||
* @param int $cacheLifetime
|
||||
* @return bool
|
||||
*/
|
||||
public function save($data, $cacheId, $cacheLifetime = 0)
|
||||
{
|
||||
if (!is_string($data)) {
|
||||
$data = $this->json->serialize($data);
|
||||
}
|
||||
if ($this->cacheState->isEnabled(static::CACHE_ID)) {
|
||||
$this->cache->save(
|
||||
$data,
|
||||
$cacheId,
|
||||
[static::CACHE_TAG],
|
||||
empty($cacheLifetime) ? static::CACHE_LIFETIME : $cacheLifetime
|
||||
);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Alignhorizontal extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('item-left'), 'value' => 'item-left'],
|
||||
['label' => __('item-right'), 'value' => 'item-right'],
|
||||
['label' => __('item-center'), 'value' => 'item-center'],
|
||||
['label' => __('menu-left'), 'value' => 'menu-left'],
|
||||
['label' => __('menu-right'), 'value' => 'menu-right'],
|
||||
['label' => __('menu-center'), 'value' => 'menu-center'],
|
||||
['label' => __('window-left'), 'value' => 'window-left'],
|
||||
['label' => __('window-right'), 'value' => 'window-right'],
|
||||
['label' => __('window-center'), 'value' => 'window-center'],
|
||||
['label' => __('container-left'), 'value' => 'container-left'],
|
||||
['label' => __('container-right'), 'value' => 'container-right'],
|
||||
['label' => __('container-center'), 'value' => 'container-center'],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Alignvertical extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('menu bottom'), 'value' => 'menu-bottom'],
|
||||
['label' => __('container bottom'), 'value' => 'container-bottom'],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Animation extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('toggle'), 'value' => 'toggle'],
|
||||
['label' => __('fade'), 'value' => 'fade'],
|
||||
['label' => __('emersion'), 'value' => 'emersion'],
|
||||
['label' => __('emersion vertical'), 'value' => 'emersion-vertical'],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Columns extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('1'), 'value' => 1],
|
||||
['label' => __('2'), 'value' => 2],
|
||||
['label' => __('3'), 'value' => 3],
|
||||
['label' => __('4'), 'value' => 4],
|
||||
['label' => __('5'), 'value' => 5],
|
||||
['label' => __('6'), 'value' => 6],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Columnsgrid extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('Full Width'), 'value' => 12],
|
||||
['label' => __('One Half'), 'value' => 6],
|
||||
['label' => __('One Third'), 'value' => 4],
|
||||
['label' => __('One Fourth'), 'value' => 3],
|
||||
['label' => __('One Sixth'), 'value' => 2]
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Duration extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('toggle'), 'value' => 'toggle'],
|
||||
['label' => __('fade'), 'value' => 'fade'],
|
||||
['label' => __('emersion'), 'value' => 'emersion'],
|
||||
['label' => __('emersion vertical'), 'value' => 'emersion-vertical'],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Layout extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('Top / Left, Categories, Right / Bottom'), 'value' => 1],
|
||||
['label' => __('Left / Top, Categories, Bottom / Right'), 'value' => 2],
|
||||
['label' => __('Left / Top, Categories / Right / Bottom'), 'value' => 3],
|
||||
['label' => __('Left / Top / Categories, Bottom / Right'), 'value' => 4],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class Menuwidth extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('Default'), 'value' => 'default'],
|
||||
['label' => __('Custom Width'), 'value' => 'custom'],
|
||||
['label' => __('Column Max Width'), 'value' => 'column-max-width'],
|
||||
['label' => __('Container Width'), 'value' => 'container'],
|
||||
['label' => __('Full website Width'), 'value' => 'fullwidth']
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php /**/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Attribute;
|
||||
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
|
||||
|
||||
class MmLvl2AlignVertical extends AbstractSource
|
||||
{
|
||||
/**
|
||||
* Retrieve option array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionArray()
|
||||
{
|
||||
$_options = [];
|
||||
foreach ($this->getAllOptions() as $option) {
|
||||
$_options[$option['value']] = $option['label'];
|
||||
}
|
||||
return $_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all options array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllOptions()
|
||||
{
|
||||
if ($this->_options === null) {
|
||||
$this->_options = [
|
||||
['label' => __('Default, Overlap Parent Drop'), 'value' => ''],
|
||||
['label' => __('Right, Relative to Link'), 'value' => 'right'],
|
||||
['label' => __('Parent Drop Top, without stretch'), 'value' => 'top'],
|
||||
['label' => __('Parent Drop Top, with Height Stretch'), 'value' => 'top-stretch'],
|
||||
];
|
||||
}
|
||||
return $this->_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a text for option value
|
||||
*
|
||||
* @param string|int $value
|
||||
* @return string|false
|
||||
*/
|
||||
public function getOptionText($value)
|
||||
{
|
||||
$options = $this->getAllOptions();
|
||||
foreach ($options as $option) {
|
||||
if ($option['value'] == $value) {
|
||||
return $option['label'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Cache;
|
||||
|
||||
use Magento\Framework\App\Cache\Type\FrontendPool;
|
||||
use Magento\Framework\Cache\Frontend\Decorator\TagScope;
|
||||
|
||||
class MegaMenu extends TagScope
|
||||
{
|
||||
|
||||
const TYPE_IDENTIFIER = 'ox_megamenu';
|
||||
const CACHE_TAG = 'OXMEGAMENU';
|
||||
|
||||
/**
|
||||
* @param FrontendPool $cacheFrontendPool
|
||||
*/
|
||||
public function __construct(
|
||||
FrontendPool $cacheFrontendPool
|
||||
) {
|
||||
parent::__construct($cacheFrontendPool->get(self::TYPE_IDENTIFIER), self::CACHE_TAG);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\MegaMenu\Model\Category;
|
||||
|
||||
/**
|
||||
* Class DataProvider
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @since 101.0.0
|
||||
*/
|
||||
class DataProvider extends \Magento\Catalog\Model\Category\DataProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @since 101.0.0
|
||||
*/
|
||||
protected function getFieldsMap()
|
||||
{
|
||||
$fields = parent::getFieldsMap();
|
||||
$fields['ox-menu'] = [
|
||||
'ox_title_text_color',
|
||||
'ox_title_bg_color',
|
||||
'ox_nav_custom_class',
|
||||
'ox_nav_custom_link_content',
|
||||
'ox_nav_custom_link',
|
||||
'ox_nav_custom_link_target',
|
||||
'ox_category_label',
|
||||
'ox_label_color',
|
||||
'ox_label_text_color',
|
||||
'ox_columns',
|
||||
'ox_nav_column_width',
|
||||
'ox_bg_image',
|
||||
'ox_data_tm_align_horizontal',
|
||||
'ox_nav_type',
|
||||
'ox_mm_lvl2_align_vertical',
|
||||
'ox_nav_subcategories',
|
||||
'ox_menu_width',
|
||||
'ox_cat_image',
|
||||
'ox_layout',
|
||||
'ox_nav_btm',
|
||||
'ox_nav_top',
|
||||
'ox_nav_left',
|
||||
'ox_nav_left_width',
|
||||
'ox_nav_right',
|
||||
'ox_nav_right_width',
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
||||
+361
@@ -0,0 +1,361 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\MegaMenu\Setup;
|
||||
|
||||
use Magento\Catalog\Model\Category;
|
||||
use Magento\Catalog\Model\Category\Attribute\Backend\Image;
|
||||
use Magento\Catalog\Setup\CategorySetupFactory;
|
||||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
||||
use Magento\Eav\Model\Entity\Attribute\Source\Boolean;
|
||||
use Magento\Eav\Setup\EavSetupFactory;
|
||||
use Magento\Framework\Setup\InstallDataInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Olegnax\MegaMenu\Model\Attribute\Alignhorizontal;
|
||||
use Olegnax\MegaMenu\Model\Attribute\MmLvl2AlignVertical;
|
||||
use Olegnax\MegaMenu\Model\Attribute\Columns;
|
||||
use Olegnax\MegaMenu\Model\Attribute\Columnsgrid;
|
||||
use Olegnax\MegaMenu\Model\Attribute\Layout;
|
||||
use Olegnax\MegaMenu\Model\Attribute\Menuwidth;
|
||||
|
||||
class InstallData implements InstallDataInterface
|
||||
{
|
||||
|
||||
private $eavSetupFactory;
|
||||
private $categorySetupFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param EavSetupFactory $eavSetupFactory
|
||||
* @param CategorySetupFactory $categorySetupFactory
|
||||
*/
|
||||
public function __construct(EavSetupFactory $eavSetupFactory, CategorySetupFactory $categorySetupFactory)
|
||||
{
|
||||
$this->eavSetupFactory = $eavSetupFactory;
|
||||
$this->categorySetupFactory = $categorySetupFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install(
|
||||
ModuleDataSetupInterface $setup,
|
||||
ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
$this->_install($setup);
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
private function _install(ModuleDataSetupInterface $setup)
|
||||
{
|
||||
$tableFields = $this->fields();
|
||||
if (!empty($tableFields)) {
|
||||
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
|
||||
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
|
||||
foreach ($tableFields as $entity => $fields) {
|
||||
foreach ($fields as $key => $value) {
|
||||
if (Category::ENTITY == $entity) {
|
||||
$categorySetup->addAttribute($entity, $key, $value);
|
||||
} else {
|
||||
$eavSetup->addAttribute($entity, $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function fields()
|
||||
{
|
||||
return [
|
||||
Category::ENTITY => [
|
||||
'ox_title_bg_color' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Menu Item Background color',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 10,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'This field is compatible only with 1st-level category megamenu'
|
||||
],
|
||||
'ox_title_text_color' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Menu Item Text color',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 12,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
],
|
||||
'ox_nav_custom_class' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Custom Class',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 20,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
],
|
||||
'ox_nav_custom_link_content' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Custom Content near Link',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 22,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'Use to show icons near menu item.'
|
||||
],
|
||||
'ox_nav_custom_link' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Custom Link Url',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 30,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'Override category link with your custom external link'
|
||||
],
|
||||
'ox_nav_custom_link_target' => [
|
||||
'type' => 'int',
|
||||
'label' => 'Open link in a new window',
|
||||
'input' => 'boolean',
|
||||
'source' => Boolean::class,
|
||||
'required' => false,
|
||||
'sort_order' => 32,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu'
|
||||
],
|
||||
'ox_category_label' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Label',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 40,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'Set any text, i.e.: Hot, Sale, Featured or whatever you want...'
|
||||
],
|
||||
'ox_label_color' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Label Background color',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 42,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
],
|
||||
'ox_label_text_color' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Label Text color',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 44,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
],
|
||||
'ox_columns' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Columns categories per row',
|
||||
'input' => 'select',
|
||||
'source' => Columns::class,
|
||||
'required' => false,
|
||||
'sort_order' => 50,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '1'
|
||||
],
|
||||
'ox_nav_column_width' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Menu Column Width',
|
||||
'input' => 'text',
|
||||
'required' => false,
|
||||
'sort_order' => 52,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'note' => 'Use to set simple drop width and for Menu Dropdown Width options Column Max Width',
|
||||
'group' => 'Mega menu'
|
||||
],
|
||||
'ox_bg_image' => [
|
||||
'type' => 'varchar',
|
||||
'label' => 'DropDown Background Image',
|
||||
'input' => 'image',
|
||||
'required' => false,
|
||||
'sort_order' => 54,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'backend' => Image::class,
|
||||
'group' => 'Mega menu',
|
||||
],
|
||||
'ox_data_tm_align_horizontal' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Top Menu Dropdown Align Horizontal',
|
||||
'input' => 'select',
|
||||
'source' => Alignhorizontal::class,
|
||||
'required' => false,
|
||||
'sort_order' => 60,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => 'menu-left',
|
||||
'note' => 'For 1st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_type' => [
|
||||
'type' => 'int',
|
||||
'label' => 'Enable Mega Menu',
|
||||
'input' => 'boolean',
|
||||
'source' => Boolean::class,
|
||||
'required' => false,
|
||||
'sort_order' => 70,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu'
|
||||
],
|
||||
'ox_mm_lvl2_align_vertical' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Mega Menu in Dropdown Behavior',
|
||||
'input' => 'select',
|
||||
'source' => MmLvl2AlignVertical::class,
|
||||
'required' => false,
|
||||
'sort_order' => 71,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '',
|
||||
'note' => 'For 2st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_subcategories' => [
|
||||
'type' => 'int',
|
||||
'label' => 'Hide subcategories',
|
||||
'input' => 'boolean',
|
||||
'source' => Boolean::class,
|
||||
'required' => false,
|
||||
'sort_order' => 72,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => 0,
|
||||
],
|
||||
'ox_menu_width' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Top Menu Dropdown Width',
|
||||
'input' => 'select',
|
||||
'source' => Menuwidth::class,
|
||||
'required' => false,
|
||||
'sort_order' => 74,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'Columns Max Width and Custom uses value from Menu Column Width option above.',
|
||||
'default' => ''
|
||||
|
||||
],
|
||||
'ox_cat_image' => [
|
||||
'type' => 'varchar',
|
||||
'label' => 'Category Image',
|
||||
'input' => 'image',
|
||||
'required' => false,
|
||||
'sort_order' => 76,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'backend' => Image::class,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'Show image above menu item'
|
||||
],
|
||||
'ox_layout' => [
|
||||
'type' => 'text',
|
||||
'label' => 'DropDown Layout',
|
||||
'input' => 'select',
|
||||
'source' => Layout::class,
|
||||
'required' => false,
|
||||
'sort_order' => 80,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '1'
|
||||
],
|
||||
'ox_nav_btm' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Html block under menu ',
|
||||
'input' => 'textarea',
|
||||
'required' => false,
|
||||
'sort_order' => 82,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'For 1st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_top' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Top Html',
|
||||
'input' => 'textarea',
|
||||
'required' => false,
|
||||
'sort_order' => 84,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'For 1st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_left' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Left Html',
|
||||
'input' => 'textarea',
|
||||
'required' => false,
|
||||
'sort_order' => 86,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'For 1st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_left_width' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Left Html Width',
|
||||
'input' => 'select',
|
||||
'source' => Columnsgrid::class,
|
||||
'required' => false,
|
||||
'sort_order' => 88,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '3'
|
||||
],
|
||||
'ox_nav_right' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Megamenu Vertical Right Html',
|
||||
'input' => 'textarea',
|
||||
'required' => false,
|
||||
'sort_order' => 90,
|
||||
'wysiwyg_enabled' => false,
|
||||
'is_html_allowed_on_front' => true,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'note' => 'For 1st-level category megamenu only'
|
||||
],
|
||||
'ox_nav_right_width' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Right Html Width',
|
||||
'input' => 'select',
|
||||
'source' => Columnsgrid::class,
|
||||
'required' => false,
|
||||
'sort_order' => 92,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '3'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax MegaMenu
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\MegaMenu\Setup;
|
||||
|
||||
use Magento\Catalog\Model\Category;
|
||||
use Magento\Catalog\Setup\CategorySetupFactory;
|
||||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
|
||||
use Magento\Eav\Setup\EavSetupFactory;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
use Magento\Framework\Setup\UpgradeDataInterface;
|
||||
use Olegnax\MegaMenu\Model\Attribute\MmLvl2AlignVertical;
|
||||
|
||||
class UpgradeData implements UpgradeDataInterface
|
||||
{
|
||||
/**
|
||||
* @var EavSetupFactory
|
||||
*/
|
||||
private $eavSetupFactory;
|
||||
/**
|
||||
* @var CategorySetupFactory
|
||||
*/
|
||||
private $categorySetupFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param EavSetupFactory $eavSetupFactory
|
||||
* @param CategorySetupFactory $categorySetupFactory
|
||||
*/
|
||||
public function __construct(EavSetupFactory $eavSetupFactory, CategorySetupFactory $categorySetupFactory)
|
||||
{
|
||||
$this->eavSetupFactory = $eavSetupFactory;
|
||||
$this->categorySetupFactory = $categorySetupFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(
|
||||
ModuleDataSetupInterface $setup,
|
||||
ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
|
||||
$this->applyUpgradeFunctions($setup, $context);
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
private function applyUpgradeFunctions(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$methods = $this->getUpgradeFunctions($context->getVersion());
|
||||
foreach ($methods as $method) {
|
||||
call_user_func_array([$this, $method], [$setup, $context]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getUpgradeFunctions($low_version = '0.1.0')
|
||||
{
|
||||
$methods = get_class_methods($this);
|
||||
foreach ($methods as $key => $method) {
|
||||
if (preg_match('/^upgrade_(.+)$/i', $method, $matches)) {
|
||||
if (version_compare($low_version, $matches[1], '<')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
unset($methods[$key]);
|
||||
}
|
||||
|
||||
$methods = array_filter($methods);
|
||||
$methods = array_unique($methods);
|
||||
sort($methods);
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
public function upgrade_0_2_0(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
|
||||
{
|
||||
$tableFields = [
|
||||
Category::ENTITY => [
|
||||
'ox_mm_lvl2_align_vertical' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Mega Menu in Dropdown Behavior',
|
||||
'input' => 'select',
|
||||
'source' => MmLvl2AlignVertical::class,
|
||||
'required' => false,
|
||||
'sort_order' => 71,
|
||||
'global' => ScopedAttributeInterface::SCOPE_STORE,
|
||||
'group' => 'Mega menu',
|
||||
'default' => '',
|
||||
'note' => 'For 2st-level category megamenu only'
|
||||
],
|
||||
],
|
||||
];
|
||||
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
|
||||
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
|
||||
foreach ($tableFields as $entity => $fields) {
|
||||
foreach ($fields as $key => $value) {
|
||||
if (Category::ENTITY == $entity) {
|
||||
$categorySetup->addAttribute($entity, $key, $value);
|
||||
} else {
|
||||
$eavSetup->addAttribute($entity, $key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
|
||||
<acl>
|
||||
<resources>
|
||||
<resource id="Magento_Backend::admin">
|
||||
<resource id="Olegnax_Core::Olegnax_Core">
|
||||
<resource id="Olegnax_MegaMenu::Olegnax_MegaMenu" sortOrder="10" title="Mega Menu"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
|
||||
<menu>
|
||||
<add id="Olegnax_MegaMenu::Olegnax_MegaMenu" title="Mega Menu" module="Olegnax_MegaMenu" sortOrder="10"
|
||||
parent="Olegnax_Core::Olegnax_Core" resource="Olegnax_MegaMenu::Olegnax_MegaMenu"/>
|
||||
<add id="Olegnax_MegaMenu::settings" title="Configuration" module="Olegnax_Athlete2" sortOrder="0"
|
||||
action="adminhtml/system_config/edit/section/ox_megamenu_settings"
|
||||
parent="Olegnax_MegaMenu::Olegnax_MegaMenu" resource="Olegnax_MegaMenu::Olegnax_MegaMenu"/>
|
||||
</menu>
|
||||
</config>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
<router id="admin">
|
||||
<route id="megamenu" frontName="megamenu">
|
||||
<module name="Olegnax_MegaMenu" before="Magento_Backend"/>
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © 2016 Magento. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
|
||||
<system>
|
||||
<tab id="olegnax" translate="label" sortOrder="15">
|
||||
<label>Olegnax</label>
|
||||
</tab>
|
||||
<section id="ox_megamenu_settings" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1"
|
||||
showInStore="1">
|
||||
<label>Mega Menu</label>
|
||||
<tab>olegnax</tab>
|
||||
<resource>Olegnax_MegaMenu::Olegnax_MegaMenu</resource>
|
||||
<group id="info" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="0" translate="label">
|
||||
<frontend_model>Olegnax\MegaMenu\Block\Adminhtml\System\Config\Form\Info</frontend_model>
|
||||
</group>
|
||||
<group id="general" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<label>General</label>
|
||||
<field id="enable_megamenu" translate="label" type="select" sortOrder="0" showInDefault="1"
|
||||
showInWebsite="1" showInStore="1">
|
||||
<label>Enable Mega Menu</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="spacer" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
|
||||
<frontend_model>Olegnax\MegaMenu\Block\System\Config\Form\Field\Spacer</frontend_model>
|
||||
</field>
|
||||
<field id="header_container" translate="label comment" type="text" sortOrder="10" showInDefault="1"
|
||||
showInWebsite="1" showInStore="1">
|
||||
<label>Header Container</label>
|
||||
<comment>Set custom css selector (which is used as wrapper for your menu) to make drop down
|
||||
container align options work. Include dots i.e.: ".page-header > .container"
|
||||
</comment>
|
||||
</field>
|
||||
<field id="show_menu_parent_arrow" translate="label" type="select" sortOrder="20" showInDefault="1"
|
||||
showInWebsite="1" showInStore="1">
|
||||
<label>Show Arrows for Parent menu item</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="show_sub_parent_arrow" translate="label" type="select" sortOrder="22" showInDefault="1"
|
||||
showInWebsite="1" showInStore="1">
|
||||
<label>Show Arrows for Subcategories parent items</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
<field id="perfect_scrollbar" translate="label" type="select" sortOrder="24" showInDefault="1"
|
||||
showInWebsite="1" showInStore="1">
|
||||
<label>Enable Perfect ScrollBar</label>
|
||||
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
|
||||
<frontend_class>on-off-trigger</frontend_class>
|
||||
</field>
|
||||
</group>
|
||||
</section>
|
||||
</system>
|
||||
</config>
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Cache/etc/cache.xsd">
|
||||
<type instance="Olegnax\MegaMenu\Model\Cache\MegaMenu" name="ox_megamenu" translate="label,description">
|
||||
<label>MegaMenu</label>
|
||||
<description>Olegnax MegaMenu</description>
|
||||
</type>
|
||||
</config>
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
|
||||
<default>
|
||||
<ox_megamenu_settings>
|
||||
<general>
|
||||
<enable_megamenu>1</enable_megamenu>
|
||||
<show_menu_parent_arrow>1</show_menu_parent_arrow>
|
||||
<show_sub_parent_arrow>1</show_sub_parent_arrow>
|
||||
<perfect_scrollbar>1</perfect_scrollbar>
|
||||
</general>
|
||||
</ox_megamenu_settings>
|
||||
</default>
|
||||
</config>
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © 2016 Magento. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<virtualType name="Magento\Catalog\CategoryImageUpload" type="Magento\Catalog\Model\ImageUploader">
|
||||
<arguments>
|
||||
<argument name="baseTmpPath" xsi:type="string">catalog/tmp/category</argument>
|
||||
<argument name="basePath" xsi:type="string">catalog/category</argument>
|
||||
<argument name="allowedExtensions" xsi:type="array">
|
||||
<item name="jpg" xsi:type="string">jpg</item>
|
||||
<item name="jpeg" xsi:type="string">jpeg</item>
|
||||
<item name="gif" xsi:type="string">gif</item>
|
||||
<item name="png" xsi:type="string">png</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</virtualType>
|
||||
<type name="Olegnax\MegaMenu\Controller\Adminhtml\Category\Image\Upload">
|
||||
<arguments>
|
||||
<argument name="imageUploader" xsi:type="object">Magento\Catalog\CategoryImageUpload</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
<preference for="Magento\Catalog\Model\Category\DataProvider" type="Olegnax\MegaMenu\Model\Category\DataProvider"/>
|
||||
<preference for="Magento\Theme\Block\Html\Topmenu" type="Olegnax\MegaMenu\Block\Html\Megamenu"/>
|
||||
</config>
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Olegnax_MegaMenu" setup_version="0.3.5.1">
|
||||
<sequence>
|
||||
<module name="Olegnax_Core"/>
|
||||
<module name="Magento_Catalog"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
|
||||
<widget id="ox_megamenu" class="Olegnax\MegaMenu\Block\Widget\Megamenu" is_email_compatible="false"
|
||||
placeholder_image="Olegnax_MegaMenu::images/megamenu.png" ttl="86400">
|
||||
<label translate="true">Olegnax - Mega Menu</label>
|
||||
<description translate="true"></description>
|
||||
<parameters>
|
||||
<parameter name="header_container" xsi:type="text" visible="true">
|
||||
<label translate="true">Header Container</label>
|
||||
</parameter>
|
||||
<parameter name="direction" xsi:type="select" visible="true">
|
||||
<label translate="true">Direction</label>
|
||||
<options>
|
||||
<option name="horizontal" value="horizontal">
|
||||
<label translate="true">Horizontal</label>
|
||||
</option>
|
||||
<option name="vertical" value="vertical">
|
||||
<label translate="true">Vertical</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="position_horizontal" xsi:type="select" visible="true">
|
||||
<label translate="true">Position Horizontal</label>
|
||||
<options>
|
||||
<option name="left" value="left">
|
||||
<label translate="true">Left</label>
|
||||
</option>
|
||||
<option name="right" value="right">
|
||||
<label translate="true">Right</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="animation_type" xsi:type="select" visible="true">
|
||||
<label translate="true">Animation Type</label>
|
||||
<options>
|
||||
<option name="fade" value="fade">
|
||||
<label translate="true">Fade</label>
|
||||
</option>
|
||||
<option name="fadeIn" value="fadeIn">
|
||||
<label translate="true">Fade In</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="cache_lifetime" xsi:type="text" visible="true">
|
||||
<label translate="true">Cache Lifetime (Seconds)</label>
|
||||
<description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML
|
||||
Output cache.
|
||||
</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</widget>
|
||||
|
||||
</widgets>
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Olegnax_MegaMenu',
|
||||
__DIR__
|
||||
);
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<head>
|
||||
<css src="Olegnax_MegaMenu::custom-styles.css"/>
|
||||
</head>
|
||||
</page>
|
||||
@@ -0,0 +1,343 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © 2016 Magento. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<fieldset name="ox-menu">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="label" xsi:type="string" translate="true">Ox Mega Menu</item>
|
||||
<item name="collapsible" xsi:type="boolean">true</item>
|
||||
<item name="sortOrder" xsi:type="number">1000</item>
|
||||
</item>
|
||||
</argument>
|
||||
<field name="ox_title_bg_color" sortOrder="10" formElement="colorPicker">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Menu Item Background color</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_title_text_color" sortOrder="12" formElement="colorPicker">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Menu Item Text Color</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_custom_class" sortOrder="20" formElement="input">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Custom Class</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_custom_link_content" sortOrder="22" formElement="input">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Custom Content near Link</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_custom_link" sortOrder="30" formElement="input">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Custom Link Url</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_custom_link_target" sortOrder="32" formElement="checkbox">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">0</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Open link in a new window</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="string">0</map>
|
||||
<map name="true" xsi:type="string">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_category_label" sortOrder="40" formElement="input">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Category label, for ex. "Hot!"</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_label_color" sortOrder="42" formElement="colorPicker">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Label Background color</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_label_text_color" sortOrder="44" formElement="colorPicker">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Label Text Color</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_columns" sortOrder="50" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Menu Columns</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_column_width" sortOrder="52" formElement="input">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Menu Column Width</label>
|
||||
<validation>
|
||||
<rule name="validate-digits" xsi:type="boolean">true</rule>
|
||||
<rule name="validate-zero-or-greater" xsi:type="boolean">true</rule>
|
||||
</validation>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_bg_image" sortOrder="54" formElement="imageUploader">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/image</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">DropDown Background Image</label>
|
||||
<visible>true</visible>
|
||||
<required>false</required>
|
||||
</settings>
|
||||
<formElements>
|
||||
<imageUploader>
|
||||
<settings>
|
||||
<required>false</required>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="megamenu/category_image/upload"/>
|
||||
</uploaderConfig>
|
||||
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
|
||||
<openDialogTitle>Media Gallery</openDialogTitle>
|
||||
<initialMediaGalleryOpenSubpath>catalog/category</initialMediaGalleryOpenSubpath>
|
||||
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
|
||||
<maxFileSize>4194304</maxFileSize>
|
||||
</settings>
|
||||
</imageUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_data_tm_align_horizontal" sortOrder="60" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Top Menu Dropdown Align Horizontal</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_type" sortOrder="70" formElement="checkbox">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">0</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Enable Mega Menu</label>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="string">0</map>
|
||||
<map name="true" xsi:type="string">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_mm_lvl2_align_vertical" sortOrder="71" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Mega Menu in Dropdown Behavior</label>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_subcategories" sortOrder="72" formElement="checkbox">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="default" xsi:type="number">0</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<dataType>boolean</dataType>
|
||||
<label translate="true">Hide subcategories</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<checkbox>
|
||||
<settings>
|
||||
<valueMap>
|
||||
<map name="false" xsi:type="string">0</map>
|
||||
<map name="true" xsi:type="string">1</map>
|
||||
</valueMap>
|
||||
<prefer>toggle</prefer>
|
||||
</settings>
|
||||
</checkbox>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_menu_width" sortOrder="74" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Menu Dropdown Width</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_cat_image" sortOrder="76" formElement="imageUploader">
|
||||
<settings>
|
||||
<elementTmpl>ui/form/element/uploader/image</elementTmpl>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Category Image</label>
|
||||
<visible>true</visible>
|
||||
<required>false</required>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<imageUploader>
|
||||
<settings>
|
||||
<required>false</required>
|
||||
<uploaderConfig>
|
||||
<param xsi:type="url" name="url" path="megamenu/category_image/upload"/>
|
||||
</uploaderConfig>
|
||||
<previewTmpl>Magento_Catalog/image-preview</previewTmpl>
|
||||
<openDialogTitle>Media Gallery</openDialogTitle>
|
||||
<initialMediaGalleryOpenSubpath>catalog/category</initialMediaGalleryOpenSubpath>
|
||||
<allowedExtensions>jpg jpeg gif png</allowedExtensions>
|
||||
<maxFileSize>4194304</maxFileSize>
|
||||
</settings>
|
||||
</imageUploader>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_layout" sortOrder="80" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">DropDown Layout</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_btm" template="ui/form/field" sortOrder="82" formElement="wysiwyg">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="wysiwygConfigData" xsi:type="array">
|
||||
<item name="add_variables" xsi:type="boolean">false</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<label translate="true">Bottom Html Block</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg">
|
||||
<settings>
|
||||
<rows>4</rows>
|
||||
<wysiwyg>true</wysiwyg>
|
||||
</settings>
|
||||
</wysiwyg>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_nav_top" template="ui/form/field" sortOrder="84" formElement="wysiwyg">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="wysiwygConfigData" xsi:type="array">
|
||||
<item name="add_variables" xsi:type="boolean">false</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<label translate="true">Top Html Block</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg">
|
||||
<settings>
|
||||
<rows>4</rows>
|
||||
<wysiwyg>true</wysiwyg>
|
||||
</settings>
|
||||
</wysiwyg>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_nav_left" template="ui/form/field" sortOrder="86" formElement="wysiwyg">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="wysiwygConfigData" xsi:type="array">
|
||||
<item name="add_variables" xsi:type="boolean">false</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<label translate="true">Left Html Block</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg">
|
||||
<settings>
|
||||
<rows>4</rows>
|
||||
<wysiwyg>true</wysiwyg>
|
||||
</settings>
|
||||
</wysiwyg>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_nav_left_width" sortOrder="88" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Left Html Width</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
</field>
|
||||
<field name="ox_nav_right" template="ui/form/field" sortOrder="90" formElement="wysiwyg">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="wysiwygConfigData" xsi:type="array">
|
||||
<item name="add_variables" xsi:type="boolean">false</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<settings>
|
||||
<label translate="true">Right Html Block</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
<formElements>
|
||||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg">
|
||||
<settings>
|
||||
<rows>4</rows>
|
||||
<wysiwyg>true</wysiwyg>
|
||||
</settings>
|
||||
</wysiwyg>
|
||||
</formElements>
|
||||
</field>
|
||||
<field name="ox_nav_right_width" sortOrder="92" formElement="select">
|
||||
<settings>
|
||||
<dataType>string</dataType>
|
||||
<label translate="true">Right Html Width</label>
|
||||
<imports>
|
||||
<link name="visible">${ $.parentName }.ox_nav_type:checked</link>
|
||||
</imports>
|
||||
</settings>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,5 @@
|
||||
.ox-settings-spacer {
|
||||
margin: 40px 0 30px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #cccccc;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<referenceContainer name="before.body.end">
|
||||
<block ifconfig="ox_megamenu_settings/general/perfect_scrollbar" class="Magento\Framework\View\Element\Template" name="ox_mm_assets" template="Olegnax_MegaMenu::assets.phtml"/>
|
||||
</referenceContainer>
|
||||
</page>
|
||||
@@ -0,0 +1,13 @@
|
||||
var config = {
|
||||
map: {
|
||||
'*': {
|
||||
'OxMegaMenu': 'Olegnax_MegaMenu/js/megamenu',
|
||||
'plugins/velocity': 'Olegnax_MegaMenu/js/velocity.min',
|
||||
'plugins/scrollbar': 'Olegnax_MegaMenu/js/perfect-scrollbar.jquery.min',
|
||||
}
|
||||
}
|
||||
};
|
||||
if(OX_MOBILE){
|
||||
delete config.map['*']['plugins/velocity'];
|
||||
delete config.map['*']['plugins/scrollbar'];
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax MegaMenu
|
||||
*
|
||||
* This file is part of Olegnax/Core.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
?>
|
||||
<link rel="stylesheet" href="<?= $block->getViewFileUrl('Olegnax_MegaMenu::css/perfect-scrollbar.min.css')?>" media="print" onload="this.media='all'">
|
||||
|
||||
<noscript><link rel="stylesheet" href="<?= $block->getViewFileUrl('Olegnax_MegaMenu::css/perfect-scrollbar.min.css')?>"></noscript>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax MegaMenu
|
||||
*
|
||||
* This file is part of Olegnax/Core.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
/** @var Megamenu $block */
|
||||
$menu_position = $block->getSystemValue('athlete2_settings/header/menu_position');
|
||||
$headerLayout = $block->getSystemValue('athlete2_settings/header/header_layout');
|
||||
$sub_icons = $block->getValueOption('header_container') ? ' ox-mm-sub-icons' : '';
|
||||
$perfect_scrollbar = $block->getValueOption('perfect_scrollbar') ? ' ps-enabled' : '';
|
||||
|
||||
$_stickyClasses = '';
|
||||
if ($menu_position == 2 || $headerLayout == 'header_6') {
|
||||
$_stickyClasses = ' ox-move-sticky ox-move-sticky-header.main.left';
|
||||
|
||||
}
|
||||
$animation_type = $block->getValueOption('animation_type', 'fade');
|
||||
$columnsLimit = $block->getColumnsLimit() ?: 0;
|
||||
$_menu = $block->getHtml('level-top', 'submenu', $columnsLimit);
|
||||
|
||||
use Olegnax\MegaMenu\Block\Html\Megamenu; ?>
|
||||
<nav class="ox-megamenu ox-move-item ox-move-item-store.menu<?= $_stickyClasses . $sub_icons . $perfect_scrollbar?>" data-action="navigation"
|
||||
data-ox-mm-anim-type="<?php echo $animation_type ?>" data-mage-init='{"OxMegaMenu":{
|
||||
"header":"<?= $block->getValueOption('header_container') ?>",
|
||||
"direction":"<?= $block->getValueOption('direction', 'horizontal') ?>",
|
||||
"mediaBreakpoint":"1025",
|
||||
"positionHorizontal":"<?= $block->getValueOption('position_horizontal', 'left') ?>"
|
||||
}}'>
|
||||
<ul class="ox-megamenu-navigation">
|
||||
<?= $_menu ?>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Olegnax MegaMenu
|
||||
*
|
||||
* This file is part of Olegnax/Core.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
$animation_type = $block->getValueOption('animation_type', 'fade');
|
||||
|
||||
$columnsLimit = $block->getColumnsLimit() ?: 0;
|
||||
$_menu = $block->getHtml('level-top', 'submenu', $columnsLimit);
|
||||
?>
|
||||
<nav class="ox-megamenu" data-action="navigation" data-ox-mm-anim-type="<?php echo $animation_type ?>" data-mage-init='{"OxMegaMenu":{
|
||||
"header":"<?= $block->getValueOption('header_container') ?>",
|
||||
"direction":"<?= $block->getValueOption('direction', 'horizontal') ?>",
|
||||
"positionHorizontal":"<?= $block->getValueOption('position_horizontal', 'left') ?>"
|
||||
}}'>
|
||||
<ul class="ox-megamenu-navigation">
|
||||
<?= $_menu ?>
|
||||
</ul>
|
||||
</nav>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/* perfect-scrollbar v0.7.1 */
|
||||
.ps{-ms-touch-action:auto;touch-action:auto;overflow:hidden !important;-ms-overflow-style:none}@supports (-ms-overflow-style: none){.ps{overflow:auto !important}}@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none){.ps{overflow:auto !important}}.ps.ps--active-x>.ps__scrollbar-x-rail,.ps.ps--active-y>.ps__scrollbar-y-rail{display:block;background-color:transparent}.ps.ps--in-scrolling.ps--x>.ps__scrollbar-x-rail{background-color:#eee;opacity:.9}.ps.ps--in-scrolling.ps--x>.ps__scrollbar-x-rail>.ps__scrollbar-x{background-color:#999;height:11px}.ps.ps--in-scrolling.ps--y>.ps__scrollbar-y-rail{background-color:#eee;opacity:.9}.ps.ps--in-scrolling.ps--y>.ps__scrollbar-y-rail>.ps__scrollbar-y{background-color:#999;width:11px}.ps>.ps__scrollbar-x-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;bottom:0px;height:15px}.ps>.ps__scrollbar-x-rail>.ps__scrollbar-x{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;bottom:2px;height:6px}.ps>.ps__scrollbar-x-rail:hover>.ps__scrollbar-x,.ps>.ps__scrollbar-x-rail:active>.ps__scrollbar-x{height:11px}.ps>.ps__scrollbar-y-rail{display:none;position:absolute;opacity:0;-webkit-transition:background-color .2s linear, opacity .2s linear;-o-transition:background-color .2s linear, opacity .2s linear;-moz-transition:background-color .2s linear, opacity .2s linear;transition:background-color .2s linear, opacity .2s linear;right:0;width:15px}.ps>.ps__scrollbar-y-rail>.ps__scrollbar-y{position:absolute;background-color:#aaa;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out;-o-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;-moz-transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out;transition:background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out;right:2px;width:6px}.ps>.ps__scrollbar-y-rail:hover>.ps__scrollbar-y,.ps>.ps__scrollbar-y-rail:active>.ps__scrollbar-y{width:11px}.ps:hover.ps--in-scrolling.ps--x>.ps__scrollbar-x-rail{background-color:#eee;opacity:.9}.ps:hover.ps--in-scrolling.ps--x>.ps__scrollbar-x-rail>.ps__scrollbar-x{background-color:#999;height:11px}.ps:hover.ps--in-scrolling.ps--y>.ps__scrollbar-y-rail{background-color:#eee;opacity:.9}.ps:hover.ps--in-scrolling.ps--y>.ps__scrollbar-y-rail>.ps__scrollbar-y{background-color:#999;width:11px}.ps:hover>.ps__scrollbar-x-rail,.ps:hover>.ps__scrollbar-y-rail{opacity:.6}.ps:hover>.ps__scrollbar-x-rail:hover{background-color:#eee;opacity:.9}.ps:hover>.ps__scrollbar-x-rail:hover>.ps__scrollbar-x{background-color:#999}.ps:hover>.ps__scrollbar-y-rail:hover{background-color:#eee;opacity:.9}.ps:hover>.ps__scrollbar-y-rail:hover>.ps__scrollbar-y{background-color:#999}
|
||||
File diff suppressed because it is too large
Load Diff
+161
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Olegnax
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_MegaMenu
|
||||
* @copyright Copyright (c) 2010-2021 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
@ox-mega-menu__column-padding: 15px;
|
||||
@ox-mega-menu__transition: ~"all 600ms ease-in-out";
|
||||
@ox-mega-menu__transition-hover: ~"all 10ms ease-in-out";
|
||||
@ox-mega-menu__animation-speed: 0.5s;
|
||||
|
||||
//
|
||||
// Navigation
|
||||
// _____________________________________________
|
||||
|
||||
/* Toggle Plus Icon */
|
||||
@ox-mega-menu-toggle-icon__show: true;
|
||||
@ox-mega-menu-toggle-icon__width: 8px;
|
||||
@ox-mega-menu-toggle-icon__height: 2px;
|
||||
@ox-mega-menu-toggle-icon__color: currentColor;
|
||||
@ox-mega-menu-arrow-icon__color: currentColor;
|
||||
|
||||
//@font-family__sans-serif: Arial, sans-serif;
|
||||
@ox-mega-menu__font-name: 'Open Sans', @font-family__sans-serif;
|
||||
@ox-mega-menu__background: transparent;
|
||||
|
||||
//Label
|
||||
@ox-mega-menu-label__color: white;
|
||||
@ox-mega-menu-label_background: red;
|
||||
@ox-mega-menu-label__font-size: 11px;
|
||||
@ox-mega-menu-label__padding: 3px 5px 4px 5px;
|
||||
@ox-mega-menu-label__border-radius: 0;
|
||||
@ox-mega-menu-label__top: -7px;
|
||||
@ox-mega-menu-label__right: 0;
|
||||
|
||||
// Level0
|
||||
@ox-mega-menu-level0-item__font-size: 14px;
|
||||
@ox-mega-menu-level0-item__font-weight: @font-weight__bold;
|
||||
@ox-mega-menu-level0-item__height: 44px;
|
||||
@ox-mega-menu-level0-item__margin: 0;
|
||||
@ox-mega-menu-level0-item__padding: 0 14px;
|
||||
@ox-mega-menu-level0-item__text-transform: uppercase;
|
||||
@ox-mega-menu-level0-item__letter-spacing: 0;
|
||||
|
||||
@ox-mega-menu-level0-item__background: transparent;
|
||||
@ox-mega-menu-level0-item__color: #333333;
|
||||
@ox-mega-menu-level0-item__active__background: #333333;
|
||||
@ox-mega-menu-level0-item__active__color: #ffffff;
|
||||
@ox-mega-menu-level0-item__hover__background: #f7f7f7;
|
||||
@ox-mega-menu-level0-item__hover__color: #333333;
|
||||
|
||||
// Submenu Items
|
||||
@ox-mega-menu-submenu-item__background: transparent;
|
||||
@ox-mega-menu-submenu-item__border: 1px solid #f1f1f1;
|
||||
@ox-mega-menu-submenu-item__padding: 10px 15px;
|
||||
@ox-mega-menu-submenu-item__margin: 0;
|
||||
@ox-mega-menu-submenu-item__font-size: 14px;
|
||||
@ox-mega-menu-submenu-item__font-weight: @font-weight__heavier;
|
||||
@ox-mega-menu-submenu-item__color: #333333;
|
||||
@ox-mega-menu-submenu-item__height: 44px;
|
||||
|
||||
@ox-mega-menu-submenu-item__active__background: #333333;
|
||||
@ox-mega-menu-submenu-item__active__color: #ffffff;
|
||||
@ox-mega-menu-submenu-item__hover__background: #f7f7f7;
|
||||
@ox-mega-menu-submenu-item__hover__color: #000000;
|
||||
@ox-mega-menu-submenu-item__text-transform: unset;
|
||||
@ox-mega-menu-submenu-item__letter-spacing: 0;
|
||||
|
||||
@ox-mega-menu-submenu__padding: 0;
|
||||
//
|
||||
// Desktop Navigation
|
||||
// ---------------------------------------------
|
||||
|
||||
@ox-mega-menu-navigation__min-height: 55px;
|
||||
@ox-mega-menu-navigation__padding: 0;
|
||||
|
||||
@ox-mega-menu-arrow-icon__show: true;
|
||||
|
||||
// Drop Down
|
||||
@ox-mega-menu-submenu__background: #ffffff;
|
||||
@ox-mega-menu-desktop-submenu__padding: 20px;
|
||||
@ox-mega-menu-desktop-submenu-mega__padding: 35px;
|
||||
@ox-mega-menu-submenu__width: 290px;
|
||||
@ox-mega-menu-submenu__shadow: 0px 4px 22px 0px rgba(0, 0, 0, 0.08);
|
||||
|
||||
// Level0
|
||||
@ox-mega-menu-desktop-level0-item__font-size: 16px;
|
||||
@ox-mega-menu-desktop-level0-item__font-weight: @font-weight__bold;
|
||||
@ox-mega-menu-desktop-level0-item__height: 44px;
|
||||
@ox-mega-menu-desktop-level0-item__margin: 0;
|
||||
@ox-mega-menu-desktop-level0-item__padding: 0 14px;
|
||||
@ox-mega-menu-desktop-level0-item__text-transform: uppercase;
|
||||
@ox-mega-menu-desktop-level0-item__letter-spacing: 0;
|
||||
|
||||
@ox-mega-menu-desktop-level0-item__background: transparent;
|
||||
@ox-mega-menu-desktop-level0-item__color: #333333;
|
||||
@ox-mega-menu-desktop-level0-item__active__background: #333333;
|
||||
@ox-mega-menu-desktop-level0-item__active__color: #ffffff;
|
||||
@ox-mega-menu-desktop-level0-item__hover__background: #f7f7f7;
|
||||
@ox-mega-menu-desktop-level0-item__hover__color: #333333;
|
||||
|
||||
// Submenu Items
|
||||
@ox-mega-menu-desktop-submenu-item__background: @ox-mega-menu-submenu-item__background;
|
||||
@ox-mega-menu-desktop-submenu-item__border: @ox-mega-menu-submenu-item__border;
|
||||
@ox-mega-menu-desktop-submenu-item__padding: @ox-mega-menu-submenu-item__padding;
|
||||
@ox-mega-menu-desktop-submenu-item__margin: @ox-mega-menu-submenu-item__margin;
|
||||
@ox-mega-menu-desktop-submenu-item__font-size: @ox-mega-menu-submenu-item__font-size;
|
||||
@ox-mega-menu-desktop-submenu-item__font-weight: @ox-mega-menu-submenu-item__font-weight;
|
||||
@ox-mega-menu-desktop-submenu-item__text-transform: unset;
|
||||
@ox-mega-menu-desktop-submenu-item__letter-spacing: 0;
|
||||
@ox-mega-menu-desktop-submenu-item__color: @ox-mega-menu-submenu-item__color;
|
||||
|
||||
@ox-mega-menu-desktop-submenu-item__active__background: @ox-mega-menu-submenu-item__active__background;
|
||||
@ox-mega-menu-desktop-submenu-item__active__color: @ox-mega-menu-submenu-item__active__color;
|
||||
@ox-mega-menu-desktop-submenu-item__hover__background: @ox-mega-menu-submenu-item__hover__background;
|
||||
@ox-mega-menu-desktop-submenu-item__hover__color: @ox-mega-menu-submenu-item__hover__color;
|
||||
|
||||
// Level1 item in Mega Drop Down
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__font-size: 14px;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__font-weight: @font-weight__bold;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__margin: 0;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__padding: 15px;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__color: #333333;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__background: transparent;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__text-transform: uppercase;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__letter-spacing: 0;
|
||||
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__active__background: @ox-mega-menu-desktop-submenu-item__active__background;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__active__color: @ox-mega-menu-desktop-submenu-item__active__color;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__hover__background: @ox-mega-menu-desktop-submenu-item__hover__background;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-item__hover__color: @ox-mega-menu-desktop-submenu-item__hover__color;
|
||||
|
||||
// Level1 Submenu item in Mega Drop Down
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__font-size: @ox-mega-menu-desktop-submenu-item__font-size;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__font-weight: @ox-mega-menu-desktop-submenu-item__font-weight;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__padding: 6px 8px;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__margin: @ox-mega-menu-desktop-submenu-item__margin;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__color: @ox-mega-menu-desktop-submenu-item__color;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__background: @ox-mega-menu-desktop-submenu-item__background;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__text-transform: @ox-mega-menu-desktop-submenu-item__text-transform;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__letter-spacing: @ox-mega-menu-desktop-submenu-item__letter-spacing;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__border: @ox-mega-menu-desktop-submenu-item__border;
|
||||
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__active__background: @ox-mega-menu-desktop-submenu-item__active__background;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__active__color: @ox-mega-menu-desktop-submenu-item__active__color;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__hover__background: @ox-mega-menu-desktop-submenu-item__hover__background;
|
||||
@ox-mega-menu-desktop-submenu-mega-level1-submenu__hover__color: @ox-mega-menu-desktop-submenu-item__hover__color;
|
||||
+596
@@ -0,0 +1,596 @@
|
||||
define([
|
||||
'jquery',
|
||||
'matchMedia',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'plugins/velocity',
|
||||
'plugins/scrollbar',
|
||||
], function ($, mediaCheck) {
|
||||
'use strict';
|
||||
|
||||
$.widget('ox.OxMegaMenu', {
|
||||
options: {
|
||||
direction: 'horizontal',
|
||||
positionHorizontal: 'left',
|
||||
btn: false,
|
||||
actionActive: 'active',
|
||||
header: '.container',
|
||||
toggleTransitionDuration: 400,
|
||||
mediaBreakpoint: 768,
|
||||
classNavigation: '.ox-megamenu-navigation',
|
||||
classDropdown: '.ox-megamenu__dropdown',
|
||||
},
|
||||
_alignFunctions: {
|
||||
'horizontal': {
|
||||
'container-left': function () {
|
||||
var $cont = $(this.options.header);
|
||||
if ($cont.length) {
|
||||
|
||||
var cont_l = $cont[0].getBoundingClientRect().left,
|
||||
ox_megamenu_l = this.element[0].getBoundingClientRect().left;
|
||||
return {
|
||||
left: cont_l - ox_megamenu_l
|
||||
};
|
||||
} else {
|
||||
console.warn('Header container not found. Please set correct header selector in Olegnax / Megamenu / Configuration.')
|
||||
}
|
||||
},
|
||||
'container-right': function () {
|
||||
var $cont = $(this.options.header),
|
||||
cont_r = $cont[0].getBoundingClientRect().right,
|
||||
ox_megamenu_r = this.element[0].getBoundingClientRect().right;
|
||||
return {
|
||||
left: 'auto',
|
||||
right: ox_megamenu_r - cont_r
|
||||
};
|
||||
},
|
||||
'container-center': function () {
|
||||
var $cont = $(this.options.header),
|
||||
cont_l = $cont[0].getBoundingClientRect().left,
|
||||
cont_w = $cont.innerWidth(),
|
||||
ox_megamenu_l = this.element[0].getBoundingClientRect().left;
|
||||
|
||||
return {
|
||||
left: cont_l - ox_megamenu_l + cont_w / 2
|
||||
};
|
||||
},
|
||||
'window-left': function () {
|
||||
var ox_megamenu_l = this.element[0].getBoundingClientRect().left;
|
||||
return {
|
||||
left: ox_megamenu_l * -1
|
||||
};
|
||||
},
|
||||
'window-right': function () {
|
||||
var windowWidth = window.innerWidth - this._scrollWidth,
|
||||
ox_megamenu_r = this.element[0].getBoundingClientRect().right;
|
||||
|
||||
return {
|
||||
left: 'auto',
|
||||
right: (windowWidth - ox_megamenu_r) * -1
|
||||
};
|
||||
},
|
||||
'window-center': function () {
|
||||
var windowWidth = window.innerWidth - this._scrollWidth,
|
||||
ox_megamenu_l = this.element[0].getBoundingClientRect().left;
|
||||
|
||||
return {
|
||||
left: ox_megamenu_l * -1 + windowWidth / 2
|
||||
};
|
||||
},
|
||||
'define': 'menu-left',
|
||||
},
|
||||
'vertical': {
|
||||
'container-left': function () {
|
||||
var $cont = $(this.options.cont),
|
||||
cont_l = $cont[0].getBoundingClientRect().left,
|
||||
ox_megamenu_l = this.element[0].getBoundingClientRect().left,
|
||||
ox_megamenu_w = this.element.innerWidth();
|
||||
|
||||
return {
|
||||
left: 'auto',
|
||||
right: ox_megamenu_l - cont_l + ox_megamenu_w
|
||||
};
|
||||
},
|
||||
'container-right': function () {
|
||||
var $cont = $(this.options.cont),
|
||||
cont_r = $cont[0].getBoundingClientRect().right,
|
||||
ox_megamenu_r = this.element[0].getBoundingClientRect().right,
|
||||
ox_megamenu_w = this.element.innerWidth();
|
||||
|
||||
return {
|
||||
left: cont_r - ox_megamenu_r + ox_megamenu_w
|
||||
};
|
||||
},
|
||||
'define': 'container-left',
|
||||
}
|
||||
},
|
||||
_create: function () {
|
||||
|
||||
var _self = this,
|
||||
$ox_megamenu = this.element,
|
||||
$ox_megamenu__navigation = $ox_megamenu.find(this.options.classNavigation),
|
||||
$ox_megamenu__dropdown = $ox_megamenu.find(this.options.classDropdown),
|
||||
$ox_megamenu__submenu = $ox_megamenu__dropdown.find('.ox-submenu');
|
||||
this._getScrollWidth();
|
||||
|
||||
mediaCheck({
|
||||
media: '(min-width:' + this.options.mediaBreakpoint + 'px)',
|
||||
entry: $.proxy(function () {
|
||||
this._toggleDesktopMode();
|
||||
}, this),
|
||||
exit: $.proxy(function () {
|
||||
this._toggleMobileMode();
|
||||
}, this),
|
||||
});
|
||||
|
||||
this._widthHandlers({
|
||||
elem: $ox_megamenu__navigation,
|
||||
delegate: '>li, li.ox-dropdown--megamenu',
|
||||
namespace: 'togglemegamenu',
|
||||
desktop: true,
|
||||
events: {
|
||||
'mouseenter': function (e) {
|
||||
_self._showMM(this);
|
||||
},
|
||||
'mouseleave': function (e) {
|
||||
_self._hideMM(this);
|
||||
},
|
||||
'touchstart': function (e) {
|
||||
if ($(this).hasClass('ox-megamenu--opened') || ($(this).find('> a').data('url') == 'custom' && !$(this).hasClass('parent'))) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
_self._showMM(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//dropdown handlers
|
||||
this._widthHandlers({
|
||||
elem: $ox_megamenu__submenu.parent('li'),
|
||||
namespace: 'toggledropdown',
|
||||
desktop: true,
|
||||
events: {
|
||||
'mouseenter': function (e) {
|
||||
_self._showDD(this);
|
||||
},
|
||||
'mouseleave': function (e) {
|
||||
_self._hideDD(this);
|
||||
},
|
||||
'touchstart': function (e) {
|
||||
if ($(this).hasClass('js-touch')) {
|
||||
return;
|
||||
}
|
||||
$(this).addClass('js-touch');
|
||||
e.preventDefault();
|
||||
_self._showDD(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this._widthHandlers({
|
||||
elem: $ox_megamenu.find('li.parent > a, li.ox-dropdown--megamenu > a'),
|
||||
namespace: 'togglelist',
|
||||
desktop: false,
|
||||
events: {
|
||||
'click': function (e) {
|
||||
if (('A' === e.target.tagName || 'SPAN' === e.target.tagName) && $(this).parent().hasClass('ox-megamenu--opened') || !$(this).closest('li').eq(0).find('.submenu, .ox-submenu, .ox-megamenu__dropdown').length)
|
||||
return;
|
||||
_self._toggleList(this);
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
$(this.window).trigger('resize');
|
||||
},
|
||||
_getScrollWidth: function () {
|
||||
var $tempElement = $('<div>').css({
|
||||
overflowY: 'scroll',
|
||||
width: '50px',
|
||||
height: '50px',
|
||||
visibility: 'hidden'
|
||||
});
|
||||
$('body').append($tempElement);
|
||||
this._scrollWidth = $tempElement[0].offsetWidth - $tempElement[0].clientWidth;
|
||||
$tempElement.remove();
|
||||
},
|
||||
_toggleDesktopMode: function () {
|
||||
this.is_desktop = true;
|
||||
this._hideAllMM();
|
||||
this.element.find('.ox-megamenu--opened').removeClass('ox-megamenu--opened');
|
||||
},
|
||||
_toggleMobileMode: function () {
|
||||
this.is_desktop = false;
|
||||
this._hideAllMM();
|
||||
var dropdown = this.element.find('.ox-megamenu__dropdown');
|
||||
dropdown.css({'width': '', 'left': ''});
|
||||
dropdown.find('.ox-megamenu-list').first().css({'width': ''});
|
||||
dropdown.find('.ox-megamenu-block-left, .ox-megamenu-block-right').css({'width': ''});
|
||||
},
|
||||
_hideAllMM: function () {
|
||||
this._hideMM(this.element.find(this.options.classNavigation).find('> li'), true);
|
||||
},
|
||||
_toggleList: function (btn) {
|
||||
var _self = this,
|
||||
$ox_megamenu = this.element,
|
||||
$btn = $(btn),
|
||||
$li = $btn.parent(),
|
||||
$lvl = $li.find('> *:not(a)');
|
||||
|
||||
$lvl.css('height', '');
|
||||
$lvl.velocity('stop');
|
||||
|
||||
if ($li.hasClass('ox-megamenu--opened')) {
|
||||
var $li_other = $li.find('.ox-megamenu--opened');
|
||||
|
||||
$li.removeClass('ox-megamenu--opened');
|
||||
|
||||
$lvl.velocity('slideUp', {
|
||||
duration: _self.options.toggleTransitionDuration,
|
||||
complete: function () {
|
||||
$li_other.removeClass('ox-megamenu--opened').removeAttr('style');
|
||||
$li_other.find('ul').removeAttr('style');
|
||||
if($ox_megamenu.hasClass('ps-enabled')){
|
||||
$ox_megamenu.perfectScrollbar('update');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$lvl.velocity('slideDown', {
|
||||
duration: _self.options.toggleTransitionDuration,
|
||||
complete: function () {
|
||||
if($ox_megamenu.hasClass('ps-enabled')){
|
||||
$ox_megamenu.perfectScrollbar('update');
|
||||
}
|
||||
}
|
||||
});
|
||||
$li.addClass('ox-megamenu--opened');
|
||||
$('body').trigger('contentUpdated');
|
||||
}
|
||||
},
|
||||
_widthHandlers: function (obj) {
|
||||
var _self = this;
|
||||
|
||||
$(window).on('resize.handlerswidth', function () {
|
||||
if (obj.desktopBp === _self.is_desktop)
|
||||
return;
|
||||
else
|
||||
obj.desktopBp = _self.is_desktop;
|
||||
|
||||
var $elem = $(obj.elem),
|
||||
ns = obj.namespace ? '.' + obj.namespace : '';
|
||||
|
||||
if (obj.desktop === _self.is_desktop) {
|
||||
$.each(obj.events, function (key, val) {
|
||||
$elem.on(key + ns, obj.delegate, val);
|
||||
});
|
||||
} else {
|
||||
$.each(obj.events, function (key) {
|
||||
$elem.off(key + ns);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
_showMM: function (element) {
|
||||
var _self = this,
|
||||
$element = $(element),
|
||||
$mm = $element.children('.ox-megamenu__dropdown'),
|
||||
$mmp = $mm.parents('.ox-megamenu__dropdown').add($mm),
|
||||
$ox_megamenu__dropdown = this.element.find('.ox-megamenu__dropdown');
|
||||
|
||||
if (!$mm.length)
|
||||
return;
|
||||
|
||||
$mm.off('transitionend.mmclose');
|
||||
$ox_megamenu__dropdown.not($mmp).removeClass('opened animate');
|
||||
|
||||
if (this.options.beforeOpenMM)
|
||||
this.options.beforeOpenMM($mm, $element);
|
||||
|
||||
this.currentButton = $element;
|
||||
this.currentMegamenu = $mm;
|
||||
|
||||
$element.addClass('ox-megamenu--opened');
|
||||
$mm.addClass('opened');
|
||||
$('body').addClass('ox-mm-opened');
|
||||
|
||||
this._beforeOpenMM();
|
||||
|
||||
var $menu_item = $element.parents('.category-item:first');
|
||||
if($menu_item.length && $menu_item.hasClass('ox-dropdown--megamenu')){
|
||||
this.setVerticalAlign();
|
||||
}
|
||||
$mm.one('transitionend.mmopen', function () {
|
||||
_self._afterOpenMM();
|
||||
if (_self.options.afterOpenMM)
|
||||
_self.options.afterOpenMM($mm, $element);
|
||||
});
|
||||
$mm.find('.owl-carousel:not(.owl-mm-reloaded), .owl-loaded:not(.owl-mm-reloaded)').trigger('refresh.owl.carousel').addClass('owl-mm-reloaded');
|
||||
$mm.addClass('animate');
|
||||
},
|
||||
_hideMM: function (btn, is_fast) {
|
||||
|
||||
var _self = this,
|
||||
$btn = $(btn),
|
||||
$mm = $btn.find('.ox-megamenu__dropdown');
|
||||
if (!$mm.length)
|
||||
return;
|
||||
|
||||
$mm.off('transitionend.mmopen');
|
||||
|
||||
if (this.options.beforeCloseMM)
|
||||
this.options.beforeCloseMM($mm, $btn);
|
||||
|
||||
this.currentButton = $btn;
|
||||
this.currentMegamenu = $mm;
|
||||
|
||||
this._beforeCloseMM();
|
||||
|
||||
$mm.one('transitionend.mmclose', function () {
|
||||
$mm.removeClass('opened');
|
||||
$('body').removeClass('ox-mm-opened');
|
||||
$btn.removeClass('ox-megamenu--opened');
|
||||
_self._afterCloseMM();
|
||||
if (_self.options.afterCloseMM)
|
||||
_self.options.afterCloseMM($mm, $btn);
|
||||
});
|
||||
$mm.removeClass('animate');
|
||||
|
||||
if (is_fast)
|
||||
$mm.trigger('transitionend.mmclose');
|
||||
},
|
||||
_isNumeric: function (val) {
|
||||
return Number(parseFloat(val)) === val;
|
||||
},
|
||||
setVerticalAlign: function() {
|
||||
if(this.currentButton.hasClass('ox-mm__lvl1-top') || this.currentButton.hasClass('ox-mm__lvl1-top-stretch') ){
|
||||
var $_parent = $(this.currentButton.closest(this.options.classDropdown));
|
||||
if ($_parent.length) {
|
||||
this.currentMegamenu.css('top', (this.currentButton[0].getBoundingClientRect().top - $_parent[0].getBoundingClientRect().top) * -1 );
|
||||
}
|
||||
}
|
||||
},
|
||||
_beforeOpenMM: function () {
|
||||
var _self = this;
|
||||
|
||||
function setWidth() {
|
||||
var mmWidth = _self.currentMegamenu.data('ox-mm-w') || _self.currentMegamenu.data('oxMmW'),
|
||||
w_funcs = _self._widthFunctions[_self.options.direction],
|
||||
set_w;
|
||||
|
||||
if (w_funcs.hasOwnProperty(mmWidth))
|
||||
set_w = w_funcs[mmWidth].apply(_self, arguments);
|
||||
else if (_self._isNumeric(mmWidth))
|
||||
set_w = mmWidth;
|
||||
|
||||
if (set_w) {
|
||||
if (mmWidth === 'column-max-width') {
|
||||
var mm_list = _self.currentMegamenu.find('.ox-megamenu-list').first();
|
||||
var mm_block_left = _self.currentMegamenu.find('.ox-megamenu-block-left');
|
||||
var mm_block_right = _self.currentMegamenu.find('.ox-megamenu-block-right');
|
||||
mm_list.innerWidth(set_w);
|
||||
mm_block_left.innerWidth(set_w);
|
||||
mm_block_right.innerWidth(set_w);
|
||||
_self.currentMegamenu.css('width', 'auto');
|
||||
} else {
|
||||
_self.currentMegamenu.innerWidth(set_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
function setAlign(attr) {
|
||||
var align = _self.currentButton.data(attr),
|
||||
align_func = _self._alignFunctions[_self.options.direction],
|
||||
align = align || align_func['define'],
|
||||
css;
|
||||
if (align_func.hasOwnProperty(align)) {
|
||||
css = align_func[align].apply(_self);
|
||||
if (css) {
|
||||
_self.currentMegamenu.css(css);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkWidth() {
|
||||
var $mm = _self.currentMegamenu,
|
||||
mmLeft = $mm[0].getBoundingClientRect().left,
|
||||
mmRight = $mm[0].getBoundingClientRect().right,
|
||||
mmWidth = $mm.innerWidth(),
|
||||
windowWidth = window.innerWidth - _self._scrollWidth;
|
||||
|
||||
if (mmWidth > windowWidth) {
|
||||
if (mmLeft > 0) {
|
||||
$mm.innerWidth(windowWidth - mmLeft);
|
||||
} else if (mmRight < windowWidth) {
|
||||
$mm.innerWidth(windowWidth - (windowWidth - mmRight));
|
||||
} else {
|
||||
$mm.innerWidth(windowWidth);
|
||||
}
|
||||
} else if (mmLeft < 0) {
|
||||
$mm.innerWidth(mmWidth + mmLeft);
|
||||
} else if (mmRight > windowWidth) {
|
||||
$mm.innerWidth(mmWidth - (mmRight - windowWidth));
|
||||
}
|
||||
}
|
||||
setWidth();
|
||||
|
||||
setAlign('ox-mm-a-h');
|
||||
|
||||
checkWidth();
|
||||
|
||||
this._toggleTransition('show');
|
||||
},
|
||||
_afterOpenMM: function () {
|
||||
this._checkWindowLimit();
|
||||
this._toggleTransition('show');
|
||||
},
|
||||
_beforeCloseMM: function () {
|
||||
this._toggleTransition('hide');
|
||||
},
|
||||
_afterCloseMM: function () {
|
||||
var $mm = this.currentMegamenu;
|
||||
|
||||
// $mm.removeAttr('style');
|
||||
$mm.css('max-height', '');
|
||||
if ($mm.hasClass('ox-megamenu--scroll')) {
|
||||
$mm.removeClass('ox-megamenu--scroll');
|
||||
$mm.perfectScrollbar('destroy').removeClass('ps');
|
||||
}
|
||||
},
|
||||
_widthFunctions: {
|
||||
'horizontal': {
|
||||
'menu': function () {
|
||||
return this.element.innerWidth();
|
||||
},
|
||||
'fullwidth': function () {
|
||||
return window.innerWidth - this._scrollWidth;
|
||||
},
|
||||
'container': function () {
|
||||
return $(this.options.header).innerWidth();
|
||||
},
|
||||
'column-max-width': function () {
|
||||
var mm_cw = this.currentMegamenu.data('ox-mm-cw') || this.currentMegamenu.data('oxMmCw'),
|
||||
mm_col = this.currentMegamenu.data('ox-mm-col') || this.currentMegamenu.data('oxMmCol');
|
||||
if (mm_cw) {
|
||||
if (mm_col) {
|
||||
return mm_cw * mm_col;
|
||||
} else {
|
||||
return mm_cw;
|
||||
}
|
||||
}
|
||||
},
|
||||
'custom': function (mm) {
|
||||
return this.currentMegamenu.data('ox-mm-cw') || this.currentMegamenu.data('oxMmCw');
|
||||
},
|
||||
},
|
||||
'vertical': {
|
||||
'fullwidth': function () {
|
||||
switch (this.options.positionHorizontal) {
|
||||
case 'right':
|
||||
return window.innerWidth - this._scrollWidth - (window.innerWidth - this._scrollWidth - this.element[0].getBoundingClientRect().left);
|
||||
default:
|
||||
return window.innerWidth - this.element[0].getBoundingClientRect().right - this._scrollWidth;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
_toggleTransition: function (act) {
|
||||
var $btn = this.currentButton,
|
||||
$mm = this.currentMegamenu,
|
||||
$trns = $btn.find('.ox-megamenu-trns');
|
||||
|
||||
switch (act) {
|
||||
case 'show':
|
||||
var set_obj = {},
|
||||
btn_pos = $btn[0].getBoundingClientRect(),
|
||||
mm_pos = $mm[0].getBoundingClientRect();
|
||||
|
||||
if (this.options.direction === 'horizontal') {
|
||||
set_obj.width = $mm.innerWidth();
|
||||
set_obj.height = mm_pos.top - btn_pos.bottom + 10;
|
||||
|
||||
if (mm_pos.left > btn_pos.left) {
|
||||
set_obj.width += mm_pos.left - btn_pos.left;
|
||||
} else if (mm_pos.right < btn_pos.right) {
|
||||
set_obj.width += btn_pos.right - mm_pos.right;
|
||||
set_obj.left = (btn_pos.left - mm_pos.left) * -1;
|
||||
} else {
|
||||
set_obj.left = (btn_pos.left - mm_pos.left) * -1;
|
||||
}
|
||||
|
||||
} else if (this.options.direction === 'vertical') {
|
||||
set_obj.height = $mm.innerHeight();
|
||||
|
||||
if (this.options.positionHorizontal === 'left') {
|
||||
set_obj.width = mm_pos.left - btn_pos.right;
|
||||
|
||||
} else if (this.options.positionHorizontal === 'right') {
|
||||
set_obj.width = btn_pos.left - mm_pos.right;
|
||||
}
|
||||
|
||||
if (mm_pos.top > btn_pos.top) {
|
||||
set_obj.height += mm_pos.top - btn_pos.top;
|
||||
} else if (mm_pos.bottom < btn_pos.bottom) {
|
||||
set_obj.height += btn_pos.bottom - mm_pos.bottom;
|
||||
set_obj.top = (btn_pos.top - mm_pos.top) * -1;
|
||||
} else {
|
||||
set_obj.top = (btn_pos.top - mm_pos.top) * -1;
|
||||
}
|
||||
}
|
||||
|
||||
$trns.css(set_obj);
|
||||
break;
|
||||
|
||||
case 'hide':
|
||||
$trns.removeAttr('style');
|
||||
break;
|
||||
}
|
||||
},
|
||||
_checkWindowLimit: function () {
|
||||
if (this.options.direction !== 'horizontal' || !this.element.find(this.options.classNavigation).parent().hasClass('ps-enabled'))
|
||||
return;
|
||||
|
||||
var $mm = this.currentMegamenu,
|
||||
mm_b = $mm[0].getBoundingClientRect().bottom,
|
||||
wind_h = window.innerHeight;
|
||||
|
||||
if (mm_b > wind_h) {
|
||||
var mm_h = $mm.innerHeight();
|
||||
|
||||
$mm.addClass('ox-megamenu--scroll');
|
||||
$mm.css({'max-height': mm_h - (mm_b - wind_h)});
|
||||
$mm.perfectScrollbar({
|
||||
suppressScrollX: true
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
_showDD: function (btn) {
|
||||
var $btn = $(btn),
|
||||
$dd = $btn.find('> ul'),
|
||||
$mm = this.currentMegamenu;
|
||||
|
||||
$dd.off('transitionend.ddclose');
|
||||
$dd.addClass('opened');
|
||||
$('body').addClass('ox-mm-opened');
|
||||
|
||||
if ($mm.hasClass('ps') && $mm.hasClass('ox-megamenu-mm--simple')) {
|
||||
$mm.perfectScrollbar('update');
|
||||
} else {
|
||||
var dd_pos = $dd[0].getBoundingClientRect(),
|
||||
windowWidth = window.innerWidth - this._scrollWidth,
|
||||
dd_lim_l = (dd_pos.left - $dd.innerWidth() - $dd.parents('ul').first().innerWidth()) < 0,
|
||||
dd_lim_r = dd_pos.right > windowWidth,
|
||||
is_prnt_reverse = $dd.parents('ul').first().hasClass('ox-megamenu-dd--reverse');
|
||||
if (dd_lim_r || (is_prnt_reverse && !dd_lim_l))
|
||||
$dd.addClass('ox-megamenu-dd--reverse');
|
||||
}
|
||||
$dd.addClass('animate');
|
||||
},
|
||||
_hideDD: function (btn) {
|
||||
var $btn = $(btn),
|
||||
$dd = $btn.find('> ul'),
|
||||
$mm = this.currentMegamenu;
|
||||
|
||||
$dd.one('transitionend.ddclose', function (e) {
|
||||
$dd.removeClass('opened ox-megamenu-dd--reverse').css('max-height', '');
|
||||
if ($mm.hasClass('ps'))
|
||||
$mm.perfectScrollbar('update');
|
||||
});
|
||||
$dd.removeClass('animate');
|
||||
},
|
||||
_setOption: function (key, value, is_attr) {
|
||||
if (is_attr && !value)
|
||||
return;
|
||||
|
||||
$.Widget.prototype._setOption.apply(this, arguments);
|
||||
},
|
||||
destroy: function () {
|
||||
$.Widget.prototype.destroy.call(this);
|
||||
}
|
||||
});
|
||||
|
||||
return $.ox.OxMegaMenu;
|
||||
});
|
||||
+2
File diff suppressed because one or more lines are too long
+4
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user