allow users to write with tabs instead of spaces

This commit is contained in:
ansuz
2017-08-11 15:21:26 +02:00
parent 64849507b3
commit 66cacf08da
3 changed files with 55 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ define([
],
'code': [
'indentUnit',
'indentType'
]
};
@@ -163,6 +164,41 @@ define([
return $div;
};
var createIndentTypeSelector = function (obj) {
var proxy = obj.proxy;
var key = 'cryptpad.indentWithTabs';
var $div = $('<div>', {
'class': 'indentType element'
});
$('<label>').text(Messages.settings_codeUseTabs).appendTo($div);
var $inputBlock = $('<div>', {
'class': 'inputBlock',
}).appendTo($div);
var $input = $('<input>', {
type: 'checkbox',
}).on('change', function () {
var val = $input.is(':checked');
if (typeof(val) !== 'boolean') { return; }
proxy[key] = val;
}).appendTo($inputBlock);
proxy.on('change', [key], function (o, n) { $input.val(n); });
Cryptpad.getAttribute('indentUnit', function (e, val) {
if (e) { return void console.error(e); }
if (typeof(val) !== 'number') {
$input.val(2);
} else {
$input.val(val);
}
});
return $div;
};
var createResetTips = function () {
var $div = $('<div>', {'class': 'resetTips element'});
$('<label>', {'for' : 'resetTips'}).text(Messages.settings_resetTips).appendTo($div);
@@ -423,6 +459,7 @@ define([
$rightside.append(createDisplayNameInput(obj));
$rightside.append(createLanguageSelector());
$rightside.append(createIndentUnitSelector(obj));
$rightside.append(createIndentTypeSelector(obj));
if (Cryptpad.isLoggedIn()) {
$rightside.append(createLogoutEverywhere(obj));