Replaced QualityModal with ContextMenu on searchbar
This commit is contained in:
parent
3afdb45d29
commit
eda80c1359
File diff suppressed because one or more lines are too long
@ -151,7 +151,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
if (isSearchingURL) {
|
if (isSearchingURL) {
|
||||||
if (isCtrlPressed) {
|
if (isCtrlPressed) {
|
||||||
this.$root.$emit('QualityModal:open', term)
|
this.$root.$emit('ContextMenu:searchbar', term)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,5 +186,3 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,10 +118,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$root.$on('ContextMenu:searchbar', this.showSearchbarMenu)
|
||||||
document.body.addEventListener('contextmenu', this.showMenu)
|
document.body.addEventListener('contextmenu', this.showMenu)
|
||||||
document.body.addEventListener('click', this.hideMenu)
|
document.body.addEventListener('click', this.hideMenu)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
showSearchbarMenu(url) {
|
||||||
|
console.log(url)
|
||||||
|
let searchbar = document.getElementById("searchbar")
|
||||||
|
searchbar.dataset.cmLink = url
|
||||||
|
let contextMenuEvent = {
|
||||||
|
pageX: 115,
|
||||||
|
pageY: 57,
|
||||||
|
target: searchbar,
|
||||||
|
dummy: true
|
||||||
|
}
|
||||||
|
this.showMenu(contextMenuEvent)
|
||||||
|
delete searchbar.dataset.cmLink
|
||||||
|
},
|
||||||
showMenu(contextMenuEvent) {
|
showMenu(contextMenuEvent) {
|
||||||
const { pageX, pageY, target: elementClicked } = contextMenuEvent
|
const { pageX, pageY, target: elementClicked } = contextMenuEvent
|
||||||
const path = generatePath(elementClicked)
|
const path = generatePath(elementClicked)
|
||||||
@ -145,11 +159,12 @@ export default {
|
|||||||
|
|
||||||
const isLink = elementClicked.matches('a')
|
const isLink = elementClicked.matches('a')
|
||||||
const isImage = elementClicked.matches('img')
|
const isImage = elementClicked.matches('img')
|
||||||
|
const isSearchbar = elementClicked.matches('input#searchbar')
|
||||||
const hasDeezerLink = !!deezerLink
|
const hasDeezerLink = !!deezerLink
|
||||||
|
|
||||||
if (!isLink && !isImage && !hasDeezerLink) return
|
if (!isLink && !isImage && !hasDeezerLink) return
|
||||||
|
|
||||||
contextMenuEvent.preventDefault()
|
if (!contextMenuEvent.dummy) contextMenuEvent.preventDefault()
|
||||||
this.menuOpen = true
|
this.menuOpen = true
|
||||||
this.positionMenu(pageX, pageY)
|
this.positionMenu(pageX, pageY)
|
||||||
|
|
||||||
@ -168,7 +183,7 @@ export default {
|
|||||||
if (deezerLink) {
|
if (deezerLink) {
|
||||||
// Show 'Copy Deezer Link' option
|
// Show 'Copy Deezer Link' option
|
||||||
this.deezerHref = deezerLink
|
this.deezerHref = deezerLink
|
||||||
this.showDeezerOptions()
|
this.showDeezerOptions(isSearchbar)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideMenu() {
|
hideMenu() {
|
||||||
@ -211,8 +226,8 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
showDeezerOptions() {
|
showDeezerOptions(isSearchbar) {
|
||||||
this.options.copyDeezerLink.show = true
|
if (!isSearchbar) this.options.copyDeezerLink.show = true
|
||||||
|
|
||||||
downloadQualities.forEach(quality => {
|
downloadQualities.forEach(quality => {
|
||||||
this.options[quality.objName].show = true
|
this.options[quality.objName].show = true
|
||||||
|
Loading…
Reference in New Issue
Block a user