mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Update popup.js
This commit is contained in:
parent
8aa6427d67
commit
7811614d53
@ -148,17 +148,41 @@ Popup.prototype.show = function(options) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Detect if a Popup contains an input field that has focus
|
||||||
|
Returns true or false
|
||||||
|
*/
|
||||||
|
Popup.prototype.detectInputWithinPopup = function(node) {
|
||||||
|
var withinPopup = false;
|
||||||
|
for(var i=0; i<this.popups.length; i++) {
|
||||||
|
var popup = (this.popups[i] && this.popups[i].domNode) ? this.popups[i].domNode : null;
|
||||||
|
while(node && popup) {
|
||||||
|
if(node === popup || (node.classList && node.classList.contains("tc-popup-keep"))) {
|
||||||
|
withinPopup = true;
|
||||||
|
}
|
||||||
|
node = node.parentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return withinPopup;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Cancel all popups at or above a specified level or DOM node
|
Cancel all popups at or above a specified level or DOM node
|
||||||
level: popup level to cancel (0 cancels all popups)
|
level: popup level to cancel (0 cancels all popups)
|
||||||
*/
|
*/
|
||||||
Popup.prototype.cancel = function(level) {
|
Popup.prototype.cancel = function(level,focusedInputNode) {
|
||||||
var numPopups = this.popups.length;
|
var numPopups = this.popups.length;
|
||||||
level = Math.max(0,Math.min(level,numPopups));
|
level = Math.max(0,Math.min(level,numPopups));
|
||||||
for(var t=level; t<numPopups; t++) {
|
for(var t=level; t<numPopups; t++) {
|
||||||
var popup = this.popups.pop();
|
var inputWithinPopup;
|
||||||
if(popup.title) {
|
if(focusedInputNode) {
|
||||||
popup.wiki.deleteTiddler(popup.title);
|
inputWithinPopup = this.detectInputWithinPopup(focusedInputNode);
|
||||||
|
}
|
||||||
|
if(!inputWithinPopup) {
|
||||||
|
var popup = this.popups.pop();
|
||||||
|
if(popup.title) {
|
||||||
|
popup.wiki.deleteTiddler(popup.title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.popups.length === 0) {
|
if(this.popups.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user