1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-10-31 23:53:00 +00:00

Switch the notifier and modal mechanisms to use the new widget mechanism

Note the use of the `$tw.rootWidget` to collect together the root event
handlers
This commit is contained in:
Jeremy Ruston
2013-10-21 20:14:01 +01:00
parent 48dbacc88a
commit 2a571b4f5f
3 changed files with 64 additions and 48 deletions

View File

@@ -12,6 +12,8 @@ Notifier mechanism
/*global $tw: false */
"use strict";
var widget = require("$:/core/modules/new_widgets/widget.js");
var Notifier = function(wiki) {
this.wiki = wiki;
};
@@ -35,12 +37,16 @@ Notifier.prototype.display = function(title,options) {
// Add classes
$tw.utils.addClass(notification,"tw-notification");
// Render the body of the notification
var bodyParser = this.wiki.parseTiddler(title),
bodyRenderTree = new $tw.WikiRenderTree(bodyParser,{wiki: $tw.wiki, context: {tiddlerTitle: title}, document: document});
bodyRenderTree.execute();
bodyRenderTree.renderInDom(notification);
var parser = this.wiki.new_parseTiddler(title),
parseTreeNode = parser ? {type: "widget", children: parser.tree} : undefined,
widgetNode = new widget.widget(parseTreeNode,{
wiki: this.wiki,
parentWidget: $tw.rootWidget,
document: document
});
widgetNode.render(notification,null);
this.wiki.addEventListener("change",function(changes) {
bodyRenderTree.refreshInDom(changes);
widgetNode.refresh(changes,notification,null);
});
// Set the initial styles for the notification
$tw.utils.setStyle(notification,[