aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.coffee
blob: e9b20ec8c3b6b0aa861820b64dc73ebeaa1b76b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# we will handle media events
_frostMediaClick = (e) ->
  element = e.target or e.srcElement
  if !element?.dataset.sigil?.toLowerCase().includes("inlinevideo")
    return

  i = 0
  while !element.hasAttribute("data-store")
    if ++i > 2
      return
    element = element.parentNode

  try
    dataStore = JSON.parse(element.dataset.store)
  catch e
    return

  url = dataStore.src

  if !url || !url.startsWith("http")
    return

  console.log "Inline video #{url}"
  if Frost?.loadVideo url, dataStore.animatedGifVideo
    e.stopPropagation()
    e.preventDefault()
  return

document.addEventListener "click", _frostMediaClick, true