aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
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);