Skip to content

Instantly share code, notes, and snippets.

@biojazzard
Created October 30, 2012 09:30
Show Gist options
  • Select an option

  • Save biojazzard/3979237 to your computer and use it in GitHub Desktop.

Select an option

Save biojazzard/3979237 to your computer and use it in GitHub Desktop.
html5-FS
e = document.getElementById("fullscreen")
pfx = ["webkit", "moz", "ms", "o", ""]
e.onClick =>
if RunPrefixMethod document, "FullScreen" || RunPrefixMethod document, "IsFullScreen"
RunPrefixMethod e, "CancelFullScreen"
else
RunPrefixMethod e, "RequestFullScreen"
prefixMethod (obj, method)=>
m = method
if pfx[p] = ""
m = m.substr(0,1).toLowerCase() + m.substr(1)
m = pfx[p] + m
t = typeof obj[m]
if t != "undefined"
pfx = pfx = [pfx[p]]
else
pfx = ''
t = if "function" then obj[m]() else obj[m]
RunPrefixMethod (obj, method) =>
p = 0
prefixMethod obj, method while p < pfx.length and !obj[m]
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment