1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 02:27:19 +00:00

Fixed tag autocomplete popup on focus

This commit is contained in:
Jeremy Ruston 2013-10-23 17:41:12 +01:00
parent dfdb34a5cc
commit f2ac04943f
2 changed files with 32 additions and 4 deletions

View File

@ -54,9 +54,10 @@ EditTextWidget.prototype.render = function(parent,nextSibling) {
domNode.setAttribute("value",editInfo.value)
}
// Add an input event handler
domNode.addEventListener("input",function (event) {
return self.handleInputEvent(event);
},false);
$tw.utils.addEventListeners(domNode,[
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},
{name: "input", handlerObject: this, handlerMethod: "handleInputEvent"}
]);
// Insert the element into the DOM
parent.insertBefore(domNode,nextSibling);
this.domNodes.push(domNode);
@ -108,6 +109,15 @@ EditTextWidget.prototype.execute = function() {
this.editDefault = this.getAttribute("default","");
this.editClass = this.getAttribute("class");
this.editPlaceholder = this.getAttribute("placeholder");
this.editFocusSet = this.getAttribute("focusSet");
this.qualifyTiddlerTitles = this.getAttribute("qualifyTiddlerTitles");;
// Qualify tiddler titles if required
if(this.qualifyTiddlerTitles) {
var qualifier = this.getStateQualifier();
if(this.editFocusSet) {
this.editFocusSet = this.editFocusSet + "-" + qualifier;
}
}
// Get the editor element tag and type
var tag,type;
if(this.editField === "text") {
@ -186,6 +196,24 @@ EditTextWidget.prototype.handleInputEvent = function(event) {
return true;
};
EditTextWidget.prototype.handleFocusEvent = function(event) {
if(this.editFocusSet) {
console.log("Focus",{
domNode: this.domNodes[0],
title: this.editFocusSet,
wiki: this.wiki,
force: true
})
$tw.popup.triggerPopup({
domNode: this.domNodes[0],
title: this.editFocusSet,
wiki: this.wiki,
force: true
});
}
return true;
};
EditTextWidget.prototype.saveChanges = function() {
var text = this.domNodes[0].value
if(this.editField) {

View File

@ -30,7 +30,7 @@ Popup.prototype.show = function(options) {
};
Popup.prototype.handleEvent = function(event) {
if(event.type === "click" && !$tw.utils.domContains(this.anchorDomNode,event.target)) {
if(event.type === "click" && this.anchorDomNode !== event.target && !$tw.utils.domContains(this.anchorDomNode,event.target)) {
this.cancel();
}
};