1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +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:
Simon Huber 2019-10-12 15:08:52 +02:00 committed by Jeremy Ruston
parent 66b68f4a58
commit d01b781283
4 changed files with 8 additions and 52 deletions

View File

@ -79,7 +79,6 @@ function FramedEngine(options) {
// Add event listeners
$tw.utils.addEventListeners(this.domNode,[
{name: "click",handlerObject: this,handlerMethod: "handleClickEvent"},
{name: "focus",handlerObject: this,handlerMethod: "handleFocusEvent"},
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},
{name: "keydown",handlerObject: this.widget,handlerMethod: "handleKeydownEvent"}
]);
@ -154,16 +153,6 @@ FramedEngine.prototype.focus = function() {
}
};
/*
Handle the focus event
*/
FramedEngine.prototype.handleFocusEvent = function(event) {
if(this.widget.cancelPopups) {
this.widget.cancelPopups();
}
return true;
};
/*
Handle a click
*/

View File

@ -122,7 +122,6 @@ SimpleEngine.prototype.handleInputEvent = function(event) {
Handle a dom "focus" event
*/
SimpleEngine.prototype.handleFocusEvent = function(event) {
this.widget.cancelPopups();
if(this.widget.editFocusPopup) {
$tw.popup.triggerPopup({
domNode: this.domNode,

View File

@ -248,13 +248,6 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
}
};
/*
Cancel Popups
*/
EditTextWidget.prototype.cancelPopups = function() {
$tw.popup.cancel(0,this.engine.domNode);
};
/*
Handle a dom "keydown" event, which we'll bubble up to our container for the keyboard widgets benefit
*/

View File

@ -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) {