diff --git a/core/modules/macros/list/list.js b/core/modules/macros/list/list.js index f4f6aee1b..5769d69df 100644 --- a/core/modules/macros/list/list.js +++ b/core/modules/macros/list/list.js @@ -22,7 +22,9 @@ exports.info = { templateText: {byName: true, type: "text"}, editTemplate: {byName: true, type: "tiddler"}, editTemplateText: {byName: true, type: "text"}, - emptyMessage: {byName: true, type: "text"} + emptyMessage: {byName: true, type: "text"}, + listviewTiddler: {byName: true, type: "tiddler"}, + listview: {byName: true, type: "text"} } }; @@ -59,6 +61,22 @@ exports.executeMacro = function() { return this.listFrame; }; +exports.postRenderInDom = function() { + // Instantiate the list view + var listviewName; + if(this.hasParameter("listviewTiddler")) { + listviewName = this.wiki.getTextReference(this.params.listviewTiddler); + } + if(!listviewName && this.hasParameter("listview")) { + listviewName = this.params.listview; + } + var ListView = this.wiki.macros.list.listviews[listviewName]; + this.listview = ListView ? new ListView(this) : null; + if(this.listview) { + this.listview.test(); + } +}; + exports.getTiddlerList = function() { var filter; if(this.hasParameter("type")) { diff --git a/core/modules/macros/list/listviews/classic.js b/core/modules/macros/list/listviews/classic.js new file mode 100644 index 000000000..af33c88d0 --- /dev/null +++ b/core/modules/macros/list/listviews/classic.js @@ -0,0 +1,25 @@ +/*\ +title: $:/core/modules/macros/list/listviews/classic.js +type: application/javascript +module-type: listview + +Views the list as a linear sequence + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +function ClassicListView(listMacro) { + this.listMacro = listMacro; +}; + +ClassicListView.prototype.test = function() { + alert("In ClassicListView"); +}; + +exports["classic"] = ClassicListView; + +})(); diff --git a/core/modules/startup.js b/core/modules/startup.js index c19952df0..9c0ad3b7f 100644 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -35,6 +35,7 @@ exports.startup = function() { $tw.wiki.initEditors(); $tw.wiki.initFieldViewers(); $tw.wiki.initStoryViews(); + $tw.wiki.initListViews(); $tw.wiki.initParsers(); // Set up the command modules $tw.Commander.initCommands(); diff --git a/core/modules/wiki.js b/core/modules/wiki.js index 756dc5bfa..58307b6b8 100644 --- a/core/modules/wiki.js +++ b/core/modules/wiki.js @@ -533,7 +533,7 @@ exports.initEditors = function(moduleType) { }; /* -Install field viewer modules for the edit macro +Install field viewer modules for the view macro */ exports.initFieldViewers = function(moduleType) { moduleType = moduleType || "fieldviewer"; @@ -544,6 +544,18 @@ exports.initFieldViewers = function(moduleType) { } }; +/* +Install list viewer modules for the list macro +*/ +exports.initListViews = function(moduleType) { + moduleType = moduleType || "listview"; + var listMacro = this.macros.list; + if(listMacro) { + listMacro.listviews = {}; + $tw.modules.applyMethods(moduleType,listMacro.listviews); + } +}; + /* Install view modules for the story macro */