summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Cheng-Han2016-10-10 20:47:57 +0800
committerWu Cheng-Han2016-10-10 20:47:57 +0800
commite4b40d11a20c4d6ab0676f7fe82a2421f8bf0800 (patch)
treecdb27816c9df3280a79df7122ff0b46ae08cc675
parentf6f469d0fe6082b046cf156a760324c53fcd72e5 (diff)
Update to make editor mode setting to a default variable
-rw-r--r--public/js/index.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/public/js/index.js b/public/js/index.js
index a50dacaa..b5ebe954 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1,6 +1,7 @@
var defaultTextHeight = 20;
var viewportMargin = 20;
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
+var defaultEditorMode = 'gfm';
var defaultExtraKeys = {
"F10": function (cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
@@ -359,8 +360,8 @@ var fileTypes = {
var textit = document.getElementById("textit");
if (!textit) throw new Error("There was no textit area!");
var editor = CodeMirror.fromTextArea(textit, {
- mode: 'gfm',
- backdrop: 'gfm',
+ mode: defaultEditorMode,
+ backdrop: defaultEditorMode,
keyMap: "sublime",
viewportMargin: viewportMargin,
styleActiveLine: true,
@@ -603,7 +604,7 @@ function setSpellcheck() {
if (cookieSpellcheck === 'true' || cookieSpellcheck === true) {
mode = 'spell-checker';
} else {
- mode = 'gfm';
+ mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@@ -613,10 +614,10 @@ function setSpellcheck() {
var spellcheckToggle = statusSpellcheck.find('.ui-spellcheck-toggle');
spellcheckToggle.click(function () {
var mode = editor.getOption('mode');
- if (mode == "gfm") {
+ if (mode == defaultEditorMode) {
mode = "spell-checker";
} else {
- mode = "gfm";
+ mode = defaultEditorMode;
}
if (mode && mode !== editor.getOption('mode')) {
editor.setOption('mode', mode);
@@ -628,7 +629,7 @@ function setSpellcheck() {
});
function checkSpellcheck() {
var mode = editor.getOption('mode');
- if (mode == "gfm") {
+ if (mode == defaultEditorMode) {
spellcheckToggle.removeClass('active');
} else {
spellcheckToggle.addClass('active');
@@ -1756,7 +1757,7 @@ function initRevisionViewer() {
if (revisionViewer) return;
var revisionViewerTextArea = document.getElementById("revisionViewer");
revisionViewer = CodeMirror.fromTextArea(revisionViewerTextArea, {
- mode: 'gfm',
+ mode: defaultEditorMode,
viewportMargin: viewportMargin,
lineNumbers: true,
lineWrapping: true,