Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions asset/javascript/TimeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function TimerController(reference) {
function init() {
bindInputs();
bindButtons();
bindFullscreenEvents();
setInputValues(DEFAULT_SECONDS);
}

Expand Down Expand Up @@ -98,6 +99,10 @@ function TimerController(reference) {
});
};

function bindFullscreenEvents() {
document.addEventListener('fullscreenchange', handleButtonFullscreenChange);
}

function validateInput(input, maxValue) {
let value = parseInt(input.value) || 0;

Expand Down Expand Up @@ -260,17 +265,26 @@ function TimerController(reference) {
}
}

function handleFullscreen() {
if (!document.fullscreenElement) {
function isInFullscreen() {
return !!document.fullscreenElement
}

function handleButtonFullscreenChange() {
if (isInFullscreen()) {
exitFullscreenButton.showElement();
enterFullscreenButton.hideElement();

document.documentElement.requestFullscreen();
return;
}

enterFullscreenButton.showElement();
exitFullscreenButton.hideElement();
}

function handleFullscreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
return;
}

document.exitFullscreen();
}
Expand Down