1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-28 04:19:56 +00:00
TiddlyWiki5/js/macros/link.js
Jeremy Ruston 95ab295fbb Refactored dependency handling
Now each class of dependency can be tracked individually
2012-02-07 19:03:59 +00:00

43 lines
899 B
JavaScript

/*\
title: js/macros/link.js
\*/
(function(){
/*jslint node: true, browser: true */
"use strict";
var HTML = require("../HTML.js").HTML,
utils = require("../Utils.js");
exports.macro = {
name: "link",
wrapperTag: "span",
types: ["text/html","text/plain"],
params: {
target: {byName: "default", type: "tiddler", rel: "link", optional: false}
},
events: {
click: function(event,node,tiddler,store,params) {
var navEvent = document.createEvent("Event");
navEvent.initEvent("tw-navigate",true,true);
navEvent.navigateTo = params.target;
node.dispatchEvent(navEvent);
event.preventDefault();
return false;
}
},
render: function(type,tiddler,store,params,content) {
return HTML(HTML.elem(
"a",{
href: params.target,
"class": store.adjustClassesForLink([],params.target)
},[
HTML.raw(content)
]
),type);
}
};
})();