From 7985fb6b95df3a3d667343138f9159ffc780485f Mon Sep 17 00:00:00 2001 From: REJack Date: Wed, 2 Dec 2020 08:26:31 +0100 Subject: [PATCH 01/29] try to avoid lgtm unused-local-variable alert --- dist/js/pages/dashboard.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dist/js/pages/dashboard.js b/dist/js/pages/dashboard.js index 9408c5814..ee65df63a 100644 --- a/dist/js/pages/dashboard.js +++ b/dist/js/pages/dashboard.js @@ -167,6 +167,7 @@ $(function () { // This will get the first returned node in the jQuery collection. // eslint-disable-next-line no-unused-vars var salesChart = new Chart(salesChartCanvas, { + // lgtm [js/unused-local-variable] type: 'line', data: salesChartData, options: salesChartOptions @@ -265,5 +266,3 @@ $(function () { options: salesGraphChartOptions }) }) - -// lgtm [js/unused-local-variable] From 5d4ed59ba900fbe7f934da22009ffe294648b0ba Mon Sep 17 00:00:00 2001 From: REJack Date: Wed, 2 Dec 2020 08:35:47 +0100 Subject: [PATCH 02/29] fix SidebarSearch --- build/js/SidebarSearch.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/build/js/SidebarSearch.js b/build/js/SidebarSearch.js index 3e8fc5844..2949e239b 100644 --- a/build/js/SidebarSearch.js +++ b/build/js/SidebarSearch.js @@ -101,7 +101,7 @@ class SidebarSearch { this._addNotFound() } else { endResults.each((i, result) => { - $(SELECTOR_SEARCH_RESULTS_GROUP).append(this._renderItem(escape(result.name), escape(result.link), escape(result.path))) + $(SELECTOR_SEARCH_RESULTS_GROUP).append(this._renderItem(escape(result.name), escape(result.link), result.path)) }) } @@ -160,6 +160,7 @@ class SidebarSearch { _renderItem(name, link, path) { path = path.join(` ${this.options.arrowSign} `) + name = unescape(name) if (this.options.highlightName || this.options.highlightPath) { const searchValue = $(SELECTOR_SEARCH_INPUT).val().toLowerCase() @@ -169,7 +170,7 @@ class SidebarSearch { name = name.replace( regExp, str => { - return `${str}` + return `${str}` } ) } @@ -178,20 +179,26 @@ class SidebarSearch { path = path.replace( regExp, str => { - return `${str}` + return `${str}` } ) } } - return ` -
- ${name} -
-
- ${path} -
-
` + const groupItemElement = $('', { + href: link, + class: 'list-group-item' + }) + const searchTitleElement = $('
', { + class: 'search-title' + }).html(name) + const searchPathElement = $('
', { + class: 'search-path' + }).html(path) + + groupItemElement.append(searchTitleElement).append(searchPathElement) + + return groupItemElement } _addNotFound() { @@ -243,9 +250,7 @@ $(document).on('keyup', SELECTOR_SEARCH_INPUT, event => { return } - let timer = 0 - clearTimeout(timer) - timer = setTimeout(() => { + setTimeout(() => { SidebarSearch._jQueryInterface.call($(SELECTOR_DATA_WIDGET), 'search') }, 100) }) From 90527a83d1f4d9ba0b458d5f431e0b4427bf5b71 Mon Sep 17 00:00:00 2001 From: REJack Date: Wed, 2 Dec 2020 08:38:35 +0100 Subject: [PATCH 03/29] new try to avoid lgtm unused-local-variable warning --- dist/js/pages/dashboard.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dist/js/pages/dashboard.js b/dist/js/pages/dashboard.js index ee65df63a..0212256a2 100644 --- a/dist/js/pages/dashboard.js +++ b/dist/js/pages/dashboard.js @@ -166,8 +166,7 @@ $(function () { // This will get the first returned node in the jQuery collection. // eslint-disable-next-line no-unused-vars - var salesChart = new Chart(salesChartCanvas, { - // lgtm [js/unused-local-variable] + var salesChart = new Chart(salesChartCanvas, { // lgtm [js/unused-local-variable] type: 'line', data: salesChartData, options: salesChartOptions From 63eff3a60f08b46903dab29b7a04edc78c45465e Mon Sep 17 00:00:00 2001 From: REJack Date: Wed, 2 Dec 2020 08:50:58 +0100 Subject: [PATCH 04/29] first changes --- build/js/SiteSearch.js | 21 ++++++++++++--------- index3.html | 18 ++++++------------ 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/build/js/SiteSearch.js b/build/js/SiteSearch.js index d0c4e4f95..f9cc7653c 100644 --- a/build/js/SiteSearch.js +++ b/build/js/SiteSearch.js @@ -18,7 +18,6 @@ const JQUERY_NO_CONFLICT = $.fn[NAME] const SELECTOR_TOGGLE_BUTTON = '[data-widget="site-search"]' const SELECTOR_SEARCH_BLOCK = '.site-search-block' -const SELECTOR_SEARCH_BACKDROP = '.site-search-backdrop' const SELECTOR_SEARCH_INPUT = '.site-search-block .form-control' const CLASS_NAME_OPEN = 'site-search-open' @@ -40,16 +39,17 @@ class SiteSearch { // Public + init() { + // eslint-disable-next-line no-console + console.log(this.element) + } + open() { - $(SELECTOR_SEARCH_BLOCK).slideDown(this.options.transitionSpeed) - $(SELECTOR_SEARCH_BACKDROP).show(0) - $(SELECTOR_SEARCH_INPUT).focus() $(SELECTOR_SEARCH_BLOCK).addClass(CLASS_NAME_OPEN) + $(SELECTOR_SEARCH_INPUT).focus() } close() { - $(SELECTOR_SEARCH_BLOCK).slideUp(this.options.transitionSpeed) - $(SELECTOR_SEARCH_BACKDROP).hide(0) $(SELECTOR_SEARCH_BLOCK).removeClass(CLASS_NAME_OPEN) } @@ -96,10 +96,13 @@ $(document).on('click', SELECTOR_TOGGLE_BUTTON, event => { SiteSearch._jQueryInterface.call(button, 'toggle') }) +$(document).on('ready', () => { + const button = $(SELECTOR_TOGGLE_BUTTON) + if (button.length == 0) { + return + } -$(document).on('click', SELECTOR_SEARCH_BACKDROP, event => { - const backdrop = $(event.currentTarget) - SiteSearch._jQueryInterface.call(backdrop, 'close') + SiteSearch._jQueryInterface.call(button, 'toggle') }) /** diff --git a/index3.html b/index3.html index d4ebd646f..dfd0d10d4 100644 --- a/index3.html +++ b/index3.html @@ -40,20 +40,14 @@ - -
-
- -
- -
-
-
-
- -
-
- -
- -
-
-
-
- -
-
- -
- -
-
-
-
- -
-
- -
- -
-
-
-