2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/startup.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: startup
|
|
|
|
|
2014-07-20 17:06:33 +00:00
|
|
|
Miscellaneous startup logic for both the client and server.
|
2012-04-30 11:23:03 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
2012-05-04 17:49:04 +00:00
|
|
|
/*global $tw: false */
|
2012-04-30 11:23:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-05-03 15:32:18 +00:00
|
|
|
// Export name and synchronous status
|
|
|
|
exports.name = "startup";
|
2014-05-03 16:10:55 +00:00
|
|
|
exports.after = ["load-modules"];
|
2014-05-03 15:32:18 +00:00
|
|
|
exports.synchronous = true;
|
|
|
|
|
2014-04-01 07:33:36 +00:00
|
|
|
// Set to `true` to enable performance instrumentation
|
2015-08-01 12:13:47 +00:00
|
|
|
var PERFORMANCE_INSTRUMENTATION = false;
|
2014-04-01 07:33:36 +00:00
|
|
|
|
2014-08-13 19:20:58 +00:00
|
|
|
var widget = require("$:/core/modules/widgets/widget.js");
|
|
|
|
|
2012-04-30 11:23:03 +00:00
|
|
|
exports.startup = function() {
|
2014-05-03 20:23:51 +00:00
|
|
|
var modules,n,m,f;
|
2012-10-25 21:20:27 +00:00
|
|
|
if($tw.browser) {
|
2014-05-03 16:10:55 +00:00
|
|
|
$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));
|
2012-10-25 21:20:27 +00:00
|
|
|
}
|
2012-07-15 16:37:03 +00:00
|
|
|
$tw.version = $tw.utils.extractVersionInfo();
|
2014-04-01 07:33:36 +00:00
|
|
|
// Set up the performance framework
|
|
|
|
$tw.perf = new $tw.Performance(PERFORMANCE_INSTRUMENTATION);
|
2014-03-20 20:55:59 +00:00
|
|
|
// Kick off the language manager and switcher
|
|
|
|
$tw.language = new $tw.Language();
|
|
|
|
$tw.languageSwitcher = new $tw.PluginSwitcher({
|
2014-02-09 19:18:46 +00:00
|
|
|
wiki: $tw.wiki,
|
|
|
|
pluginType: "language",
|
|
|
|
controllerTitle: "$:/language",
|
|
|
|
defaultPlugins: [
|
|
|
|
"$:/languages/en-US"
|
|
|
|
]
|
|
|
|
});
|
2013-04-30 22:04:15 +00:00
|
|
|
// Kick off the theme manager
|
2014-02-08 09:29:37 +00:00
|
|
|
$tw.themeManager = new $tw.PluginSwitcher({
|
|
|
|
wiki: $tw.wiki,
|
|
|
|
pluginType: "theme",
|
|
|
|
controllerTitle: "$:/theme",
|
|
|
|
defaultPlugins: [
|
|
|
|
"$:/themes/tiddlywiki/snowwhite",
|
|
|
|
"$:/themes/tiddlywiki/vanilla"
|
|
|
|
]
|
|
|
|
});
|
2014-04-30 21:49:02 +00:00
|
|
|
// Clear outstanding tiddler store change events to avoid an unnecessary refresh cycle at startup
|
|
|
|
$tw.wiki.clearTiddlerEventQueue();
|
2014-08-13 19:06:44 +00:00
|
|
|
// Create a root widget for attaching event handlers. By using it as the parentWidget for another widget tree, one can reuse the event handlers
|
2014-08-13 19:20:58 +00:00
|
|
|
if($tw.browser) {
|
|
|
|
$tw.rootWidget = new widget.widget({
|
|
|
|
type: "widget",
|
|
|
|
children: []
|
|
|
|
},{
|
|
|
|
wiki: $tw.wiki,
|
|
|
|
document: document
|
|
|
|
});
|
|
|
|
}
|
2014-08-14 10:12:25 +00:00
|
|
|
// Find a working syncadaptor
|
|
|
|
$tw.syncadaptor = undefined;
|
|
|
|
$tw.modules.forEachModuleOfType("syncadaptor",function(title,module) {
|
|
|
|
if(!$tw.syncadaptor && module.adaptorClass) {
|
|
|
|
$tw.syncadaptor = new module.adaptorClass({wiki: $tw.wiki});
|
|
|
|
}
|
|
|
|
});
|
2014-08-20 09:02:44 +00:00
|
|
|
// Set up the syncer object if we've got a syncadaptor
|
2014-08-14 10:12:25 +00:00
|
|
|
if($tw.syncadaptor) {
|
|
|
|
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki, syncadaptor: $tw.syncadaptor});
|
2014-08-20 09:02:44 +00:00
|
|
|
}
|
|
|
|
// Setup the saver handler
|
|
|
|
$tw.saverHandler = new $tw.SaverHandler({wiki: $tw.wiki, dirtyTracking: !$tw.syncadaptor});
|
2012-05-05 10:21:59 +00:00
|
|
|
// Host-specific startup
|
2012-05-19 10:29:51 +00:00
|
|
|
if($tw.browser) {
|
2012-07-15 16:37:03 +00:00
|
|
|
// Install the popup manager
|
2014-11-22 10:19:03 +00:00
|
|
|
$tw.popup = new $tw.utils.Popup();
|
2013-10-21 19:14:01 +00:00
|
|
|
// Install the animator
|
|
|
|
$tw.anim = new $tw.utils.Animator();
|
2012-05-05 10:21:59 +00:00
|
|
|
}
|
2012-05-04 17:49:04 +00:00
|
|
|
};
|
2012-04-30 11:23:03 +00:00
|
|
|
|
|
|
|
})();
|