aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/assets/js/media.coffee
blob: a15a527962ff763ae4c5fa5ba2bd70f23e78954c (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
30
# 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