From ec5b74984d783245f8dd6e9663b1fe4f53012525 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Mon, 3 Jun 2019 23:27:07 +0200 Subject: [PATCH] Movie popup is now a prototype on the vue instance. Initialized in App and accessible on this.$popup --- src/App.vue | 26 +++++++++++++++++--------- src/components/MoviePopup.vue | 13 +++++++------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/App.vue b/src/App.vue index cbb9ecf..669c904 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,7 +10,7 @@ - +
@@ -120,15 +120,23 @@ export default { } }, created(){ - window.addEventListener('popstate', this.onHistoryState); - window.addEventListener('pagehide', this.changeHistoryState); - eventHub.$on('openMoviePopup', this.openMoviePopup); - eventHub.$on('setSearchQuery', this.setSearchQuery); - eventHub.$on('requestToken', this.requestToken); - eventHub.$on('setUserStatus', this.setUserStatus); - if (this.isTouchDevice()) { - document.querySelector('body').classList.add('touch'); + let that = this + Vue.prototype.$popup = { + get isOpen() { + return that.moviePopupIsVisible + }, + open: (id, type) => { + this.popupID = id || this.popupID + this.popupType = type || this.popupType + this.moviePopupIsVisible = true + console.log('opened') + }, + close: () => { + this.moviePopupIsVisible = false + console.log('closed') + } } + console.log('MoviePopup registered at this.$popup and has state: ', this.$popup.isOpen) } } diff --git a/src/components/MoviePopup.vue b/src/components/MoviePopup.vue index dfcca60..eacce46 100644 --- a/src/components/MoviePopup.vue +++ b/src/components/MoviePopup.vue @@ -1,8 +1,8 @@