Stackedit/res/main.js

124 lines
3.1 KiB
JavaScript
Raw Normal View History

2013-04-05 17:44:10 +00:00
// RequireJS configuration
2013-04-02 18:42:47 +00:00
requirejs.config({
2013-06-02 00:38:23 +00:00
waitSeconds: 0,
2013-08-04 11:27:50 +00:00
packages: [
{
name: 'css',
location: 'libs/css',
main: 'css'
},
{
name: 'less',
location: 'libs/less',
main: 'less'
}
],
2013-06-02 00:38:23 +00:00
paths: {
"jquery": "libs/jquery",
"underscore": "libs/underscore",
2013-07-28 17:14:42 +00:00
"crel": "libs/crel",
2013-08-20 22:40:19 +00:00
"jgrowl": "libs/jgrowl/jquery.jgrowl",
2013-06-10 21:22:32 +00:00
"mousetrap": "libs/mousetrap",
2013-06-16 10:47:35 +00:00
"toMarkdown": "libs/to-markdown",
2013-06-10 21:22:32 +00:00
"text": "libs/text",
2013-06-02 00:38:23 +00:00
"libs/MathJax": '../lib/MathJax/MathJax.js?config=TeX-AMS_HTML'
2013-05-13 23:26:55 +00:00
},
2013-04-02 18:42:47 +00:00
shim: {
2013-06-02 00:38:23 +00:00
'underscore': {
2013-05-27 19:45:33 +00:00
exports: '_'
},
2013-05-27 22:13:41 +00:00
'jgrowl': {
2013-06-02 00:38:23 +00:00
deps: [
'jquery'
],
2013-05-27 19:45:33 +00:00
exports: 'jQuery.jGrowl'
},
2013-06-10 21:22:32 +00:00
'mousetrap': {
exports: 'Mousetrap'
},
2013-06-16 10:47:35 +00:00
'toMarkdown': {
deps: [
'jquery'
],
exports: 'toMarkdown'
},
2013-06-02 00:38:23 +00:00
'libs/jquery-ui': [
'jquery'
],
2013-08-05 14:05:34 +00:00
'libs/bootstrap/bootstrap': [
2013-06-02 00:38:23 +00:00
'jquery'
],
'libs/jquery.waitforimages': [
'jquery'
],
2013-06-03 22:19:52 +00:00
'libs/jquery.mousewheel': [
'jquery'
],
2013-06-02 00:38:23 +00:00
'libs/layout': [
'libs/jquery-ui'
],
'libs/Markdown.Extra': [
'libs/Markdown.Converter',
2013-08-20 22:40:19 +00:00
'libs/prettify/prettify',
'libs/highlight/highlight.pack',
2013-06-02 00:38:23 +00:00
],
'libs/Markdown.Editor': [
'libs/Markdown.Converter'
]
2013-04-02 18:42:47 +00:00
}
});
2013-04-05 17:44:10 +00:00
2013-05-28 23:41:09 +00:00
// Defines the logger object
var logger = {
2013-06-02 00:38:23 +00:00
log: function() {
},
info: function() {
},
warn: function() {
},
error: function() {
}
2013-05-28 23:41:09 +00:00
};
2013-06-02 00:38:23 +00:00
// We can run StackEdit with http://.../?console to print logs in the console
if(location.search.match(/(\?|&)console/)) {
logger = console;
2013-05-28 23:41:09 +00:00
}
2013-08-21 00:16:10 +00:00
var viewerMode = /(^| )viewer($| )/.test(document.body.className);
2013-08-23 23:50:14 +00:00
2013-08-19 20:44:13 +00:00
var theme = localStorage.theme || 'default';
2013-08-23 23:50:14 +00:00
var themeModule = "less!themes/" + theme;
2013-08-26 04:58:18 +00:00
if(baseDir.indexOf('-min') !== -1) {
2013-08-23 23:50:14 +00:00
themeModule = "css!themes/" + theme;
}
2013-08-19 20:44:13 +00:00
2013-06-02 00:38:23 +00:00
// RequireJS entry point. By requiring synchronizer, publisher and
// media-importer, we are actually loading all the modules
2013-05-27 19:45:33 +00:00
require([
2013-06-02 00:38:23 +00:00
"jquery",
"core",
"synchronizer",
"publisher",
2013-08-04 00:53:46 +00:00
"mediaImporter",
2013-08-05 14:05:34 +00:00
"css",
2013-08-23 23:50:14 +00:00
themeModule,
2013-05-27 19:45:33 +00:00
], function($, core) {
2013-06-02 00:38:23 +00:00
$(function() {
// If browser has detected a new application cache.
if(window.applicationCache) {
window.applicationCache.addEventListener('updateready', function(e) {
if(window.applicationCache.status === window.applicationCache.UPDATEREADY) {
window.applicationCache.swapCache();
window.location.reload();
}
}, false);
}
// Here, all the modules are loaded and the DOM is ready
2013-08-04 00:53:46 +00:00
core.onReady();
2013-06-02 00:38:23 +00:00
});
2013-04-02 18:42:47 +00:00
});