mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-03 18:03:38 +00:00
* One-shot development * Move jsonp to module * Tooltip -> module * Remove d3.jsonp * Fix tooltip lint * Load all libs but d3 itself with require * Add top-level brfs * Unformat intro graph
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
import { cmd } from './cmd';
|
|
|
|
export function FullScreen(context) {
|
|
var element = context.container().node(),
|
|
keybinding = d3.keybinding('full-screen');
|
|
// button;
|
|
|
|
function getFullScreenFn() {
|
|
if (element.requestFullscreen) {
|
|
return element.requestFullscreen;
|
|
} else if (element.msRequestFullscreen) {
|
|
return element.msRequestFullscreen;
|
|
} else if (element.mozRequestFullScreen) {
|
|
return element.mozRequestFullScreen;
|
|
} else if (element.webkitRequestFullscreen) {
|
|
return element.webkitRequestFullscreen;
|
|
}
|
|
}
|
|
|
|
function getExitFullScreenFn() {
|
|
if (document.exitFullscreen) {
|
|
return document.exitFullscreen;
|
|
} else if (document.msExitFullscreen) {
|
|
return document.msExitFullscreen;
|
|
} else if (document.mozCancelFullScreen) {
|
|
return document.mozCancelFullScreen;
|
|
} else if (document.webkitExitFullscreen) {
|
|
return document.webkitExitFullscreen;
|
|
}
|
|
}
|
|
|
|
function isFullScreen() {
|
|
return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement ||
|
|
document.msFullscreenElement;
|
|
}
|
|
|
|
function isSupported() {
|
|
return !!getFullScreenFn();
|
|
}
|
|
|
|
function fullScreen() {
|
|
d3.event.preventDefault();
|
|
if (!isFullScreen()) {
|
|
// button.classed('active', true);
|
|
getFullScreenFn().apply(element);
|
|
} else {
|
|
// button.classed('active', false);
|
|
getExitFullScreenFn().apply(document);
|
|
}
|
|
}
|
|
|
|
return function() { // selection) {
|
|
if (!isSupported())
|
|
return;
|
|
|
|
// button = selection.append('button')
|
|
// .attr('title', t('full_screen'))
|
|
// .attr('tabindex', -1)
|
|
// .on('click', fullScreen)
|
|
// .call(tooltip);
|
|
|
|
// button.append('span')
|
|
// .attr('class', 'icon full-screen');
|
|
|
|
keybinding
|
|
.on('f11', fullScreen)
|
|
.on(cmd('⌘⇧F'), fullScreen);
|
|
|
|
d3.select(document)
|
|
.call(keybinding);
|
|
};
|
|
}
|