Skip to content

Commit

Permalink
Fix #19
Browse files Browse the repository at this point in the history
  • Loading branch information
magiccart committed Jun 25, 2024
1 parent 94141e7 commit 50a5f84
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion view/frontend/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var config = {

shim: {
'magicmenu': {
deps: ['jquery']
deps: ['jquery', 'easing']
},

}
Expand Down
4 changes: 1 addition & 3 deletions view/frontend/templates/accordion.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ $mobileMenu = $menuHtml['mobile'];
<div class="all-cat"><span><?php /* @escapeNotVerified */ echo __('All Categories')?></span><span style="display:none"><?php /* @escapeNotVerified */ echo __('Close')?></span></div>
</div>
</div>
<script type="text/javascript">
require(['jquery','easing','magicmenu']);
</script>
<script type="text/x-magento-init">{"body": {"magicmenu": {}}}</script>
4 changes: 1 addition & 3 deletions view/frontend/templates/aio-topmenu.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,4 @@ $drawExtraMenu = $menu['extraCat'] ? $extraHtml : '';
</ul>
</div>
<?php endif ?>
<script type="text/javascript">
require(['jquery','easing','magicmenu']);
</script>
<script type="text/x-magento-init">{"body": {"magicmenu": {}}}</script>
4 changes: 1 addition & 3 deletions view/frontend/templates/topmenu.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ $drawExtraMenu = $menu['extraCat'] ? $this->drawExtraMenu() : '';
<?php echo $drawExtraMenu ?>
</ul>
</div>
<script type="text/javascript">
require(['jquery','easing','magicmenu']);
</script>
<script type="text/x-magento-init">{"body": {"magicmenu": {}}}</script>
4 changes: 1 addition & 3 deletions view/frontend/templates/vmenu.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,4 @@ $classes = $vmenu['event'];
</ul>
</nav>
<?php endif; ?>
<script type="text/javascript">
require(['jquery','easing','magicmenu']);
</script>
<script type="text/x-magento-init">{"body": {"magicmenu": {}}}</script>
6 changes: 4 additions & 2 deletions view/frontend/web/js/magicmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
* @@Modify Date: 2021-10-19 09:16:29
* @@Function:
*/
require(['jquery', 'easing'], function($, easing){

define([
'jquery',
'easing'
], function ($, easing) {
!(function($){"use strict";$.fn.magicaccordion=function(options){var defaults={accordion:!0,mouseType:!1,speed:300,closedSign:'collapse',openedSign:'expand',openedActive:!1,};var methods={init:function(){return this.each(function(){var self=$(this);methods.menuLoad(self)})},menuLoad:function(self){var opts=$.extend(defaults,options);if(self.hasClass('menu-init'))return;self.addClass('menu-init');self.find("li").each(function(){if($(this).find("ul").length){$(this).find("ul").hide();$(this).find("a:first").after("<span class='"+opts.closedSign+"'>"+opts.closedSign+"</span>");if($(this).find("a:first").attr('href')=="#"){$(this).find("a:first").on('click',function(){return!1})}}});if(opts.openedActive){methods.openedActive(self)}if(opts.mouseType){self.find("li a").mouseenter(function(){methods.menuAction(self,$(this))})}else{self.find("li span").on('click',function(){methods.menuAction(self,$(this))})}var catplus=self.find('.nav-accordion >.level0:hidden').not('.all-cat');if(catplus.length){self.find('.all-cat').show().on('click',function(event){$(this).children().toggle();catplus.slideToggle('slow')})}else{self.find('.all-cat').hide()}},menuAction:function(self,item){var opts=$.extend(defaults,options);var parent=item.parent();if(parent.find("ul").length){if(opts.accordion){if(!parent.find("ul").is(':visible')){var parents=parent.parents("ul");var visible=self.find("ul:visible");visible.each(function(visibleIndex){var close=!0;parents.each(function(parentIndex){if(parents[parentIndex]==visible[visibleIndex]){close=!1;return!1}});if(close){if($(this).parent().find("ul")!=visible[visibleIndex]){$(visible[visibleIndex]).slideUp(opts.speed,function(){$(this).parent("li").find("a:first").next().html(opts.closedSign).addClass(opts.closedSign).removeClass(opts.openedSign)})}}})}}var parentFirst=parent.find("ul:first");if(parentFirst.is(":visible")){parentFirst.slideUp(opts.speed,function(){$(this).parent("li").find("a:first").next().delay(opts.speed+1000).html(opts.closedSign).removeClass(opts.openedSign).addClass(opts.closedSign)})}else{parentFirst.slideDown(opts.speed,function(){$(this).parent("li").find("a:first").next().delay(opts.speed+1000).html(opts.openedSign).removeClass(opts.closedSign).addClass(opts.openedSign)})}}},openedActive:function(self){var opts=$.extend(defaults,options);self.find("li.active").each(function(){$(this).parents("ul").slideDown(opts.speed,opts.easing);$(this).parents("ul").parent("li").find("a:first").next().html(opts.openedSign).removeClass(opts.closedSign).addClass(opts.openedSign);$(this).find("ul:first").slideDown(opts.speed,opts.easing);$(this).find("a:first").next().html(opts.openedSign).removeClass(opts.closedSign).addClass(opts.openedSign)})}};if(methods[options]){return methods[options].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof options==='object'||!options){return methods.init.apply(this)}else{$.error('Method "'+method+'" does not exist in magicaccordion plugin!')}}})(jQuery);
(function ($) {
"use strict";
Expand Down

0 comments on commit 50a5f84

Please sign in to comment.