Movie popup is now a prototype on the vue instance. Initialized in App and accessible on this.$popup

This commit is contained in:
2019-06-03 23:27:07 +02:00
parent a30529e192
commit ec5b74984d
2 changed files with 24 additions and 15 deletions

View File

@@ -10,7 +10,7 @@
</div>
</header>
<movie-popup v-if="moviePopupIsVisible" @close="closeMoviePopup" :id="moviePopupId" :type="moviePopupType"></movie-popup>
<movie-popup v-if="moviePopupIsVisible" :id="popupID" :type="popupType"></movie-popup>
<section class="main">
<transition name="fade" @after-leave="afterLeave">
@@ -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)
}
}
</script>