Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/design/frontend/Cnc/default/Magento_Theme/web/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/design/frontend/Cnc/default/Magento_Theme/web/js/menu-nav.js
/**
 * @license http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @author Romain Cuillerier <[email protected]>
 * @copyright Copyright (c) 2019 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com/)
 */
define([
    "jquery",
    "tools",
    "mage/translate"
], function ($, tools) {
    "use strict";

    $(function () {

        // Desktop menu
        var desktopMenu = {
            body:               $('body'),
            menu:               $('.nav-sections-item-content > .navigation'),
            menuItems:          $('li.level0'),
            subMenuItems:       $('.level0.submenu > li'),
            subMenuItemsLink:   $('.level0.submenu > li > a'),
            menuVisited:        false,

            init: function(){
                this.menuHover();
                this.cursorNavigationDesktop();
            },

            menuHover: function(){
                var self = this;
                var timer;
                var delay = 200;
                var animationTiming = 300;

                // LEVEL 0 - Menu
                self.menu.hover(function() {
                    self.menuVisited = true;
                }, function() {
                    self.menuVisited = false;
                    $('.overlay').stop(true, true).removeClass('is-visible');
                });

                // LEVEL 0 - Menu items
                self.menuItems.mouseenter(function(){
                    var el = $(this);

                    if(!el.hasClass('parent')) {
                        $('.overlay').stop(true, true).removeClass('is-visible');
                    } else {
                        if (!self.menuVisited){
                            timer = setTimeout(function () {
                                el.addClass('is-active').find($('ul.level0 > li.parent:first-child')).addClass('is-active');
                                $('.overlay').stop(true, true).delay(delay).addClass('is-visible');
                            }, delay);
                        } else {
                            el.addClass('is-active').find($('ul.level0 > li.parent:first-child')).addClass('is-active');
                            $('.overlay').stop(true, true).delay(delay).addClass('is-visible');
                        }
                    }

                })
                    .mouseleave(function(){
                        $(this).removeClass('is-active');
                        self.subMenuItems.removeClass('is-active');
                        clearTimeout(timer);
                    });

                // LEVEL 1 - Submenu
                self.subMenuItemsLink.on('mouseenter', function () {
                    self.subMenuItems.removeClass('is-active');
                    $(this).parent().addClass('is-active');
                });
            },

            cursorNavigationDesktop: function () {
                var mainNavigationItem = $('.navigation > ul > li');

                /**
                 * Create navigation section cursor html
                 */
                $('.nav-sections-item-content').append('<div class="nav-sections-cursor"><span></span></div>');

                /**
                 * Show navigation section cursor and move it under item overflown
                 */
                mainNavigationItem.on('mouseenter', function () {
                    var navItemPosition = $(this).offset().left,
                        navItemWidth = $(this).width() / 2;

                    $('.nav-sections-cursor').addClass('is-visible');
                    $('.nav-sections-cursor > span').css('left',navItemPosition + navItemWidth);
                });

                /**
                 * Hide navigation section cursor
                 */
                mainNavigationItem.on('mouseleave', function () {
                    $('.nav-sections-cursor').removeClass('is-visible');
                });
            },
        };


        // Mobile menu
        var mobileMenu = {
            navigationItemsLink:   $('.navigation li.parent > a.level-top'),
            navigationItemsLevel0:  $('.navigation li.level0.parent a.level-top'),

            init: function(){
                this.menuNavigationMobile();
            },

            menuNavigationMobile: function() {
                var self = this;

                /**
                 * Append Link to redirect to parent category page
                 */
                self.navigationItemsLevel0.each(function() {
                    var elementHref =  $(this).attr('href');
                    $(this).next('.submenu-container').find('.submenu')
                        .prepend('<li class="see-all"><a href="' + elementHref + '">' + $.mage.__("View all") + '</a></li>');
                });

                /**
                 * Display Menu Item
                 */
                self.navigationItemsLink.on('click', function (e) {
                    /**
                     * Break link redirection
                     */
                    e.preventDefault();

                    /**
                     * Add parent classname to display sub level
                     */
                    if($(this).parent().hasClass('is-active')) {
                        $(this).parent().removeClass('is-active');
                    } else {
                        $('.navigation li.parent').removeClass('is-active');
                        $(this).parent().addClass('is-active');
                    }
                })
            }
        };

        if(tools.windowWidth > tools.xl){
            desktopMenu.init();
        } else {
            mobileMenu.init();
        }
    });
});

Spamworldpro Mini