Disable fullscreen button, add keyboard shortcuts

This commit is contained in:
Bryan Housel
2015-09-05 23:09:07 -04:00
parent 93e2e6ab94
commit 594b4c19cf
3 changed files with 26 additions and 16 deletions

View File

@@ -401,6 +401,7 @@ en:
in: Zoom In
out: Zoom Out
cannot_zoom: "Cannot zoom out further in current mode."
full_screen: Toggle Full Screen
gpx:
local_layer: "Local GPX file"
drag_drop: "Drag and drop a .gpx file on the page, or click the button to the right to browse"

View File

@@ -430,7 +430,6 @@
"help": "Another user changed some of the same map features you changed.\nClick on each item below for more details about the conflict, and choose whether to keep\nyour changes or the other user's changes.\n"
}
},
"full_screen": "Toggle Fullscreen",
"merge_remote_changes": {
"conflict": {
"deleted": "This object has been deleted by {user}.",
@@ -485,6 +484,7 @@
"out": "Zoom Out"
},
"cannot_zoom": "Cannot zoom out further in current mode.",
"full_screen": "Toggle Full Screen",
"gpx": {
"local_layer": "Local GPX file",
"drag_drop": "Drag and drop a .gpx file on the page, or click the button to the right to browse",

View File

@@ -1,5 +1,7 @@
iD.ui.FullScreen = function(context) {
var element = context.container().node(), button;
var element = context.container().node(),
keybinding = d3.keybinding('full-screen');
// button;
function getFullScreenFn() {
if (element.requestFullscreen) {
@@ -30,35 +32,42 @@ iD.ui.FullScreen = function(context) {
document.msFullscreenElement;
}
function is_supported() {
function isSupported() {
return !!getFullScreenFn();
}
function fullScreen() {
d3.event.preventDefault();
if (!isFullScreen()) {
button.classed('active', true);
// button.classed('active', true);
getFullScreenFn().apply(element);
} else {
button.classed('active', false);
// button.classed('active', false);
getExitFullScreenFn().apply(document);
}
}
return function(selection) {
if (!is_supported())
return function() { // selection) {
if (!isSupported())
return;
var tooltip = bootstrap.tooltip()
.placement('left');
// var tooltip = bootstrap.tooltip()
// .placement('left');
button = selection.append('button')
.attr('title', t('full_screen'))
.attr('tabindex', -1)
.on('click', fullScreen)
.call(tooltip);
// 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');
// button.append('span')
// .attr('class', 'icon full-screen');
keybinding
.on(iD.ui.cmd('f11'), fullScreen)
.on(iD.ui.cmd('⌘⇧F'), fullScreen);
d3.select(document)
.call(keybinding);
};
};