Commit 27586412 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

FormGroup.js: tweaked readonly/enabled state display.

parent 447298dd
......@@ -92,12 +92,48 @@ if (!QfqNS.Element) {
};
n.FormGroup.prototype.setEnabled = function (enabled) {
this.$formGroup.data("enabled", enabled);
this.$element.prop('disabled', !enabled);
// Test if we're not readonly, if so set classes. This is required because we share `text-muted` with the
// readonly-state
if (this.$formGroup.data("readonly") !== true) {
if (enabled) {
this.$formGroup.removeClass("text-muted");
} else {
this.$formGroup.addClass("text-muted");
}
}
if (enabled) {
this.$label.removeClass("disabled");
this.$element.parents("div[class=radio]").removeClass("disabled");
} else {
this.$label.addClass("disabled");
this.$element.parents("div[class=radio]").addClass("disabled");
}
};
n.FormGroup.prototype.setReadOnly = function (readonly) {
this.$formGroup.data("readonly", readonly);
this.$element.prop('readonly', readonly);
this.handleReadOnlyEmulationIfRequired(readonly);
// Test if we're enabled, if so set classes. This is required because we share `text-muted` with the
// enabled-state
if (this.$formGroup.data("enabled") !== false) {
if (readonly) {
this.$formGroup.addClass("text-muted");
} else {
this.$formGroup.removeClass("text-muted");
}
}
if (readonly) {
this.$label.addClass("readonly");
} else {
this.$formGroup.removeClass("readonly");
}
};
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment