@@ -134,34 +134,35 @@ define([
134
134
* If menu item has parent categories, sets 'has-active' class to all af them.
135
135
*
136
136
* @param {String } url - possible category URL
137
- * @returns {boolean } - true if active category was founded by provided URL, otherwise return false
137
+ * @returns {Boolean } - true if active category was founded by provided URL, otherwise return false
138
138
* @private
139
139
*/
140
140
_setActiveMenuForCategory : function ( url ) {
141
141
var activeCategoryLink = this . element . find ( 'a[href="' + url + '"]' ) ,
142
142
classes ,
143
143
classNav ;
144
144
145
- if ( activeCategoryLink && activeCategoryLink . hasClass ( 'ui-corner-all' ) ) {
145
+ if ( ! activeCategoryLink || ! activeCategoryLink . hasClass ( 'ui-corner-all' ) ) {
146
146
147
- if ( ! activeCategoryLink . parent ( ) . hasClass ( 'active' ) ) {
148
- activeCategoryLink . parent ( ) . addClass ( 'active' ) ;
149
- classes = activeCategoryLink . parent ( ) . attr ( 'class' ) ;
150
- classNav = classes . match ( / ( n a v \- ) [ 0 - 9 ] + ( \- [ 0 - 9 ] + ) + / gi) ;
147
+ //category was not found by provided URL
148
+ return false ;
149
+ } else if ( ! activeCategoryLink . parent ( ) . hasClass ( 'active' ) ) {
150
+ activeCategoryLink . parent ( ) . addClass ( 'active' ) ;
151
+ classes = activeCategoryLink . parent ( ) . attr ( 'class' ) ;
152
+ classNav = classes . match ( / ( n a v \- ) [ 0 - 9 ] + ( \- [ 0 - 9 ] + ) + / gi) ;
151
153
152
- if ( classNav ) {
153
- this . _setActiveParent ( classNav [ 0 ] ) ;
154
- }
154
+ if ( classNav ) {
155
+ this . _setActiveParent ( classNav [ 0 ] ) ;
155
156
}
156
- return true ;
157
157
}
158
- return false ;
158
+
159
+ return true ;
159
160
} ,
160
161
161
162
/**
162
163
* Sets 'has-active' CSS class to all parent categories which have part of provided class in childClassName
163
164
*
164
- * @example :
165
+ * @example
165
166
* childClassName - 'nav-1-2-3'
166
167
* CSS class 'has-active' will be added to categories have 'nav-1-2' and 'nav-1' classes
167
168
*
@@ -187,7 +188,7 @@ define([
187
188
* Tries to retrieve category URL from current URL and mark this category as active
188
189
* @see _setActiveMenuForCategory(url)
189
190
*
190
- * @example :
191
+ * @example
191
192
* currentUrl - http://magento.com/category1/category12/product.html,
192
193
* category URLs has extensions .phtml - http://magento.com/category1.phtml
193
194
* method sets active category which has URL http://magento.com/category1/category12.phtml
0 commit comments