mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-22 02:41:23 +02:00
Small change to implementation for new tab
This commit is contained in:
parent
06b21e3d27
commit
edb59ffdc6
@ -725,7 +725,9 @@ Preview:
|
|||||||
| <kbd>Ctrl</kbd> + <kbd>Enter</kbd> | Perform search in a new tab | Search input is focused and not empty |
|
| <kbd>Ctrl</kbd> + <kbd>Enter</kbd> | Perform search in a new tab | Search input is focused and not empty |
|
||||||
| <kbd>Escape</kbd> | Leave focus | Search input is focused |
|
| <kbd>Escape</kbd> | Leave focus | Search input is focused |
|
||||||
|
|
||||||
If property `new-tab` is set to `true`, keys <kbd>Enter</kbd> and <kbd>Ctrl</kbd> + <kbd>Enter</kbd> will be switched.
|
> [!TIP]
|
||||||
|
>
|
||||||
|
> You can use the property `new-tab` with a value of `true` if you want to show search results in a new tab by default. <kbd>Ctrl</kbd> + <kbd>Enter</kbd> will then show results in the same tab.
|
||||||
|
|
||||||
#### Properties
|
#### Properties
|
||||||
| Name | Type | Required | Default |
|
| Name | Type | Required | Default |
|
||||||
@ -742,6 +744,9 @@ Either a value from the table below or a URL to a custom search engine. Use `{QU
|
|||||||
| duckduckgo | `https://duckduckgo.com/?q={QUERY}` |
|
| duckduckgo | `https://duckduckgo.com/?q={QUERY}` |
|
||||||
| google | `https://www.google.com/search?q={QUERY}` |
|
| google | `https://www.google.com/search?q={QUERY}` |
|
||||||
|
|
||||||
|
##### `new-tab`
|
||||||
|
When set to `true`, swaps the shortcuts for showing results in the same or new tab, defaulting to showing results in a new tab.
|
||||||
|
|
||||||
##### `bangs`
|
##### `bangs`
|
||||||
What now? [Bangs](https://duckduckgo.com/bangs). They're shortcuts that allow you to use the same search box for many different sites. Assuming you have it configured, if for example you start your search input with `!yt` you'd be able to perform a search on YouTube:
|
What now? [Bangs](https://duckduckgo.com/bangs). They're shortcuts that allow you to use the same search box for many different sites. Assuming you have it configured, if for example you start your search input with `!yt` you'd be able to perform a search on YouTube:
|
||||||
|
|
||||||
|
@ -370,10 +370,6 @@ kbd:active {
|
|||||||
box-shadow: 0 0 0 0 var(--color-widget-background-highlight);
|
box-shadow: 0 0 0 0 var(--color-widget-background-highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
new-tab {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-bounds {
|
.content-bounds {
|
||||||
max-width: 1600px;
|
max-width: 1600px;
|
||||||
margin-inline: auto;
|
margin-inline: auto;
|
||||||
|
@ -107,7 +107,7 @@ function updateRelativeTimeForElements(elements)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSearchboxes() {
|
function setupSearchBoxes() {
|
||||||
const searchWidgets = document.getElementsByClassName("search");
|
const searchWidgets = document.getElementsByClassName("search");
|
||||||
|
|
||||||
if (searchWidgets.length == 0) {
|
if (searchWidgets.length == 0) {
|
||||||
@ -117,10 +117,10 @@ function setupSearchboxes() {
|
|||||||
for (let i = 0; i < searchWidgets.length; i++) {
|
for (let i = 0; i < searchWidgets.length; i++) {
|
||||||
const widget = searchWidgets[i];
|
const widget = searchWidgets[i];
|
||||||
const defaultSearchUrl = widget.dataset.defaultSearchUrl;
|
const defaultSearchUrl = widget.dataset.defaultSearchUrl;
|
||||||
|
const newTab = widget.dataset.newTab === "true";
|
||||||
const inputElement = widget.getElementsByClassName("search-input")[0];
|
const inputElement = widget.getElementsByClassName("search-input")[0];
|
||||||
const bangElement = widget.getElementsByClassName("search-bang")[0];
|
const bangElement = widget.getElementsByClassName("search-bang")[0];
|
||||||
const bangs = widget.querySelectorAll(".search-bangs > input");
|
const bangs = widget.querySelectorAll(".search-bangs > input");
|
||||||
const newTab = widget.getElementsByTagName("new-tab")[0].innerHTML === "true";
|
|
||||||
const bangsMap = {};
|
const bangsMap = {};
|
||||||
const kbdElement = widget.getElementsByTagName("kbd")[0];
|
const kbdElement = widget.getElementsByTagName("kbd")[0];
|
||||||
let currentBang = null;
|
let currentBang = null;
|
||||||
@ -552,7 +552,7 @@ async function setupPage() {
|
|||||||
try {
|
try {
|
||||||
setupClocks()
|
setupClocks()
|
||||||
setupCarousels();
|
setupCarousels();
|
||||||
setupSearchboxes();
|
setupSearchBoxes();
|
||||||
setupCollapsibleLists();
|
setupCollapsibleLists();
|
||||||
setupCollapsibleGrids();
|
setupCollapsibleGrids();
|
||||||
setupDynamicRelativeTime();
|
setupDynamicRelativeTime();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{{ define "widget-content-classes" }}widget-content-frameless{{ end }}
|
{{ define "widget-content-classes" }}widget-content-frameless{{ end }}
|
||||||
|
|
||||||
{{ define "widget-content" }}
|
{{ define "widget-content" }}
|
||||||
<div class="search widget-content-frame padding-inline-widget flex gap-15 items-center" data-default-search-url="{{ .SearchEngine }}">
|
<div class="search widget-content-frame padding-inline-widget flex gap-15 items-center" data-default-search-url="{{ .SearchEngine }}" data-new-tab="{{ .NewTab }}">
|
||||||
<div class="search-bangs">
|
<div class="search-bangs">
|
||||||
{{ range .Bangs }}
|
{{ range .Bangs }}
|
||||||
<input type="hidden" data-shortcut="{{ .Shortcut }}" data-title="{{ .Title }}" data-url="{{ .URL }}">
|
<input type="hidden" data-shortcut="{{ .Shortcut }}" data-title="{{ .Title }}" data-url="{{ .URL }}">
|
||||||
@ -20,6 +20,5 @@
|
|||||||
|
|
||||||
<div class="search-bang"></div>
|
<div class="search-bang"></div>
|
||||||
<kbd class="hide-on-mobile" title="Press [S] to focus the search input">S</kbd>
|
<kbd class="hide-on-mobile" title="Press [S] to focus the search input">S</kbd>
|
||||||
<new-tab>{{ .NewTab }}</new-tab>
|
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user