fix #3594: incomplete conversion to CodeMirror widget

This commit is contained in:
Raymond Hill 2018-03-12 12:08:45 -04:00
parent b42c128213
commit b89ec2861c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 13 additions and 21 deletions

View File

@ -111,9 +111,7 @@ var handleImportFilePicker = function() {
var fileReaderOnLoadHandler = function() { var fileReaderOnLoadHandler = function() {
var sanitized = abpImporter(this.result); var sanitized = abpImporter(this.result);
var textarea = uDom('#userFilters'); cmEditor.setValue(cmEditor.getValue().trim() + '\n' + sanitized);
textarea.val(textarea.val().trim() + '\n' + sanitized);
userFiltersChanged();
}; };
var file = this.files[0]; var file = this.files[0];
if ( file === undefined || file.name === '' ) { if ( file === undefined || file.name === '' ) {
@ -141,10 +139,8 @@ var startImportFilePicker = function() {
/******************************************************************************/ /******************************************************************************/
var exportUserFiltersToFile = function() { var exportUserFiltersToFile = function() {
var val = uDom('#userFilters').val().trim(); var val = cmEditor.getValue().trim();
if ( val === '' ) { if ( val === '' ) { return; }
return;
}
var filename = vAPI.i18n('1pExportFilename') var filename = vAPI.i18n('1pExportFilename')
.replace('{{datetime}}', uBlockDashboard.dateNowToSensibleString()) .replace('{{datetime}}', uBlockDashboard.dateNowToSensibleString())
.replace(/ +/g, '_'); .replace(/ +/g, '_');
@ -160,15 +156,16 @@ var applyChanges = function() {
var onWritten = function(details) { var onWritten = function(details) {
if ( details.error ) { return; } if ( details.error ) { return; }
cachedUserFilters = details.content.trim(); cachedUserFilters = details.content.trim();
userFiltersChanged();
allFiltersApplyHandler(); allFiltersApplyHandler();
}; };
messaging.send(
var request = { 'dashboard',
{
what: 'writeUserFilters', what: 'writeUserFilters',
content: cmEditor.getValue() content: cmEditor.getValue()
}; },
messaging.send('dashboard', request, onWritten); onWritten
);
}; };
var revertChanges = function() { var revertChanges = function() {
@ -177,7 +174,6 @@ var revertChanges = function() {
content += '\n'; content += '\n';
} }
cmEditor.setValue(content); cmEditor.setValue(content);
userFiltersChanged();
}; };
/******************************************************************************/ /******************************************************************************/
@ -187,15 +183,11 @@ var getCloudData = function() {
}; };
var setCloudData = function(data, append) { var setCloudData = function(data, append) {
if ( typeof data !== 'string' ) { if ( typeof data !== 'string' ) { return; }
return;
}
var textarea = uDom.nodeFromId('userFilters');
if ( append ) { if ( append ) {
data = uBlockDashboard.mergeNewLines(textarea.value, data); data = uBlockDashboard.mergeNewLines(cmEditor.getValue(), data);
} }
cmEditor.setValue(data); cmEditor.setValue(data);
userFiltersChanged();
}; };
self.cloud.onPush = getCloudData; self.cloud.onPush = getCloudData;