|
7 | 7 |
|
8 | 8 | // TODO take non-menubar buttons into account
|
9 | 9 | $.widget("ui.menubar", {
|
| 10 | + options: { |
| 11 | + buttons: false, |
| 12 | + menuIcon: false |
| 13 | + }, |
10 | 14 | _create: function() {
|
11 | 15 | var self = this;
|
12 | 16 | var items = this.element.children("button, a");
|
13 |
| - |
| 17 | + var o = this.options; |
| 18 | + |
14 | 19 | this.element.addClass('ui-menubar ui-widget-header ui-helper-clearfix');
|
15 | 20 |
|
16 | 21 | items.next("ul").each(function(i, elm) {
|
@@ -42,18 +47,26 @@ $.widget("ui.menubar", {
|
42 | 47 | });
|
43 | 48 | items.each(function() {
|
44 | 49 | 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 | + |
57 | 70 | });
|
58 | 71 | $(document).click(function(event) {
|
59 | 72 | !$(event.target).closest(".ui-menubar").length && items.next("ul").hide();
|
|
0 commit comments