Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
commit
007db0b080
@ -61,19 +61,28 @@ define([
|
|||||||
$iframe.find('.CodeMirror').addClass('fullPage');
|
$iframe.find('.CodeMirror').addClass('fullPage');
|
||||||
editor = CodeMirror.editor;
|
editor = CodeMirror.editor;
|
||||||
|
|
||||||
var setIndentation = APP.setIndentation = function (units) {
|
var setIndentation = APP.setIndentation = function (units, useTabs) {
|
||||||
if (typeof(units) !== 'number') { return; }
|
if (typeof(units) !== 'number') { return; }
|
||||||
editor.setOption('indentUnit', units);
|
editor.setOption('indentUnit', units);
|
||||||
editor.setOption('tabSize', units);
|
editor.setOption('tabSize', units);
|
||||||
//editor.setOption('indentWithTabs', true);
|
editor.setOption('indentWithTabs', useTabs);
|
||||||
};
|
};
|
||||||
|
|
||||||
var indentKey = 'cryptpad.indentUnit';
|
var indentKey = 'cryptpad.indentUnit';
|
||||||
|
var useTabsKey = 'cryptpad.indentWithTabs';
|
||||||
|
|
||||||
var proxy = Cryptpad.getProxy();
|
var proxy = Cryptpad.getProxy();
|
||||||
proxy.on('change', [indentKey], function (o, n) {
|
|
||||||
APP.setIndentation(n);
|
var updateIndentSettings = function () {
|
||||||
});
|
var indentUnit = proxy[indentKey];
|
||||||
setIndentation(proxy[indentKey]);
|
var useTabs = proxy[useTabsKey];
|
||||||
|
setIndentation(
|
||||||
|
typeof(indentUnit) === 'number'? indentUnit: 2,
|
||||||
|
typeof(useTabs) === 'boolean'? useTabs: false);
|
||||||
|
};
|
||||||
|
|
||||||
|
proxy.on('change', [indentKey], updateIndentSettings);
|
||||||
|
proxy.on('change', [useTabsKey], updateIndentSettings);
|
||||||
|
|
||||||
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,7 @@ define([
|
|||||||
],
|
],
|
||||||
'code': [
|
'code': [
|
||||||
'indentUnit',
|
'indentUnit',
|
||||||
|
'indentType'
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,6 +164,41 @@ define([
|
|||||||
return $div;
|
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 createResetTips = function () {
|
||||||
var $div = $('<div>', {'class': 'resetTips element'});
|
var $div = $('<div>', {'class': 'resetTips element'});
|
||||||
$('<label>', {'for' : 'resetTips'}).text(Messages.settings_resetTips).appendTo($div);
|
$('<label>', {'for' : 'resetTips'}).text(Messages.settings_resetTips).appendTo($div);
|
||||||
@ -423,6 +459,7 @@ define([
|
|||||||
$rightside.append(createDisplayNameInput(obj));
|
$rightside.append(createDisplayNameInput(obj));
|
||||||
$rightside.append(createLanguageSelector());
|
$rightside.append(createLanguageSelector());
|
||||||
$rightside.append(createIndentUnitSelector(obj));
|
$rightside.append(createIndentUnitSelector(obj));
|
||||||
|
$rightside.append(createIndentTypeSelector(obj));
|
||||||
|
|
||||||
if (Cryptpad.isLoggedIn()) {
|
if (Cryptpad.isLoggedIn()) {
|
||||||
$rightside.append(createLogoutEverywhere(obj));
|
$rightside.append(createLogoutEverywhere(obj));
|
||||||
|
|||||||
@ -31,6 +31,9 @@
|
|||||||
&[type="number"] {
|
&[type="number"] {
|
||||||
border-right: 1px solid #adadad;
|
border-right: 1px solid #adadad;
|
||||||
}
|
}
|
||||||
|
&[type="checkbox"] {
|
||||||
|
margin-right: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.infoBlock {
|
.infoBlock {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user