diff --git a/browser/src/control/Control.DownloadProgress.js b/browser/src/control/Control.DownloadProgress.js index d22fd1b9fed2d..e092e4ff2698b 100644 --- a/browser/src/control/Control.DownloadProgress.js +++ b/browser/src/control/Control.DownloadProgress.js @@ -18,6 +18,7 @@ L.Control.DownloadProgress = L.Control.extend({ this._started = false; this._complete = false; this._closed = false; + this._isLargeCopy = false; }, _userAlreadyWarned: function () { @@ -77,15 +78,22 @@ L.Control.DownloadProgress = L.Control.extend({ _showDownloadProgress: function (inSnackbar) { var modalId = this._getDownloadProgressDialogId(); var msg = _('Downloading clipboard content'); - var buttonText = _('Copy') + ' (Ctrl + C)'; // TODO: on Mac Ctrl == Command? + var buttonText = _('Cancel'); if (inSnackbar) { this._map.uiManager.showProgressBar(msg, buttonText, this._onClose.bind(this)); - } else { + } else if (this._isLargeCopy) { + // downloading for copy, next: show download complete dialog + buttonText = _('Copy') + ' (Ctrl + C)'; // TODO: on Mac Ctrl == Command? + this._map.uiManager.showProgressBarDialog(modalId, this._getDialogTitle(), msg, buttonText, this._onConfirmCopyAction.bind(this), 0, this._onClose.bind(this)); JSDialog.enableButtonInModal(modalId, modalId + '-response', false); + } else { + // downloading for paste, next: dialog will dissapear + this._map.uiManager.showProgressBarDialog(modalId, this._getDialogTitle(), msg, + '', this._onClose.bind(this), 0, this._onClose.bind(this)); } }, @@ -126,22 +134,30 @@ L.Control.DownloadProgress = L.Control.extend({ setupKeyboardShortcutForDialog: function (modalId) { var dialogId = this._map.uiManager.generateModalId(modalId); - this._setupKeyboardShortcutForElement(dialogId, modalId + '-response'); + var buttonId = modalId + '-response'; + this._setupKeyboardShortcutForElement(dialogId, buttonId); + document.getElementById(buttonId).focus(); }, setupKeyboardShortcutForSnackbar: function () { this._setupKeyboardShortcutForElement('snackbar', 'button'); }, - show: function () { + // isLargeCopy specifies if we are copying and have to explain user the process + // if it is false we do paste so only show download progress + show: function (isLargeCopy) { window.app.console.log('DownloadProgress.show'); // better to init the following state variables here, // since the widget could be re-used without having been destroyed this._started = false; this._complete = false; this._closed = false; + this._isLargeCopy = isLargeCopy; - this._showLargeCopyPasteWarning(this._userAlreadyWarned()); + if (isLargeCopy) + this._showLargeCopyPasteWarning(this._userAlreadyWarned()); + else + this._showDownloadProgress(this._userAlreadyWarned()); }, isClosed: function () { @@ -224,7 +240,10 @@ L.Control.DownloadProgress = L.Control.extend({ this._complete = true; this._started = false; - this._showDownloadComplete(this._userAlreadyWarned()); + if (this._isLargeCopy) + this._showDownloadComplete(this._userAlreadyWarned()); + else + this._closeDownloadProgressDialog(); }, _onConfirmCopyAction: function () { diff --git a/browser/src/control/Control.UIManager.js b/browser/src/control/Control.UIManager.js index 099ca46358de6..e75b03c34d6bc 100644 --- a/browser/src/control/Control.UIManager.js +++ b/browser/src/control/Control.UIManager.js @@ -1182,7 +1182,7 @@ L.Control.UIManager = L.Control.extend({ vertical: false, layoutstyle: 'end' }, - ], responseButtonId); + ], buttonText ? responseButtonId : cancelButtonId); var that = this; this.showModal(json, [ diff --git a/browser/src/map/Clipboard.js b/browser/src/map/Clipboard.js index bfe42bca8b48f..b3d39371ebead 100644 --- a/browser/src/map/Clipboard.js +++ b/browser/src/map/Clipboard.js @@ -208,7 +208,7 @@ L.Clipboard = L.Class.extend({ // avoid to invoke the following code if the download widget depends on user interaction if (!that._downloadProgress || that._downloadProgress.isClosed()) { - that._startProgress(); + that._startProgress(false); that._downloadProgress.startProgressMode(); } request.onload = function() { @@ -801,12 +801,12 @@ L.Clipboard = L.Class.extend({ this._scheduleHideDownload(); }, - _startProgress: function() { + _startProgress: function(isLargeCopy) { if (!this._downloadProgress) { this._downloadProgress = L.control.downloadProgress(); this._map.addControl(this._downloadProgress); } - this._downloadProgress.show(); + this._downloadProgress.show(isLargeCopy); }, _onDownloadOnLargeCopyPaste: function () { @@ -815,7 +815,7 @@ L.Clipboard = L.Class.extend({ // Otherwise, it's easier to flash the widget or something. this._warnLargeCopyPasteAlreadyStarted(); } else { - this._startProgress(); + this._startProgress(true); } },