Joris van der Burgh avatar Joris van der Burgh committed 3921001

added some minor improvements

Comments (0)

Files changed (3)

jquery-simplemenu.js

             itemselector: 'li',
             childselector: 'ul',
             
+			itemActiveClass: '',
+			
 			closeDelay: 200,
             
 			hideFn: function(el) {
             }
             
             me.delegate(opts.itemselector,'mouseover', function(e) {
-                 var self = $(this),
-                     submenu = self.children(opts.childselector),
-                     to = self.data(menuCloseTimeoutKey);
-                if(submenu.length < 1) { return; }
-                if(to) {
-                    clearTimeout(to);
-                    self.data(menuCloseTimeoutKey,null);
-                }
+				var self = $(this),
+					 submenu = self.children(opts.childselector),
+					 to = self.data(menuCloseTimeoutKey);
+				if(submenu.length < 1) { return; }
+				if(to) {
+					clearTimeout(to);
+					self.data(menuCloseTimeoutKey,null);
+				}
                 
-                submenu.trigger(eventNameOpen, [submenu, self, me]);
-                opts.showFn(submenu);
+				submenu.trigger(eventNameOpen, [submenu, self, me]);
+				if(opts.itemActiveClass) {
+					self.addClass(opts.itemActiveClass);
+				}
+				opts.showFn(submenu);
+				
             });
             me.delegate(opts.itemselector,'mouseout', function(e) {
-                 var self = $(this),
-                     to = self.data(menuCloseTimeoutKey),
-                     submenu = self.children(opts.childselector);
-                if(submenu.length < 1) { return; }
-                if(to) { clearTimeout(to); }
-                to = setTimeout(function() {
-                     self.data(menuCloseTimeoutKey,null);
-                     submenu.trigger(eventNameClose, [submenu, self, me]);
-                     opts.hideFn(self.children(opts.childselector));
-                }, opts.closeDelay || 100);
-                self.data(menuCloseTimeoutKey, to);
+				var self = $(this),
+					 to = self.data(menuCloseTimeoutKey),
+					 submenu = self.children(opts.childselector);
+				if(submenu.length < 1) { return; }
+				if(to) { clearTimeout(to); }
+				to = setTimeout(function() {
+				     self.data(menuCloseTimeoutKey,null);
+				     submenu.trigger(eventNameClose, [submenu, self, me]);
+				     opts.hideFn(submenu);
+					 if(opts.itemActiveClass) {
+						self.removeClass(opts.itemActiveClass);
+					 }
+				}, opts.closeDelay || 100);
+				self.data(menuCloseTimeoutKey, to);
             });
             
             if(opts.autoPositionSubmenus) {
 	//$.fn.simplemenu.EVENT_OPEN = eventNameOpen;
 	//$.fn.simplemenu.EVENT_CLOSE = eventNameClose; 
 	
-}(jQuery));
+})(jQuery);
 

jquery-simplemenu.min.js

  * jQuery Simple Menu v0.3
  * (c) 2012 J.B. van der Burgh
  */
- (function(e){function g(a,f){var b=[],c=0,d=f.autoDecoratePrefix||"x-level-";for(b.push(a);0<b.length;){c++;var e=b.pop().addClass(d+c).children("li").addClass(d+c).children("ul");0<e.length&&b.push(e)}}var h={hidechildren:!1,autoStyle:!1,autoPositionSubmenus:!1,autoDecorate:!1,itemselector:"li",childselector:"ul",closeDelay:200,hideFn:function(a){a.stop(!0,!0).hide()},showFn:function(a){a.stop(!0,!0).show()}};e.fn.simplemenu=function(a){a=e.extend({},h,a||{});a.autoStyle&&this.find("li").css({"float":"left",
+(function(e){function g(a,f){var b=[],c=0,d=f.autoDecoratePrefix||"x-level-";for(b.push(a);0<b.length;){c++;var e=b.pop().addClass(d+c).children("li").addClass(d+c).children("ul");0<e.length&&b.push(e)}}var h={hidechildren:!1,autoStyle:!1,autoPositionSubmenus:!1,autoDecorate:!1,itemselector:"li",childselector:"ul",itemActiveClass:"",closeDelay:200,hideFn:function(a){a.stop(!0,!0).hide()},showFn:function(a){a.stop(!0,!0).show()}};e.fn.simplemenu=function(a){a=e.extend({},h,a||{});a.autoStyle&&this.find("li").css({"float":"left",
 position:"relative",padding:"0 5px 0 5px"}).end().find("ul").css({position:"absolute",display:"none",left:0}).andSelf().css("display","block").end();a.autoDecorate&&g(this,a);return this.each(function(){var f=e(this);a.hidechildren&&f.find(a.childselector).hide();f.delegate(a.itemselector,"mouseover",function(){var b=e(this),c=b.children(a.childselector),d=b.data("simplemenu-menu-close-timeout");1>c.length||(d&&(clearTimeout(d),b.data("simplemenu-menu-close-timeout",null)),c.trigger("simplemenu:open",
-[c,b,f]),a.showFn(c))});f.delegate(a.itemselector,"mouseout",function(){var b=e(this),c=b.data("simplemenu-menu-close-timeout"),d=b.children(a.childselector);1>d.length||(c&&clearTimeout(c),c=setTimeout(function(){b.data("simplemenu-menu-close-timeout",null);d.trigger("simplemenu:close",[d,b,f]);a.hideFn(b.children(a.childselector))},a.closeDelay||100),b.data("simplemenu-menu-close-timeout",c))});a.autoPositionSubmenus&&f.delegate("li li ul","simplemenu:open",function(a,c,d){c.css({top:0,left:10+
-parseInt(d.width(),10)+"px"})})})}})(jQuery);
+[c,b,f]),a.itemActiveClass&&b.addClass(a.itemActiveClass),a.showFn(c))});f.delegate(a.itemselector,"mouseout",function(){var b=e(this),c=b.data("simplemenu-menu-close-timeout"),d=b.children(a.childselector);1>d.length||(c&&clearTimeout(c),c=setTimeout(function(){b.data("simplemenu-menu-close-timeout",null);d.trigger("simplemenu:close",[d,b,f]);a.hideFn(d);a.itemActiveClass&&b.removeClass(a.itemActiveClass)},a.closeDelay||100),b.data("simplemenu-menu-close-timeout",c))});a.autoPositionSubmenus&&f.delegate("li li ul",
+"simplemenu:open",function(a,c,d){c.css({top:0,left:10+parseInt(d.width(),10)+"px"})})})}})(jQuery);
 			
 				var menu = $('.menu');
 				
-				
 				//create the menu
 				menu.simplemenu({
 					//hidechildren: false,
 					//autoStyle: false,
 					autoPositionSubmenus: false,
-					
+					//itemActiveClass: 'active-item',
 					//autoDecorate: true,
 					//autoDecoratePrefix: 'x-menu x-menu-level-',
 					
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.