Update style settings on USO without page reload

This commit is contained in:
tophf 2017-06-04 10:39:27 +03:00
parent be9cfe072d
commit 2b1d874236

View File

@ -122,18 +122,32 @@ function saveStyleCode(message, name, addProps) {
if (!confirm(chrome.i18n.getMessage(message, [name]))) { if (!confirm(chrome.i18n.getMessage(message, [name]))) {
return; return;
} }
enableUpdateButton(false);
getResource(getStyleURL()).then(code => { getResource(getStyleURL()).then(code => {
chrome.runtime.sendMessage( chrome.runtime.sendMessage(
Object.assign(JSON.parse(code), addProps, { Object.assign(JSON.parse(code), addProps, {
method: 'saveStyle', method: 'saveStyle',
reason: 'update', reason: 'update',
}), }),
() => sendEvent('styleInstalledChrome') style => {
if (style.updateUrl.includes('?')) {
enableUpdateButton(true);
} else {
sendEvent('styleInstalledChrome');
}
}
); );
resolve(); resolve();
}); });
}); });
function enableUpdateButton(state) {
const button = document.getElementById('update_style_button');
if (button) {
button.style.cssText = state ? '' :
'pointer-events: none !important; opacity: .25 !important;';
}
}
} }