Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDillon <dillonzq@outlook.com>2020-05-03 06:06:10 +0300
committerGitHub <noreply@github.com>2020-05-03 06:06:10 +0300
commit09a7c953627dc6543cf6a1fc189d5c7604efec12 (patch)
treee75b7af855dd322c9181cecf6bf0323e7935b453 /src
parent971eff815c8c1826a50ef85954714a429b96e990 (diff)
fix(search): theme.js error when search is disabled (#310)
Diffstat (limited to 'src')
-rw-r--r--src/js/theme.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/js/theme.js b/src/js/theme.js
index 0f25881..8459a05 100644
--- a/src/js/theme.js
+++ b/src/js/theme.js
@@ -94,17 +94,19 @@ class Theme {
initSearch() {
const searchConfig = this.config.search;
+ const isMobile = this.util.isMobile();
+ if (!searchConfig || isMobile && this._searchMobileOnce || !isMobile && this._searchDesktopOnce) return;
+
if (!searchConfig.maxResultLength) searchConfig.maxResultLength = 10;
if (!searchConfig.snippetLength) searchConfig.snippetLength = 50;
if (!searchConfig.highlightTag) searchConfig.highlightTag = 'em';
- const isMobile = this.util.isMobile();
- if (!searchConfig || isMobile && this._searchMobileOnce || !isMobile && this._searchDesktopOnce) return;
- const classSuffix = isMobile ? 'mobile' : 'desktop';
- const $header = document.getElementById(`header-${classSuffix}`);
- const $searchInput = document.getElementById(`search-input-${classSuffix}`);
- const $searchToggle = document.getElementById(`search-toggle-${classSuffix}`);
- const $searchLoading = document.getElementById(`search-loading-${classSuffix}`);
- const $searchClear = document.getElementById(`search-clear-${classSuffix}`);
+
+ const suffix = isMobile ? 'mobile' : 'desktop';
+ const $header = document.getElementById(`header-${suffix}`);
+ const $searchInput = document.getElementById(`search-input-${suffix}`);
+ const $searchToggle = document.getElementById(`search-toggle-${suffix}`);
+ const $searchLoading = document.getElementById(`search-loading-${suffix}`);
+ const $searchClear = document.getElementById(`search-clear-${suffix}`);
if (isMobile) {
this._searchMobileOnce = true;
$searchInput.addEventListener('focus', () => {
@@ -156,10 +158,10 @@ class Theme {
}, false);
const initAutosearch = () => {
- const autosearch = autocomplete(`#search-input-${classSuffix}`, {
+ const autosearch = autocomplete(`#search-input-${suffix}`, {
hint: false,
autoselect: true,
- dropdownMenuContainer: `#search-dropdown-${classSuffix}`,
+ dropdownMenuContainer: `#search-dropdown-${suffix}`,
clearOnSelected: true,
cssClasses: { noPrefix: true },
debug: true,