Use links instead of buttons on context page

This commit is contained in:
toasted-nutbread 2019-10-19 22:54:58 -04:00
parent 205498ef3b
commit 7abc7fd0e7
2 changed files with 16 additions and 8 deletions

View File

@ -91,9 +91,9 @@
<input type="checkbox" id="enable-search"> <input type="checkbox" id="enable-search">
</div> </div>
<div class="btn-group"> <div class="btn-group">
<button type="button" title="Search (Alt + Insert)" class="btn btn-default btn-xs action-open-search"><span class="glyphicon glyphicon-search"></span></button> <a title="Search (Alt + Insert)" class="btn btn-default btn-xs action-open-search"><span class="glyphicon glyphicon-search"></span></a>
<button type="button" title="Options" class="btn btn-default btn-xs action-open-options"><span class="glyphicon glyphicon-wrench"></span></button> <a title="Options" class="btn btn-default btn-xs action-open-options"><span class="glyphicon glyphicon-wrench"></span></a>
<button type="button" title="Help" class="btn btn-default btn-xs action-open-help"><span class="glyphicon glyphicon-question-sign"></span></button> <a title="Help" class="btn btn-default btn-xs action-open-help"><span class="glyphicon glyphicon-question-sign"></span></a>
</div> </div>
</div> </div>
<div id="full"> <div id="full">

View File

@ -25,9 +25,9 @@ function showExtensionInfo() {
node.textContent = `${manifest.name} v${manifest.version}`; node.textContent = `${manifest.name} v${manifest.version}`;
} }
function setupButtonEvents(selector, command) { function setupButtonEvents(selector, command, url) {
$(selector) const node = $(selector);
.on('click', (e) => { node.on('click', (e) => {
if (e.button !== 0) { return; } if (e.button !== 0) { return; }
apiCommandExec(command, {newTab: e.ctrlKey}); apiCommandExec(command, {newTab: e.ctrlKey});
e.preventDefault(); e.preventDefault();
@ -37,6 +37,12 @@ function setupButtonEvents(selector, command) {
apiCommandExec(command, {newTab: true}); apiCommandExec(command, {newTab: true});
e.preventDefault(); e.preventDefault();
}); });
if (typeof url === 'string') {
node.attr('href', url);
node.attr('target', '_blank');
node.attr('rel', 'noopener');
}
} }
$(document).ready(utilAsync(() => { $(document).ready(utilAsync(() => {
@ -47,8 +53,10 @@ $(document).ready(utilAsync(() => {
document.documentElement.dataset.mode = (browser === 'firefox-mobile' ? 'full' : 'mini'); document.documentElement.dataset.mode = (browser === 'firefox-mobile' ? 'full' : 'mini');
}); });
setupButtonEvents('.action-open-search', 'search'); const manifest = chrome.runtime.getManifest();
setupButtonEvents('.action-open-options', 'options');
setupButtonEvents('.action-open-search', 'search', chrome.extension.getURL('/bg/search.html'));
setupButtonEvents('.action-open-options', 'options', chrome.extension.getURL(manifest.options_ui.page));
setupButtonEvents('.action-open-help', 'help'); setupButtonEvents('.action-open-help', 'help');
const optionsContext = { const optionsContext = {