mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-23 20:40:21 +01:00
Added ability to exit from full screen
This commit is contained in:
@@ -1,30 +1,46 @@
|
||||
iD.ui.FullScreen = function(context) {
|
||||
var element = context.container().node(),
|
||||
key = iD.ui.cmd('⌃f11');
|
||||
|
||||
/*function saving() {
|
||||
return context.mode().id === 'save';
|
||||
}*/
|
||||
var element = context.container().node();
|
||||
|
||||
function getFullScreenFn() {
|
||||
var prefixes = ['moz', 'webkit', 'ms'];
|
||||
if (element.requestFullscreen)
|
||||
if (element.requestFullscreen) {
|
||||
return element.requestFullscreen;
|
||||
|
||||
for (var i = 0; i < prefixes.length; i++) {
|
||||
var fn = element[prefixes[i] + 'RequestFullScreen'];
|
||||
if (fn)
|
||||
return fn;
|
||||
} 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 is_supported() {
|
||||
return !!getFullScreenFn();
|
||||
}
|
||||
|
||||
function fullScreen() {
|
||||
d3.event.preventDefault();
|
||||
getFullScreenFn().apply(element);
|
||||
if (!isFullScreen()) {
|
||||
getFullScreenFn().apply(element);
|
||||
} else {
|
||||
getExitFullScreenFn().apply(document);
|
||||
}
|
||||
}
|
||||
|
||||
return function(selection) {
|
||||
@@ -34,7 +50,7 @@ iD.ui.FullScreen = function(context) {
|
||||
var tooltip = bootstrap.tooltip()
|
||||
.placement('bottom')
|
||||
.html(true)
|
||||
.title(iD.ui.tooltipHtml(t('full_screen.tooltip'), key));
|
||||
.title(iD.ui.tooltipHtml(t('full_screen.tooltip')));
|
||||
|
||||
var button = selection.append('button')
|
||||
.attr('class', 'save col12')
|
||||
@@ -45,35 +61,5 @@ iD.ui.FullScreen = function(context) {
|
||||
button.append('span')
|
||||
.attr('class', 'label')
|
||||
.text(t('full_screen.title'));
|
||||
|
||||
var keybinding = d3.keybinding('full-screen')
|
||||
.on(key, fullScreen, true);
|
||||
|
||||
d3.select(document)
|
||||
.call(keybinding);
|
||||
|
||||
/*var numChanges = 0;
|
||||
|
||||
context.history().on('change.save', function() {
|
||||
var _ = history.difference().summary().length;
|
||||
if (_ === numChanges)
|
||||
return;
|
||||
numChanges = _;
|
||||
|
||||
tooltip.title(iD.ui.tooltipHtml(t(numChanges > 0 ?
|
||||
'save.help' : 'save.no_changes'), key));
|
||||
|
||||
button
|
||||
.classed('disabled', numChanges === 0)
|
||||
.classed('has-count', numChanges > 0);
|
||||
|
||||
button.select('span.count')
|
||||
.text(numChanges);
|
||||
});*/
|
||||
|
||||
/*context.on('enter.save', function() {
|
||||
button.property('disabled', saving());
|
||||
if (saving()) button.call(tooltip.hide);
|
||||
});*/
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user