|
|
|
@ -77,7 +77,10 @@ define([
|
|
|
|
|
}
|
|
|
|
|
CodeMirror.autoLoadMode(editor, mode);
|
|
|
|
|
editor.setOption('mode', mode);
|
|
|
|
|
if ($select && $select.val) { $select.val(mode); }
|
|
|
|
|
if ($select) {
|
|
|
|
|
var name = $select.find('a[data-value="' + mode + '"]').text() || 'Mode';
|
|
|
|
|
$select.find('.buttonTitle').text(name);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
editor.setValue(Messages.codeInitialState); // HERE
|
|
|
|
@ -107,7 +110,7 @@ define([
|
|
|
|
|
}
|
|
|
|
|
editor.setOption('theme', theme);
|
|
|
|
|
}
|
|
|
|
|
if ($select && $select.val) { $select.val(theme || 'default'); }
|
|
|
|
|
if ($select) { $select.find('.buttonTitle').text(theme || 'Theme'); }
|
|
|
|
|
};
|
|
|
|
|
}());
|
|
|
|
|
|
|
|
|
@ -441,58 +444,68 @@ define([
|
|
|
|
|
|
|
|
|
|
var configureLanguage = function (cb) {
|
|
|
|
|
// FIXME this is async so make it happen as early as possible
|
|
|
|
|
|
|
|
|
|
/* Let the user select different syntax highlighting modes */
|
|
|
|
|
var $language = module.$language = $('<select>', {
|
|
|
|
|
title: 'syntax highlighting',
|
|
|
|
|
id: 'language-mode',
|
|
|
|
|
'class': 'rightside-element'
|
|
|
|
|
}).on('change', function () {
|
|
|
|
|
setMode($language.val());
|
|
|
|
|
onLocal();
|
|
|
|
|
var options = [];
|
|
|
|
|
Modes.list.forEach(function (l) {
|
|
|
|
|
options.push({
|
|
|
|
|
tag: 'a',
|
|
|
|
|
attributes: {
|
|
|
|
|
'data-value': l.mode,
|
|
|
|
|
'href': '#',
|
|
|
|
|
},
|
|
|
|
|
content: l.language // Pretty name of the language value
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Modes.list.map(function (o) {
|
|
|
|
|
$language.append($('<option>', {
|
|
|
|
|
value: o.mode,
|
|
|
|
|
}).text(o.language));
|
|
|
|
|
var dropdownConfig = {
|
|
|
|
|
text: 'Mode', // Button initial text
|
|
|
|
|
options: options, // Entries displayed in the menu
|
|
|
|
|
left: true, // Open to the left of the button
|
|
|
|
|
};
|
|
|
|
|
var $block = module.$language = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
|
var $button = $block.find('.buttonTitle');
|
|
|
|
|
|
|
|
|
|
$block.find('a').click(function (e) {
|
|
|
|
|
setMode($(this).attr('data-value'));
|
|
|
|
|
$button.text($(this).text());
|
|
|
|
|
});
|
|
|
|
|
$rightside.append($language);
|
|
|
|
|
|
|
|
|
|
$rightside.append($block);
|
|
|
|
|
cb();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var configureTheme = function () {
|
|
|
|
|
/* Remember the user's last choice of theme using localStorage */
|
|
|
|
|
var themeKey = 'CRYPTPAD_CODE_THEME';
|
|
|
|
|
var lastTheme = localStorage.getItem(themeKey) || 'default';
|
|
|
|
|
|
|
|
|
|
/* Let the user select different themes */
|
|
|
|
|
var $themeDropdown = $('<select>', {
|
|
|
|
|
title: 'color theme',
|
|
|
|
|
id: 'display-theme',
|
|
|
|
|
'class': 'rightside-element'
|
|
|
|
|
});
|
|
|
|
|
Themes.forEach(function (o) {
|
|
|
|
|
$themeDropdown.append($('<option>', {
|
|
|
|
|
selected: o.name === lastTheme,
|
|
|
|
|
}).val(o.name).text(o.name));
|
|
|
|
|
var options = [];
|
|
|
|
|
Themes.forEach(function (l) {
|
|
|
|
|
options.push({
|
|
|
|
|
tag: 'a',
|
|
|
|
|
attributes: {
|
|
|
|
|
'data-value': l.name,
|
|
|
|
|
'href': '#',
|
|
|
|
|
},
|
|
|
|
|
content: l.name // Pretty name of the language value
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$rightside.append($themeDropdown);
|
|
|
|
|
|
|
|
|
|
var $theme = $bar.find('select#display-theme');
|
|
|
|
|
|
|
|
|
|
setTheme(lastTheme, $theme);
|
|
|
|
|
|
|
|
|
|
$theme.on('change', function () {
|
|
|
|
|
var theme = $theme.val();
|
|
|
|
|
console.log("Setting theme to %s", theme);
|
|
|
|
|
setTheme(theme, $theme);
|
|
|
|
|
// remember user choices
|
|
|
|
|
var dropdownConfig = {
|
|
|
|
|
text: 'Theme', // Button initial text
|
|
|
|
|
options: options, // Entries displayed in the menu
|
|
|
|
|
left: true, // Open to the left of the button
|
|
|
|
|
};
|
|
|
|
|
var $block = module.$theme = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
|
var $button = $block.find('.buttonTitle');
|
|
|
|
|
|
|
|
|
|
setTheme(lastTheme, $block);
|
|
|
|
|
|
|
|
|
|
$block.find('a').click(function (e) {
|
|
|
|
|
var theme = $(this).attr('data-value');
|
|
|
|
|
setTheme(theme, $block);
|
|
|
|
|
$button.text($(this).text());
|
|
|
|
|
localStorage.setItem(themeKey, theme);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$rightside.append($block);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
|