aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-05-15 16:30:33 -0400
committerGitHub <noreply@github.com>2021-05-15 16:30:33 -0400
commit2c752fd89d3427da855704406e34c9458d33e832 (patch)
tree1af110210e39fccc008ef6c31940303a38ddc60a /ext/js/pages
parentbc6fb4e7d742b40bb18965f5aa3e8a1a867b068e (diff)
Popup action search (#1678)
* Set up search page in the action popup * Fix a style causing incorrect overflow * Fix error when trying to take a screenshot * Fix popup size on Firefox
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/action-popup-main.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js
index 4934802b..b3198676 100644
--- a/ext/js/pages/action-popup-main.js
+++ b/ext/js/pages/action-popup-main.js
@@ -31,7 +31,7 @@ class DisplayController {
this._showExtensionInfo(manifest);
this._setupEnvironment();
- this._setupButtonEvents('.action-open-search', 'openSearchPage', chrome.runtime.getURL('/search.html'));
+ this._setupButtonEvents('.action-open-search', 'openSearchPage', chrome.runtime.getURL('/search.html'), this._onSearchClick.bind(this));
this._setupButtonEvents('.action-open-info', 'openInfoPage', chrome.runtime.getURL('/info.html'));
const optionsFull = await yomichan.api.optionsGetFull();
@@ -60,6 +60,13 @@ class DisplayController {
// Private
+ _onSearchClick(e) {
+ if (!e.shiftKey) { return; }
+ e.preventDefault();
+ location.href = '/search.html?action-popup=true';
+ return false;
+ }
+
_showExtensionInfo(manifest) {
const node = document.getElementById('extension-info');
if (node === null) { return; }
@@ -67,12 +74,16 @@ class DisplayController {
node.textContent = `${manifest.name} v${manifest.version}`;
}
- _setupButtonEvents(selector, command, url) {
+ _setupButtonEvents(selector, command, url, customHandler) {
const nodes = document.querySelectorAll(selector);
for (const node of nodes) {
if (typeof command === 'string') {
node.addEventListener('click', (e) => {
if (e.button !== 0) { return; }
+ if (typeof customHandler === 'function') {
+ const result = customHandler(e);
+ if (typeof result !== 'undefined') { return; }
+ }
yomichan.api.commandExec(command, {mode: e.ctrlKey ? 'newTab' : 'existingOrNewTab'});
e.preventDefault();
}, false);