mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 17:40:29 +00:00
Extend the tiddler button so that it can set a tiddler to a given value
This commit is contained in:
parent
05eeacd270
commit
7346a146f0
@ -17,6 +17,8 @@ exports.info = {
|
|||||||
params: {
|
params: {
|
||||||
message: {byName: "default", type: "text"},
|
message: {byName: "default", type: "text"},
|
||||||
param: {byName: true, type: "text"},
|
param: {byName: true, type: "text"},
|
||||||
|
set: {byName: true, type: "tiddler"},
|
||||||
|
setTo: {byName: true, type: "text"},
|
||||||
popup: {byName: true, type: "tiddler"},
|
popup: {byName: true, type: "tiddler"},
|
||||||
qualifyTiddlerTitles: {byName: true, type: "text"},
|
qualifyTiddlerTitles: {byName: true, type: "text"},
|
||||||
"class": {byName: true, type: "text"}
|
"class": {byName: true, type: "text"}
|
||||||
@ -58,6 +60,13 @@ exports.triggerPopup = function(event,cancel) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.setTiddler = function() {
|
||||||
|
var set = this.params.set,
|
||||||
|
setTo = this.params.setTo,
|
||||||
|
tiddler = this.wiki.getTiddler(set);
|
||||||
|
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: set, text: setTo}));
|
||||||
|
};
|
||||||
|
|
||||||
exports.handleEvent = function(event) {
|
exports.handleEvent = function(event) {
|
||||||
if(event.type === "click") {
|
if(event.type === "click") {
|
||||||
if(this.hasParameter("message")) {
|
if(this.hasParameter("message")) {
|
||||||
@ -66,6 +75,9 @@ exports.handleEvent = function(event) {
|
|||||||
if(this.hasParameter("popup")) {
|
if(this.hasParameter("popup")) {
|
||||||
this.triggerPopup(event);
|
this.triggerPopup(event);
|
||||||
}
|
}
|
||||||
|
if(this.hasParameter("set") && this.hasParameter("setTo")) {
|
||||||
|
this.setTiddler();
|
||||||
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user