mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-27 04:25:15 +00:00
@@ -56,32 +56,39 @@ RevealWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
RevealWidget.prototype.positionPopup = function(domNode) {
|
RevealWidget.prototype.positionPopup = function(domNode) {
|
||||||
domNode.style.position = "absolute";
|
domNode.style.position = "absolute";
|
||||||
domNode.style.zIndex = "1000";
|
domNode.style.zIndex = "1000";
|
||||||
|
var left,top;
|
||||||
switch(this.position) {
|
switch(this.position) {
|
||||||
case "left":
|
case "left":
|
||||||
domNode.style.left = Math.max(0, this.popup.left - domNode.offsetWidth) + "px";
|
left = this.popup.left - domNode.offsetWidth;
|
||||||
domNode.style.top = this.popup.top + "px";
|
top = this.popup.top;
|
||||||
break;
|
break;
|
||||||
case "above":
|
case "above":
|
||||||
domNode.style.left = this.popup.left + "px";
|
left = this.popup.left;
|
||||||
domNode.style.top = Math.max(0, this.popup.top - domNode.offsetHeight) + "px";
|
top = this.popup.top - domNode.offsetHeight;
|
||||||
break;
|
break;
|
||||||
case "aboveright":
|
case "aboveright":
|
||||||
domNode.style.left = (this.popup.left + this.popup.width) + "px";
|
left = this.popup.left + this.popup.width;
|
||||||
domNode.style.top = Math.max(0, this.popup.top + this.popup.height - domNode.offsetHeight) + "px";
|
top = this.popup.top + this.popup.height - domNode.offsetHeight;
|
||||||
break;
|
break;
|
||||||
case "right":
|
case "right":
|
||||||
domNode.style.left = (this.popup.left + this.popup.width) + "px";
|
left = this.popup.left + this.popup.width;
|
||||||
domNode.style.top = this.popup.top + "px";
|
top = this.popup.top;
|
||||||
break;
|
break;
|
||||||
case "belowleft":
|
case "belowleft":
|
||||||
domNode.style.left = Math.max(0, this.popup.left + this.popup.width - domNode.offsetWidth) + "px";
|
left = this.popup.left + this.popup.width - domNode.offsetWidth;
|
||||||
domNode.style.top = (this.popup.top + this.popup.height) + "px";
|
top = this.popup.top + this.popup.height;
|
||||||
break;
|
break;
|
||||||
default: // Below
|
default: // Below
|
||||||
domNode.style.left = this.popup.left + "px";
|
left = this.popup.left;
|
||||||
domNode.style.top = (this.popup.top + this.popup.height) + "px";
|
top = this.popup.top + this.popup.height;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(!this.positionAllowNegative) {
|
||||||
|
left = Math.max(0,left);
|
||||||
|
top = Math.max(0,top);
|
||||||
|
}
|
||||||
|
domNode.style.left = left + "px";
|
||||||
|
domNode.style.top = top + "px";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -94,6 +101,7 @@ RevealWidget.prototype.execute = function() {
|
|||||||
this.type = this.getAttribute("type");
|
this.type = this.getAttribute("type");
|
||||||
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["class"] = this.getAttribute("class","");
|
this["class"] = this.getAttribute("class","");
|
||||||
this.style = this.getAttribute("style","");
|
this.style = this.getAttribute("style","");
|
||||||
this["default"] = this.getAttribute("default","");
|
this["default"] = this.getAttribute("default","");
|
||||||
@@ -191,7 +199,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
|
|||||||
*/
|
*/
|
||||||
RevealWidget.prototype.refresh = function(changedTiddlers) {
|
RevealWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
if(changedAttributes.state || changedAttributes.type || changedAttributes.text || changedAttributes.position || 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 {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
caption: reveal
|
caption: reveal
|
||||||
created: 20131024141900000
|
created: 20131024141900000
|
||||||
jeremy: tiddlywiki
|
jeremy: tiddlywiki
|
||||||
modified: 20181007231748909
|
modified: 20190704145627537
|
||||||
tags: Widgets
|
tags: Widgets
|
||||||
title: RevealWidget
|
title: RevealWidget
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@@ -34,6 +34,7 @@ The content of the `<$reveal>` widget is displayed according to the rules given
|
|||||||
|class |An optional CSS class name to be assigned to the HTML element<br/>» Set to `tc-popup-keep` to make a popup "sticky", so it won't close when you click inside of it|
|
|class |An optional CSS class name to be assigned to the HTML element<br/>» Set to `tc-popup-keep` to make a popup "sticky", so it won't close when you click inside of it|
|
||||||
|style |An optional CSS style attribute to be assigned to the HTML element |
|
|style |An optional CSS style attribute to be assigned to the HTML element |
|
||||||
|position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveright'', ''right'', ''belowleft'' or ''below'' |
|
|position |The position used for the popup when the type is ''popup''. Can be ''left'', ''above'', ''aboveright'', ''right'', ''belowleft'' or ''below'' |
|
||||||
|
|positionAllowNegative |Set to "yes" to prevent computed popup positions from being clamped to be above zero |
|
||||||
|default |Default value to use when the state tiddler is missing |
|
|default |Default value to use when the state tiddler is missing |
|
||||||
|animate |Set to "yes" to animate opening and closure (defaults to "no") |
|
|animate |Set to "yes" to animate opening and closure (defaults to "no") |
|
||||||
|retain |Set to "yes" to force the content to be retained even when hidden (defaults to "no") |
|
|retain |Set to "yes" to force the content to be retained even when hidden (defaults to "no") |
|
||||||
|
|||||||
Reference in New Issue
Block a user