From b3c0bec83824e4c8657d970607d17ce55f458ee2 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 20 Jun 2012 17:59:38 +0100 Subject: [PATCH] Fixed support for storyviewTiddler parameter for story macro --- core/modules/macros/story/story.js | 23 ++++++++++++++++++- .../story/views/{scroller.js => classic.js} | 0 core/templates/PageTemplate.tid | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) rename core/modules/macros/story/views/{scroller.js => classic.js} (100%) diff --git a/core/modules/macros/story/story.js b/core/modules/macros/story/story.js index cf01cacf4..b6d14e8c0 100644 --- a/core/modules/macros/story/story.js +++ b/core/modules/macros/story/story.js @@ -170,7 +170,14 @@ exports.executeMacro = function() { exports.postRenderInDom = function() { // Instantiate the story view - var StoryView = this.wiki.macros.story.viewers[this.params.storyview]; + var storyviewName; + if(this.hasParameter("storyviewTiddler")) { + storyviewName = this.wiki.getTextReference(this.params.storyviewTiddler) + } + if(!storyviewName && this.hasParameter("storyview")) { + storyviewName = this.params.storyview; + } + var StoryView = this.wiki.macros.story.viewers[storyviewName]; if(StoryView) { this.storyview = new StoryView(this); } @@ -184,6 +191,20 @@ exports.postRenderInDom = function() { exports.refreshInDom = function(changes) { var t; + // If the storyview has changed we'll have to completely re-execute the macro + if(this.hasParameter("storyviewTiddler") && $tw.utils.hop(changes,this.params.storyviewTiddler)) { + // This logic should be reused from the base macro class, and not duplicated + var child = this.child; + while(!child.domNode && child.child) { + child = child.child; + } + var parentDomNode = child.domNode.parentNode, + insertBefore = child.domNode.nextSibling; + parentDomNode.removeChild(child.domNode); + this.execute(this.parents,this.tiddlerTitle); + this.renderInDom(parentDomNode,insertBefore); + return; + } /*jslint browser: true */ if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) { // Get the tiddlers we're supposed to be displaying diff --git a/core/modules/macros/story/views/scroller.js b/core/modules/macros/story/views/classic.js similarity index 100% rename from core/modules/macros/story/views/scroller.js rename to core/modules/macros/story/views/classic.js diff --git a/core/templates/PageTemplate.tid b/core/templates/PageTemplate.tid index 1995a5842..c9c030c90 100644 --- a/core/templates/PageTemplate.tid +++ b/core/templates/PageTemplate.tid @@ -1,7 +1,7 @@ title: $:/templates/PageTemplate
-<< +<< {{navigation-panel{ <<<>>> }}} @@ -17,7 +17,7 @@ title: $:/templates/PageTemplate *{{divider-vertical}} {{pull-right btn btn-info{ -<