Custom click event handling #777
-
I will briefly explain what i want to achieve. But there are several problems with the code mentioned above.
So the question is, would it be possible to add a custom click handler for example only to mp4 and mkv files so that it does not open the file menu but does something else (custom) when clicked? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 1 reply
-
are you using using thumbnails plugin with "video" option enabled? |
Beta Was this translation helpful? Give feedback.
-
i don't have a clear vision of your situation, i guess the code you showed above is a piece of your custom code. Maybe you are editing the min-media-player plugin? [beforeHeader]
<script>
document.body.addEventListener('click', ev => {
const el = ev.target
if (!el?.matches('video.icon')) return
ev.preventDefault()
alert('hey!')
}, { capture: true })
</script> in this example i'm recognizing the icon of a video because i use the thumbnails plugin, and it will produce a you could check if @SanokKule is interested in working on an option like the one you want, or integrate your work into his. |
Beta Was this translation helpful? Give feedback.
-
Yes, i am trying to rewrite/extend an old thumbnail plugin and combine it with the player plugin. MMP.video(entry) opens the floating window player developed by SanokKule. |
Beta Was this translation helpful? Give feedback.
-
I put the code in the before header, but the result was quite mixed. The original feature i wanted to start the video from a thumbnail works, but there are a few issues. If i modify the access menu to [by dedicated button] then it works. But the problem is that if I click even a little bit next to the thumbnail (first image, red area), it starts downloading the movie instead of showing the player. If i try to handle/prevent it, it will break the page navigation. And the second problem, i can open the floating window player, but not the audio player. The audio player will open a new tab for some reason (i have no idea why). Also, because of this new function, if i click on anything else (exe, doc, pdf...), it will start downloading immediately. And I don't really want that. My before header file (modified to json because txt is not allowed): Maybe you have an idea how to solve this? |
Beta Was this translation helpful? Give feedback.
-
I don't know what's happening on my side. Even with this modification, the menu opens for videos and the navigation is broken. I see this when [by clicking on file name] is selected. I get this result when I use the before_header script attached above. I'm using the latest release: 0.54.0 rc8. Untitled_Project_V1.mp4 |
Beta Was this translation helpful? Give feedback.
-
you didn't include in your screenshot an important part of the script: { capture: true } |
Beta Was this translation helpful? Give feedback.
-
after ev.preventDefault() |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! All i had to do was add the ev.stopPropagation() line. Now it works as I wanted. |
Beta Was this translation helpful? Give feedback.
-
cool! |
Beta Was this translation helpful? Give feedback.
after ev.preventDefault()
add ev.stopPropagation()