Stackedit/res/main.js

162 lines
4.9 KiB
JavaScript
Raw Permalink 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',
2013-08-30 22:45:29 +00:00
location: 'bower-libs/require-css',
2013-08-04 11:27:50 +00:00
main: 'css'
},
{
name: 'less',
2013-08-30 22:45:29 +00:00
location: 'bower-libs/require-less',
2013-08-04 11:27:50 +00:00
main: 'less'
}
],
2013-06-02 00:38:23 +00:00
paths: {
2013-08-30 22:45:29 +00:00
jquery: 'bower-libs/jquery/jquery',
underscore: 'bower-libs/underscore/underscore',
crel: 'libs/crel',
jgrowl: 'bower-libs/jgrowl/jquery.jgrowl',
mousetrap: 'bower-libs/mousetrap/mousetrap',
toMarkdown: 'libs/to-markdown',
text: 'bower-libs/requirejs-text/text',
mathjax: '../lib/MathJax/MathJax.js?config=TeX-AMS_HTML',
bootstrap: 'bower-libs/bootstrap/dist/js/bootstrap',
requirejs: 'bower-libs/requirejs/require',
'google-code-prettify': 'bower-libs/google-code-prettify/src/prettify',
highlightjs: 'bower-libs/highlightjs/highlight.pack',
'jquery-mousewheel': 'bower-libs/jquery-mousewheel/jquery.mousewheel',
'jquery-waitforimages': 'libs/jquery.waitforimages',
'jquery-ui': 'bower-libs/jquery-ui/ui/jquery-ui',
'jquery-ui-core': 'bower-libs/jquery-ui/ui/jquery.ui.core',
'jquery-ui-widget': 'bower-libs/jquery-ui/ui/jquery.ui.widget',
'jquery-ui-mouse': 'bower-libs/jquery-ui/ui/jquery.ui.mouse',
'jquery-ui-draggable': 'bower-libs/jquery-ui/ui/jquery.ui.draggable',
'jquery-ui-effect': 'bower-libs/jquery-ui/ui/jquery.ui.effect',
'jquery-ui-effect-slide': 'bower-libs/jquery-ui/ui/jquery.ui.effect-slide',
uilayout: 'libs/layout',
css_browser_selector: 'bower-libs/css_browser_selector/css_browser_selector',
FileSaver: 'bower-libs/FileSaver/FileSaver',
stacktrace: 'bower-libs/stacktrace/stacktrace',
2013-09-03 10:37:59 +00:00
'requirejs-text': 'bower-libs/requirejs-text/text',
'bootstrap-tour': 'bower-libs/bootstrap-tour/build/js/bootstrap-tour'
2013-05-13 23:26:55 +00:00
},
2013-04-02 18:42:47 +00:00
shim: {
2013-08-30 22:45:29 +00:00
underscore: {
2013-05-27 19:45:33 +00:00
exports: '_'
},
2013-08-30 22:45:29 +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-08-30 22:45:29 +00:00
mousetrap: {
2013-06-10 21:22:32 +00:00
exports: 'Mousetrap'
},
2013-08-30 22:45:29 +00:00
toMarkdown: {
2013-06-16 10:47:35 +00:00
deps: [
'jquery'
],
exports: 'toMarkdown'
},
2013-09-03 10:37:59 +00:00
'bootstrap-tour': [
'bootstrap'
],
2013-08-30 22:45:29 +00:00
bootstrap: [
2013-06-02 00:38:23 +00:00
'jquery'
],
2013-08-30 22:45:29 +00:00
'jquery-waitforimages': [
2013-06-02 00:38:23 +00:00
'jquery'
],
2013-08-30 22:45:29 +00:00
'jquery-mousewheel': [
2013-06-02 00:38:23 +00:00
'jquery'
],
2013-08-30 22:45:29 +00:00
uilayout: [
'jquery-ui-effect-slide'
],
'jquery-ui-effect-slide': [
'jquery-ui-effect'
],
'jquery-ui-effect': [
'jquery-ui-draggable'
],
'jquery-ui-draggable': [
'jquery-ui-mouse'
2013-06-03 22:19:52 +00:00
],
2013-08-30 22:45:29 +00:00
'jquery-ui-mouse': [
'jquery-ui-widget'
],
'jquery-ui-widget': [
'jquery-ui-core'
],
'jquery-ui-core': [
'jquery'
2013-06-02 00:38:23 +00:00
],
'libs/Markdown.Extra': [
'libs/Markdown.Converter',
2013-08-30 22:45:29 +00:00
'google-code-prettify',
'highlightjs'
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",
2013-09-03 11:29:19 +00:00
"eventMgr",
2013-06-02 00:38:23 +00:00
"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-09-03 11:29:19 +00:00
], function($, core, eventMgr) {
2013-06-02 00:38:23 +00:00
$(function() {
2013-09-03 11:29:19 +00:00
// Here, all the modules are loaded and the DOM is ready
core.onReady();
2013-06-02 00:38:23 +00:00
// 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();
2013-09-03 21:51:39 +00:00
eventMgr.onMessage('New version available.\nJust refresh the page to upgrade.');
2013-06-02 00:38:23 +00:00
}
}, false);
}
});
2013-04-02 18:42:47 +00:00
});