small CSS bug

3 просмотра
Перейти к первому непрочитанному сообщению

Yakov

не прочитано,
18 нояб. 2010 г., 12:24:1918.11.2010
– TiddlyWiki
Hi,

while experimenting with CSS in TW I figured out somewhat like a bug.

How to reproduce it:
make a tiddler A with CSS other than than StyleSheet (or core
StyleSheets);
include it into the StyelSheet, change CSS in A.

What happens:
CSS is not changed until I open the StyleSheet in editMode and close
it. Or restart TW.

This was tried in Opera (9.64) and FireFox (somewhat latest version).

Is this a bug or I do something wrong?

Yakov.

Eric Shulman

не прочитано,
18 нояб. 2010 г., 12:58:2518.11.2010
– TiddlyWiki
> make a tiddler A with CSS other than than StyleSheet (or core
> StyleSheets);
> include it into the StyelSheet, change CSS in A.
>
> What happens:
> CSS is not changed until I open the StyleSheet in editMode and close
> it. Or restart TW.

This is a 'design weakness' of the current stylesheet handling.

Because you can *nest* embedded CSS from other tiddlers, the
Stylesheet definition is recursively retrieved, replacing the embedded
[[TiddlerName]] references with their respective content. Only after
all the content has been retrieved is the entire block handed to the
brower and applied to the current rendered content.

There is a TW core 'notification' mechanism that can automatically
trigger a function whenever a given tiddler is changed. When
[[StyleSheet]] is changed, it (and all the embedded CSS) is re-
applied.

However, as you noted, if a nested tiddler is changed, the
notification for *StyleSheet* does not occur. Of course, there is a
notification for the actual tiddler that was changed, but that tiddler
has not been 'registered' with the core, so no side-effect CSS
processing is triggered.

To make nested tiddlers re-apply as you want, it would be necessary,
during the recursive expansion of the CSS source, to collect the names
of the all the tiddlers whose content is being embedded, and then
register notifications for each of these tiddlers.

One issue is that this could lead to a great deal of overhead
processing if a lot of small CSS 'fragments' are used. Another
potential problem is that, when switching themes, a lot of 'cleanup'
work would be needed to *reset* the notifications on the currently
used CSS tiddlers, before switching themes and then adding
notifications for all the CSS tiddlers used by the new theme.

Lastly, the lack of notifications for nested CSS tiddlers is, in
general, only a minor problem that occurs while you are adjusting your
CSS definitions. Once you have gotten the styles the way you want, it
is unlikely that the StyleSheet (and nested CSS tiddlers it
references) will be changing much at all.

In any case, if you can live with a one-click *semi-manual* solution,
you can put this bit of HTML into your document:

<html><a href="javascript:;"
onclick="story.switchTheme(config.options.txtTheme)">refresh styles</
a></html>

It creates a 'command link' that, when clicked, forces the core to re-
process the currently loaded systemTheme, which re-applies the
StyleSheet (and, of course, any nested CSS it references). While not
a totally automatic solution, it is just ONE click, and it does avoid
having to 'touch' (edit/done) the [[StyleSheet]] just to apply the CSS
changes made in another tiddler.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Yakov

не прочитано,
21 нояб. 2010 г., 11:42:1921.11.2010
– TiddlyWiki
I see. I suspected some sort of design flow.

However, I didn't crearly understand the thing with the themes. Would
the processing and cleanup be so bulky if, say, it would be demanded
from the user to mark all the CSS-tiddlers with a tag "StyleSheet" or
another?

> Once you have gotten the styles the way you want, it is unlikely that the StyleSheet (and nested CSS tiddlers it references) will be changing much at all.

Unfortunately, this seems not to apply to things I do.. I Experiment
much with empasizing some semantics and also I'm planning to make
hypertext lectures and study and show it's pros and cons, so styling
is changed quite frequently.

How diffuclt is it to write a plugin (or tweak?) which causes a
"refresh" function to launch after saving a tiddler with a tag
"StyleSheet"?

Anyway, thanks for the solution, it works momently. I think I'll put
it into the right sidebar.

Yakov

не прочитано,
21 нояб. 2010 г., 11:45:4121.11.2010
– TiddlyWiki
A side question:

- what does the

href="javascript:;"

part mean?

FND

не прочитано,
22 нояб. 2010 г., 03:11:0522.11.2010
– tiddl...@googlegroups.com
> A side question: - what does the href="javascript:;" part mean?

This is common practice to indicate that an anchor's target is not a URI
(i.e. it's not a link), but rather an action (i.e. it's a button).


-- F.

Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений