From 6c94d56bf0e696b0100491e74d381eeab2d3fa8b Mon Sep 17 00:00:00 2001 From: Monirzadeh <25131576+Monirzadeh@users.noreply.github.com> Date: Sun, 26 May 2024 17:03:17 +0330 Subject: [PATCH] feat: Home button clear search query (#916) * click on home will clear searchbox * clearHome when mounted * clearHomePage just when you are in homepage * check clearHomePage signal out of clearHomePage method * fix style --- bun.lockb | Bin 18693 -> 18693 bytes internal/view/assets/js/component/eventBus.js | 4 ++++ internal/view/assets/js/page/home.js | 10 ++++++++++ internal/view/index.html | 5 +++++ 4 files changed, 19 insertions(+) create mode 100644 internal/view/assets/js/component/eventBus.js diff --git a/bun.lockb b/bun.lockb index be93a5ff0ca087880603bcbaf3607f47d86b1667..f1294b59ecfb172f1e78b7483c381f6c82e45395 100755 GIT binary patch delta 322 zcmW;AD-42Q07c>b!x1Sc_{0ZjG#Z`BNQ6ct5{Wj92H1>7B4cwS(j*d%Mx(PxWO8r$ zc6OpzM6t+!st`$|x}A0(rnIHb04JlehW2Pd6&=T?CDn#F0j;Pp!U<_jH)EU=ebVg& z=S*L8H^sToH{H*0uJl8X2F{H()Sly{w584hC!_Kb?a_iND;%GeR5Nh`T2aHo32AM) PNiONhSL)pl>xcOVpSx9l delta 322 zcmW;AD-42Q07YRLjz~d&eBuK%8ja3mBtjz+i9{Pl18hbkk?GusG>Jr`(daA^nciEz zot-F_qFB0oHK~=EdKm5onL*RMl~OT2Rr$31~@;K2At0x*Xu_>4UC@ zI0yQq>k-b8zUXF*bE0p$GjPtdruGCUr44naI2l!DXpiPpo#Xhlpu)rnXh{tVC#03- PCRbTcK63lEUEIwde~nd5 diff --git a/internal/view/assets/js/component/eventBus.js b/internal/view/assets/js/component/eventBus.js new file mode 100644 index 0000000..91d0b93 --- /dev/null +++ b/internal/view/assets/js/component/eventBus.js @@ -0,0 +1,4 @@ +// Create a new Vue instance as the EventBus +const EventBus = new Vue(); + +export default EventBus; diff --git a/internal/view/assets/js/page/home.js b/internal/view/assets/js/page/home.js index 1a4755b..da26d6a 100644 --- a/internal/view/assets/js/page/home.js +++ b/internal/view/assets/js/page/home.js @@ -90,6 +90,9 @@ import paginationBox from "../component/pagination.js"; import bookmarkItem from "../component/bookmark.js"; import customDialog from "../component/dialog.js"; import basePage from "./base.js"; +import EventBus from "../component/eventBus.js"; + +Vue.prototype.$bus = EventBus; export default { template: template, @@ -153,6 +156,10 @@ export default { }, }, methods: { + clearHomePage() { + this.search = ""; + this.searchBookmarks(); + }, reloadData() { if (this.loading) return; this.page = 1; @@ -999,6 +1006,9 @@ export default { }, }, mounted() { + this.$bus.$on("clearHomePage", () => { + this.clearHomePage(); + }); // Prepare history state watcher var stateWatcher = (e) => { var state = e.state || {}, diff --git a/internal/view/index.html b/internal/view/index.html index 0f120d7..387d634 100644 --- a/internal/view/index.html +++ b/internal/view/index.html @@ -42,6 +42,8 @@ import pageHome from "./assets/js/page/home.js"; import pageSetting from "./assets/js/page/setting.js"; import customDialog from "./assets/js/component/dialog.js"; + import EventBus from "../assets/js/component/eventBus.js"; + Vue.prototype.$bus = EventBus; var app = new Vue({ el: '#main-scene', @@ -69,6 +71,9 @@ state = { activePage: page }, url = new Url; + if (page === 'page-home' && this.activePage === 'page-home') { + Vue.prototype.$bus.$emit('clearHomePage', {}); + } url.hash = pageName; this.activePage = page; history.pushState(state, page, url);