2012-01-15 14:37:49 +00:00
|
|
|
/*\
|
|
|
|
title: js/macros/image.js
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var utils = require("../Utils.js");
|
|
|
|
|
|
|
|
exports.macro = {
|
|
|
|
name: "image",
|
|
|
|
types: ["text/html","text/plain"],
|
|
|
|
params: {
|
|
|
|
src: {byName: "default", type: "tiddler", optional: false},
|
2012-01-16 08:58:51 +00:00
|
|
|
text: {byName: true, type: "text", optional: true},
|
|
|
|
alignment: {byName: true, type: "text", optional: true}
|
2012-01-15 14:37:49 +00:00
|
|
|
},
|
2012-01-30 20:04:47 +00:00
|
|
|
render: function(type,tiddler,store,params) {
|
2012-01-15 14:37:49 +00:00
|
|
|
if(type === "text/html") {
|
2012-01-16 08:58:51 +00:00
|
|
|
if(store.tiddlerExists(params.src)) {
|
|
|
|
if(params.text) {
|
|
|
|
return utils.stitchElement("div",{
|
|
|
|
alt: params.text,
|
|
|
|
title: params.text
|
|
|
|
},{
|
|
|
|
content: store.renderTiddler(type,params.src)
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return store.renderTiddler(type,params.src);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return utils.stitchElement("img",{
|
|
|
|
href: params.src,
|
|
|
|
alt: params.text,
|
|
|
|
title: params.text
|
|
|
|
},{
|
|
|
|
selfClosing: true
|
|
|
|
});
|
|
|
|
}
|
2012-01-15 14:37:49 +00:00
|
|
|
} else if (type === "text/plain") {
|
2012-01-17 15:21:56 +00:00
|
|
|
return params.text ? params.text : "";
|
2012-01-15 14:37:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|