Cleanup + fix popover.getContent can be a function and apply #4450 changes

This commit is contained in:
GogoVega 2024-06-02 20:16:10 +02:00
parent ca37d1ec9d
commit 6aae50294f
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B
2 changed files with 5 additions and 4 deletions

View File

@ -53,8 +53,8 @@
* Returns the popover object with the following properties/functions: * Returns the popover object with the following properties/functions:
* properties: * properties:
* - element : DOM element - the popover dom element * - element : DOM element - the popover dom element
* - content : string|function - the popover content
* functions: * functions:
* - getContent() - get the popover content
* - setContent(content) - change the popover content. This only works if the * - setContent(content) - change the popover content. This only works if the
* popover is not currently displayed. It does not * popover is not currently displayed. It does not
* change the content of a visible popover. * change the content of a visible popover.
@ -160,7 +160,7 @@ RED.popover = (function() {
var size = options.size||"default"; var size = options.size||"default";
var popupOffset = options.offset || 0; var popupOffset = options.offset || 0;
if (!deltaSizes[size]) { if (!deltaSizes[size]) {
throw new Error("Invalid RED.popover size value:" + size); throw new Error("Invalid RED.popover size value: " + size);
} }
var timer = null; var timer = null;
@ -420,7 +420,6 @@ RED.popover = (function() {
} }
var res = { var res = {
get element() { return div }, get element() { return div },
get content() { return content },
setContent: function(_content) { setContent: function(_content) {
content = _content; content = _content;
@ -471,7 +470,7 @@ RED.popover = (function() {
delay: { show: 750, hide: 50 } delay: { show: 750, hide: 50 }
}); });
popover.getContent = function () { popover.getContent = function () {
return content; return label();
} }
popover.setContent = function(newContent) { popover.setContent = function(newContent) {
content = newContent; content = newContent;

View File

@ -1560,6 +1560,7 @@
} }
} }
if ((typeof valid === "string") || !valid) { if ((typeof valid === "string") || !valid) {
this.element.addClass("input-error");
this.uiSelect.addClass("input-error"); this.uiSelect.addClass("input-error");
if (typeof valid === "string") { if (typeof valid === "string") {
let tooltip = this.element.data("tooltip"); let tooltip = this.element.data("tooltip");
@ -1571,6 +1572,7 @@
} }
} }
} else { } else {
this.element.removeClass("input-error");
this.uiSelect.removeClass("input-error"); this.uiSelect.removeClass("input-error");
const tooltip = this.element.data("tooltip"); const tooltip = this.element.data("tooltip");
if (tooltip) { if (tooltip) {