mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-08 23:20:03 +00:00
Starting to get the behaviour of the search popup more correct
This commit is contained in:
parent
42d4be3f20
commit
81a565e608
@ -15,10 +15,11 @@ Edit macro for editting fields and tiddlers
|
|||||||
exports.info = {
|
exports.info = {
|
||||||
name: "edit",
|
name: "edit",
|
||||||
params: {
|
params: {
|
||||||
field: {byPos: 0, type: "text"},
|
|
||||||
tiddler: {byName: true, type: "tiddler"},
|
tiddler: {byName: true, type: "tiddler"},
|
||||||
|
field: {byPos: 0, type: "text"},
|
||||||
type: {byName: true, type: "text"},
|
type: {byName: true, type: "text"},
|
||||||
"default": {byName: true, type: "text"}
|
"default": {byName: true, type: "text"},
|
||||||
|
requireFocus: {byName: true, type: "text"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,28 +81,34 @@ TextEditor.prototype.getChild = function() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Wrap the editor control in a div
|
// Wrap the editor control in a div
|
||||||
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content)],{
|
return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content,{
|
||||||
events: ["focus","keyup"],
|
events: ["focus","blur","keyup"],
|
||||||
eventHandler: this
|
eventHandler: this
|
||||||
});
|
})]);
|
||||||
};
|
};
|
||||||
|
|
||||||
TextEditor.prototype.handleEvent = function(event) {
|
TextEditor.prototype.handleEvent = function(event) {
|
||||||
|
console.log("event type",event.type);
|
||||||
// Get the value of the field if it might have changed
|
// Get the value of the field if it might have changed
|
||||||
if("keyup".split(" ").indexOf(event.type) !== -1) {
|
if("keyup focus blur".split(" ").indexOf(event.type) !== -1) {
|
||||||
this.saveChanges();
|
this.saveChanges();
|
||||||
}
|
}
|
||||||
// Whatever the event, fix the height of the textarea if required
|
// Fix the height of the textarea if required
|
||||||
|
if("keyup focus".split(" ").indexOf(event.type) !== -1) {
|
||||||
var self = this;
|
var self = this;
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
self.fixHeight();
|
self.fixHeight();
|
||||||
},5);
|
},5);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
TextEditor.prototype.saveChanges = function() {
|
TextEditor.prototype.saveChanges = function() {
|
||||||
var text = this.macroNode.child.children[0].domNode.value,
|
var text = this.macroNode.child.children[0].domNode.value,
|
||||||
tiddler = this.macroNode.wiki.getTiddler(this.macroNode.editTiddler);
|
tiddler = this.macroNode.wiki.getTiddler(this.macroNode.editTiddler);
|
||||||
|
if(this.macroNode.params.requireFocus === "yes" && document.activeElement !== this.macroNode.child.children[0].domNode) {
|
||||||
|
text = this.macroNode.params["default"] || "";
|
||||||
|
}
|
||||||
if(!tiddler) {
|
if(!tiddler) {
|
||||||
tiddler = new $tw.Tiddler({title: this.macroNode.editTiddler});
|
tiddler = new $tw.Tiddler({title: this.macroNode.editTiddler});
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,11 @@ title: $:/templates/PageTemplate
|
|||||||
* [[Docs]]
|
* [[Docs]]
|
||||||
*{{divider-vertical}}
|
*{{divider-vertical}}
|
||||||
|
|
||||||
|
<!-- Search box -->
|
||||||
<form class="form-search">
|
<form class="form-search">
|
||||||
|
|
||||||
{{search-query{
|
{{search-query{
|
||||||
<<edit tiddler:[[$:/search/text]] type:search>>
|
<<edit tiddler:[[$:/search/text]] type:search requireFocus:yes>>
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
<div style="position:absolute; z-index:1000;">
|
<div style="position:absolute; z-index:1000;">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user