[tw] Re: [TWC] Tiddler Refresh vs Close and re-open

2015-01-12 Thread Arc Acorn
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] Tiddler Refresh vs Close and re-open

2015-01-12 Thread Tobias Beer
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] Tiddler Refresh vs Close and re-open

2015-01-12 Thread Arc Acorn
bump

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] Tiddler Refresh vs Close and re-open

2015-01-05 Thread Eric Shulman
On Monday, January 5, 2015 10:04:31 AM UTC-8, Arc Acorn wrote:
>
> Bump.
>

Can you provide a minimal test case (MTC) document that shows what you've 
done so far?
Or, at least post a message tht shows me how you've defined the listbox 
(i.e., the macro call you used, and the parameters you provided).

-e
 

>
> On Friday, January 2, 2015 11:05:33 PM UTC-8, Arc Acorn wrote:
>>
>> I'm now using ListboxPlugin to 
>> change custom field values to change per-tiddler themes using the 
>> "ThemedTiddlerPlugin" (Link no longer works so I added it to the bottom of 
>> this post.)
>>
>> The issue I"m running into is that as I change the values with 
>> ListboxPlugin it simply compounds the new classes without removing the old 
>> ones, until I close the tiddler and re-open it than It'll just have the 
>> last value. 
>>
>> So there seems to be a difference between simply "refreshing" a tiddler 
>> using javascript and closing and re-opening. 
>>
>> Which is as far as I can seem to get on my own.
>>
>>
>> Plugin
>>
>> /***
>> |''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.1|
>> |''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);
>> var tiddler = store.getTiddler(title);
>> if (tiddler) {
>> addClass(tiddlerElem, store.getTiddler(title).fields.theme);
>> }
>> return tiddlerElem;
>> };
>> }
>> //}}}
>>
>>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.


[tw] Re: [TWC] Tiddler Refresh vs Close and re-open

2015-01-05 Thread Arc Acorn
Bump.

On Friday, January 2, 2015 11:05:33 PM UTC-8, Arc Acorn wrote:
>
> I'm now using ListboxPlugin to 
> change custom field values to change per-tiddler themes using the 
> "ThemedTiddlerPlugin" (Link no longer works so I added it to the bottom of 
> this post.)
>
> The issue I"m running into is that as I change the values with 
> ListboxPlugin it simply compounds the new classes without removing the old 
> ones, until I close the tiddler and re-open it than It'll just have the 
> last value. 
>
> So there seems to be a difference between simply "refreshing" a tiddler 
> using javascript and closing and re-opening. 
>
> Which is as far as I can seem to get on my own.
>
>
> Plugin
>
> /***
> |''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.1|
> |''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);
> var tiddler = store.getTiddler(title);
> if (tiddler) {
> addClass(tiddlerElem, store.getTiddler(title).fields.theme);
> }
> return tiddlerElem;
> };
> }
> //}}}
>
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.