2014-05-05 13:41:46 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/startup/rootwidget.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: startup
|
|
|
|
|
2014-05-05 14:25:51 +00:00
|
|
|
Setup the root widget and the core root widget handlers
|
2014-05-05 13:41:46 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
// Export name and synchronous status
|
|
|
|
exports.name = "rootwidget";
|
|
|
|
exports.platforms = ["browser"];
|
2014-08-13 19:20:58 +00:00
|
|
|
exports.after = ["startup"];
|
2014-05-05 14:25:51 +00:00
|
|
|
exports.before = ["story"];
|
2014-05-05 13:41:46 +00:00
|
|
|
exports.synchronous = true;
|
|
|
|
|
|
|
|
exports.startup = function() {
|
|
|
|
// Install the modal message mechanism
|
|
|
|
$tw.modal = new $tw.utils.Modal($tw.wiki);
|
2014-08-28 20:43:44 +00:00
|
|
|
$tw.rootWidget.addEventListener("tm-modal",function(event) {
|
2014-11-07 14:54:46 +00:00
|
|
|
$tw.modal.display(event.param,{variables: event.paramObject});
|
2014-05-05 13:41:46 +00:00
|
|
|
});
|
|
|
|
// Install the notification mechanism
|
|
|
|
$tw.notifier = new $tw.utils.Notifier($tw.wiki);
|
2014-08-28 20:43:44 +00:00
|
|
|
$tw.rootWidget.addEventListener("tm-notify",function(event) {
|
2016-07-03 13:55:41 +00:00
|
|
|
$tw.notifier.display(event.param,{variables: event.paramObject});
|
2014-05-05 13:41:46 +00:00
|
|
|
});
|
2017-12-15 15:08:18 +00:00
|
|
|
// Install the copy-to-clipboard mechanism
|
|
|
|
$tw.rootWidget.addEventListener("tm-copy-to-clipboard",function(event) {
|
|
|
|
$tw.utils.copyToClipboard(event.param);
|
|
|
|
});
|
2014-05-05 13:41:46 +00:00
|
|
|
// Install the scroller
|
|
|
|
$tw.pageScroller = new $tw.utils.PageScroller();
|
2014-08-28 20:43:44 +00:00
|
|
|
$tw.rootWidget.addEventListener("tm-scroll",function(event) {
|
2014-05-05 13:41:46 +00:00
|
|
|
$tw.pageScroller.handleEvent(event);
|
|
|
|
});
|
2014-08-01 15:52:12 +00:00
|
|
|
var fullscreen = $tw.utils.getFullScreenApis();
|
2014-08-03 11:35:53 +00:00
|
|
|
if(fullscreen) {
|
2014-08-28 20:43:44 +00:00
|
|
|
$tw.rootWidget.addEventListener("tm-full-screen",function(event) {
|
2018-08-14 21:53:53 +00:00
|
|
|
if(event.param === "enter") {
|
|
|
|
event.event.target.ownerDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
} else if(event.param === "exit") {
|
2018-06-16 09:03:38 +00:00
|
|
|
event.event.target.ownerDocument[fullscreen._exitFullscreen]();
|
2014-08-03 11:35:53 +00:00
|
|
|
} else {
|
2018-08-14 21:53:53 +00:00
|
|
|
if(event.event.target.ownerDocument[fullscreen._fullscreenElement]) {
|
|
|
|
event.event.target.ownerDocument[fullscreen._exitFullscreen]();
|
|
|
|
} else {
|
|
|
|
event.event.target.ownerDocument.documentElement[fullscreen._requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
}
|
2014-08-03 11:35:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-05-05 13:41:46 +00:00
|
|
|
// If we're being viewed on a data: URI then give instructions for how to save
|
|
|
|
if(document.location.protocol === "data:") {
|
|
|
|
$tw.rootWidget.dispatchEvent({
|
2014-08-28 20:43:44 +00:00
|
|
|
type: "tm-modal",
|
2014-05-05 13:41:46 +00:00
|
|
|
param: "$:/language/Modals/SaveInstructions"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|