Support disabled attribute for menu item
This commit is contained in:
Родитель
7e255e969b
Коммит
bf26e27f90
|
@ -42,6 +42,11 @@ window.toolbar = new ToolbarView({
|
||||||
text: 'The 2nd DropdownItem',
|
text: 'The 2nd DropdownItem',
|
||||||
id: 'dropdown-item-2nd',
|
id: 'dropdown-item-2nd',
|
||||||
onClick: () => console.log('click dropdown-item-2nd'),
|
onClick: () => console.log('click dropdown-item-2nd'),
|
||||||
|
}, {
|
||||||
|
text: 'The 3rd DropdownItem',
|
||||||
|
id: 'dropdown-item-3rd',
|
||||||
|
disabled: true,
|
||||||
|
onClick: () => console.log('click dropdown-item-3rd'),
|
||||||
}, {
|
}, {
|
||||||
type: 'dropdown-divider',
|
type: 'dropdown-divider',
|
||||||
}, {
|
}, {
|
||||||
|
@ -77,4 +82,3 @@ window.toolbar = new ToolbarView({
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
}).render();
|
}).render();
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,3 @@ li.dropdown-item(role='presentation', class=classes, id=id)
|
||||||
span.text=text
|
span.text=text
|
||||||
if iconRight
|
if iconRight
|
||||||
span.icon-right(class=iconRight)
|
span.icon-right(class=iconRight)
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,25 @@ export function renderDropdownItem(dropdownItem) {
|
||||||
classes: [],
|
classes: [],
|
||||||
id: _.uniqueId('dropdown-item-'),
|
id: _.uniqueId('dropdown-item-'),
|
||||||
text: '',
|
text: '',
|
||||||
|
disabled: false,
|
||||||
iconLeft: null,
|
iconLeft: null,
|
||||||
iconRight: null,
|
iconRight: null,
|
||||||
tabindex: -1,
|
tabindex: -1,
|
||||||
onClick: null,
|
onClick: null,
|
||||||
}, dropdownItem);
|
}, dropdownItem);
|
||||||
|
|
||||||
|
if (options.disabled) {
|
||||||
|
options.classes = _.union(options.classes, ['disabled']);
|
||||||
|
}
|
||||||
|
|
||||||
const html = dropdownItemTemplate(options);
|
const html = dropdownItemTemplate(options);
|
||||||
const events = {};
|
const events = {};
|
||||||
|
|
||||||
const { id, onClick } = options;
|
const { id, onClick } = options;
|
||||||
|
|
||||||
if (_.isFunction(onClick)) {
|
if (_.isFunction(onClick) && !options.disabled) {
|
||||||
events[`click .dropdown-item#${id}`] = onClick;
|
events[`click .dropdown-item#${id}`] = onClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { html, events };
|
return { html, events };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"main": "dist/backbone-toolbar.js",
|
"main": "dist/backbone-toolbar.js",
|
||||||
"version": "0.0.5",
|
"version": "0.1.1",
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
|
|
Загрузка…
Ссылка в новой задаче