Support disabled attribute for menu item

This commit is contained in:
Wei Wei 2017-04-23 17:40:14 +08:00
Родитель 7e255e969b
Коммит bf26e27f90
4 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -42,6 +42,11 @@ window.toolbar = new ToolbarView({
text: 'The 2nd DropdownItem',
id: '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',
}, {
@ -77,4 +82,3 @@ window.toolbar = new ToolbarView({
},
}],
}).render();

Просмотреть файл

@ -5,4 +5,3 @@ li.dropdown-item(role='presentation', class=classes, id=id)
span.text=text
if iconRight
span.icon-right(class=iconRight)

Просмотреть файл

@ -6,20 +6,25 @@ export function renderDropdownItem(dropdownItem) {
classes: [],
id: _.uniqueId('dropdown-item-'),
text: '',
disabled: false,
iconLeft: null,
iconRight: null,
tabindex: -1,
onClick: null,
}, dropdownItem);
if (options.disabled) {
options.classes = _.union(options.classes, ['disabled']);
}
const html = dropdownItemTemplate(options);
const events = {};
const { id, onClick } = options;
if (_.isFunction(onClick)) {
if (_.isFunction(onClick) && !options.disabled) {
events[`click .dropdown-item#${id}`] = onClick;
}
return { html, events };
}

Просмотреть файл

@ -1,6 +1,6 @@
{
"main": "dist/backbone-toolbar.js",
"version": "0.0.5",
"version": "0.1.1",
"files": [
"dist"
],