* standard validation constraints are checked. The function should return
* `true` to accept the given input value. Any other return value type is
* converted to a string and treated as validation error message.
+ *
+ * @property {boolean} [disabled=false]
+ * Specifies whether the widget should be rendered in disabled state
+ * (`true`) or not (`false`). Disabled widgets cannot be interacted with
+ * and are displayed in a slightly faded style.
*/
/**
'type': this.options.password ? 'password' : 'text',
'class': this.options.password ? 'cbi-input-password' : 'cbi-input-text',
'readonly': this.options.readonly ? '' : null,
+ 'disabled': this.options.disabled ? '' : null,
'maxlength': this.options.maxlength,
'placeholder': this.options.placeholder,
'value': this.value,
'name': this.options.name,
'class': 'cbi-input-textarea',
'readonly': this.options.readonly ? '' : null,
+ 'disabled': this.options.disabled ? '' : null,
'placeholder': this.options.placeholder,
'style': !this.options.cols ? 'width:100%' : null,
'cols': this.options.cols,
'type': 'checkbox',
'value': this.options.value_enabled,
'checked': (this.value == this.options.value_enabled) ? '' : null,
+ 'disabled': this.options.disabled ? '' : null,
'data-widget-id': this.options.id ? 'widget.' + this.options.id : null
}));
'name': this.options.name,
'size': this.options.size,
'class': 'cbi-input-select',
- 'multiple': this.options.multiple ? '' : null
+ 'multiple': this.options.multiple ? '' : null,
+ 'disabled': this.options.disabled ? '' : null
}));
if (this.options.optional)
'type': this.options.multiple ? 'checkbox' : 'radio',
'class': this.options.multiple ? 'cbi-input-checkbox' : 'cbi-input-radio',
'value': keys[i],
- 'checked': (this.values.indexOf(keys[i]) > -1) ? '' : null
+ 'checked': (this.values.indexOf(keys[i]) > -1) ? '' : null,
+ 'disabled': this.options.disabled ? '' : null
}),
this.choices[keys[i]] || keys[i]
]));
'class': 'cbi-dropdown',
'multiple': this.options.multiple ? '' : null,
'optional': this.options.optional ? '' : null,
+ 'disabled': this.options.disabled ? '' : null
}, E('ul'));
var keys = Object.keys(this.choices);
'id': this.options.id ? 'widget.' + this.options.id : null,
'type': 'text',
'class': 'cbi-input-text',
- 'placeholder': this.options.placeholder
+ 'placeholder': this.options.placeholder,
+ 'disabled': this.options.disabled ? '' : null
});
dl.lastElementChild.appendChild(inputEl);
var dl = ev.currentTarget,
item = findParent(ev.target, '.item');
+ if (this.options.disabled)
+ return;
+
if (item) {
this.removeItem(dl, item);
}
return this.bind(E('div', { 'id': this.options.id }, [
E('button', {
'class': 'btn',
- 'click': UI.prototype.createHandlerFn(this, 'handleFileBrowser')
+ 'click': UI.prototype.createHandlerFn(this, 'handleFileBrowser'),
+ 'disabled': this.options.disabled ? '' : null
}, label),
E('div', {
'class': 'cbi-filebrowser'