1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

Use id when handling hotkeys for specific dialogs

Identifying a dialog by it's header title is kinda dirty and now we use
the dialogs id instead. We also check if the dialog is visible before executing
the hotkey action.
This commit is contained in:
Sven Depondt 2017-07-28 22:32:18 +02:00
parent a52ef89161
commit 0978dbf890
2 changed files with 60 additions and 30 deletions

View file

@ -41,6 +41,11 @@ Dialog.prototype = {
* *
*--------------------------------------------*/ *--------------------------------------------*/
executeCallback: function () {
this._callback();
dialog.hideDialog();
},
hideDialog: function () { hideDialog: function () {
$('body.dialog_showing').removeClass('dialog_showing'); $('body.dialog_showing').removeClass('dialog_showing');
this._container.hide(); this._container.hide();
@ -48,14 +53,16 @@ Dialog.prototype = {
transmission.updateButtonStates(); transmission.updateButtonStates();
}, },
isVisible: function () {
return this._container.is(':visible');
},
onCancelClicked: function (event) { onCancelClicked: function (event) {
event.data.dialog.hideDialog(); event.data.dialog.hideDialog();
}, },
onConfirmClicked: function (event) { onConfirmClicked: function (event) {
var dialog = event.data.dialog; event.data.dialog.executeCallback();
dialog._callback();
dialog.hideDialog();
}, },
/*-------------------------------------------- /*--------------------------------------------

View file

@ -505,9 +505,7 @@ Transmission.prototype = {
} }
if (o_key || u_key) { if (o_key || u_key) {
$('body').addClass('open_showing'); this.openTorrentClicked(ev);
this.uploadTorrentFile();
this.updateButtonStates();
handled = true; handled = true;
} }
@ -527,36 +525,61 @@ Transmission.prototype = {
} }
} }
if (enter_key) {
// check if remove dialog
if ($('.dialog_heading:visible').text().match("Remove") != null) {
$("#dialog_confirm_button").click();
handled = true;
}
// check if upload torrent dialog
if ($('.dialog_heading:visible').text() == "Upload Torrent Files") {
this.confirmUploadClicked();
handled = true;
}
// check if location dialog
if ($('.dialog_heading:visible').text() == "Set Location") {
this.confirmMoveClicked();
handled = true;
}
}
if (slash_key) { if (slash_key) {
this.showHotkeysDialog(); this.showHotkeysDialog();
handled = true; handled = true;
} }
if (enter_key) {
// handle other dialogs
if (dialog && dialog.isVisible()) {
dialog.executeCallback();
handled = true;
}
// handle upload dialog
if ($('#upload_container').is(':visible')) {
this.confirmUploadClicked();
handled = true;
}
// handle move dialog
if ($('#move_container').is(':visible')) {
this.confirmMoveClicked();
handled = true;
}
// handle rename dialog
if ($('#rename_container').is(':visible')) {
this.confirmRenameClicked();
handled = true;
}
}
if (esc_key) { if (esc_key) {
this.hideMoveDialog(); // handle other dialogs
this.hideUploadDialog(); if (dialog && dialog.isVisible()) {
dialog.hideDialog(); dialog.hideDialog();
handled = true; handled = true;
}
// handle upload dialog
if ($('#upload_container').is(':visible')) {
this.hideUploadDialog();
handled = true;
}
// handle move dialog
if ($('#move_container').is(':visible')) {
this.hideMoveDialog();
handled = true;
}
// handle rename dialog
if ($('#rename_container').is(':visible')) {
this.hideRenameDialog();
handled = true;
}
} }
if ((up_key || dn_key) && rows.length) { if ((up_key || dn_key) && rows.length) {