Stackedit/public/res/main.js
2014-03-20 00:24:56 +00:00

205 lines
6.4 KiB
JavaScript

// RequireJS configuration
/*global requirejs */
requirejs.config({
waitSeconds: 0,
packages: [
{
name: 'css',
location: 'bower-libs/require-css',
main: 'css'
},
{
name: 'less',
location: 'bower-libs/require-less',
main: 'less'
}
],
paths: {
jquery: 'bower-libs/jquery/jquery',
underscore: 'bower-libs/underscore/underscore',
crel: 'bower-libs/crel/crel',
jgrowl: 'bower-libs/jgrowl/jquery.jgrowl',
mousetrap: 'bower-libs/mousetrap/mousetrap',
'mousetrap-record': 'bower-libs/mousetrap/plugins/record/mousetrap-record',
toMarkdown: 'bower-libs/to-markdown/src/to-markdown',
text: 'bower-libs/requirejs-text/text',
mathjax: '../libs/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: 'libs/highlight/highlight.pack',
'jquery-waitforimages': 'bower-libs/waitForImages/src/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',
FileSaver: 'bower-libs/FileSaver/FileSaver',
stacktrace: 'bower-libs/stacktrace/stacktrace',
'requirejs-text': 'bower-libs/requirejs-text/text',
'bootstrap-tour': 'bower-libs/bootstrap-tour/build/js/bootstrap-tour',
css_browser_selector: 'bower-libs/css_browser_selector/css_browser_selector',
'jquery-mousewheel': 'bower-libs/jquery-mousewheel/jquery.mousewheel',
'pagedown-extra': 'bower-libs/pagedown-extra/Markdown.Extra',
'pagedown': 'bower-libs/stackedit-pagedown/Markdown.Editor',
'require-css': 'bower-libs/require-css/css',
xregexp: 'bower-libs/xregexp/xregexp-all',
yaml: 'bower-libs/yaml.js',
'yaml.js': 'bower-libs/yaml.js',
'yaml-js': 'bower-libs/yaml.js/bin/yaml',
css: 'bower-libs/require-css/css',
'css-builder': 'bower-libs/require-css/css-builder',
normalize: 'bower-libs/require-css/normalize',
prism: 'bower-libs/prism/prism',
'prism-core': 'bower-libs/prism/components/prism-core'
},
shim: {
underscore: {
exports: '_'
},
mathjax: [
'libs/mathjax_init'
],
jgrowl: {
deps: [
'jquery'
],
exports: 'jQuery.jGrowl'
},
mousetrap: {
exports: 'Mousetrap'
},
'yaml-js': {
exports: 'YAML'
},
'prism-core': {
exports: 'Prism'
},
'bower-libs/prism/components/prism-markup': [
'prism-core'
],
'libs/prism-latex': [
'prism-core'
],
'libs/prism-markdown': [
'bower-libs/prism/components/prism-markup',
'libs/prism-latex'
],
'bootstrap-record': [
'mousetrap'
],
toMarkdown: {
deps: [
'jquery'
],
exports: 'toMarkdown'
},
stacktrace: {
exports: 'printStackTrace'
},
FileSaver: {
exports: 'saveAs'
},
highlightjs: {
exports: 'hljs'
},
'bootstrap-tour': {
deps: [
'bootstrap'
],
exports: 'Tour'
},
bootstrap: [
'jquery'
],
'jquery-waitforimages': [
'jquery'
],
'jquery-mousewheel': [
'jquery'
],
uilayout: [
'jquery-ui-effect-slide'
],
'jquery-ui-effect-slide': [
'jquery-ui-effect'
],
'jquery-ui-effect': [
'jquery-ui-draggable'
],
'jquery-ui-draggable': [
'jquery-ui-mouse'
],
'jquery-ui-mouse': [
'jquery-ui-widget'
],
'jquery-ui-widget': [
'jquery-ui-core'
],
'jquery-ui-core': [
'jquery'
],
'pagedown': [
'bower-libs/stackedit-pagedown/Markdown.Converter'
],
'pagedown-extra': [
'bower-libs/stackedit-pagedown/Markdown.Converter'
],
}
});
// Check browser compatibility
try {
var test = 'seLocalStorageCheck';
localStorage.setItem(test, test);
localStorage.removeItem(test);
var obj = {};
Object.defineProperty(obj, 'prop', {
get: function() {},
set: function() {}
});
}
catch (e) {
alert('Your browser is not supported, sorry!');
throw e;
}
// Viewer mode is deduced from the body class
window.viewerMode = /(^| )viewer($| )/.test(document.body.className);
// Keep the theme in a global variable
window.theme = localStorage.themeV3 || 'default';
var themeModule = "less!themes/" + window.theme;
if (window.baseDir.indexOf('-min') !== -1) {
themeModule = "css!themes/" + window.theme;
}
// RequireJS entry point. By requiring synchronizer, publisher and
// media-importer, we are actually loading all the modules
require(["jquery", "core", "eventMgr", "synchronizer", "publisher", "mediaImporter", "css",
themeModule, ], function($, core, eventMgr) {
if(window.noStart) {
return;
}
$(function() {
// Here, all the modules are loaded and the DOM is ready
core.onReady();
// If browser has detected a new application cache.
if (window.applicationCache) {
window.applicationCache.addEventListener('updateready', function() {
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
window.applicationCache.swapCache();
eventMgr.onMessage('New version available!\nJust refresh the page to upgrade.');
}
}, false);
}
});
});