Set font size in code editor from the settings page (#140)

This commit is contained in:
yflory
2018-10-29 11:46:57 +01:00
parent 2af2fccc11
commit 8b554dec63
3 changed files with 43 additions and 4 deletions

View File

@@ -73,7 +73,8 @@ define([
],
'code': [
'cp-settings-code-indent-unit',
'cp-settings-code-indent-type'
'cp-settings-code-indent-type',
'cp-settings-code-font-size',
],
'subscription': {
onClick: function () {
@@ -1207,6 +1208,39 @@ define([
return $div;
};
create['code-font-size'] = function () {
var key = 'fontSize';
var $div = $('<div>', {
'class': 'cp-settings-code-font-size cp-sidebarlayout-element'
});
$('<label>').text(Messages.settings_codeFontSize).appendTo($div);
var $inputBlock = $('<div>', {
'class': 'cp-sidebarlayout-input-block',
}).appendTo($div);
var $input = $('<input>', {
'min': 8,
'max': 30,
type: 'number',
}).on('change', function () {
var val = parseInt($input.val());
if (typeof(val) !== 'number') { return; }
common.setAttribute(['codemirror', key], val);
}).appendTo($inputBlock);
common.getAttribute(['codemirror', key], function (e, val) {
if (e) { return void console.error(e); }
if (typeof(val) !== 'number') {
$input.val(12);
} else {
$input.val(val);
}
});
return $div;
};
// Settings app
var createUsageButton = function () {