Thanks a ton again Tobias!
Works great, and will make my sister way happy. 
She's not super savvy with CSS so she wanted an easy way to apply and 
switch through a small number of different mini-themes per each tiddler. 


P/s 
As a note to anybody else if they ever use this:
For some reason Google decided to "quote" parts of the code so make sure to 
expand it and than delete the two "- hide quoted text -" after pasting into 
your tiddlywiki.


On Monday, January 12, 2015 at 1:36:44 PM UTC-8, Tobias Beer wrote:
>
> Hi Arc,
>
> the problem is in *ThemedTiddlerPlugin*, not *ListBoxPlugin*,
> it sets the class at the tiddler but never removes the old class when 
> applying the new one.
>
> I changed it to remember the *oldTheme*. Try this...
>
> /***
> |''Name:''|ThemedTiddlerPlugin |
> |''Description:''|Per-Tiddler Mini-Themes |
> |''Author:''|PaulDowney (psd (at) osmosoft (dot) com) |
> |''Source:''|http://whatfettle.com/2008/07/ThemedTiddlerPlugin/ |
> |''CodeRepository:''|
> http://svn.tiddlywiki.org/Trunk/contributors/PaulDowney/plugins/ThemedTiddlerPlugin/
>  
> |
> |''Version:''|0.2 — fix Tobias Beer (oldTheme)|
> |''License:''|[[BSD License|
> http://www.opensource.org/licenses/bsd-license.php]] |
> |''Comments:''|Please make comments at 
> http://groups.google.co.uk/group/TiddlyWikiDev |
> |''~CoreVersion:''|2.4|
> !!Documentation
> The extended field "theme" is used to reference a tiddler containing a 
> "mini-theme"
>
>
> A mini-theme is a tiddler containing a [[ViewTemplate]], [[EditTemplate]] 
> and [[StyleSheet]] sections which are applied when the tiddler is 
> displayed. 
>
>
> In addition, a CSS class of the theme name is added to the tiddler which 
> may be useful when writing a mini-theme [[StyleSheet]]. 
> !!Code
> ***/
> //{{{
> /*jslint onevar: false nomen: false plusplus: false */
> /*global Story, store, setStylesheet, addClass */
> if (!version.extensions.ThemedTiddlerPlugin) {
>     version.extensions.ThemedTiddlerPlugin = {installed: true};
>
>     Story.prototype.__chooseTemplateForTiddler = Story.prototype.
> chooseTemplateForTiddler;
>     Story.prototype.chooseTemplateForTiddler = function (title, n)
>     {
>         // translate number into template name
>         var template = ["ViewTemplate", "EditTemplate"][n ? n - 1 : 0];
>
>         var tiddler = store.getTiddler(title);
>
>         if (tiddler) {
>             var theme = tiddler.fields.theme;
>             if (theme) {
>
>                 // assert stylesheet
>                 var style = store.getTiddlerText(theme + '##StyleSheet');
>                 if (style) {
>                     setStylesheet(style, theme);
>                 }
>
>                 // return theme template
>                 var slice = theme + '##' + template;
>                 if (store.getTiddlerText(slice)) {
>                     return slice;
>                 }
>             }
>         }
>
>         // default template
>         return this.__chooseTemplateForTiddler.apply(this, arguments);
>     };
>
>     // assert theme name as a class on the tiddler
>     Story.prototype.__refreshTiddler = Story.prototype.refreshTiddler;
>     Story.prototype.refreshTiddler = function (title, template, force, 
> customFields, defaultText)
>     {
>         var tiddlerElem = this.__refreshTiddler.apply(this, arguments),
>             tiddler = store.getTiddler(title),
>             oldTheme = tiddlerElem.getAttribute("oldTheme") || "",
>             newTheme = store.getTiddler(title).fields.theme;
>
>         if (tiddler) {
>             removeClass(tiddlerElem, oldTheme);
>             tiddlerElem.setAttribute("oldTheme", newTheme);
>             addClass(tiddlerElem, newTheme);
>         }
>         return tiddlerElem;
>     };
> }
> //}}}
>
>
> Best wishes, Tobias.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

Reply via email to