-
Notifications
You must be signed in to change notification settings - Fork 1
/
garmin-connect.js
35 lines (27 loc) · 1.39 KB
/
garmin-connect.js
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
31
32
33
34
35
function addFullscreenButton() {
if ('jQuery' in window) {
var $mapControls = jQuery('.map-controls').eq(0).has('.map-control-item');
if ($mapControls.length) {
var $mapContainer = jQuery('#activity-map-canvas'),
mapContainer = $mapContainer[0];
mapContainer.requestFullscreen = mapContainer.requestFullscreen ||
mapContainer.mozRequestFullScreen ||
mapContainer.webkitRequestFullscreen ||
mapContainer.msRequestFullscreen;
var $fullscreenButton = jQuery('<button class="map-control-item map-btn map-full-screen" title="Fullscreen"><i class="map-btn-icon icon-full-screen-2"></i></button>');
$fullscreenButton.click(function() {
mapContainer.requestFullscreen();
});
$(document).on('fullscreenchange mozfullscreenchange webkitfullscreenchange', function(event) {
setTimeout(function() { window.dispatchEvent(new Event('resize')); }, 1200);
});
$mapControls.append($fullscreenButton);
$mapContainer.before('<style>#activity-map-canvas:-webkit-full-screen {width: 100% !important; height: 100% !important;}</style>');
return;
}
}
if (--addFullscreenButton.retries)
setTimeout(addFullscreenButton, 1500);
}
addFullscreenButton.retries = 10;
addFullscreenButton();