1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 11:00:27 +00:00

Add the ability to set classes on list elements

This commit is contained in:
Jeremy Ruston 2012-10-26 14:00:56 +01:00
parent 031e3b8b80
commit da43887d7c

View File

@ -24,7 +24,8 @@ exports.info = {
editTemplateText: {byName: true, type: "text"},
emptyMessage: {byName: true, type: "text"},
listviewTiddler: {byName: true, type: "tiddler"},
listview: {byName: true, type: "text"}
listview: {byName: true, type: "text"},
itemClass: {byName: true, type: "text"}
}
};
@ -110,13 +111,18 @@ Create a list element representing a given tiddler
*/
exports.createListElement = function(title) {
var node = this.createListElementMacro(title),
attributes = {"class": ["tw-list-element"]},
eventHandler = {handleEvent: function(event) {
// Add context information to the event
event.navigateFromTitle = title;
return true;
}};
node.execute(this.parents,this.tiddlerTitle);
var listElement = $tw.Tree.Element(this.isBlock ? "div" : "span",{"class": ["tw-list-element"]},[node],{
// Add any specified classes
if(this.hasParameter("itemClass")) {
attributes["class"].push(this.params["itemClass"]);
}
var listElement = $tw.Tree.Element(this.isBlock ? "div" : "span",attributes,[node],{
events: ["tw-navigate","tw-EditTiddler","tw-SaveTiddler","tw-CloseTiddler","tw-NewTiddler"],
eventHandler: eventHandler
});