Simplify options page
This commit is contained in:
parent
9b9985bd4b
commit
c620b4ba36
@ -33,23 +33,16 @@ function formToOptions() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#saveOptions').click(() => {
|
function onOptionsChanged() {
|
||||||
const opts = formToOptions();
|
const opts = formToOptions();
|
||||||
saveOptions(opts, () => {
|
saveOptions(opts, () => {
|
||||||
$('.notifyAlerts').hide();
|
|
||||||
$('#notifySave').slideDown();
|
|
||||||
chrome.extension.getBackgroundPage().yomichan.setOptions(opts);
|
chrome.extension.getBackgroundPage().yomichan.setOptions(opts);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
$('#resetOptions').click(() => {
|
$(document).ready(() => {
|
||||||
optionsToForm(sanitizeOptions({}));
|
loadOptions((opts) => {
|
||||||
$('.notifyAlerts').hide();
|
optionsToForm(opts);
|
||||||
$('#notifyReset').slideDown();
|
$('input').on('input paste change', onOptionsChanged);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-hide]').on('click', function() {
|
|
||||||
$('#' + $(this).attr('data-hide')).hide();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(() => loadOptions((opts) => optionsToForm(opts)));
|
|
||||||
|
@ -5,11 +5,6 @@
|
|||||||
<title>Yomichan Options</title>
|
<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.min.css">
|
||||||
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -46,25 +41,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</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">×</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">×</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>
|
</form>
|
||||||
|
|
||||||
<script src="../lib/jquery-2.2.2.min.js"></script>
|
<script src="../lib/jquery-2.2.2.min.js"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user