AntonLV 8 лет назад
Родитель
Сommit
db8f5e1305
2 измененных файлов с 27 добавлено и 28 удалено
  1. 26 27
      inc/js/classes/BxDolMenuMoreAuto.js
  2. 1 1
      template/scripts/BxBaseMenuCustom.php

+ 26 - 27
inc/js/classes/BxDolMenuMoreAuto.js

@@ -16,44 +16,43 @@ function BxDolMenuMoreAuto(options)
     this._sClassItem = '.bx-menu-item';
     this._sClassItemMore = this._sClassItem + '.bx-menu-item-more-auto';
     this._sClassItemMoreSubmenu = '.bx-menu-submenu-more-auto';
-
-    var $this = this;
-    $(document).ready(function () {
-        $this.init();
-
-        $(window).on('resize', function() {
-           $this.update();
-        });
-
-        $($this._sClassItem).on('resize', function() {
-            $this.update(true);
-        });
-    });
 }
 
 BxDolMenuMoreAuto.prototype.init = function() {
     var $this = this;
 
-    $('.bx-menu-object-' + this._sObject).each(function() {
-        var oMenu = $(this);
-        var oItemMore = oMenu.find($this._sClassItemMore);
-        var oItemMoreSubmenu = oItemMore.find($this._sClassItemMoreSubmenu);
+    $(document).ready(function() {
+        //--- Initialize ---//
+        $('.bx-menu-object-' + $this._sObject).each(function() {
+            var oMenu = $(this);
+            var oItemMore = oMenu.find($this._sClassItemMore);
+            var oItemMoreSubmenu = oItemMore.find($this._sClassItemMoreSubmenu);
 
-        var iMenu = 0;
-        oMenu.children($this._sClassItem + ':visible').each(function() {
-            iMenu += $this._getWidth($(this));
-        });
+            var iMenu = 0;
+            oMenu.children($this._sClassItem + ':visible').each(function() {
+                iMenu += $this._getWidth($(this));
+            });
 
-        var iParent = oMenu.parent().width();
+            var iParent = oMenu.parent().width();
 
-        var iItemMore = oItemMore.outerWidth(true);
+            var iItemMore = oItemMore.outerWidth(true);
 
-        oMenu.css('overflow', 'visible');
+            oMenu.css('overflow', 'visible');
 
-        if(iMenu < iParent)
-            return;
+            if(iMenu < iParent)
+                return;
+
+            $this._moveToSubmenu(oMenu, oItemMore, oItemMoreSubmenu, iParent, iItemMore);
+        });
+
+        //--- Add event handlers ---//
+        $(window).on('resize', function() {
+           $this.update();
+        });
 
-        $this._moveToSubmenu(oMenu, oItemMore, oItemMoreSubmenu, iParent, iItemMore);
+        $($this._sClassItem).on('resize', function() {
+            $this.update(true);
+        });
     });
 };
 

+ 1 - 1
template/scripts/BxBaseMenuCustom.php

@@ -81,7 +81,7 @@ class BxBaseMenuCustom extends BxTemplMenu
             'sObject' => $this->_sObject,
             'aHtmlIds' => $this->_aHtmlIds
         );
-        return $this->_oTemplate->_wrapInTagJsCode("if(!" . $this->_sJsObjectMoreAuto . ") var " . $this->_sJsObjectMoreAuto . " = new BxDolMenuMoreAuto(" . json_encode($aParams) . ");");
+        return $this->_oTemplate->_wrapInTagJsCode("if(!" . $this->_sJsObjectMoreAuto . ") var " . $this->_sJsObjectMoreAuto . " = new BxDolMenuMoreAuto(" . json_encode($aParams) . "); " . $this->_sJsObjectMoreAuto . ".init();");
     }
 
     protected function _getMenuItem ($aItem)