init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/** @var \WeltPixel\Backend\Helper\Utility $wpHelper */
|
||||
$wpHelper = $this->helper('WeltPixel\Backend\Helper\Utility');
|
||||
$cspNonceProvider = $wpHelper->getCspNonceProvider();
|
||||
?>
|
||||
<script<?php if ($cspNonceProvider): ?> nonce="<?= $block->escapeHtmlAttr($cspNonceProvider->generateNonce()) ?>"<?php endif; ?>>
|
||||
requirejs(['jquery' ],
|
||||
function ($) {
|
||||
$(document).ready(function() {
|
||||
var wpSubmenu = $('#menu-weltpixel-backend-weltpixel > .submenu');
|
||||
function wpAdjustMenuWidth() {
|
||||
var windowWidth = $(window).width() - 80;
|
||||
|
||||
if (wpSubmenu && wpSubmenu.length) {
|
||||
if (wpSubmenu[0].scrollWidth > windowWidth) {
|
||||
wpSubmenu.css({
|
||||
'overflow-x': 'scroll',
|
||||
'width': windowWidth - 20,
|
||||
'max-width': windowWidth - 20
|
||||
});
|
||||
} else {
|
||||
wpSubmenu.css({
|
||||
'overflow-x': 'initial',
|
||||
'width': 'initial',
|
||||
'max-width': 'initial'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wpAdjustMenuWidth();
|
||||
$(window).resize(function(){
|
||||
wpAdjustMenuWidth();
|
||||
});
|
||||
|
||||
$(wpSubmenu).on('scroll', function(event) {
|
||||
$('.action-close').css('right', ( -1 * wpSubmenu.scrollLeft()) + 'px');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user