summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-12 12:59:51 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-12 15:44:32 -0400
commitbe7fa57d5ced7f6969c5d66f0a35fafb9de3bcee (patch)
tree35d7e02c9d49adb2bb42ccba0dc7f241d7da2eb3 /ext/bg/js/settings.js
parent537d2ef532aa7b7498de13ab039bd23f28d32714 (diff)
Add support for a popup preview
Diffstat (limited to 'ext/bg/js/settings.js')
-rw-r--r--ext/bg/js/settings.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index bd15f5d0..5732b8ae 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -248,6 +248,7 @@ async function onReady() {
showExtensionInformation();
formSetupEventListeners();
+ appearanceInitialize();
await audioSettingsInitialize();
await profileOptionsSetup();
@@ -260,6 +261,43 @@ $(document).ready(utilAsync(onReady));
/*
+ * Appearance
+ */
+
+function appearanceInitialize() {
+ let previewVisible = false;
+ $('#settings-popup-preview-button').on('click', () => {
+ if (previewVisible) { return; }
+ showAppearancePreview();
+ previewVisible = true;
+ });
+}
+
+function showAppearancePreview() {
+ const container = $('#settings-popup-preview-container');
+ const buttonContainer = $('#settings-popup-preview-button-container');
+ const settings = $('#settings-popup-preview-settings');
+ const text = $('#settings-popup-preview-text');
+
+ const frame = document.createElement('iframe');
+ frame.src = '/bg/settings-popup-preview.html';
+ frame.id = 'settings-popup-preview-frame';
+
+ window.wanakana.bind(text[0]);
+
+ text.on('input', () => {
+ const action = 'setText';
+ const params = {text: text.val()};
+ frame.contentWindow.postMessage({action, params}, '*');
+ });
+
+ container.append(frame);
+ buttonContainer.remove();
+ settings.css('display', '');
+}
+
+
+/*
* Audio
*/