mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-17 15:21:22 +00:00
Restore previous popup mechanism (no cancelling when focusing inputs) (#4305)
* remove cancelpopups from factory.js * remove handleFocusEvent from framed engine * remove cancelPopups from simple engine * Update popup.js
This commit is contained in:
committed by
Jeremy Ruston
parent
66b68f4a58
commit
d01b781283
@@ -149,46 +149,21 @@ 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,
|
||||
currNode = node;
|
||||
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") || (node !== currNode && node.classList.contains("tc-popup-handle"))))) {
|
||||
withinPopup = true;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
return withinPopup;
|
||||
};
|
||||
|
||||
/*
|
||||
Cancel all popups at or above a specified level or DOM node
|
||||
level: popup level to cancel (0 cancels all popups)
|
||||
*/
|
||||
Popup.prototype.cancel = function(level,focusedInputNode) {
|
||||
Popup.prototype.cancel = function(level) {
|
||||
var numPopups = this.popups.length;
|
||||
level = Math.max(0,Math.min(level,numPopups));
|
||||
for(var t=level; t<numPopups; t++) {
|
||||
var inputWithinPopup;
|
||||
if(focusedInputNode) {
|
||||
inputWithinPopup = this.detectInputWithinPopup(focusedInputNode);
|
||||
}
|
||||
if(!inputWithinPopup) {
|
||||
var popup = this.popups.pop();
|
||||
if(popup.title) {
|
||||
if(popup.noStateReference) {
|
||||
popup.wiki.deleteTiddler(popup.title);
|
||||
} else {
|
||||
popup.wiki.deleteTiddler($tw.utils.parseTextReference(popup.title).title);
|
||||
}
|
||||
}
|
||||
var popup = this.popups.pop();
|
||||
if(popup.title) {
|
||||
if(popup.noStateReference) {
|
||||
popup.wiki.deleteTiddler(popup.title);
|
||||
} else {
|
||||
popup.wiki.deleteTiddler($tw.utils.parseTextReference(popup.title).title);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.popups.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user