1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 17:40:29 +00:00

Starting to introduce list views

These are custom modules for visualising list manipulations and
navigations
This commit is contained in:
Jeremy Ruston 2012-10-23 17:13:47 +01:00
parent 5ced636abf
commit c087228b33
4 changed files with 58 additions and 2 deletions

View File

@ -22,7 +22,9 @@ exports.info = {
templateText: {byName: true, type: "text"}, templateText: {byName: true, type: "text"},
editTemplate: {byName: true, type: "tiddler"}, editTemplate: {byName: true, type: "tiddler"},
editTemplateText: {byName: true, type: "text"}, 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; 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() { exports.getTiddlerList = function() {
var filter; var filter;
if(this.hasParameter("type")) { if(this.hasParameter("type")) {

View File

@ -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;
})();

View File

@ -35,6 +35,7 @@ exports.startup = function() {
$tw.wiki.initEditors(); $tw.wiki.initEditors();
$tw.wiki.initFieldViewers(); $tw.wiki.initFieldViewers();
$tw.wiki.initStoryViews(); $tw.wiki.initStoryViews();
$tw.wiki.initListViews();
$tw.wiki.initParsers(); $tw.wiki.initParsers();
// Set up the command modules // Set up the command modules
$tw.Commander.initCommands(); $tw.Commander.initCommands();

View File

@ -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) { exports.initFieldViewers = function(moduleType) {
moduleType = moduleType || "fieldviewer"; 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 Install view modules for the story macro
*/ */