1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Update edit widget to trigger a popup when focussed

This will allow us to do autocompletion
This commit is contained in:
Jeremy Ruston 2013-06-09 19:27:45 +01:00
parent e4aa80b277
commit 2c20e6579d

View File

@ -76,6 +76,11 @@ TextEditor.prototype.render = function() {
node.attributes.value = {type: "string", value: editInfo.value};
break;
}
node.events = [
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},
{name: "blur", handlerObject: this, handlerMethod: "handleBlurEvent"},
{name: "input", handlerObject: this, handlerMethod: "handleInputEvent"}
];
// Add a placeholder if specified
if(this.editWidget.renderer.hasAttribute("placeholder")) {
node.attributes.placeholder = {type: "string", value: this.editWidget.renderer.getAttribute("placeholder")};
@ -93,22 +98,38 @@ TextEditor.prototype.render = function() {
this.editWidget.attributes.style += this.editWidget.renderer.getAttribute("style");
}
this.editWidget.children = this.editWidget.renderer.renderTree.createRenderers(this.editWidget.renderer,[node]);
this.editWidget.events = [
{name: "focus", handlerObject: this},
{name: "blur", handlerObject: this},
{name: "input", handlerObject: this}
];
};
TextEditor.prototype.handleEvent = function(event) {
// Get the value of the field if it might have changed
if(["input","focus","blur"].indexOf(event.type) !== -1) {
this.saveChanges();
}
// Fix the height of the textarea if required
if(["input","focus"].indexOf(event.type) !== -1) {
this.fixHeight();
TextEditor.prototype.setFocus = function() {
if(this.editWidget.renderer.hasAttribute("focusSet")) {
var title = this.editWidget.renderer.getAttribute("focusSet");
if(this.editWidget.renderer.getAttribute("qualifyTiddlerTitles") === "yes") {
title = title + "-" + this.editWidget.renderer.renderTree.getContextScopeId(this.editWidget.renderer.parentRenderer);
}
$tw.popup.triggerPopup({
domNode: this.editWidget.renderer.domNode,
title: title,
wiki: this.editWidget.renderer.renderTree.wiki,
force: true
});
}
};
TextEditor.prototype.handleFocusEvent = function(event) {
// this.saveChanges();
// this.fixHeight();
this.setFocus();
return true;
};
TextEditor.prototype.handleBlurEvent = function(event) {
// this.saveChanges();
return true;
};
TextEditor.prototype.handleInputEvent = function(event) {
this.saveChanges();
this.fixHeight();
return true;
};