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

Renamed "target" parameter of link macro to "to"

To avoid confusion with the HTML target attribute of link elements
This commit is contained in:
Jeremy Ruston 2012-04-07 11:32:41 +01:00
parent 9e4404bb97
commit 5d10e7b750
4 changed files with 16 additions and 16 deletions

View File

@ -102,7 +102,7 @@ var App = function() {
// Install the default link massager
this.store.linkMassager = function(linkInfo) {
if(!linkInfo.isExternal) {
linkInfo.target = encodeURIComponent(linkInfo.target);
linkInfo.to = encodeURIComponent(linkInfo.to);
}
};
// Set up for the browser

View File

@ -467,7 +467,7 @@ var rules = [
// Pretty bracketted link
link = lookaheadMatch[3];
}
insertMacroCall(w,w.output,"link",{target: link},[Renderer.TextNode(text)]);
insertMacroCall(w,w.output,"link",{to: link},[Renderer.TextNode(text)]);
w.nextMatch = this.lookaheadRegExp.lastIndex;
}
}
@ -492,7 +492,7 @@ var rules = [
}
}
if(w.autoLinkWikiWords) {
insertMacroCall(w,w.output,"link",{target: w.matchText},[Renderer.TextNode(w.source.substring(w.matchStart,w.nextMatch))]);
insertMacroCall(w,w.output,"link",{to: w.matchText},[Renderer.TextNode(w.source.substring(w.matchStart,w.nextMatch))]);
} else {
w.outputText(w.output,w.matchStart,w.nextMatch);
}
@ -504,7 +504,7 @@ var rules = [
match: textPrimitives.urlPattern,
handler: function(w)
{
insertMacroCall(w,w.output,"link",{target: w.matchText},[Renderer.TextNode(w.source.substring(w.matchStart,w.nextMatch))]);
insertMacroCall(w,w.output,"link",{to: w.matchText},[Renderer.TextNode(w.source.substring(w.matchStart,w.nextMatch))]);
}
},

View File

@ -10,7 +10,7 @@ that takes a `linkInfo` structure as the only parameter. It contains a hashmap o
as follows:
{
target: the target of the link
to: the target of the link
space: an optional space associated with the link
isExternal: true if the link has been determined to be an external link by the default heuristics
isMissing: true if a non-external link references a missing tiddler
@ -28,26 +28,26 @@ The linkMassager can modify the `classes` and `href` fields as required.
var Renderer = require("../Renderer.js").Renderer;
var isLinkExternal = function(target) {
var isLinkExternal = function(to) {
var externalRegExp = /(?:file|http|https|mailto|ftp|irc|news|data):[^\s'"]+(?:\/|\b)/i;
return externalRegExp.test(target);
return externalRegExp.test(to);
};
exports.macro = {
name: "link",
params: {
target: {byName: "default", type: "tiddler", skinny: true},
to: {byName: "default", type: "tiddler", skinny: true},
space: {byName: true, type: "text"}
},
events: {
click: function(event) {
if(isLinkExternal(this.params.target)) {
if(isLinkExternal(this.params.to)) {
event.target.setAttribute("target","_blank");
return true;
} else {
var navEvent = document.createEvent("Event");
navEvent.initEvent("tw-navigate",true,true);
navEvent.navigateTo = this.params.target;
navEvent.navigateTo = this.params.to;
event.target.dispatchEvent(navEvent);
event.preventDefault();
return false;
@ -57,15 +57,15 @@ exports.macro = {
execute: function() {
// Assemble the information about the link
var linkInfo = {
target: this.params.target,
to: this.params.to,
space: this.params.space
};
// Generate the default link characteristics
linkInfo.isExternal = isLinkExternal(linkInfo.target);
linkInfo.isExternal = isLinkExternal(linkInfo.to);
if(!linkInfo.isExternal) {
linkInfo.isMissing = !this.store.tiddlerExists(linkInfo.target);
linkInfo.isMissing = !this.store.tiddlerExists(linkInfo.to);
}
linkInfo.href = encodeURIComponent(linkInfo.target);
linkInfo.href = encodeURIComponent(linkInfo.to);
// Generate the default classes for the link
linkInfo.classes = ["tw-tiddlylink"];
if(linkInfo.isExternal) {
@ -85,7 +85,7 @@ exports.macro = {
// Figure out the classes to assign to the link
var content = [Renderer.ElementNode(
"a",{
href: linkInfo.target,
href: linkInfo.href,
"class": linkInfo.classes
},this.cloneChildren())];
for(var t=0; t<content.length; t++) {

View File

@ -52,7 +52,7 @@ exports.macro = {
return [];
} else {
var link = Renderer.MacroNode("link",
{target: value},
{to: value},
[Renderer.TextNode(value)],
this.store);
link.execute(parents,this.tiddlerTitle);