mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-09 11:29:58 +00:00
91a7c39791
@felixhayashi I’m afraid I haven’t used your pull request as there were a few details that I wanted to do differently. The main change is that these changes allow both a param string and hashmap to be specified.
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
/*\
|
|
title: $:/core/modules/startup/rootwidget.js
|
|
type: application/javascript
|
|
module-type: startup
|
|
|
|
Setup the root widget and the core root widget handlers
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
// Export name and synchronous status
|
|
exports.name = "rootwidget";
|
|
exports.platforms = ["browser"];
|
|
exports.after = ["startup"];
|
|
exports.before = ["story"];
|
|
exports.synchronous = true;
|
|
|
|
exports.startup = function() {
|
|
// Install the modal message mechanism
|
|
$tw.modal = new $tw.utils.Modal($tw.wiki);
|
|
$tw.rootWidget.addEventListener("tm-modal",function(event) {
|
|
$tw.modal.display(event.param,{variables: event.paramObject});
|
|
});
|
|
// Install the notification mechanism
|
|
$tw.notifier = new $tw.utils.Notifier($tw.wiki);
|
|
$tw.rootWidget.addEventListener("tm-notify",function(event) {
|
|
$tw.notifier.display(event.param);
|
|
});
|
|
// Install the scroller
|
|
$tw.pageScroller = new $tw.utils.PageScroller();
|
|
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
|
$tw.pageScroller.handleEvent(event);
|
|
});
|
|
var fullscreen = $tw.utils.getFullScreenApis();
|
|
if(fullscreen) {
|
|
$tw.rootWidget.addEventListener("tm-full-screen",function(event) {
|
|
if(document[fullscreen._fullscreenElement]) {
|
|
document[fullscreen._exitFullscreen]();
|
|
} else {
|
|
document.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
}
|
|
});
|
|
}
|
|
// If we're being viewed on a data: URI then give instructions for how to save
|
|
if(document.location.protocol === "data:") {
|
|
$tw.rootWidget.dispatchEvent({
|
|
type: "tm-modal",
|
|
param: "$:/language/Modals/SaveInstructions"
|
|
});
|
|
}
|
|
};
|
|
|
|
})();
|