fix fullscreen

This commit is contained in:
Xuan Sang LE 2018-03-01 20:07:27 +01:00
parent 7911f259b1
commit 1e62eea8ea

View File

@ -1,6 +1,7 @@
self.OS.GUI = self.OS.GUI =
subwindows: new Object() subwindows: new Object()
dialog: undefined dialog: undefined
fullscreen: false
htmlToScheme: (html, app, parent) -> htmlToScheme: (html, app, parent) ->
scheme = $.parseHTML html scheme = $.parseHTML html
($ parent).append scheme ($ parent).append scheme
@ -156,8 +157,14 @@ self.OS.GUI =
app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0] app.appmenu = ($ "[data-id = 'appmenu']", "#syspanel")[0]
app.init() app.init()
enterFullscreen: () -> toggleFullscreen: () ->
el = ($ "body")[0] el = ($ "body")[0]
if _GUI.fullscreen
return document.exitFullscreen() if document.exitFullscreen
return document.mozCancelFullScreen() if document.mozCancelFullScreen
return document.webkitExitFullscreen() if document.webkitExitFullscreen
return document.exitFullscreen() if document.exitFullscreen
else
return el.requestFullscreen() if el.requestFullscreen return el.requestFullscreen() if el.requestFullscreen
return el.mozRequestFullScreen() if el.mozRequestFullScreen return el.mozRequestFullScreen() if el.mozRequestFullScreen
return el.webkitRequestFullscreen() if el.webkitRequestFullscreen return el.webkitRequestFullscreen() if el.webkitRequestFullscreen
@ -182,6 +189,8 @@ self.OS.GUI =
event.preventDefault() event.preventDefault()
initDM: -> initDM: ->
($ "body").on 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange', ()->
_GUI.fullscreen = not _GUI.fullscreen
# check login first # check login first
_API.resource "schemes/dm.html", (x) -> _API.resource "schemes/dm.html", (x) ->
return null unless x return null unless x
@ -317,7 +326,7 @@ self.OS.GUI =
] ]
menu.child = menu.child.concat (v for k, v of _OS.setting.system.menu) menu.child = menu.child.concat (v for k, v of _OS.setting.system.menu)
menu.child.push menu.child.push
text: "Full screen", text: "Toggle Full screen",
dataid: "os-fullsize", dataid: "os-fullsize",
iconclass: "fa fa-tv" iconclass: "fa fa-tv"
menu.child.push menu.child.push
@ -326,7 +335,7 @@ self.OS.GUI =
iconclass: "fa fa-user-times" iconclass: "fa fa-user-times"
menu.onmenuselect = (d) -> menu.onmenuselect = (d) ->
return _API.handler.logout() if d.item.data.dataid is "sys-logout" return _API.handler.logout() if d.item.data.dataid is "sys-logout"
return _GUI.enterFullscreen() if d.item.data.dataid is "os-fullsize" return _GUI.toggleFullscreen() if d.item.data.dataid is "os-fullsize"
_GUI.launch d.item.data.app unless d.item.data.dataid _GUI.launch d.item.data.app unless d.item.data.dataid
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu] ($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]