Fix & cleanup config in popup. Closes #602 (#603)

* Fix & cleanup config in popup. Closes #602

* Hide icon for USO with no config
This commit is contained in:
Rob Garrison 2018-12-10 07:57:44 -06:00 committed by GitHub
parent 8b8a3d60ab
commit 7f3013f477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,15 +276,24 @@ function createStyleElement({
}); });
styleName.checkbox = checkbox; styleName.checkbox = checkbox;
styleName.appendChild(document.createTextNode(' ')); styleName.appendChild(document.createTextNode(' '));
const config = $('.configure', entry); const config = $('.configure', entry);
if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) { config.onclick = handleEvent.configure;
config.target = '_blank'; if (!style.usercssData) {
config.title = t('configureStyleOnHomepage'); if (style.updateUrl && style.updateUrl.includes('?') && style.url) {
config.dataset.sendMessage = JSON.stringify({method: 'openSettings'}); config.href = style.url;
$('use', config).attributes['xlink:href'].nodeValue = '#svg-icon-config-uso'; config.target = '_blank';
config.title = t('configureStyleOnHomepage');
config.dataset.sendMessage = JSON.stringify({method: 'openSettings'});
$('use', config).attributes['xlink:href'].nodeValue = '#svg-icon-config-uso';
} else {
config.classList.add('hidden');
}
} else if (Object.keys(style.usercssData.vars || {}).length === 0) {
config.classList.add('hidden');
} }
$('.delete', entry).onclick = handleEvent.delete; $('.delete', entry).onclick = handleEvent.delete;
$('.configure', entry).onclick = handleEvent.configure;
const indicator = template.regexpProblemIndicator.cloneNode(true); const indicator = template.regexpProblemIndicator.cloneNode(true);
indicator.appendChild(document.createTextNode('!')); indicator.appendChild(document.createTextNode('!'));
@ -307,15 +316,6 @@ function createStyleElement({
styleName.textContent : ''; styleName.textContent : '';
}); });
const config = $('.configure', entry);
if (!style.usercssData && style.updateUrl && style.updateUrl.includes('?') && style.url) {
config.href = style.url;
}
config.style.display =
!style.usercssData && config.href ||
style.usercssData && Object.keys(style.usercssData.vars || {}).length ?
'' : 'none';
entry.classList.toggle('not-applied', style.excluded || style.sloppy); entry.classList.toggle('not-applied', style.excluded || style.sloppy);
entry.classList.toggle('regexp-partial', style.sloppy); entry.classList.toggle('regexp-partial', style.sloppy);