2013-10-19 22:59:17 +00:00
|
|
|
// RequireJS configuration
|
2013-11-05 23:03:38 +00:00
|
|
|
/*global requirejs */
|
2013-10-19 22:59:17 +00:00
|
|
|
requirejs.config({
|
2014-04-27 20:10:30 +00:00
|
|
|
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',
|
2014-09-01 21:27:15 +00:00
|
|
|
mathjax: 'bower-libs/MathJax/MathJax.js?config=TeX-AMS_HTML',
|
2014-04-27 20:10:30 +00:00
|
|
|
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',
|
|
|
|
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',
|
2014-08-31 19:51:13 +00:00
|
|
|
'pagedown-extra': 'bower-libs/pagedown-extra/node-pagedown-extra',
|
|
|
|
pagedownExtra: 'bower-libs/pagedown-extra/Markdown.Extra',
|
2014-04-27 20:10:30 +00:00
|
|
|
pagedown: 'libs/Markdown.Editor',
|
|
|
|
'require-css': 'bower-libs/require-css/css',
|
|
|
|
xregexp: 'bower-libs/xregexp/xregexp-all',
|
2014-08-31 19:51:13 +00:00
|
|
|
yaml: 'bower-libs/yaml.js/bin/yaml',
|
2014-04-27 20:10:30 +00:00
|
|
|
'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',
|
|
|
|
MutationObservers: 'bower-libs/MutationObservers/MutationObserver',
|
|
|
|
WeakMap: 'bower-libs/WeakMap/weakmap',
|
|
|
|
rangy: 'bower-libs/rangy/rangy-core',
|
|
|
|
'rangy-cssclassapplier': 'bower-libs/rangy/rangy-cssclassapplier',
|
|
|
|
diff_match_patch: 'bower-libs/google-diff-match-patch-js/diff_match_patch',
|
|
|
|
diff_match_patch_uncompressed: 'bower-libs/google-diff-match-patch-js/diff_match_patch_uncompressed',
|
|
|
|
jsondiffpatch: 'bower-libs/jsondiffpatch/build/bundle',
|
|
|
|
hammerjs: 'bower-libs/hammerjs/hammer',
|
2014-08-31 19:51:13 +00:00
|
|
|
Diagram: 'bower-libs/js-sequence-diagrams/src/sequence-diagram',
|
2014-08-21 23:16:15 +00:00
|
|
|
'diagram-grammar': 'bower-libs/js-sequence-diagrams/build/diagram-grammar',
|
2014-04-27 20:10:30 +00:00
|
|
|
raphael: 'bower-libs/raphael/raphael',
|
|
|
|
'flow-chart': 'bower-libs/flowchart/release/flowchart.amd-1.2.10.min',
|
2014-08-10 23:45:52 +00:00
|
|
|
flowchart: 'bower-libs/flowchart/release/flowchart-1.2.10.min',
|
2014-08-31 19:51:13 +00:00
|
|
|
monetizejs: 'bower-libs/monetizejs/src/monetize',
|
|
|
|
'to-markdown': 'bower-libs/to-markdown/src/to-markdown',
|
2014-09-01 21:27:15 +00:00
|
|
|
waitForImages: 'bower-libs/waitForImages/dist/jquery.waitforimages',
|
|
|
|
MathJax: 'bower-libs/MathJax/MathJax'
|
2014-04-27 20:10:30 +00:00
|
|
|
},
|
|
|
|
shim: {
|
|
|
|
underscore: {
|
|
|
|
exports: '_'
|
|
|
|
},
|
|
|
|
mathjax: [
|
|
|
|
'libs/mathjax_init'
|
|
|
|
],
|
|
|
|
jgrowl: {
|
|
|
|
deps: [
|
|
|
|
'jquery'
|
|
|
|
],
|
|
|
|
exports: 'jQuery.jGrowl'
|
|
|
|
},
|
|
|
|
diff_match_patch_uncompressed: {
|
|
|
|
exports: 'diff_match_patch'
|
|
|
|
},
|
|
|
|
jsondiffpatch: [
|
|
|
|
'diff_match_patch_uncompressed'
|
|
|
|
],
|
|
|
|
rangy: {
|
|
|
|
exports: 'rangy'
|
|
|
|
},
|
|
|
|
'rangy-cssclassapplier': [
|
|
|
|
'rangy'
|
|
|
|
],
|
|
|
|
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'
|
|
|
|
},
|
|
|
|
MutationObservers: [
|
|
|
|
'WeakMap'
|
|
|
|
],
|
|
|
|
highlightjs: {
|
|
|
|
exports: 'hljs'
|
|
|
|
},
|
|
|
|
'bootstrap-tour': {
|
|
|
|
deps: [
|
|
|
|
'bootstrap'
|
|
|
|
],
|
|
|
|
exports: 'Tour'
|
|
|
|
},
|
|
|
|
bootstrap: [
|
|
|
|
'jquery'
|
|
|
|
],
|
|
|
|
'jquery-waitforimages': [
|
|
|
|
'jquery'
|
|
|
|
],
|
|
|
|
pagedown: [
|
|
|
|
'libs/Markdown.Converter'
|
|
|
|
],
|
2014-08-31 19:51:13 +00:00
|
|
|
pagedownExtra: [
|
2014-04-27 20:10:30 +00:00
|
|
|
'libs/Markdown.Converter'
|
|
|
|
],
|
|
|
|
'flow-chart': [
|
|
|
|
'raphael'
|
2014-08-21 23:16:15 +00:00
|
|
|
],
|
|
|
|
'diagram-grammar': [
|
|
|
|
'underscore'
|
|
|
|
],
|
2014-08-31 19:51:13 +00:00
|
|
|
Diagram: [
|
2014-08-21 23:16:15 +00:00
|
|
|
'raphael',
|
|
|
|
'diagram-grammar'
|
2014-04-27 20:10:30 +00:00
|
|
|
]
|
|
|
|
}
|
2013-10-19 22:59:17 +00:00
|
|
|
});
|
|
|
|
|
2014-09-01 21:27:15 +00:00
|
|
|
if(window.baseDir.slice(-7) == 'res-min') {
|
|
|
|
requirejs.config({
|
|
|
|
paths: {
|
|
|
|
mathjax: '//cdn.mathjax.org/mathjax/2.4-latest/MathJax.js?config=TeX-AMS_HTML'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-19 22:59:17 +00:00
|
|
|
// Check browser compatibility
|
|
|
|
try {
|
2014-04-27 20:10:30 +00:00
|
|
|
var test = 'seLocalStorageCheck';
|
|
|
|
localStorage.setItem(test, test);
|
|
|
|
localStorage.removeItem(test);
|
|
|
|
var obj = {};
|
|
|
|
Object.defineProperty(obj, 'prop', {
|
|
|
|
get: function() {
|
|
|
|
},
|
|
|
|
set: function() {
|
|
|
|
}
|
|
|
|
});
|
2013-10-19 22:59:17 +00:00
|
|
|
}
|
2014-04-27 20:10:30 +00:00
|
|
|
catch(e) {
|
|
|
|
alert('Your browser is not supported, sorry!');
|
|
|
|
throw e;
|
2013-10-19 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Viewer mode is deduced from the body class
|
2013-11-05 23:03:38 +00:00
|
|
|
window.viewerMode = /(^| )viewer($| )/.test(document.body.className);
|
2013-10-19 22:59:17 +00:00
|
|
|
|
|
|
|
// Keep the theme in a global variable
|
2014-08-19 08:17:27 +00:00
|
|
|
window.theme = localStorage.themeV4 || 'default';
|
2013-11-07 23:10:38 +00:00
|
|
|
var themeModule = "less!themes/" + window.theme;
|
2014-04-27 20:10:30 +00:00
|
|
|
if(window.baseDir.indexOf('-min') !== -1) {
|
|
|
|
themeModule = "css!themes/" + window.theme;
|
2013-10-19 22:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RequireJS entry point. By requiring synchronizer, publisher and
|
|
|
|
// media-importer, we are actually loading all the modules
|
2014-04-27 20:10:30 +00:00
|
|
|
require([
|
|
|
|
"jquery",
|
|
|
|
"rangy",
|
|
|
|
"core",
|
|
|
|
"eventMgr",
|
|
|
|
"synchronizer",
|
|
|
|
"publisher",
|
|
|
|
"mediaImporter",
|
|
|
|
"css",
|
|
|
|
"rangy-cssclassapplier",
|
2014-08-31 19:51:13 +00:00
|
|
|
themeModule
|
2014-04-27 20:10:30 +00:00
|
|
|
], function($, rangy, core, eventMgr) {
|
2014-03-20 00:24:56 +00:00
|
|
|
|
2014-04-27 20:10:30 +00:00
|
|
|
if(window.noStart) {
|
|
|
|
return;
|
|
|
|
}
|
2013-10-19 22:59:17 +00:00
|
|
|
|
2014-04-27 20:10:30 +00:00
|
|
|
$(function() {
|
|
|
|
rangy.init();
|
2014-03-22 01:57:31 +00:00
|
|
|
|
2014-04-27 20:10:30 +00:00
|
|
|
// Here, all the modules are loaded and the DOM is ready
|
|
|
|
core.onReady();
|
2013-10-19 22:59:17 +00:00
|
|
|
|
2014-04-27 20:10:30 +00:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
});
|
2013-10-19 22:59:17 +00:00
|
|
|
|
|
|
|
});
|