From d42a07dc0b722f77f64acf14ce818a2be532ea3f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 13 Oct 2019 18:23:59 -0400 Subject: [PATCH] Improve layout of context.html on Firefox Mobile --- ext/bg/context.html | 96 ++++++++++++++++++++++++++++++++++++++++---- ext/bg/js/context.js | 25 ++++++++++-- 2 files changed, 111 insertions(+), 10 deletions(-) diff --git a/ext/bg/context.html b/ext/bg/context.html index 843d3fd5..07dead87 100644 --- a/ext/bg/context.html +++ b/ext/bg/context.html @@ -9,25 +9,107 @@ -
- +
+
+ +
+
+ + + +
-
- - - +
+

Yomichan

+ + + Search + + + Options + + + Help +
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 0f88e9c0..a29f7aa7 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -17,10 +17,25 @@ */ +function showExtensionInfo() { + const node = document.getElementById('extension-info'); + if (node === null) { return; } + + const manifest = chrome.runtime.getManifest(); + node.textContent = `${manifest.name} v${manifest.version}`; +} + $(document).ready(utilAsync(() => { - $('#open-search').click(() => apiCommandExec('search')); - $('#open-options').click(() => apiCommandExec('options')); - $('#open-help').click(() => apiCommandExec('help')); + showExtensionInfo(); + + apiGetEnvironmentInfo().then(({browser}) => { + // Firefox mobile opens this page as a full webpage. + document.documentElement.dataset.mode = (browser === 'firefox-mobile' ? 'full' : 'mini'); + }); + + $('.action-open-search').click(() => apiCommandExec('search')); + $('.action-open-options').click(() => apiCommandExec('options')); + $('.action-open-help').click(() => apiCommandExec('help')); const optionsContext = { depth: 0, @@ -31,5 +46,9 @@ $(document).ready(utilAsync(() => { toggle.prop('checked', options.general.enable).change(); toggle.bootstrapToggle(); toggle.change(() => apiCommandExec('toggle')); + + const toggle2 = $('#enable-search2'); + toggle2.prop('checked', options.general.enable).change(); + toggle2.change(() => apiCommandExec('toggle')); }); }));