Simplify options page

This commit is contained in:
Alex Yatskov 2016-05-07 14:02:54 -07:00
parent 9b9985bd4b
commit c620b4ba36
2 changed files with 7 additions and 38 deletions

View File

@ -33,23 +33,16 @@ function formToOptions() {
});
}
$('#saveOptions').click(() => {
function onOptionsChanged() {
const opts = formToOptions();
saveOptions(opts, () => {
$('.notifyAlerts').hide();
$('#notifySave').slideDown();
chrome.extension.getBackgroundPage().yomichan.setOptions(opts);
});
});
}
$('#resetOptions').click(() => {
optionsToForm(sanitizeOptions({}));
$('.notifyAlerts').hide();
$('#notifyReset').slideDown();
$(document).ready(() => {
loadOptions((opts) => {
optionsToForm(opts);
$('input').on('input paste change', onOptionsChanged);
});
});
$('[data-hide]').on('click', function() {
$('#' + $(this).attr('data-hide')).hide();
});
$(document).ready(() => loadOptions((opts) => optionsToForm(opts)));

View File

@ -5,11 +5,6 @@
<title>Yomichan Options</title>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
<style type="text/css">
.notifyAlerts {
display: none;
}
</style>
</head>
<body>
<div class="container">
@ -46,25 +41,6 @@
</div>
</div>
</div>
<div class="alert alert-success notifyAlerts" id="notifySave">
Preferences saved
<button type="button" class="close" data-hide="notifySave">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="alert alert-warning notifyAlerts" id="notifyReset">
Preferences reset to defaults
<button type="button" class="close" data-hide="notifyReset">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="text-right">
<button type="button" id="saveOptions" class="btn btn-default">Save</button>
<button type="button" id="resetOptions" class="btn btn-danger">Reset</button>
</div>
</form>
<script src="../lib/jquery-2.2.2.min.js"></script>