From 24802c93990f8986793ce692c773fa06640c4598 Mon Sep 17 00:00:00 2001 From: Paul Annekov Date: Fri, 10 Jul 2015 23:44:03 +0300 Subject: [PATCH] Added button to switch to full screen mode --- css/app.css | 1 - dist/locales/en.json | 3 +++ index.html | 1 + js/id/ui.js | 4 +++ js/id/ui/full_screen.js | 60 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 js/id/ui/full_screen.js diff --git a/css/app.css b/css/app.css index c2cb031d4..08d939ccd 100644 --- a/css/app.css +++ b/css/app.css @@ -29,7 +29,6 @@ body { .id-container { height: 100%; width: 100%; - position: fixed; min-width: 768px; } diff --git a/dist/locales/en.json b/dist/locales/en.json index 94adb4e45..c401c721d 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -430,6 +430,9 @@ "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": { + "title": "Full Screen" + }, "merge_remote_changes": { "conflict": { "deleted": "This object has been deleted by {user}.", diff --git a/index.html b/index.html index cf71e0b9e..b54c337c6 100644 --- a/index.html +++ b/index.html @@ -99,6 +99,7 @@ + diff --git a/js/id/ui.js b/js/id/ui.js index 6d8534501..59f4f02d8 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -60,6 +60,10 @@ iD.ui = function(context) { .attr('class', 'button-wrap col1') .call(iD.ui.Save(context)); + limiter.append('div') + .attr('class', 'button-wrap col1') + .call(iD.ui.FullScreen(context)); + bar.append('div') .attr('class', 'spinner') .call(iD.ui.Spinner(context)); diff --git a/js/id/ui/full_screen.js b/js/id/ui/full_screen.js new file mode 100644 index 000000000..e5a01352d --- /dev/null +++ b/js/id/ui/full_screen.js @@ -0,0 +1,60 @@ +iD.ui.FullScreen = function(context) { + var history = context.history(), + key = iD.ui.cmd('⌘S'); + + function saving() { + return context.mode().id === 'save'; + } + + function fullScreen() { + d3.event.preventDefault(); + context.container().node().webkitRequestFullscreen(); + } + + return function(selection) { + /*var tooltip = bootstrap.tooltip() + .placement('bottom') + .html(true) + .title(iD.ui.tooltipHtml(t('save.no_changes'), key));*/ + + var button = selection.append('button') + .attr('class', 'save col12') + .attr('tabindex', -1) + .on('click', fullScreen) + /*.call(tooltip)*/; + + button.append('span') + .attr('class', 'label') + .text(t('full_screen.title')); + + /*var keybinding = d3.keybinding('undo-redo') + .on(key, save, 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); + }); + }; +};