Skip to content

Commit 63a7281

Browse files
author
maggiewachs
committed
Added two options to set the button style and add down arrow icons
1 parent 75afd33 commit 63a7281

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

tests/visual/menu/menubar.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77

88
// TODO take non-menubar buttons into account
99
$.widget("ui.menubar", {
10+
options: {
11+
buttons: false,
12+
menuIcon: false
13+
},
1014
_create: function() {
1115
var self = this;
1216
var items = this.element.children("button, a");
13-
17+
var o = this.options;
18+
1419
this.element.addClass('ui-menubar ui-widget-header ui-helper-clearfix');
1520

1621
items.next("ul").each(function(i, elm) {
@@ -42,18 +47,26 @@ $.widget("ui.menubar", {
4247
});
4348
items.each(function() {
4449
var input = $(this),
45-
menu = input.next("ul");
46-
input.bind("click focus mouseenter", function(event) {
47-
if (menu.length && (!/^mouse/.test(event.type) || self.active && self.active.is(":visible") )) {
48-
self._open(event, menu);
49-
}
50-
event.preventDefault();
51-
event.stopPropagation();
52-
}).button({
53-
icons: {
54-
secondary: menu.length ? 'ui-icon-triangle-1-s' : ''
55-
}
56-
});
50+
menu = input.next("ul");
51+
52+
input
53+
.bind("click focus mouseenter", function(event) {
54+
if (menu.length && (!/^mouse/.test(event.type) || self.active && self.active.is(":visible") )) {
55+
self._open(event, menu);
56+
}
57+
event.preventDefault();
58+
event.stopPropagation();
59+
})
60+
.button({
61+
icons: {
62+
secondary: o.menuIcon ? (menu.length ? 'ui-icon-triangle-1-s' : '') : ''
63+
}
64+
});
65+
66+
if (!o.buttons) {
67+
input.addClass('ui-menubar-link').removeClass('ui-state-default');
68+
};
69+
5770
});
5871
$(document).click(function(event) {
5972
!$(event.target).closest(".ui-menubar").length && items.next("ul").hide();

0 commit comments

Comments
 (0)