mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-10-04 15:11:41 +00:00
Popup manager enhancements
This commit is contained in:
@@ -25,9 +25,11 @@ var Popup = function(options) {
|
|||||||
/*
|
/*
|
||||||
Trigger a popup open or closed. Parameters are in a hashmap:
|
Trigger a popup open or closed. Parameters are in a hashmap:
|
||||||
title: title of the tiddler where the popup details are stored
|
title: title of the tiddler where the popup details are stored
|
||||||
domNode: dom node to which the popup will be positioned
|
domNode: dom node to which the popup will be positioned (one of domNode or domNodeRect is required)
|
||||||
|
domNodeRect: rectangle to which the popup will be positioned
|
||||||
wiki: wiki
|
wiki: wiki
|
||||||
force: if specified, forces the popup state to true or false (instead of toggling it)
|
force: if specified, forces the popup state to true or false (instead of toggling it)
|
||||||
|
floating: if true, skips registering the popup, meaning that it will need manually clearing
|
||||||
*/
|
*/
|
||||||
Popup.prototype.triggerPopup = function(options) {
|
Popup.prototype.triggerPopup = function(options) {
|
||||||
// Check if this popup is already active
|
// Check if this popup is already active
|
||||||
@@ -113,7 +115,7 @@ Popup.prototype.show = function(options) {
|
|||||||
// Cancel any higher level popups
|
// Cancel any higher level popups
|
||||||
this.cancel(info.popupLevel);
|
this.cancel(info.popupLevel);
|
||||||
// Store the popup details if not already there
|
// Store the popup details if not already there
|
||||||
if(this.findPopup(options.title) === -1) {
|
if(!options.floating && this.findPopup(options.title) === -1) {
|
||||||
this.popups.push({
|
this.popups.push({
|
||||||
title: options.title,
|
title: options.title,
|
||||||
wiki: options.wiki,
|
wiki: options.wiki,
|
||||||
@@ -121,9 +123,20 @@ Popup.prototype.show = function(options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Set the state tiddler
|
// Set the state tiddler
|
||||||
|
var rect;
|
||||||
|
if(options.domNodeRect) {
|
||||||
|
rect = options.domNodeRect;
|
||||||
|
} else {
|
||||||
|
rect = {
|
||||||
|
left: options.domNode.offsetLeft,
|
||||||
|
top: options.domNode.offsetTop,
|
||||||
|
width: options.domNode.offsetWidth,
|
||||||
|
height: options.domNode.offsetHeight
|
||||||
|
};
|
||||||
|
}
|
||||||
options.wiki.setTextReference(options.title,
|
options.wiki.setTextReference(options.title,
|
||||||
"(" + options.domNode.offsetLeft + "," + options.domNode.offsetTop + "," +
|
"(" + rect.left + "," + rect.top + "," +
|
||||||
options.domNode.offsetWidth + "," + options.domNode.offsetHeight + ")");
|
rect.width + "," + rect.height + ")");
|
||||||
// Add the click handler if we have any popups
|
// Add the click handler if we have any popups
|
||||||
if(this.popups.length > 0) {
|
if(this.popups.length > 0) {
|
||||||
this.rootElement.addEventListener("click",this,true);
|
this.rootElement.addEventListener("click",this,true);
|
||||||
|
|||||||
Reference in New Issue
Block a user