1 parent 8e45689 commit 5773fb1Copy full SHA for 5773fb1
1 file changed
src/utils/menu.js
@@ -50,9 +50,11 @@ const menu = (() => {
50
}
51
if (typeof data.action === 'function') {
52
button.on('click', (e) => {
53
- data.action(e);
54
- if (data.close) {
55
- close();
+ if (typeof data.enabled !== 'function' || data.enabled()) {
+ data.action(e);
+ if (data.close) {
56
+ close();
57
+ }
58
59
}).css({
60
cursor: 'pointer',
@@ -83,12 +85,12 @@ const menu = (() => {
83
85
return menuOpen;
84
86
87
function addButton(button = {}) {
- if (!button || !button.text) throw new Error('Missing button information');
88
+ if (!button || !button.text) return fn.debug('Missing button information');
89
cooked = false;
- const { text, action, url, note } = button;
90
+ const { text, action, url, note, enabled } = button;
91
const close = (button.closeMenu || button.close) === true;
92
buttons.push({
- text, action, url, close, note
93
+ text, action, url, close, note, enabled
94
});
95
96
0 commit comments