-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.3.x' into dependabot/github_actions/laminas/automatic…
…-releases-1.25.0
- Loading branch information
Showing
51 changed files
with
547 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends Controller { | ||
dispatchEvent = (name, payload) => { | ||
this.dispatch(name, { detail: payload }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
update = async ({counter}) => { | ||
await navigator.setAppBadge(counter); | ||
this.dispatchEvent('badge:updated', { counter }); | ||
} | ||
|
||
clear = async () => { | ||
await navigator.clearAppBadge(); | ||
this.dispatchEvent('badge:cleared'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
async connect() { | ||
const battery = await navigator.getBattery(); | ||
battery.addEventListener('chargingchange', () => this.updateChargeInfo(battery)); | ||
battery.addEventListener('levelchange', () => this.updateLevelInfo(battery)); | ||
battery.addEventListener('chargingtimechange', () => this.updateChargingInfo(battery)); | ||
battery.addEventListener('dischargingtimechange', () => this.updateDischargingInfo(battery)); | ||
|
||
await this.updateChargeInfo(battery); | ||
await this.updateLevelInfo(battery); | ||
await this.updateChargingInfo(battery); | ||
await this.updateDischargingInfo(battery); | ||
} | ||
update = async ({counter}) => { | ||
await navigator.setAppBadge(counter); | ||
this.dispatchEvent('badge:updated', { counter }); | ||
} | ||
|
||
updateChargeInfo = async (battery) => { | ||
this.dispatchEvent('battery:charge', { charging: battery.charging }); | ||
} | ||
updateLevelInfo = async (battery) => { | ||
this.dispatchEvent('battery:level', { level: battery.level }); | ||
} | ||
updateChargingInfo = async (battery) => { | ||
this.dispatchEvent('battery:chargingtime', { chargingTime: battery.chargingTime }); | ||
} | ||
updateDischargingInfo = async (battery) => { | ||
this.dispatchEvent('battery:dischargingtime', { dischargingTime: battery.dischargingTime }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
connect() { | ||
window.addEventListener( | ||
'deviceorientation', | ||
(event) => { | ||
this.dispatchEvent({ | ||
absolute: event.absolute, | ||
alpha: event.alpha, | ||
beta: event.beta, | ||
gamma: event.gamma | ||
}) | ||
}, | ||
true | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
connect () { | ||
document.addEventListener("fullscreenchange", () => { | ||
this.dispatchEvent('fullscreen:change', { | ||
fullscreen: document.fullscreenElement !== null, | ||
element: document.fullscreenElement | ||
}); | ||
}); | ||
document.addEventListener("fullscreenerror", () => { | ||
this.dispatchEvent('fullscreen:error', { | ||
element: document.fullscreenElement | ||
}); | ||
}); | ||
} | ||
|
||
request = async (event) => { | ||
const {params} = event; | ||
const {target, ...rest} = params; | ||
if (!target) { | ||
await document.documentElement.requestFullscreen(rest); | ||
return | ||
} | ||
const element = document.getElementById(target); | ||
if (!element) { | ||
console.error('Element not found:', target); | ||
return; | ||
} | ||
await element.requestFullscreen(rest); | ||
} | ||
|
||
exit = async () => { | ||
await document.exitFullscreen(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
watchId = null; | ||
|
||
locate({params}) { | ||
if (!navigator.geolocation) { | ||
this.dispatchEvent('geolocation:unsupported'); | ||
return; | ||
} | ||
|
||
navigator.geolocation.getCurrentPosition( | ||
(position) => {this.dispatchEvent('geolocation:position', {latitude: position.coords.latitude, longitude: position.coords.longitude});}, | ||
(error) => {this.dispatchEvent('geolocation:error', {error: error});}, | ||
params | ||
); | ||
} | ||
|
||
watch({params}) { | ||
if (!navigator.geolocation) { | ||
this.dispatchEvent('geolocation:unsupported'); | ||
return; | ||
} | ||
if (this.watchId) { | ||
return; | ||
} | ||
|
||
this.watchId = navigator.geolocation.watchPosition( | ||
(position) => {this.dispatchEvent('geolocation:position', {latitude: position.coords.latitude, longitude: position.coords.longitude});}, | ||
(error) => {this.dispatchEvent('geolocation:error', {error: error});}, | ||
params | ||
); | ||
} | ||
|
||
clearWatch() { | ||
if (!this.watchId) { | ||
return; | ||
} | ||
|
||
navigator.geolocation.clearWatch(this.watchId); | ||
this.watchId = null; | ||
this.dispatchEvent('geolocation:watch:cleared'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
import AbstractController from './abstract_controller.js'; | ||
|
||
/* stimulusFetch: 'lazy' */ | ||
export default class extends AbstractController { | ||
static targets = ['install']; | ||
installPrompt = null; | ||
|
||
async connect() { | ||
this.disableInstallTargets(); | ||
window.addEventListener("beforeinstallprompt", async (event) => { | ||
event.preventDefault(); | ||
this.installPrompt = event; | ||
this.enableInstallTargets(); | ||
}); | ||
} | ||
|
||
async install() { | ||
if (!this.installPrompt) { | ||
return; | ||
} | ||
const result = await this.installPrompt.prompt(); | ||
if (result.outcome === 'accepted') { | ||
this.disableInstallTargets(); | ||
} else { | ||
this.dispatchEvent('install:cancelled'); | ||
} | ||
} | ||
|
||
enableInstallTargets() { | ||
this.installTargets.forEach((installElement) => { | ||
installElement.removeAttribute("hidden"); | ||
}); | ||
} | ||
|
||
disableInstallTargets() { | ||
this.installTargets.forEach((installElement) => { | ||
installElement.setAttribute("hidden", ""); | ||
}); | ||
} | ||
} |
Oops, something went wrong.