kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Update the popup manager to allow popup state to be forced, rather than toggled
We'll be needing this shortlyprint-window-tiddler
rodzic
b3c6b51fc7
commit
2c8352c442
|
@ -48,21 +48,26 @@ 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
|
||||||
wiki: wiki
|
wiki: wiki
|
||||||
|
force: if specified, forces the popup state to true or false
|
||||||
*/
|
*/
|
||||||
Popup.prototype.triggerPopup = function(options) {
|
Popup.prototype.triggerPopup = function(options) {
|
||||||
// Get the current popup state tiddler
|
// Get the current popup state tiddler
|
||||||
var value = options.wiki.getTextReference(options.title,"");
|
var value = options.wiki.getTextReference(options.title,"");
|
||||||
// Check if the popup is open by checking whether it matches "(<x>,<y>)"
|
// Check if the popup is open by checking whether it matches "(<x>,<y>)"
|
||||||
var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/;
|
var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/,
|
||||||
if(popupLocationRegExp.test(value)) {
|
state = !popupLocationRegExp.test(value);
|
||||||
this.cancel();
|
if("force" in options) {
|
||||||
} else {
|
state = options.force;
|
||||||
|
}
|
||||||
|
if(state) {
|
||||||
// Set the position if we're opening it
|
// Set the position if we're opening it
|
||||||
this.cancel();
|
this.cancel();
|
||||||
options.wiki.setTextReference(options.title,
|
options.wiki.setTextReference(options.title,
|
||||||
"(" + options.domNode.offsetLeft + "," + options.domNode.offsetTop + "," +
|
"(" + options.domNode.offsetLeft + "," + options.domNode.offsetTop + "," +
|
||||||
options.domNode.offsetWidth + "," + options.domNode.offsetHeight + ")");
|
options.domNode.offsetWidth + "," + options.domNode.offsetHeight + ")");
|
||||||
this.show(options);
|
this.show(options);
|
||||||
|
} else {
|
||||||
|
this.cancel();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue