mirror of https://github.com/gorhill/uBlock.git
addendum to fix for #2206: auto scroll to the end of user filters text box
This commit is contained in:
parent
4837b15895
commit
d1ac1286b7
|
@ -36,22 +36,29 @@ var cachedUserFilters = '';
|
||||||
|
|
||||||
// This is to give a visual hint that the content of user blacklist has changed.
|
// This is to give a visual hint that the content of user blacklist has changed.
|
||||||
|
|
||||||
function userFiltersChanged() {
|
function userFiltersChanged(changed) {
|
||||||
var changed = uDom.nodeFromId('userFilters').value.trim() !== cachedUserFilters;
|
if ( typeof changed !== 'boolean' ) {
|
||||||
|
changed = uDom.nodeFromId('userFilters').value.trim() !== cachedUserFilters;
|
||||||
|
}
|
||||||
uDom.nodeFromId('userFiltersApply').disabled = !changed;
|
uDom.nodeFromId('userFiltersApply').disabled = !changed;
|
||||||
uDom.nodeFromId('userFiltersRevert').disabled = !changed;
|
uDom.nodeFromId('userFiltersRevert').disabled = !changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
function renderUserFilters() {
|
function renderUserFilters(first) {
|
||||||
var onRead = function(details) {
|
var onRead = function(details) {
|
||||||
if ( details.error ) {
|
if ( details.error ) { return; }
|
||||||
return;
|
var textarea = uDom.nodeFromId('userFilters');
|
||||||
}
|
|
||||||
cachedUserFilters = details.content.trim();
|
cachedUserFilters = details.content.trim();
|
||||||
uDom.nodeFromId('userFilters').value = details.content;
|
textarea.value = details.content;
|
||||||
userFiltersChanged();
|
if ( first ) {
|
||||||
|
textarea.value += '\n';
|
||||||
|
var textlen = textarea.value.length;
|
||||||
|
textarea.setSelectionRange(textlen, textlen);
|
||||||
|
textarea.focus();
|
||||||
|
}
|
||||||
|
userFiltersChanged(false);
|
||||||
};
|
};
|
||||||
messaging.send('dashboard', { what: 'readUserFilters' }, onRead);
|
messaging.send('dashboard', { what: 'readUserFilters' }, onRead);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +202,7 @@ uDom('#userFilters').on('input', userFiltersChanged);
|
||||||
uDom('#userFiltersApply').on('click', applyChanges);
|
uDom('#userFiltersApply').on('click', applyChanges);
|
||||||
uDom('#userFiltersRevert').on('click', revertChanges);
|
uDom('#userFiltersRevert').on('click', revertChanges);
|
||||||
|
|
||||||
renderUserFilters();
|
renderUserFilters(true);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue