Resolve a regression in the Chromium extension's preferences handling

Commit df10513e10 unfortunately broke the options dialog of the Chromium extension because the logic required to work with the preference was not added. This patch adds the required logic to show the preference in the options dialog and to persist it to the preferences storage.

Verified using Chromium 50 on Arch Linux.
This commit is contained in:
Tim van der Meij 2016-05-25 00:32:32 +02:00
parent 6316ca0299
commit fdfaa43f5e
2 changed files with 34 additions and 0 deletions

View File

@ -80,6 +80,21 @@ body {
</div>
</template>
<template id="externalLinkTarget-template">
<div class="settings-row">
<label>
<span></span>
<select>
<option value="0">Default</option>
<option value="1">Current window/tab</option>
<option value="2">New window/tab</option>
<option value="3">Parent window/tab</option>
<option value="4">Top window/tab</option>
</select>
</label>
</div>
</template>
<script src="options.js"></script>
</body>
</html>

View File

@ -74,6 +74,8 @@ Promise.all([
renderPreference = renderDefaultZoomValue(prefSchema.title);
} else if (prefName === 'sidebarViewOnLoad') {
renderPreference = renderSidebarViewOnLoad(prefSchema.title);
} else if (prefName === 'externalLinkTarget') {
renderPreference = renderExternalLinkTarget(prefSchema.title);
} else {
// Should NEVER be reached. Only happens if a new type of preference is
// added to the storage manifest.
@ -190,3 +192,20 @@ function renderSidebarViewOnLoad(shortDescription) {
}
return renderPreference;
}
function renderExternalLinkTarget(shortDescription) {
var wrapper = importTemplate('externalLinkTarget-template');
var select = wrapper.querySelector('select');
select.onchange = function() {
chrome.storage.local.set({
externalLinkTarget: parseInt(this.value)
});
};
wrapper.querySelector('span').textContent = shortDescription;
document.getElementById('settings-boxes').appendChild(wrapper);
function renderPreference(value) {
select.value = value;
}
return renderPreference;
}