Recently I tried jquery's mbmenu control to display the control, which is quite powerful. I am a super JavaScript white, and I am also a little white on jquery. I can use this control with a good attitude. However, you may need to display a sub-menu on the left of the main menu. However, mbmenu displays sub-Menus under the main menu by default. You can also set it to display sub-menus on the right of the main menu, however, there is no function to display sub-menus on the left of the main menu. What should I do? You can only do it yourself. Fortunately, there is only one level sub-menu currently.
The Code involved in the modification is as an archive.
First, add an openonleft parameter. The first line is the added code.
1 options: {
2 template: "yourMenuVoiceTemplate", // the url that returns the menu voices via ajax. the data passed in the request is the "menu" attribute value as "menuId"
3 additionalData: "",
4 menuSelector: ".menuContainer",
5 menuWidth: 400,
6 openOnRight: false,
7 openOnLeft: false,
8 containment: "window",
9 iconPath: "ico/",
10 hasImages: true,
11 fadeInTime: 100,
12 fadeOutTime: 200,
13 menuTop: 0,
14 menuLeft: 0,
15 submenuTop: 0,
16 submenuLeft: 4,
17 opacity: 1,
18 openOnClick: true,
19 closeOnMouseOut: false,
20 closeAfter: 500,
21 minZindex: "auto", // or number
22 hoverIntent: 0, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
23 submenuHoverIntent: 200, //if you use jquery.hoverIntent.js set this to time in milliseconds; 0= false;
24 onContextualMenu: function () { } //it pass 'o' (the menu you clicked on) and 'e' (the event)
25 },
The following code contains the processing of openonleft. Lines 18th to 22 are the added code.
1 switch (type)
2 {
3 case "sm":
4 t = $(this).position().top + op.options.submenuTop;
5
6 l = $(this).position().left + $(this).width() - op.options.submenuLeft;
7 break;
8 case "cm":
9 t = this.mouseY - 5;
10 l = this.mouseX - 5;
11 break;
12 default:
13 if (op.options.openOnRight)
14 {
15 t = $(this).offset().top - ($.browser.msie ? 2 : 0) + op.options.menuTop;
16 l = $(this).offset().left + $(this).outerWidth() - op.options.menuLeft - ($.browser.msie ? 2 : 0);
17 }
18 else if (op.options.openOnLeft)
19 {
20 t = $(this).offset().top - ($.browser.msie ? 2 : 0) + op.options.menuTop;
21 l = $(this).offset().left - $(this.menuContainer).outerWidth() - op.options.menuLeft - ($.browser.msie ? 2 : 0);
22 }
23 else
24 {
25 t = $(this).offset().top + $(this).outerHeight() - (!$.browser.mozilla ? 2 : 0) + op.options.menuTop;
26 l = $(this).offset().left + op.options.menuLeft;
27 }
28 break;
29 }