From 594b4c19cfa83b701fe9b45124ade35d57ee47f6 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 5 Sep 2015 23:09:07 -0400 Subject: [PATCH] Disable fullscreen button, add keyboard shortcuts --- data/core.yaml | 1 + dist/locales/en.json | 2 +- js/id/ui/full_screen.js | 39 ++++++++++++++++++++++++--------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 627e62a2c..8297146be 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -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" diff --git a/dist/locales/en.json b/dist/locales/en.json index 96f58b475..2c59ab543 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -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", diff --git a/js/id/ui/full_screen.js b/js/id/ui/full_screen.js index 1e00f63b2..e16569221 100644 --- a/js/id/ui/full_screen.js +++ b/js/id/ui/full_screen.js @@ -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); }; };