addendum to fix for #2206: auto scroll to the end of user filters text box

This commit is contained in:
gorhill 2016-12-07 09:43:11 -05:00
parent 4837b15895
commit d1ac1286b7
1 changed files with 16 additions and 9 deletions

View File

@ -36,22 +36,29 @@ var cachedUserFilters = '';
// This is to give a visual hint that the content of user blacklist has changed.
function userFiltersChanged() {
var changed = uDom.nodeFromId('userFilters').value.trim() !== cachedUserFilters;
function userFiltersChanged(changed) {
if ( typeof changed !== 'boolean' ) {
changed = uDom.nodeFromId('userFilters').value.trim() !== cachedUserFilters;
}
uDom.nodeFromId('userFiltersApply').disabled = !changed;
uDom.nodeFromId('userFiltersRevert').disabled = !changed;
}
/******************************************************************************/
function renderUserFilters() {
function renderUserFilters(first) {
var onRead = function(details) {
if ( details.error ) {
return;
}
if ( details.error ) { return; }
var textarea = uDom.nodeFromId('userFilters');
cachedUserFilters = details.content.trim();
uDom.nodeFromId('userFilters').value = details.content;
userFiltersChanged();
textarea.value = details.content;
if ( first ) {
textarea.value += '\n';
var textlen = textarea.value.length;
textarea.setSelectionRange(textlen, textlen);
textarea.focus();
}
userFiltersChanged(false);
};
messaging.send('dashboard', { what: 'readUserFilters' }, onRead);
}
@ -195,7 +202,7 @@ uDom('#userFilters').on('input', userFiltersChanged);
uDom('#userFiltersApply').on('click', applyChanges);
uDom('#userFiltersRevert').on('click', revertChanges);
renderUserFilters();
renderUserFilters(true);
/******************************************************************************/