mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-07 18:39:13 +00:00
Start responding to dynamic stylesheet changes
This mechanism will only be triggered by changes to the stylesheet tiddlers themselves, and not to any dependencies that they might have. It'll stay that way for a while. The next thing is making the theme manager actually switch themes, forcing the right wiki change events to make the stylesheet manager update itself
This commit is contained in:
+3
-15
@@ -89,21 +89,9 @@ exports.startup = function() {
|
||||
document.addEventListener("tw-clear-password",function(event) {
|
||||
$tw.crypto.setPassword(null);
|
||||
});
|
||||
// Unpack the current theme tiddlers
|
||||
$tw.wiki.unpackPluginTiddlers("theme");
|
||||
// Apply stylesheets
|
||||
var stylesheetTiddlers = $tw.wiki.filterTiddlers("[is[shadow]tag[$:/tags/stylesheet]]");
|
||||
$tw.utils.each(stylesheetTiddlers,function(title,index) {
|
||||
// Stylesheets don't refresh, yet
|
||||
var parser = $tw.wiki.parseTiddler(title),
|
||||
renderTree = new $tw.WikiRenderTree(parser,{wiki: $tw.wiki});
|
||||
renderTree.execute({tiddlerTitle: title});
|
||||
var styleNode = document.createElement("style");
|
||||
styleNode.type = "text/css";
|
||||
var text = renderTree.render("text/plain");
|
||||
styleNode.appendChild(document.createTextNode(text));
|
||||
document.getElementsByTagName("head")[0].appendChild(styleNode);
|
||||
});
|
||||
// Kick off the theme and the stylesheet manager
|
||||
$tw.themeManager = new $tw.ThemeManager($tw.wiki);
|
||||
$tw.stylesheetManager = new $tw.utils.StylesheetManager($tw.wiki);
|
||||
// If we're being viewed on a data: URI then give instructions for how to save
|
||||
if(document.location.protocol === "data:") {
|
||||
$tw.utils.dispatchCustomEvent(document,"tw-modal",{
|
||||
|
||||
Reference in New Issue
Block a user