mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-26 00:46:52 +00:00
Reveal widget should update on changed class and style attributes (#5258)
This commit is contained in:
parent
ae61b08ae5
commit
c0dd13d446
@ -35,9 +35,8 @@ RevealWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
tag = this.revealTag;
|
tag = this.revealTag;
|
||||||
}
|
}
|
||||||
var domNode = this.document.createElement(tag);
|
var domNode = this.document.createElement(tag);
|
||||||
var classes = this["class"].split(" ") || [];
|
this.domNode = domNode;
|
||||||
classes.push("tc-reveal");
|
this.assignDomNodeClasses();
|
||||||
domNode.className = classes.join(" ");
|
|
||||||
if(this.style) {
|
if(this.style) {
|
||||||
domNode.setAttribute("style",this.style);
|
domNode.setAttribute("style",this.style);
|
||||||
}
|
}
|
||||||
@ -110,7 +109,7 @@ RevealWidget.prototype.execute = function() {
|
|||||||
this.text = this.getAttribute("text");
|
this.text = this.getAttribute("text");
|
||||||
this.position = this.getAttribute("position");
|
this.position = this.getAttribute("position");
|
||||||
this.positionAllowNegative = this.getAttribute("positionAllowNegative") === "yes";
|
this.positionAllowNegative = this.getAttribute("positionAllowNegative") === "yes";
|
||||||
this["class"] = this.getAttribute("class","");
|
// class attribute handled in assignDomNodeClasses()
|
||||||
this.style = this.getAttribute("style","");
|
this.style = this.getAttribute("style","");
|
||||||
this["default"] = this.getAttribute("default","");
|
this["default"] = this.getAttribute("default","");
|
||||||
this.animate = this.getAttribute("animate","no");
|
this.animate = this.getAttribute("animate","no");
|
||||||
@ -203,6 +202,12 @@ RevealWidget.prototype.readPopupState = function(state) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RevealWidget.prototype.assignDomNodeClasses = function() {
|
||||||
|
var classes = this.getAttribute("class","").split(" ");
|
||||||
|
classes.push("tc-reveal");
|
||||||
|
this.domNode.className = classes.join(" ");
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||||||
*/
|
*/
|
||||||
@ -211,7 +216,12 @@ RevealWidget.prototype.refresh = function(changedTiddlers) {
|
|||||||
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex) {
|
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || changedAttributes.positionAllowNegative || changedAttributes["default"] || changedAttributes.animate || changedAttributes.stateTitle || changedAttributes.stateField || changedAttributes.stateIndex) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else if(changedAttributes.style) {
|
||||||
|
this.domNode.style = this.getAttribute("style");
|
||||||
|
} else if(changedAttributes["class"]) {
|
||||||
|
this.assignDomNodeClasses();
|
||||||
|
}
|
||||||
|
else {
|
||||||
var currentlyOpen = this.isOpen;
|
var currentlyOpen = this.isOpen;
|
||||||
this.readState();
|
this.readState();
|
||||||
if(this.isOpen !== currentlyOpen) {
|
if(this.isOpen !== currentlyOpen) {
|
||||||
@ -222,7 +232,7 @@ RevealWidget.prototype.refresh = function(changedTiddlers) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if(this.type === "popup" && this.updatePopupPosition && (changedTiddlers[this.state] || changedTiddlers[this.stateTitle])) {
|
} else if(this.type === "popup" && this.updatePopupPosition && (changedTiddlers[this.state] || changedTiddlers[this.stateTitle])) {
|
||||||
this.positionPopup(this.domNodes[0]);
|
this.positionPopup(this.domNode);
|
||||||
}
|
}
|
||||||
return this.refreshChildren(changedTiddlers);
|
return this.refreshChildren(changedTiddlers);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user